While in ext4_validate_block_bitmap(), if an block allocation bitmapis found to be invalid, we call ext4_error() while the block group isstill locked. This causes ext4_commit_super() to call a functionwhich might sleep while in an atomic context.

There's no need to keep the block group locked at this point, so hoistthe ext4_error() call up to ext4_validate_block_bitmap() and releasethe block group spinlock before calling ext4_error().

if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG)) {@@ -297,37 +301,33 @@ static int ext4_valid_block_bitmap(struct super_block *sb, * or it has to also read the block group where the bitmaps * are located to verify they are set. */- return 1;+ return 0; } group_first_block = ext4_group_first_block_no(sb, block_group);