public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Zorro Lang <zlang@redhat.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [Bug][xfstests xfs/556] inconsistent {HARDIRQ-ON-W} -> {IN-HARDIRQ-W} usage
Date: Fri, 20 Mar 2026 09:34:44 -0700	[thread overview]
Message-ID: <20260320163444.GE6223@frogsfrogsfrogs> (raw)
In-Reply-To: <20260319194303.efw4wcu7c4idhthz@doltdoltdolt>

On Fri, Mar 20, 2026 at 03:43:03AM +0800, Zorro Lang wrote:
> Hi,
> 
> While running fstests xfs/556 on kernel 7.0.0-rc4+ (HEAD=04a9f1766954), a
> lockdep warning was triggered indicating an inconsistent lock state for
> sb->s_type->i_lock_key.
> 
> The deadlock might occur because iomap_read_end_io (called from a hardware
> interrupt completion path) invokes fserror_report, which then calls igrab.
> igrab attempts to acquire the i_lock spinlock. However, the i_lock is frequently
> acquired in process context with interrupts enabled. If an interrupt occurs while
> a process holds the i_lock, and that interrupt handler calls fserror_report, the
> system deadlocks.
> 
> I hit this warning several times by running xfs/556 (mostly) or generic/648
> on xfs. More details refer to below console log.
> 
> Thanks,
> Zorro

Does the patch below fix the lockdep complaint for you?  It fixes it
here on my local machine...

diff --git a/fs/iomap/bio.c b/fs/iomap/bio.c
index fc045f2e4c459e..cf98247e51f81e 100644
--- a/fs/iomap/bio.c
+++ b/fs/iomap/bio.c
@@ -8,7 +8,15 @@
 #include "internal.h"
 #include "trace.h"
 
-static void iomap_read_end_io(struct bio *bio)
+struct iomap_failed_bio {
+	struct list_head io_list;
+	struct bio *bio;
+};
+
+static DEFINE_SPINLOCK(failed_read_lock);
+static LIST_HEAD(failed_read_list);
+
+static void __iomap_read_end_io(struct bio *bio)
 {
 	int error = blk_status_to_errno(bio->bi_status);
 	struct folio_iter fi;
@@ -18,6 +26,61 @@ static void iomap_read_end_io(struct bio *bio)
 	bio_put(bio);
 }
 
+static void
+iomap_fail_reads(
+	struct work_struct	*work)
+{
+	struct iomap_failed_bio	*fb;
+	struct list_head	tmp;
+	unsigned long		flags;
+
+	spin_lock_irqsave(&failed_read_lock, flags);
+	list_replace_init(&failed_read_list, &tmp);
+	spin_unlock_irqrestore(&failed_read_lock, flags);
+
+	while ((fb = list_first_entry_or_null(&tmp, struct iomap_failed_bio,
+			io_list))) {
+		list_del_init(&fb->io_list);
+		__iomap_read_end_io(fb->bio);
+		kfree(fb);
+		cond_resched();
+	}
+}
+
+static DECLARE_WORK(failed_read_work, iomap_fail_reads);
+
+static void iomap_fail_buffered_read(struct iomap_failed_bio *fb)
+{
+	unsigned long flags;
+
+	/*
+	 * Bounce I/O errors to a workqueue to avoid nested i_lock acquisitions
+	 * in the fserror code.  The caller no longer owns the fb reference
+	 * after the spinlock drops.
+	 */
+	spin_lock_irqsave(&failed_read_lock, flags);
+	if (list_empty(&failed_read_list))
+		WARN_ON_ONCE(!schedule_work(&failed_read_work));
+	list_add_tail(&fb->io_list, &failed_read_list);
+	spin_unlock_irqrestore(&failed_read_lock, flags);
+}
+
+static void iomap_read_end_io(struct bio *bio)
+{
+	if (bio->bi_status) {
+		struct iomap_failed_bio *fb = kzalloc_obj(*fb, GFP_ATOMIC);
+
+		if (fb) {
+			fb->bio = bio;
+			INIT_LIST_HEAD(&fb->io_list);
+			iomap_fail_buffered_read(fb);
+			return;
+		}
+	}
+
+	__iomap_read_end_io(bio);
+}
+
 static void iomap_bio_submit_read(struct iomap_read_folio_ctx *ctx)
 {
 	struct bio *bio = ctx->read_ctx;

  parent reply	other threads:[~2026-03-20 16:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-19 19:43 [Bug][xfstests xfs/556] inconsistent {HARDIRQ-ON-W} -> {IN-HARDIRQ-W} usage Zorro Lang
2026-03-20  7:23 ` Christoph Hellwig
2026-03-20 14:27   ` Darrick J. Wong
2026-03-23  6:15     ` Christoph Hellwig
2026-03-20 16:34 ` Darrick J. Wong [this message]
2026-03-21 18:20   ` Zorro Lang
2026-03-23 11:29     ` Zorro Lang
2026-03-23  6:17   ` Christoph Hellwig
2026-03-23 15:22     ` Darrick J. Wong
2026-03-23 21:00       ` [PATCH] iomap: fix lockdep complaint when reads fail Darrick J. Wong
2026-03-24  6:14         ` Christoph Hellwig
2026-03-25  0:16           ` Jens Axboe
2026-03-24  8:15         ` Christian Brauner
2026-03-24 17:06           ` Darrick J. Wong

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=20260320163444.GE6223@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=zlang@redhat.com \
    /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