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>, linux-xfs@vger.kernel.org
Subject: [PATCH 6/9] xfs: lift setting the NOFS context to xfs_end_io
Date: Thu, 24 Sep 2026 11:57:07 +0200	[thread overview]
Message-ID: <20260924095740.2732474-7-hch@lst.de> (raw)
In-Reply-To: <20260924095740.2732474-1-hch@lst.de>

No point in clearing and restoring it for every processed bio.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_ioend.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/fs/xfs/xfs_ioend.c b/fs/xfs/xfs_ioend.c
index e70be5b86f0b..258c6130bee8 100644
--- a/fs/xfs/xfs_ioend.c
+++ b/fs/xfs/xfs_ioend.c
@@ -175,16 +175,8 @@ xfs_end_ioend_write(
 	bool			is_zoned = xfs_is_zoned_inode(ip);
 	xfs_off_t		offset = ioend->io_offset;
 	size_t			size = ioend->io_size;
-	unsigned int		nofs_flag;
 	int			error;
 
-	/*
-	 * We can allocate memory here while doing writeback on behalf of
-	 * memory reclaim.  To avoid memory allocation deadlocks set the
-	 * task-wide nofs context for the following operations.
-	 */
-	nofs_flag = memalloc_nofs_save();
-
 	/*
 	 * Just clean up the in-memory structures if the fs has been shut down.
 	 */
@@ -241,7 +233,6 @@ xfs_end_ioend_write(
 	if (is_zoned)
 		xfs_ioend_put_open_zones(ioend);
 	iomap_finish_ioends(ioend, error);
-	memalloc_nofs_restore(nofs_flag);
 }
 
 /*
@@ -266,6 +257,7 @@ xfs_end_io(
 		container_of(work, struct xfs_inode, i_ioend_work);
 	struct iomap_ioend	*ioend;
 	struct list_head	tmp;
+	unsigned int		nofs_flag;
 	unsigned long		flags;
 
 	spin_lock_irqsave(&ip->i_ioend_lock, flags);
@@ -273,6 +265,13 @@ xfs_end_io(
 	spin_unlock_irqrestore(&ip->i_ioend_lock, flags);
 
 	iomap_sort_ioends(&tmp);
+
+	/*
+	 * We can allocate memory here while doing writeback on behalf of
+	 * memory reclaim.  To avoid memory allocation deadlocks set the
+	 * task-wide nofs context for the following operations.
+	 */
+	nofs_flag = memalloc_nofs_save();
 	while ((ioend = list_first_entry_or_null(&tmp, struct iomap_ioend,
 			io_list))) {
 		list_del_init(&ioend->io_list);
@@ -280,6 +279,7 @@ xfs_end_io(
 		xfs_end_ioend_write(ioend);
 		cond_resched();
 	}
+	memalloc_nofs_restore(nofs_flag);
 }
 
 void
-- 
2.53.0


  parent reply	other threads:[~2026-09-24  9:58 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-24  9:57 misc cleanups Christoph Hellwig
2026-09-24  9:57 ` [PATCH 1/9] xfs: centralize setting of buf_ops/buf_type/magic for rtblocks Christoph Hellwig
2026-09-24 19:01   ` Darrick J. Wong
2026-09-24  9:57 ` [PATCH 2/9] xfs: factor out a xfs_rtfile_initialize_buf helper Christoph Hellwig
2026-09-24 19:02   ` Darrick J. Wong
2026-09-24  9:57 ` [PATCH 3/9] xfs: add a xfs_rtblock_payload helper Christoph Hellwig
2026-09-24 20:13   ` Darrick J. Wong
2026-09-24  9:57 ` [PATCH 4/9] xfs: cleanup xfs_verify_media_error Christoph Hellwig
2026-09-24 20:14   ` Darrick J. Wong
2026-09-24  9:57 ` [PATCH 5/9] xfs: use bdev_rw_virt in xfs_verify_media Christoph Hellwig
2026-09-24 20:18   ` Darrick J. Wong
2026-09-24  9:57 ` Christoph Hellwig [this message]
2026-09-24 20:18   ` [PATCH 6/9] xfs: lift setting the NOFS context to xfs_end_io Darrick J. Wong
2026-09-24  9:57 ` [PATCH 7/9] xfs: split xfs_end_ioend_write Christoph Hellwig
2026-09-24 20:26   ` Darrick J. Wong
2026-09-25  5:46     ` Christoph Hellwig
2026-09-24  9:57 ` [PATCH 8/9] xfs: factor out a xfs_zoned_fill_srcmap helper Christoph Hellwig
2026-09-24 20:27   ` Darrick J. Wong
2026-09-24  9:57 ` [PATCH 9/9] xfs: calculate end_fsb later in xfs_zoned_fill_srcmap Christoph Hellwig
2026-09-24 20:29   ` Darrick J. Wong
2026-10-05 18:06 ` misc cleanups 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=20260924095740.2732474-7-hch@lst.de \
    --to=hch@lst.de \
    --cc=cem@kernel.org \
    --cc=djwong@kernel.org \
    --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