Skip to content

Commit 8326983

Browse files
LiBaokun96tytso
authored andcommitted
ext4: avoid allocating blocks from corrupted group in ext4_mb_find_by_goal()
Places the logic for checking if the group's block bitmap is corrupt under the protection of the group lock to avoid allocating blocks from the group with a corrupted block bitmap. Signed-off-by: Baokun Li <libaokun1@huawei.com> Reviewed-by: Jan Kara <jack@suse.cz> Link: https://lore.kernel.org/r/20240104142040.2835097-8-libaokun1@huawei.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent 4530b36 commit 8326983

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

fs/ext4/mballoc.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2336,12 +2336,10 @@ int ext4_mb_find_by_goal(struct ext4_allocation_context *ac,
23362336
if (err)
23372337
return err;
23382338

2339-
if (unlikely(EXT4_MB_GRP_BBITMAP_CORRUPT(e4b->bd_info))) {
2340-
ext4_mb_unload_buddy(e4b);
2341-
return 0;
2342-
}
2343-
23442339
ext4_lock_group(ac->ac_sb, group);
2340+
if (unlikely(EXT4_MB_GRP_BBITMAP_CORRUPT(e4b->bd_info)))
2341+
goto out;
2342+
23452343
max = mb_find_extent(e4b, ac->ac_g_ex.fe_start,
23462344
ac->ac_g_ex.fe_len, &ex);
23472345
ex.fe_logical = 0xDEADFA11; /* debug value */
@@ -2374,6 +2372,7 @@ int ext4_mb_find_by_goal(struct ext4_allocation_context *ac,
23742372
ac->ac_b_ex = ex;
23752373
ext4_mb_use_best_found(ac, e4b);
23762374
}
2375+
out:
23772376
ext4_unlock_group(ac->ac_sb, group);
23782377
ext4_mb_unload_buddy(e4b);
23792378

0 commit comments

Comments
 (0)