Skip to content

Commit

Permalink
ext4: protect bb_first_free in ext4_trim_all_free() with group lock
Browse files Browse the repository at this point in the history
We should protect reading bd_info->bb_first_free with the group lock
because otherwise we might miss some free blocks. This is not a big deal
at all, but the change to do right thing is really simple, so lets do
that.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
  • Loading branch information
Lukas Czerner authored and Theodore Ts'o committed May 24, 2011
1 parent 7894408 commit 28739ee
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fs/ext4/mballoc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4825,11 +4825,11 @@ ext4_trim_all_free(struct super_block *sb, ext4_group_t group,
"information for %u", group);
return ret;
}

bitmap = e4b.bd_bitmap;

ext4_lock_group(sb, group);
start = (e4b.bd_info->bb_first_free > start) ?
e4b.bd_info->bb_first_free : start;
ext4_lock_group(sb, group);

while (start < max) {
start = mb_find_next_zero_bit(bitmap, max, start);
Expand Down

0 comments on commit 28739ee

Please sign in to comment.