Skip to content

Commit 66d5e02

Browse files
brookxu-cntytso
authored andcommitted
ext4: reorganize if statement of ext4_mb_release_context()
Reorganize the if statement of ext4_mb_release_context(), make it easier to read. Signed-off-by: Chunguang Xu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Ritesh Harjani <[email protected]> Signed-off-by: Theodore Ts'o <[email protected]>
1 parent c55ee7d commit 66d5e02

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

fs/ext4/mballoc.c

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2309,7 +2309,7 @@ ext4_mb_regular_allocator(struct ext4_allocation_context *ac)
23092309
struct ext4_sb_info *sbi;
23102310
struct super_block *sb;
23112311
struct ext4_buddy e4b;
2312-
unsigned int lost;
2312+
int lost;
23132313

23142314
sb = ac->ac_sb;
23152315
sbi = EXT4_SB(sb);
@@ -2464,8 +2464,8 @@ ext4_mb_regular_allocator(struct ext4_allocation_context *ac)
24642464
* The only thing we can do is just take first
24652465
* found block(s)
24662466
*/
2467-
lost = (unsigned int)atomic_inc_return(&sbi->s_mb_lost_chunks);
2468-
mb_debug(sb, "lost chunk, group: %u, start: %d, len: %d, lost: %u\n",
2467+
lost = atomic_inc_return(&sbi->s_mb_lost_chunks);
2468+
mb_debug(sb, "lost chunk, group: %u, start: %d, len: %d, lost: %d\n",
24692469
ac->ac_b_ex.fe_group, ac->ac_b_ex.fe_start,
24702470
ac->ac_b_ex.fe_len, lost);
24712471

@@ -4706,20 +4706,19 @@ static int ext4_mb_release_context(struct ext4_allocation_context *ac)
47064706
pa->pa_free -= ac->ac_b_ex.fe_len;
47074707
pa->pa_len -= ac->ac_b_ex.fe_len;
47084708
spin_unlock(&pa->pa_lock);
4709-
}
4710-
}
4711-
if (pa) {
4712-
/*
4713-
* We want to add the pa to the right bucket.
4714-
* Remove it from the list and while adding
4715-
* make sure the list to which we are adding
4716-
* doesn't grow big.
4717-
*/
4718-
if ((pa->pa_type == MB_GROUP_PA) && likely(pa->pa_free)) {
4719-
spin_lock(pa->pa_obj_lock);
4720-
list_del_rcu(&pa->pa_inode_list);
4721-
spin_unlock(pa->pa_obj_lock);
4722-
ext4_mb_add_n_trim(ac);
4709+
4710+
/*
4711+
* We want to add the pa to the right bucket.
4712+
* Remove it from the list and while adding
4713+
* make sure the list to which we are adding
4714+
* doesn't grow big.
4715+
*/
4716+
if (likely(pa->pa_free)) {
4717+
spin_lock(pa->pa_obj_lock);
4718+
list_del_rcu(&pa->pa_inode_list);
4719+
spin_unlock(pa->pa_obj_lock);
4720+
ext4_mb_add_n_trim(ac);
4721+
}
47234722
}
47244723
ext4_mb_put_pa(ac, ac->ac_sb, pa);
47254724
}

0 commit comments

Comments
 (0)