summaryrefslogtreecommitdiff
path: root/fs/ext4/extents_status.c
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2014-11-25 19:49:25 +0300
committerTheodore Ts'o <tytso@mit.edu>2014-11-25 19:49:25 +0300
commitb0dea4c1651f3cdb6d17604fa473e72cb74cdc6b (patch)
tree2d95931301e7d82cc086881dfb08c636a3f9c314 /fs/ext4/extents_status.c
parentedaa53cac8fd4b96ed4b8f96c4933158ff2dd337 (diff)
downloadlinux-b0dea4c1651f3cdb6d17604fa473e72cb74cdc6b.tar.xz
ext4: move handling of list of shrinkable inodes into extent status code
Currently callers adding extents to extent status tree were responsible for adding the inode to the list of inodes with freeable extents. This is error prone and puts list handling in unnecessarily many places. Just add inode to the list automatically when the first non-delay extent is added to the tree and remove inode from the list when the last non-delay extent is removed. Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/extents_status.c')
-rw-r--r--fs/ext4/extents_status.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
index 0193ca107396..de2d9d8bf22f 100644
--- a/fs/ext4/extents_status.c
+++ b/fs/ext4/extents_status.c
@@ -298,7 +298,7 @@ out:
trace_ext4_es_find_delayed_extent_range_exit(inode, es);
}
-void ext4_es_list_add(struct inode *inode)
+static void ext4_es_list_add(struct inode *inode)
{
struct ext4_inode_info *ei = EXT4_I(inode);
struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
@@ -314,7 +314,7 @@ void ext4_es_list_add(struct inode *inode)
spin_unlock(&sbi->s_es_lock);
}
-void ext4_es_list_del(struct inode *inode)
+static void ext4_es_list_del(struct inode *inode)
{
struct ext4_inode_info *ei = EXT4_I(inode);
struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
@@ -344,7 +344,8 @@ ext4_es_alloc_extent(struct inode *inode, ext4_lblk_t lblk, ext4_lblk_t len,
* We don't count delayed extent because we never try to reclaim them
*/
if (!ext4_es_is_delayed(es)) {
- EXT4_I(inode)->i_es_shk_nr++;
+ if (!EXT4_I(inode)->i_es_shk_nr++)
+ ext4_es_list_add(inode);
percpu_counter_inc(&EXT4_SB(inode->i_sb)->
s_es_stats.es_stats_shk_cnt);
}
@@ -363,7 +364,8 @@ static void ext4_es_free_extent(struct inode *inode, struct extent_status *es)
/* Decrease the shrink counter when this es is not delayed */
if (!ext4_es_is_delayed(es)) {
BUG_ON(EXT4_I(inode)->i_es_shk_nr == 0);
- EXT4_I(inode)->i_es_shk_nr--;
+ if (!--EXT4_I(inode)->i_es_shk_nr)
+ ext4_es_list_del(inode);
percpu_counter_dec(&EXT4_SB(inode->i_sb)->
s_es_stats.es_stats_shk_cnt);
}