Skip to content

Commit

Permalink
ext4: add checksum calculation when clearing UNINIT flag in ext4_new_…
Browse files Browse the repository at this point in the history
…inode

When initializing an uninitialized block group in ext4_new_inode(),
its block group checksum must be re-calculated.  This fixes a race
when several threads try to allocate a new inode in an UNINIT'd group.

There is some question whether we need to be initializing the block
bitmap in ext4_new_inode() at all, but for now, if we are going to
init the block group, let's eliminate the race.

Signed-off-by: Frederic Bohe <frederic.bohe@bull.net>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
  • Loading branch information
Frederic Bohe authored and Theodore Ts'o committed Nov 7, 2008
1 parent ed9b3e3 commit 23712a9
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fs/ext4/ialloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,8 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode)
gdp->bg_flags &= cpu_to_le16(~EXT4_BG_BLOCK_UNINIT);
free = ext4_free_blocks_after_init(sb, group, gdp);
gdp->bg_free_blocks_count = cpu_to_le16(free);
gdp->bg_checksum = ext4_group_desc_csum(sbi, group,
gdp);
}
spin_unlock(sb_bgl_lock(sbi, group));

Expand Down

0 comments on commit 23712a9

Please sign in to comment.