Skip to content

Commit

Permalink
ext4: change LRU to round-robin in extent status tree shrinker
Browse files Browse the repository at this point in the history
In this commit we discard the lru algorithm for inodes with extent
status tree because it takes significant effort to maintain a lru list
in extent status tree shrinker and the shrinker can take a long time to
scan this lru list in order to reclaim some objects.

We replace the lru ordering with a simple round-robin.  After that we
never need to keep a lru list.  That means that the list needn't be
sorted if the shrinker can not reclaim any objects in the first round.

Cc: Andreas Dilger <[email protected]>
Signed-off-by: Zheng Liu <[email protected]>
Signed-off-by: Jan Kara <[email protected]>
Signed-off-by: Theodore Ts'o <[email protected]>
  • Loading branch information
gnehzuil authored and tytso committed Nov 25, 2014
1 parent 2f8e0a7 commit edaa53c
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 153 deletions.
10 changes: 5 additions & 5 deletions fs/ext4/ext4.h
Original file line number Diff line number Diff line change
Expand Up @@ -878,10 +878,9 @@ struct ext4_inode_info {
/* extents status tree */
struct ext4_es_tree i_es_tree;
rwlock_t i_es_lock;
struct list_head i_es_lru;
struct list_head i_es_list;
unsigned int i_es_all_nr; /* protected by i_es_lock */
unsigned int i_es_lru_nr; /* protected by i_es_lock */
unsigned long i_touch_when; /* jiffies of last accessing */
unsigned int i_es_shk_nr; /* protected by i_es_lock */

/* ialloc */
ext4_group_t i_last_alloc_group;
Expand Down Expand Up @@ -1322,10 +1321,11 @@ struct ext4_sb_info {

/* Reclaim extents from extent status tree */
struct shrinker s_es_shrinker;
struct list_head s_es_lru;
struct list_head s_es_list;
long s_es_nr_inode;
struct ext4_es_stats s_es_stats;
struct mb_cache *s_mb_cache;
spinlock_t s_es_lru_lock ____cacheline_aligned_in_smp;
spinlock_t s_es_lock ____cacheline_aligned_in_smp;

/* Ratelimit ext4 messages. */
struct ratelimit_state s_err_ratelimit_state;
Expand Down
4 changes: 2 additions & 2 deletions fs/ext4/extents.c
Original file line number Diff line number Diff line change
Expand Up @@ -4632,7 +4632,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,

trace_ext4_ext_map_blocks_exit(inode, flags, map,
err ? err : allocated);
ext4_es_lru_add(inode);
ext4_es_list_add(inode);
return err ? err : allocated;
}

Expand Down Expand Up @@ -5191,7 +5191,7 @@ int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
error = ext4_fill_fiemap_extents(inode, start_blk,
len_blks, fieinfo);
}
ext4_es_lru_add(inode);
ext4_es_list_add(inode);
return error;
}

Expand Down
Loading

0 comments on commit edaa53c

Please sign in to comment.