two clean up patches for mballoc
cover two clean up patches for mballoc
Hi,
Please review the two patches which clean up code a bit.
Thanks,
Guoqing
Guoqing Jiang (2):
ext4: cleanup ext4_issue_discard
ext4: make ext4_mb_release_group_pa returns void
fs/ext4/mballoc.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-)
Signature · 1 line
2.35.3
PATCH 1/2 ext4: cleanup ext4_issue_discard
We can remove the 'biop' parameter and remove the 'if' branch in ext4_issue_discard, since all call sites pass NULL to biop with commit 55cdd0af2bc5 ("ext4: get discard out of jbd2 commit kthread contex").
Signed-off-by Guoqing Jiang <[email protected]>
--- fs/ext4/mballoc.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)
fs/ext4/mballoc.c +4 -12
@@ -3604,8 +3604,7 @@ int ext4_mb_release(struct super_block *sb) }static inline int ext4_issue_discard (struct super_block *sb, -ext4_group_t block_group,ext4_grpblk_t cluster,int count, -struct bio **biop) +ext4_group_t block_group,ext4_grpblk_t cluster,int count) {ext4_fsblk_t discard_block;
@@ -3614,13 +3613,7 @@ static inline int ext4_issue_discard(struct super_block *sb, count =EXT4_C2B (EXT4_SB (sb), count);trace_ext4_discard_blocks (sb, (unsigned long long ) discard_block, count); -if (biop) { -return __blkdev_issue_discard (sb->s_bdev, - (sector_t )discard_block << (sb->s_blocksize_bits -9 ), - (sector_t )count << (sb->s_blocksize_bits -9 ), -GFP_NOFS , biop); - }else -return sb_issue_discard (sb, discard_block, count,GFP_NOFS ,0 ); +return sb_issue_discard (sb, discard_block, count,GFP_NOFS ,0 ); } static void ext4_free_data_in_buddy(struct super_block *sb,
@@ -6229,8 +6222,7 @@ static void ext4_mb_clear_bb(handle_t *handle, struct inode *inode,* them with group lock_held */ if (test_opt (sb,DISCARD )) { - err =ext4_issue_discard (sb, block_group, bit, count, -NULL ); + err =ext4_issue_discard (sb, block_group, bit, count);if (err && err != -EOPNOTSUPP )ext4_msg (sb,KERN_WARNING ,"discard request in" " group:%u block:%d count:%lu failed"
@@ -6568,7 +6560,7 @@ __acquires(bitlock)*/ mb_mark_used (e4b, &ex);ext4_unlock_group (sb, group); - ret =ext4_issue_discard (sb, group, start, count,NULL ); + ret =ext4_issue_discard (sb, group, start, count);ext4_lock_group (sb, group);mb_free_blocks (NULL , e4b, start, ex.fe_len);return ret;
Signature · 1 line
2.35.3
PATCH 2/2 ext4: make ext4_mb_release_group_pa returns void
In reply to Guoqing JiangIt is always return 0 and no one check the return value too.
Signed-off-by Guoqing Jiang <[email protected]>
--- fs/ext4/mballoc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
fs/ext4/mballoc.c +2 -4
@@ -5029,7 +5029,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,return 0 ; } -static noinline_for_stack int +static noinline_for_stack voidext4_mb_release_group_pa (struct ext4_buddy *e4b,struct ext4_prealloc_space *pa) {
@@ -5043,13 +5043,11 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,if (unlikely (group != e4b->bd_group && pa->pa_len !=0 )) {ext4_warning (sb,"bad group: expected %u, group %u, pa_start %llu" , e4b->bd_group, group, pa->pa_pstart); -return 0 ; +return ; }mb_free_blocks (pa->pa_inode, e4b, bit, pa->pa_len);atomic_add (pa->pa_len, &EXT4_SB (sb)->s_mb_discarded);trace_ext4_mballoc_discard (sb,NULL , group, bit, pa->pa_len); - -return 0 ; }/*
Signature · 1 line
2.35.3