public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: cem@kernel.org
To: linux-xfs@vger.kernel.org
Cc: hch@lst.de, dlemoal@kernel.org
Subject: [PATCH v2 2/4] xfs: factor out xfs_dio_write_zoned_end_io
Date: Tue, 10 Mar 2026 18:36:47 +0100	[thread overview]
Message-ID: <20260310173709.457047-3-cem@kernel.org> (raw)
In-Reply-To: <20260310173709.457047-1-cem@kernel.org>

From: Carlos Maiolino <cem@kernel.org>

Stop sharing direct IO end_io between regular and zoned devices
by factoring out zoned dio end_io to its own function.

Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>

---
v2: Rewrite commit description - no code change

 fs/xfs/xfs_file.c | 35 ++++++++++++++++++++++++++++++++---
 1 file changed, 32 insertions(+), 3 deletions(-)

diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index fce6be55d90c..7918968e1d62 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -596,6 +596,36 @@ xfs_dio_endio_set_isize(
 	return xfs_setfilesize(ip, offset, size);
 }
 
+static int
+xfs_zoned_dio_write_end_io(
+	struct kiocb		*iocb,
+	ssize_t			size,
+	int			error,
+	unsigned		flags)
+{
+	struct inode		*inode = file_inode(iocb->ki_filp);
+	struct xfs_inode	*ip = XFS_I(inode);
+	unsigned int		nofs_flag;
+
+	ASSERT(!(flags & (IOMAP_DIO_UNWRITTEN | IOMAP_DIO_COW)));
+
+	trace_xfs_end_io_direct_write(ip, iocb->ki_pos, size);
+
+	if (xfs_is_shutdown(ip->i_mount))
+		return -EIO;
+
+	if (error || !size)
+		return error;
+
+	XFS_STATS_ADD(ip->i_mount, xs_write_bytes, size);
+
+	nofs_flag = memalloc_nofs_save();
+	error = xfs_dio_endio_set_isize(inode, iocb->ki_pos, size);
+	memalloc_nofs_restore(nofs_flag);
+
+	return error;
+}
+
 static int
 xfs_dio_write_end_io(
 	struct kiocb		*iocb,
@@ -608,8 +638,7 @@ xfs_dio_write_end_io(
 	loff_t			offset = iocb->ki_pos;
 	unsigned int		nofs_flag;
 
-	ASSERT(!xfs_is_zoned_inode(ip) ||
-	       !(flags & (IOMAP_DIO_UNWRITTEN | IOMAP_DIO_COW)));
+	ASSERT(!xfs_is_zoned_inode(ip));
 
 	trace_xfs_end_io_direct_write(ip, offset, size);
 
@@ -702,7 +731,7 @@ xfs_dio_zoned_submit_io(
 static const struct iomap_dio_ops xfs_dio_zoned_write_ops = {
 	.bio_set	= &iomap_ioend_bioset,
 	.submit_io	= xfs_dio_zoned_submit_io,
-	.end_io		= xfs_dio_write_end_io,
+	.end_io		= xfs_zoned_dio_write_end_io,
 };
 
 /*
-- 
2.53.0


  parent reply	other threads:[~2026-03-10 17:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-10 17:36 [PATCH v2 0/4] Zoned device cleanups cem
2026-03-10 17:36 ` [PATCH v2 1/4] xfs: factor out isize updates from xfs_dio_write_end_io cem
2026-03-11  7:03   ` Damien Le Moal
2026-03-12  6:52   ` Christoph Hellwig
2026-03-10 17:36 ` cem [this message]
2026-03-11  7:03   ` [PATCH v2 2/4] xfs: factor out xfs_dio_write_zoned_end_io Damien Le Moal
2026-03-10 17:36 ` [PATCH v2 3/4] xfs: factor out xfs_zone_inc_written cem
2026-03-10 17:36 ` [PATCH v2 4/4] xfs: opencode xfs_zone_record_blocks cem
2026-03-18  8:14   ` Christoph Hellwig
2026-03-18  8:33     ` Carlos Maiolino
2026-03-12  8:37 ` [PATCH v2 0/4] Zoned device 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=20260310173709.457047-3-cem@kernel.org \
    --to=cem@kernel.org \
    --cc=dlemoal@kernel.org \
    --cc=hch@lst.de \
    --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