Commit 372d1f3e authored by Dan Carpenter's avatar Dan Carpenter Committed by Jan Kara

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@kiliSigned-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
parent 23ca067b
...@@ -48,8 +48,7 @@ struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb, ...@@ -48,8 +48,7 @@ struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb,
struct ext2_sb_info *sbi = EXT2_SB(sb); struct ext2_sb_info *sbi = EXT2_SB(sb);
if (block_group >= sbi->s_groups_count) { if (block_group >= sbi->s_groups_count) {
ext2_error (sb, "ext2_get_group_desc", WARN(1, "block_group >= groups_count - "
"block_group >= groups_count - "
"block_group = %d, groups_count = %lu", "block_group = %d, groups_count = %lu",
block_group, sbi->s_groups_count); block_group, sbi->s_groups_count);
...@@ -59,8 +58,7 @@ struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb, ...@@ -59,8 +58,7 @@ struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb,
group_desc = block_group >> EXT2_DESC_PER_BLOCK_BITS(sb); group_desc = block_group >> EXT2_DESC_PER_BLOCK_BITS(sb);
offset = block_group & (EXT2_DESC_PER_BLOCK(sb) - 1); offset = block_group & (EXT2_DESC_PER_BLOCK(sb) - 1);
if (!sbi->s_group_desc[group_desc]) { if (!sbi->s_group_desc[group_desc]) {
ext2_error (sb, "ext2_get_group_desc", WARN(1, "Group descriptor not loaded - "
"Group descriptor not loaded - "
"block_group = %d, group_desc = %lu, desc = %lu", "block_group = %d, group_desc = %lu, desc = %lu",
block_group, group_desc, offset); block_group, group_desc, offset);
return NULL; return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment