From: Viacheslav Dubeyko <slava@dubeyko.com>
To: glaubitz@physik.fu-berlin.de, frank.li@vivo.com, hch@lst.de
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
vdubeyko@coreweave.com, brauner@kernel.org,
linux-xfs@vger.kernel.org, Viacheslav Dubeyko <slava@dubeyko.com>,
"Darrick J. Wong" <djwong@kernel.org>
Subject: [PATCH v5 1/5] iomap: add iomap_dio_end_io() helper
Date: Tue, 17 Nov 2026 16:48:40 -0800 [thread overview]
Message-ID: <20261118004844.3849979-2-slava@dubeyko.com> (raw)
In-Reply-To: <20261118004844.3849979-1-slava@dubeyko.com>
Several file systems implement an almost identical ->end_io callback
for direct writes: if the write succeeded and went beyond the current
end-of-file, update i_size and mark the inode dirty (for example,
ext2_dio_write_end_io()). Add a generic iomap_dio_end_io() helper for
this case, so that file systems don't need to open-code it.
The helper updates i_size without any locking, so it can be used only
by file systems that issue all direct writes extending i_size
synchronously (IOMAP_DIO_FORCE_WAIT) under inode_lock.
The first user will be HFS+.
cc: Christian Brauner <brauner@kernel.org>
cc: Christoph Hellwig <hch@lst.de>
cc: Darrick J. Wong <djwong@kernel.org>
cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
cc: Yangtao Li <frank.li@vivo.com>
cc: linux-xfs@vger.kernel.org
cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Viacheslav Dubeyko <slava@dubeyko.com>
---
include/linux/iomap.h | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/include/linux/iomap.h b/include/linux/iomap.h
index 5254430844b2..616abe7ebad9 100644
--- a/include/linux/iomap.h
+++ b/include/linux/iomap.h
@@ -672,6 +672,26 @@ struct iomap_dio_ops {
struct bio_set *bio_set;
};
+/*
+ * Direct I/O completion handler
+ */
+static inline
+int iomap_dio_end_io(struct kiocb *iocb, ssize_t size,
+ int error, unsigned int flags)
+{
+ struct inode *inode = file_inode(iocb->ki_filp);
+
+ if (error)
+ return error;
+
+ if (size && i_size_read(inode) < iocb->ki_pos + size) {
+ i_size_write(inode, iocb->ki_pos + size);
+ mark_inode_dirty(inode);
+ }
+
+ return 0;
+}
+
/*
* Wait for the I/O to complete in iomap_dio_rw even if the kiocb is not
* synchronous.
--
2.53.0
next prev parent reply other threads:[~2026-11-18 0:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 0:48 [PATCH v5 0/5] hfsplus: convert regular file I/O to iomap Viacheslav Dubeyko
2026-11-18 0:48 ` Viacheslav Dubeyko [this message]
2026-11-18 0:48 ` [PATCH v5 2/5] hfsplus: move file related operations to file.c Viacheslav Dubeyko
2026-11-18 0:48 ` [PATCH v5 3/5] hfsplus: rework hfsplus_get_block() logic Viacheslav Dubeyko
2026-11-18 0:48 ` [PATCH v5 4/5] hfsplus: return -EIO from hfsplus_map_extent() if no extent covers the block Viacheslav Dubeyko
2026-11-18 0:48 ` [PATCH v5 5/5] hfsplus: convert regular file I/O to iomap Viacheslav Dubeyko
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=20261118004844.3849979-2-slava@dubeyko.com \
--to=slava@dubeyko.com \
--cc=brauner@kernel.org \
--cc=djwong@kernel.org \
--cc=frank.li@vivo.com \
--cc=glaubitz@physik.fu-berlin.de \
--cc=hch@lst.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=vdubeyko@coreweave.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
all inboxes | Powered by JetHome®