From: Jan Kara <jack@suse.cz>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Jan Kara <jack@suse.com>,
linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH v2] ext2: fix sleeping in atomic bugs on error
Date: Wed, 22 Sep 2021 13:05:41 +0200 [thread overview]
Message-ID: <20210922110541.GA23575@quack2.suse.cz> (raw)
In-Reply-To: <20210921203233.GA16529@kili>
On Tue 21-09-21 23:32:33, Dan Carpenter wrote:
> 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().
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Thanks! I've added the patch to my tree.
Honza
> ---
> v2: The first version disabled the sync in ext2_error()
>
> fs/ext2/balloc.c | 14 ++++++--------
> 1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
> index 1f3f4326bf3c..c17ccc19b938 100644
> --- a/fs/ext2/balloc.c
> +++ b/fs/ext2/balloc.c
> @@ -48,10 +48,9 @@ struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb,
> struct ext2_sb_info *sbi = EXT2_SB(sb);
>
> if (block_group >= sbi->s_groups_count) {
> - ext2_error (sb, "ext2_get_group_desc",
> - "block_group >= groups_count - "
> - "block_group = %d, groups_count = %lu",
> - block_group, sbi->s_groups_count);
> + WARN(1, "block_group >= groups_count - "
> + "block_group = %d, groups_count = %lu",
> + block_group, sbi->s_groups_count);
>
> return NULL;
> }
> @@ -59,10 +58,9 @@ struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb,
> group_desc = block_group >> EXT2_DESC_PER_BLOCK_BITS(sb);
> offset = block_group & (EXT2_DESC_PER_BLOCK(sb) - 1);
> if (!sbi->s_group_desc[group_desc]) {
> - ext2_error (sb, "ext2_get_group_desc",
> - "Group descriptor not loaded - "
> - "block_group = %d, group_desc = %lu, desc = %lu",
> - block_group, group_desc, offset);
> + WARN(1, "Group descriptor not loaded - "
> + "block_group = %d, group_desc = %lu, desc = %lu",
> + block_group, group_desc, offset);
> return NULL;
> }
>
> --
> 2.20.1
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
prev parent reply other threads:[~2021-09-22 11:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-21 20:32 [PATCH v2] ext2: fix sleeping in atomic bugs on error Dan Carpenter
2021-09-22 11:05 ` Jan Kara [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210922110541.GA23575@quack2.suse.cz \
--to=jack@suse.cz \
--cc=dan.carpenter@oracle.com \
--cc=jack@suse.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox