Skip to content

Commit 372d1f3

Browse files
Dan Carpenterjankara
authored andcommitted
ext2: fix sleeping in atomic bugs on error
The ext2_error() function syncs the filesystem so it sleeps. The caller is holding a spinlock so it's not allowed to sleep. ext2_statfs() <- disables preempt -> ext2_count_free_blocks() -> ext2_get_group_desc() Fix this by using WARN() to print an error message and a stack trace instead of using ext2_error(). Link: https://lore.kernel.org/r/20210921203233.GA16529@kili Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Jan Kara <[email protected]>
1 parent 23ca067 commit 372d1f3

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

fs/ext2/balloc.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,19 @@ struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb,
4848
struct ext2_sb_info *sbi = EXT2_SB(sb);
4949

5050
if (block_group >= sbi->s_groups_count) {
51-
ext2_error (sb, "ext2_get_group_desc",
52-
"block_group >= groups_count - "
53-
"block_group = %d, groups_count = %lu",
54-
block_group, sbi->s_groups_count);
51+
WARN(1, "block_group >= groups_count - "
52+
"block_group = %d, groups_count = %lu",
53+
block_group, sbi->s_groups_count);
5554

5655
return NULL;
5756
}
5857

5958
group_desc = block_group >> EXT2_DESC_PER_BLOCK_BITS(sb);
6059
offset = block_group & (EXT2_DESC_PER_BLOCK(sb) - 1);
6160
if (!sbi->s_group_desc[group_desc]) {
62-
ext2_error (sb, "ext2_get_group_desc",
63-
"Group descriptor not loaded - "
64-
"block_group = %d, group_desc = %lu, desc = %lu",
65-
block_group, group_desc, offset);
61+
WARN(1, "Group descriptor not loaded - "
62+
"block_group = %d, group_desc = %lu, desc = %lu",
63+
block_group, group_desc, offset);
6664
return NULL;
6765
}
6866

0 commit comments

Comments
 (0)