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 /fs/ext4/ext4.h | |
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 'fs/ext4/ext4.h')
-rw-r--r-- | fs/ext4/ext4.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 0c565c941f7a..6e16c1867959 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h | |||
@@ -888,6 +888,8 @@ struct ext4_inode_info { | |||
888 | /* extents status tree */ | 888 | /* extents status tree */ |
889 | struct ext4_es_tree i_es_tree; | 889 | struct ext4_es_tree i_es_tree; |
890 | rwlock_t i_es_lock; | 890 | rwlock_t i_es_lock; |
891 | struct list_head i_es_lru; | ||
892 | unsigned int i_es_lru_nr; /* protected by i_es_lock */ | ||
891 | 893 | ||
892 | /* ialloc */ | 894 | /* ialloc */ |
893 | ext4_group_t i_last_alloc_group; | 895 | ext4_group_t i_last_alloc_group; |
@@ -1303,6 +1305,11 @@ struct ext4_sb_info { | |||
1303 | 1305 | ||
1304 | /* Precomputed FS UUID checksum for seeding other checksums */ | 1306 | /* Precomputed FS UUID checksum for seeding other checksums */ |
1305 | __u32 s_csum_seed; | 1307 | __u32 s_csum_seed; |
1308 | |||
1309 | /* Reclaim extents from extent status tree */ | ||
1310 | struct shrinker s_es_shrinker; | ||
1311 | struct list_head s_es_lru; | ||
1312 | spinlock_t s_es_lru_lock ____cacheline_aligned_in_smp; | ||
1306 | }; | 1313 | }; |
1307 | 1314 | ||
1308 | static inline struct ext4_sb_info *EXT4_SB(struct super_block *sb) | 1315 | static inline struct ext4_sb_info *EXT4_SB(struct super_block *sb) |