Linux XFS filesystem development
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Carlos Maiolino <cem@kernel.org>
Cc: "Darrick J. Wong" <djwong@kernel.org>,
	Dan Carpenter <dan.carpenter@linaro.org>,
	Hans Holmberg <hans.holmberg@wdc.com>,
	linux-xfs@vger.kernel.org
Subject: [PATCH 3/3] xfs: don't wake zone space waiters without m_zone_info
Date: Mon, 17 Mar 2025 06:44:54 +0100	[thread overview]
Message-ID: <20250317054512.1131950-4-hch@lst.de> (raw)
In-Reply-To: <20250317054512.1131950-1-hch@lst.de>

From: "Darrick J. Wong" <djwong@kernel.org>

xfs_zoned_wake_all checks SB_ACTIVE to make sure it does the right thing
when a shutdown happens during unmount, but it fails to account for the
log recovery special case that sets SB_ACTIVE temporarily.  Add a NULL
check to cover both cases.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
[hch: added a commit log and comment]
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_zone_alloc.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/fs/xfs/xfs_zone_alloc.c b/fs/xfs/xfs_zone_alloc.c
index fd4c60a050e6..52af234936a2 100644
--- a/fs/xfs/xfs_zone_alloc.c
+++ b/fs/xfs/xfs_zone_alloc.c
@@ -853,13 +853,22 @@ xfs_zone_alloc_and_submit(
 	bio_io_error(&ioend->io_bio);
 }
 
+/*
+ * Wake up all threads waiting for a zoned space allocation when the file system
+ * is shut down.
+ */
 void
 xfs_zoned_wake_all(
 	struct xfs_mount	*mp)
 {
-	if (!(mp->m_super->s_flags & SB_ACTIVE))
-		return; /* can happen during log recovery */
-	wake_up_all(&mp->m_zone_info->zi_zone_wait);
+	/*
+	 * Don't wake up if there is no m_zone_info.  This is complicated by the
+	 * fact that unmount can't atomically clear m_zone_info and thus we need
+	 * to check SB_ACTIVE for that, but mount temporarily enables SB_ACTIVE
+	 * during log recovery so we can't entirely rely on that either.
+	 */
+	if ((mp->m_super->s_flags & SB_ACTIVE) && mp->m_zone_info)
+		wake_up_all(&mp->m_zone_info->zi_zone_wait);
 }
 
 /*
-- 
2.45.2


  parent reply	other threads:[~2025-03-17  5:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-17  5:44 zoned fixes Christoph Hellwig
2025-03-17  5:44 ` [PATCH 1/3] xfs: fix a missing unlock in xfs_growfs_data Christoph Hellwig
2025-03-18 11:54   ` Carlos Maiolino
2025-03-24  8:52   ` Carlos Maiolino
2025-03-17  5:44 ` [PATCH 2/3] xfs: don't increment m_generation for all errors " Christoph Hellwig
2025-03-18 12:01   ` Carlos Maiolino
2025-03-17  5:44 ` Christoph Hellwig [this message]
2025-03-17 14:46   ` [PATCH 3/3] xfs: don't wake zone space waiters without m_zone_info Hans Holmberg
2025-03-18 12:04   ` Carlos Maiolino

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=20250317054512.1131950-4-hch@lst.de \
    --to=hch@lst.de \
    --cc=cem@kernel.org \
    --cc=dan.carpenter@linaro.org \
    --cc=djwong@kernel.org \
    --cc=hans.holmberg@wdc.com \
    --cc=linux-xfs@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