diff options
author | Chengguang Xu <cgxu519@mykernel.net> | 2019-11-04 12:40:35 +0100 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2019-11-07 12:35:27 +0100 |
commit | 44dd6161338ef528b5b011184639beadcf038b14 (patch) | |
tree | 15ee851136fd2b53aa080f68d0de62a032458f4a /fs | |
parent | ext2: skip unnecessary operations in ext2_try_to_allocate() (diff) | |
download | linux-44dd6161338ef528b5b011184639beadcf038b14.tar.xz linux-44dd6161338ef528b5b011184639beadcf038b14.zip |
ext2: code cleanup for ext2_try_to_allocate()
Code cleanup by removing duplicated code.
Link: https://lore.kernel.org/r/20191104114036.9893-4-cgxu519@mykernel.net
Signed-off-by: Chengguang Xu <cgxu519@mykernel.net>
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ext2/balloc.c | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c index f3ff05edaf8c..4beb416be9cf 100644 --- a/fs/ext2/balloc.c +++ b/fs/ext2/balloc.c @@ -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: |