Skip to content

Commit

Permalink
ext2: code cleanup for ext2_try_to_allocate()
Browse files Browse the repository at this point in the history
Code cleanup by removing duplicated code.

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Chengguang Xu <[email protected]>
Signed-off-by: Jan Kara <[email protected]>
  • Loading branch information
cgxu519 authored and jankara committed Nov 7, 2019
1 parent ac3820f commit 44dd616
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions fs/ext2/balloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -698,29 +698,20 @@ ext2_try_to_allocate(struct super_block *sb, int group,
;
}
}
start = grp_goal;

repeat:
if (ext2_set_bit_atomic(sb_bgl_lock(EXT2_SB(sb), group), grp_goal,
bitmap_bh->b_data)) {
/*
* The block was allocated by another thread, or it was
* allocated and then freed by another thread
*/
start++;
grp_goal++;
if (start >= end)
goto fail_access;
goto repeat;
}
num++;
grp_goal++;
while (num < *count && grp_goal < end
&& !ext2_set_bit_atomic(sb_bgl_lock(EXT2_SB(sb), group),
for (; num < *count && grp_goal < end; grp_goal++) {
if (ext2_set_bit_atomic(sb_bgl_lock(EXT2_SB(sb), group),
grp_goal, bitmap_bh->b_data)) {
if (num == 0)
continue;
break;
}
num++;
grp_goal++;
}

if (num == 0)
goto fail_access;

*count = num;
return grp_goal - num;
fail_access:
Expand Down

0 comments on commit 44dd616

Please sign in to comment.