* [PATCH] ext4: use ext4_grp_locked_error in mb_find_extent
@ 2021-06-23 23:21 Stephen Brennan
2021-06-24 9:55 ` Lukas Czerner
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Brennan @ 2021-06-23 23:21 UTC (permalink / raw)
To: Theodore Ts'o, Andreas Dilger, linux-ext4, linux-kernel,
Junxiao Bi
Commit 5d1b1b3f492f ("ext4: fix BUG when calling ext4_error with locked
block group") introduces ext4_grp_locked_error to handle unlocking a
group in error cases. Otherwise, there is a possibility of a sleep while
atomic. However, since 43c73221b3b1 ("ext4: replace BUG_ON with WARN_ON
in mb_find_extent()"), mb_find_extent() has contained a ext4_error()
call while a group spinlock is held. Replace this with
ext4_grp_locked_error.
Fixes: 43c73221b3b1 ("ext4: replace BUG_ON with WARN_ON in mb_find_extent()")
Cc: <stable@vger.kernel.org> # 4.14+
Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
Reviewed-by: Junxiao Bi <junxiao.bi@oracle.com>
---
fs/ext4/mballoc.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index c2c22c2baac0..089c958aa2c3 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -1909,10 +1909,11 @@ static int mb_find_extent(struct ext4_buddy *e4b, int block,
if (ex->fe_start + ex->fe_len > EXT4_CLUSTERS_PER_GROUP(e4b->bd_sb)) {
/* Should never happen! (but apparently sometimes does?!?) */
WARN_ON(1);
- ext4_error(e4b->bd_sb, "corruption or bug in mb_find_extent "
- "block=%d, order=%d needed=%d ex=%u/%d/%d@%u",
- block, order, needed, ex->fe_group, ex->fe_start,
- ex->fe_len, ex->fe_logical);
+ ext4_grp_locked_error(e4b->bd_sb, e4b->bd_group, 0, 0,
+ "corruption or bug in mb_find_extent "
+ "block=%d, order=%d needed=%d ex=%u/%d/%d@%u",
+ block, order, needed, ex->fe_group, ex->fe_start,
+ ex->fe_len, ex->fe_logical);
ex->fe_len = 0;
ex->fe_start = 0;
ex->fe_group = 0;
--
2.30.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ext4: use ext4_grp_locked_error in mb_find_extent
2021-06-23 23:21 [PATCH] ext4: use ext4_grp_locked_error in mb_find_extent Stephen Brennan
@ 2021-06-24 9:55 ` Lukas Czerner
2021-07-01 21:14 ` Theodore Ts'o
0 siblings, 1 reply; 3+ messages in thread
From: Lukas Czerner @ 2021-06-24 9:55 UTC (permalink / raw)
To: Stephen Brennan
Cc: Theodore Ts'o, Andreas Dilger, linux-ext4, linux-kernel,
Junxiao Bi
On Wed, Jun 23, 2021 at 04:21:14PM -0700, Stephen Brennan wrote:
> Commit 5d1b1b3f492f ("ext4: fix BUG when calling ext4_error with locked
> block group") introduces ext4_grp_locked_error to handle unlocking a
> group in error cases. Otherwise, there is a possibility of a sleep while
> atomic. However, since 43c73221b3b1 ("ext4: replace BUG_ON with WARN_ON
> in mb_find_extent()"), mb_find_extent() has contained a ext4_error()
> call while a group spinlock is held. Replace this with
> ext4_grp_locked_error.
>
> Fixes: 43c73221b3b1 ("ext4: replace BUG_ON with WARN_ON in mb_find_extent()")
> Cc: <stable@vger.kernel.org> # 4.14+
> Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
> Reviewed-by: Junxiao Bi <junxiao.bi@oracle.com>
Good catch, looks good to me.
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
Thanks!
-Lukas
> ---
> fs/ext4/mballoc.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index c2c22c2baac0..089c958aa2c3 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -1909,10 +1909,11 @@ static int mb_find_extent(struct ext4_buddy *e4b, int block,
> if (ex->fe_start + ex->fe_len > EXT4_CLUSTERS_PER_GROUP(e4b->bd_sb)) {
> /* Should never happen! (but apparently sometimes does?!?) */
> WARN_ON(1);
> - ext4_error(e4b->bd_sb, "corruption or bug in mb_find_extent "
> - "block=%d, order=%d needed=%d ex=%u/%d/%d@%u",
> - block, order, needed, ex->fe_group, ex->fe_start,
> - ex->fe_len, ex->fe_logical);
> + ext4_grp_locked_error(e4b->bd_sb, e4b->bd_group, 0, 0,
> + "corruption or bug in mb_find_extent "
> + "block=%d, order=%d needed=%d ex=%u/%d/%d@%u",
> + block, order, needed, ex->fe_group, ex->fe_start,
> + ex->fe_len, ex->fe_logical);
> ex->fe_len = 0;
> ex->fe_start = 0;
> ex->fe_group = 0;
> --
> 2.30.2
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ext4: use ext4_grp_locked_error in mb_find_extent
2021-06-24 9:55 ` Lukas Czerner
@ 2021-07-01 21:14 ` Theodore Ts'o
0 siblings, 0 replies; 3+ messages in thread
From: Theodore Ts'o @ 2021-07-01 21:14 UTC (permalink / raw)
To: Lukas Czerner
Cc: Stephen Brennan, Andreas Dilger, linux-ext4, linux-kernel,
Junxiao Bi
On Thu, Jun 24, 2021 at 11:55:01AM +0200, Lukas Czerner wrote:
> On Wed, Jun 23, 2021 at 04:21:14PM -0700, Stephen Brennan wrote:
> > Commit 5d1b1b3f492f ("ext4: fix BUG when calling ext4_error with locked
> > block group") introduces ext4_grp_locked_error to handle unlocking a
> > group in error cases. Otherwise, there is a possibility of a sleep while
> > atomic. However, since 43c73221b3b1 ("ext4: replace BUG_ON with WARN_ON
> > in mb_find_extent()"), mb_find_extent() has contained a ext4_error()
> > call while a group spinlock is held. Replace this with
> > ext4_grp_locked_error.
> >
> > Fixes: 43c73221b3b1 ("ext4: replace BUG_ON with WARN_ON in mb_find_extent()")
> > Cc: <stable@vger.kernel.org> # 4.14+
> > Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
> > Reviewed-by: Junxiao Bi <junxiao.bi@oracle.com>
>
> Good catch, looks good to me.
>
> Reviewed-by: Lukas Czerner <lczerner@redhat.com>
Thanks, applied.
- Ted
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-07-01 21:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-06-23 23:21 [PATCH] ext4: use ext4_grp_locked_error in mb_find_extent Stephen Brennan
2021-06-24 9:55 ` Lukas Czerner
2021-07-01 21:14 ` Theodore Ts'o
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).