diff options
author | Zheng Liu <wenqing.lz@taobao.com> | 2013-02-18 00:32:55 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2013-02-18 00:32:55 -0500 |
commit | 74cd15cd02708c7188581f279f33a98b2ae8d322 (patch) | |
tree | 5d5c2380ffc7ddf1cd529127b89bf572c1798ffd /include | |
parent | bdedbb7b8d5b960e1ff0d116f5d4935febe73183 (diff) |
ext4: reclaim extents from extent status tree
Although extent status is loaded on-demand, we also need to reclaim
extent from the tree when we are under a heavy memory pressure because
in some cases fragmented extent tree causes status tree costs too much
memory.
Here we maintain a lru list in super_block. When the extent status of
an inode is accessed and changed, this inode will be move to the tail
of the list. The inode will be dropped from this list when it is
cleared. In the inode, a counter is added to count the number of
cached objects in extent status tree. Here only written/unwritten/hole
extent is counted because delayed extent doesn't be reclaimed due to
fiemap, bigalloc and seek_data/hole need it. The counter will be
increased as a new extent is allocated, and it will be decreased as a
extent is freed.
In this commit we use normal shrinker framework to reclaim memory from
the status tree. ext4_es_reclaim_extents_count() traverses the lru list
to count the number of reclaimable extents. ext4_es_shrink() tries to
reclaim written/unwritten/hole extents from extent status tree. The
inode that has been shrunk is moved to the tail of lru list.
Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: Jan kara <jack@suse.cz>
Diffstat (limited to 'include')
-rw-r--r-- | include/trace/events/ext4.h | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/include/trace/events/ext4.h b/include/trace/events/ext4.h index 1e590b68cec4..c0457c0d1a68 100644 --- a/include/trace/events/ext4.h +++ b/include/trace/events/ext4.h | |||
@@ -2255,6 +2255,66 @@ TRACE_EVENT(ext4_es_lookup_extent_exit, | |||
2255 | __entry->found ? __entry->status : 0) | 2255 | __entry->found ? __entry->status : 0) |
2256 | ); | 2256 | ); |
2257 | 2257 | ||
2258 | TRACE_EVENT(ext4_es_reclaim_extents_count, | ||
2259 | TP_PROTO(struct super_block *sb, int nr_cached), | ||
2260 | |||
2261 | TP_ARGS(sb, nr_cached), | ||
2262 | |||
2263 | TP_STRUCT__entry( | ||
2264 | __field( dev_t, dev ) | ||
2265 | __field( int, nr_cached ) | ||
2266 | ), | ||
2267 | |||
2268 | TP_fast_assign( | ||
2269 | __entry->dev = sb->s_dev; | ||
2270 | __entry->nr_cached = nr_cached; | ||
2271 | ), | ||
2272 | |||
2273 | TP_printk("dev %d,%d cached objects nr %d", | ||
2274 | MAJOR(__entry->dev), MINOR(__entry->dev), | ||
2275 | __entry->nr_cached) | ||
2276 | ); | ||
2277 | |||
2278 | TRACE_EVENT(ext4_es_shrink_enter, | ||
2279 | TP_PROTO(struct super_block *sb, int nr_to_scan), | ||
2280 | |||
2281 | TP_ARGS(sb, nr_to_scan), | ||
2282 | |||
2283 | TP_STRUCT__entry( | ||
2284 | __field( dev_t, dev ) | ||
2285 | __field( int, nr_to_scan ) | ||
2286 | ), | ||
2287 | |||
2288 | TP_fast_assign( | ||
2289 | __entry->dev = sb->s_dev; | ||
2290 | __entry->nr_to_scan = nr_to_scan; | ||
2291 | ), | ||
2292 | |||
2293 | TP_printk("dev %d,%d nr to scan %d", | ||
2294 | MAJOR(__entry->dev), MINOR(__entry->dev), | ||
2295 | __entry->nr_to_scan) | ||
2296 | ); | ||
2297 | |||
2298 | TRACE_EVENT(ext4_es_shrink_exit, | ||
2299 | TP_PROTO(struct super_block *sb, int shrunk_nr), | ||
2300 | |||
2301 | TP_ARGS(sb, shrunk_nr), | ||
2302 | |||
2303 | TP_STRUCT__entry( | ||
2304 | __field( dev_t, dev ) | ||
2305 | __field( int, shrunk_nr ) | ||
2306 | ), | ||
2307 | |||
2308 | TP_fast_assign( | ||
2309 | __entry->dev = sb->s_dev; | ||
2310 | __entry->shrunk_nr = shrunk_nr; | ||
2311 | ), | ||
2312 | |||
2313 | TP_printk("dev %d,%d nr to scan %d", | ||
2314 | MAJOR(__entry->dev), MINOR(__entry->dev), | ||
2315 | __entry->shrunk_nr) | ||
2316 | ); | ||
2317 | |||
2258 | #endif /* _TRACE_EXT4_H */ | 2318 | #endif /* _TRACE_EXT4_H */ |
2259 | 2319 | ||
2260 | /* This part must be outside protection */ | 2320 | /* This part must be outside protection */ |