aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2014-11-25 11:49:25 -0500
committerTheodore Ts'o <tytso@mit.edu>2014-11-25 11:49:25 -0500
commitb0dea4c1651f3cdb6d17604fa473e72cb74cdc6b (patch)
tree2d95931301e7d82cc086881dfb08c636a3f9c314 /fs/ext4
parentedaa53cac8fd4b96ed4b8f96c4933158ff2dd337 (diff)
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')
-rw-r--r--fs/ext4/extents.c2
-rw-r--r--fs/ext4/extents_status.c10
-rw-r--r--fs/ext4/extents_status.h2
-rw-r--r--fs/ext4/inode.c2
-rw-r--r--fs/ext4/ioctl.c2
-rw-r--r--fs/ext4/super.c1
6 files changed, 6 insertions, 13 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index e406f66a903f..e2424bafd6fe 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4632,7 +4632,6 @@ out2:
4632 4632
4633 trace_ext4_ext_map_blocks_exit(inode, flags, map, 4633 trace_ext4_ext_map_blocks_exit(inode, flags, map,
4634 err ? err : allocated); 4634 err ? err : allocated);
4635 ext4_es_list_add(inode);
4636 return err ? err : allocated; 4635 return err ? err : allocated;
4637} 4636}
4638 4637
@@ -5191,7 +5190,6 @@ int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
5191 error = ext4_fill_fiemap_extents(inode, start_blk, 5190 error = ext4_fill_fiemap_extents(inode, start_blk,
5192 len_blks, fieinfo); 5191 len_blks, fieinfo);
5193 } 5192 }
5194 ext4_es_list_add(inode);
5195 return error; 5193 return error;
5196} 5194}
5197 5195
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:
298 trace_ext4_es_find_delayed_extent_range_exit(inode, es); 298 trace_ext4_es_find_delayed_extent_range_exit(inode, es);
299} 299}
300 300
301void ext4_es_list_add(struct inode *inode) 301static void ext4_es_list_add(struct inode *inode)
302{ 302{
303 struct ext4_inode_info *ei = EXT4_I(inode); 303 struct ext4_inode_info *ei = EXT4_I(inode);
304 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); 304 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
@@ -314,7 +314,7 @@ void ext4_es_list_add(struct inode *inode)
314 spin_unlock(&sbi->s_es_lock); 314 spin_unlock(&sbi->s_es_lock);
315} 315}
316 316
317void ext4_es_list_del(struct inode *inode) 317static void ext4_es_list_del(struct inode *inode)
318{ 318{
319 struct ext4_inode_info *ei = EXT4_I(inode); 319 struct ext4_inode_info *ei = EXT4_I(inode);
320 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); 320 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,
344 * We don't count delayed extent because we never try to reclaim them 344 * We don't count delayed extent because we never try to reclaim them
345 */ 345 */
346 if (!ext4_es_is_delayed(es)) { 346 if (!ext4_es_is_delayed(es)) {
347 EXT4_I(inode)->i_es_shk_nr++; 347 if (!EXT4_I(inode)->i_es_shk_nr++)
348 ext4_es_list_add(inode);
348 percpu_counter_inc(&EXT4_SB(inode->i_sb)-> 349 percpu_counter_inc(&EXT4_SB(inode->i_sb)->
349 s_es_stats.es_stats_shk_cnt); 350 s_es_stats.es_stats_shk_cnt);
350 } 351 }
@@ -363,7 +364,8 @@ static void ext4_es_free_extent(struct inode *inode, struct extent_status *es)
363 /* Decrease the shrink counter when this es is not delayed */ 364 /* Decrease the shrink counter when this es is not delayed */
364 if (!ext4_es_is_delayed(es)) { 365 if (!ext4_es_is_delayed(es)) {
365 BUG_ON(EXT4_I(inode)->i_es_shk_nr == 0); 366 BUG_ON(EXT4_I(inode)->i_es_shk_nr == 0);
366 EXT4_I(inode)->i_es_shk_nr--; 367 if (!--EXT4_I(inode)->i_es_shk_nr)
368 ext4_es_list_del(inode);
367 percpu_counter_dec(&EXT4_SB(inode->i_sb)-> 369 percpu_counter_dec(&EXT4_SB(inode->i_sb)->
368 s_es_stats.es_stats_shk_cnt); 370 s_es_stats.es_stats_shk_cnt);
369 } 371 }
diff --git a/fs/ext4/extents_status.h b/fs/ext4/extents_status.h
index 0e6a33e81e5f..b0b78b95f481 100644
--- a/fs/ext4/extents_status.h
+++ b/fs/ext4/extents_status.h
@@ -150,7 +150,5 @@ static inline void ext4_es_store_pblock_status(struct extent_status *es,
150 150
151extern int ext4_es_register_shrinker(struct ext4_sb_info *sbi); 151extern int ext4_es_register_shrinker(struct ext4_sb_info *sbi);
152extern void ext4_es_unregister_shrinker(struct ext4_sb_info *sbi); 152extern void ext4_es_unregister_shrinker(struct ext4_sb_info *sbi);
153extern void ext4_es_list_add(struct inode *inode);
154extern void ext4_es_list_del(struct inode *inode);
155 153
156#endif /* _EXT4_EXTENTS_STATUS_H */ 154#endif /* _EXT4_EXTENTS_STATUS_H */
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 540b0b0481a5..b416b461fa50 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -486,7 +486,6 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
486 486
487 /* Lookup extent status tree firstly */ 487 /* Lookup extent status tree firstly */
488 if (ext4_es_lookup_extent(inode, map->m_lblk, &es)) { 488 if (ext4_es_lookup_extent(inode, map->m_lblk, &es)) {
489 ext4_es_list_add(inode);
490 if (ext4_es_is_written(&es) || ext4_es_is_unwritten(&es)) { 489 if (ext4_es_is_written(&es) || ext4_es_is_unwritten(&es)) {
491 map->m_pblk = ext4_es_pblock(&es) + 490 map->m_pblk = ext4_es_pblock(&es) +
492 map->m_lblk - es.es_lblk; 491 map->m_lblk - es.es_lblk;
@@ -1388,7 +1387,6 @@ static int ext4_da_map_blocks(struct inode *inode, sector_t iblock,
1388 1387
1389 /* Lookup extent status tree firstly */ 1388 /* Lookup extent status tree firstly */
1390 if (ext4_es_lookup_extent(inode, iblock, &es)) { 1389 if (ext4_es_lookup_extent(inode, iblock, &es)) {
1391 ext4_es_list_add(inode);
1392 if (ext4_es_is_hole(&es)) { 1390 if (ext4_es_is_hole(&es)) {
1393 retval = 0; 1391 retval = 0;
1394 down_read(&EXT4_I(inode)->i_data_sem); 1392 down_read(&EXT4_I(inode)->i_data_sem);
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 7b377c41dd81..f58a0d106726 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -78,8 +78,6 @@ static void swap_inode_data(struct inode *inode1, struct inode *inode2)
78 memswap(&ei1->i_disksize, &ei2->i_disksize, sizeof(ei1->i_disksize)); 78 memswap(&ei1->i_disksize, &ei2->i_disksize, sizeof(ei1->i_disksize));
79 ext4_es_remove_extent(inode1, 0, EXT_MAX_BLOCKS); 79 ext4_es_remove_extent(inode1, 0, EXT_MAX_BLOCKS);
80 ext4_es_remove_extent(inode2, 0, EXT_MAX_BLOCKS); 80 ext4_es_remove_extent(inode2, 0, EXT_MAX_BLOCKS);
81 ext4_es_list_del(inode1);
82 ext4_es_list_del(inode2);
83 81
84 isize = i_size_read(inode1); 82 isize = i_size_read(inode1);
85 i_size_write(inode1, i_size_read(inode2)); 83 i_size_write(inode1, i_size_read(inode2));
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 32df08e99ca9..e2a17f8b7adc 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -962,7 +962,6 @@ void ext4_clear_inode(struct inode *inode)
962 dquot_drop(inode); 962 dquot_drop(inode);
963 ext4_discard_preallocations(inode); 963 ext4_discard_preallocations(inode);
964 ext4_es_remove_extent(inode, 0, EXT_MAX_BLOCKS); 964 ext4_es_remove_extent(inode, 0, EXT_MAX_BLOCKS);
965 ext4_es_list_del(inode);
966 if (EXT4_I(inode)->jinode) { 965 if (EXT4_I(inode)->jinode) {
967 jbd2_journal_release_jbd_inode(EXT4_JOURNAL(inode), 966 jbd2_journal_release_jbd_inode(EXT4_JOURNAL(inode),
968 EXT4_I(inode)->jinode); 967 EXT4_I(inode)->jinode);