After tracking all extent status, we already have a extent cache in memory. Every time we want to lookup a block mapping, we can first try to lookup it in extent status tree to avoid a potential disk I/O. A new function called ext4_es_lookup_extent is defined to finish this work. When we try to lookup a block mapping, we always call ext4_map_blocks and/or ext4_da_map_blocks. So in these functions we first try to lookup a block mapping in extent status tree. A new flag EXT4_GET_BLOCKS_NO_PUT_HOLE is used in ext4_da_map_blocks in order not to put a hole into extent status tree because this hole will be converted to delayed extent in the tree immediately.
Showing the changes to include/trace (1 of 6 files). Show all
Unified · Split
| @@ -2199,6 +2199,62 @@ TRACE_EVENT(ext4_es_find_delayed_extent_exit, · 2198 unmodified lines | ||
| 2199 | 2199 | __entry->pblk, __entry->status) |
| 2200 | 2200 | ); |
| 2201 | 2201 | |
| 2202 | +TRACE_EVENT(ext4_es_lookup_extent_enter, | |
| 2203 | + TP_PROTO(struct inode *inode, ext4_lblk_t lblk), | |
| 2204 | + | |
| 2205 | + TP_ARGS(inode, lblk), | |
| 2206 | + | |
| 2207 | + TP_STRUCT__entry( | |
| 2208 | + __field( dev_t, dev ) | |
| 2209 | + __field( ino_t, ino ) | |
| 2210 | + __field( ext4_lblk_t, lblk ) | |
| 2211 | + ), | |
| 2212 | + | |
| 2213 | + TP_fast_assign( | |
| 2214 | + __entry->dev = inode->i_sb->s_dev; | |
| 2215 | + __entry->ino = inode->i_ino; | |
| 2216 | + __entry->lblk = lblk; | |
| 2217 | + ), | |
| 2218 | + | |
| 2219 | + TP_printk("dev %d,%d ino %lu lblk %u", | |
| 2220 | + MAJOR(__entry->dev), MINOR(__entry->dev), | |
| 2221 | + (unsigned long) __entry->ino, __entry->lblk) | |
| 2222 | +); | |
| 2223 | + | |
| 2224 | +TRACE_EVENT(ext4_es_lookup_extent_exit, | |
| 2225 | + TP_PROTO(struct inode *inode, struct extent_status *es, | |
| 2226 | + int found), | |
| 2227 | + | |
| 2228 | + TP_ARGS(inode, es, found), | |
| 2229 | + | |
| 2230 | + TP_STRUCT__entry( | |
| 2231 | + __field( dev_t, dev ) | |
| 2232 | + __field( ino_t, ino ) | |
| 2233 | + __field( ext4_lblk_t, lblk ) | |
| 2234 | + __field( ext4_lblk_t, len ) | |
| 2235 | + __field( ext4_fsblk_t, pblk ) | |
| 2236 | + __field( unsigned long long, status ) | |
| 2237 | + __field( int, found ) | |
| 2238 | + ), | |
| 2239 | + | |
| 2240 | + TP_fast_assign( | |
| 2241 | + __entry->dev = inode->i_sb->s_dev; | |
| 2242 | + __entry->ino = inode->i_ino; | |
| 2243 | + __entry->lblk = es->es_lblk; | |
| 2244 | + __entry->len = es->es_len; | |
| 2245 | + __entry->pblk = ext4_es_pblock(es); | |
| 2246 | + __entry->status = ext4_es_status(es); | |
| 2247 | + __entry->found = found; | |
| 2248 | + ), | |
| 2249 | + | |
| 2250 | + TP_printk("dev %d,%d ino %lu found %d [%u/%u) %llu %llx", | |
| 2251 | + MAJOR(__entry->dev), MINOR(__entry->dev), | |
| 2252 | + (unsigned long) __entry->ino, __entry->found, | |
| 2253 | + __entry->lblk, __entry->len, | |
| 2254 | + __entry->found ? __entry->pblk : 0, | |
| 2255 | + __entry->found ? __entry->status : 0) | |
| 2256 | +); | |
| 2257 | + | |
| 2202 | 2258 | #endif /* _TRACE_EXT4_H */ |
| 2203 | 2259 | |
| 2204 | 2260 | /* This part must be outside protection */ |