Skip to contentSkip to conversation

decouple simple direct I/O reads from iomap_dio_rw

PATCH In review Christoph Hellwig 8 participants 20 messages Jul 22 – Jul 28 1 message not in the archive

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

Hi all,

this series reworks how the iomap simple dio read fast path is called and decouples it from the generic iomap_dio_rw and the iomap iter. This is to make the iomap_iter_next transition easier and cleaner. It slots in after the first patch from Joanne's

[PATCH v3 00/20] iomap: convert to in-iter iomap_next() model

series, and the first patch from that is included as the first patch here unmodified as reference. If the approach looks good to everyone, I'd suggest to include it in the next spin of that series.

#1 lore raw

PATCH 1/3 iomap: split iomap_iter() logic into iomap_iter_next()

From: Joanne Koong <[email protected]>

In preparation for changing iomap to use an in-iter (->iomap_next()) model, move the iomap_iter() logic out into the new iomap_iter_next() helper function.

iomap_iter_next() is added as an inlined helper so it can be called directly by ->iomap_next() implementations where the begin()/end() callbacks can be direct calls.

The DEFINE_IOMAP_ITER_NEXT() and DEFINE_IOMAP_ITER_NEXT_END() macros are also provided to generate the boilerplate ->iomap_next() wrapper functions that simply forward to iomap_iter_next() with the appropriate begin/end callbacks. DEFINE_IOMAP_ITER_NEXT() is for the common case where there is no end() callback. DEFINE_IOMAP_ITER_NEXT_END() is for the case where there is an explicit end() callback.

No functional change intended. The only code-level difference is that on the iomap_end() error path (ret < 0 && !advanced), the old code returned with iter.status left as the caller's last value whereas the new code zeroes it, but this is not observable in practice as there are no in-tree callers that read iter.status after the iteration loop.

---
 fs/iomap/iter.c       | 123 +++++++++++++++++++++---------------------
 include/linux/iomap.h | 102 +++++++++++++++++++++++++++++------
 2 files changed, 147 insertions(+), 78 deletions(-)
fs/iomap/iter.c +62 -61
index e4a29829591a..66ccb87441ab 100644
@@ -6,15 +6,6 @@
 #include <linux/iomap.h>
 #include "trace.h"
 
-static inline void iomap_iter_clean_fbatch(struct iomap_iter *iter)
-{
-	if (iter->iomap.flags & IOMAP_F_FOLIO_BATCH) {
-		folio_batch_release(iter->fbatch);
-		folio_batch_reinit(iter->fbatch);
-		iter->iomap.flags &= ~IOMAP_F_FOLIO_BATCH;
-	}
-}
-
 /* Advance the current iterator position and decrement the remaining length */
 int iomap_iter_advance(struct iomap_iter *iter, u64 count)
 {
@@ -40,51 +31,28 @@ static inline void iomap_iter_done(struct iomap_iter *iter)
 }
 
 /**
- * iomap_iter - iterate over a ranges in a file
- * @iter: iteration structue
- * @ops: iomap ops provided by the file system
+ * iomap_iter_continue - decide whether iteration should continue
+ * @iter: iteration structure
+ * @iomap: the mapping that was just processed
+ * @srcmap: the source mapping that was just processed
  *
- * Iterate over filesystem-provided space mappings for the provided file range.
+ * Helper normally called via iomap_iter_next(). Called after the previous
+ * mapping has been finished to determine whether there is more of the file
+ * range left to process.
  *
- * This function handles cleanup of resources acquired for iteration when the
- * filesystem indicates there are no more space mappings, which means that this
- * function must be called in a loop that continues as long it returns a
- * positive value.  If 0 or a negative value is returned, the caller must not
- * return to the loop body.  Within a loop body, there are two ways to break out
- * of the loop body:  leave @iter.status unchanged, or set it to a negative
- * errno.
+ * Returns 1 if there is more work to do, in which case @iomap and @srcmap are
+ * cleared so the caller can produce the next mapping; zero if the range is
+ * fully consumed; or a negative errno on error. Any folio batch attached to
+ * the mapping is released before returning.
  */
-int iomap_iter(struct iomap_iter *iter, const struct iomap_ops *ops)
+int iomap_iter_continue(const struct iomap_iter *iter, struct iomap *iomap,
+		struct iomap *srcmap, int ret)
 {
-	bool stale = iter->iomap.flags & IOMAP_F_STALE;
-	ssize_t advanced;
-	u64 olen;
-	int ret;
-
-	trace_iomap_iter(iter, ops, _RET_IP_);
-
-	if (!iter->iomap.length)
-		goto begin;
-
-	/*
-	 * Calculate how far the iter was advanced and the original length bytes
-	 * for ->iomap_end().
-	 */
-	advanced = iter->pos - iter->iter_start_pos;
-	olen = iter->len + advanced;
-
-	if (ops->iomap_end) {
-		ret = ops->iomap_end(iter->inode, iter->iter_start_pos,
-				iomap_length_trim(iter, iter->iter_start_pos,
-						  olen),
-				advanced, iter->flags, &iter->iomap);
-		if (ret < 0 && !advanced)
-			return ret;
-	}
+	const bool stale = iomap->flags & IOMAP_F_STALE;
+	const ssize_t advanced = iter->pos - iter->iter_start_pos;
 
-	/* detect old return semantics where this would advance */
-	if (WARN_ON_ONCE(iter->status > 0))
-		iter->status = -EIO;
+	if (ret < 0 && !advanced)
+		return ret;
 
 	/*
 	 * Use iter->len to determine whether to continue onto the next mapping.
@@ -92,25 +60,58 @@ int iomap_iter(struct iomap_iter *iter, const struct iomap_ops *ops)
 	 * advanced at all (i.e. no work was done for some reason) unless the
 	 * mapping has been marked stale and needs to be reprocessed.
 	 */
-	if (iter->status < 0)
+	if (WARN_ON_ONCE(iter->status > 0))
+		/* detect old return semantics where this would advance */
+		ret = -EIO;
+	else if (iter->status < 0)
 		ret = iter->status;
 	else if (iter->len == 0 || (!advanced && !stale))
 		ret = 0;
 	else
 		ret = 1;
-	iomap_iter_clean_fbatch(iter);
-	iter->status = 0;
+
+	if (iomap->flags & IOMAP_F_FOLIO_BATCH) {
+		folio_batch_release(iter->fbatch);
+		folio_batch_reinit(iter->fbatch);
+		iomap->flags &= ~IOMAP_F_FOLIO_BATCH;
+	}
+
 	if (ret <= 0)
 		return ret;
 
-	memset(&iter->iomap, 0, sizeof(iter->iomap));
-	memset(&iter->srcmap, 0, sizeof(iter->srcmap));
+	memset(iomap, 0, sizeof(*iomap));
+	memset(srcmap, 0, sizeof(*srcmap));
 
-begin:
-	ret = ops->iomap_begin(iter->inode, iter->pos, iter->len, iter->flags,
-			       &iter->iomap, &iter->srcmap);
-	if (ret < 0)
-		return ret;
-	iomap_iter_done(iter);
-	return 1;
+	return ret;
+}
+EXPORT_SYMBOL_GPL(iomap_iter_continue);
+
+/**
+ * iomap_iter - iterate over ranges in a file
+ * @iter: iteration structure
+ * @ops: iomap ops provided by the filesystem
+ *
+ * Iterate over filesystem-provided space mappings for the provided file range.
+ *
+ * This function handles cleanup of resources acquired for iteration when the
+ * filesystem indicates there are no more space mappings, which means that this
+ * function must be called in a loop that continues as long it returns a
+ * positive value.  If 0 or a negative value is returned, the caller must not
+ * return to the loop body.  Within a loop body, there are two ways to break out
+ * of the loop body:  leave @iter.status unchanged, or set it to a negative
+ * errno.
+ */
+int iomap_iter(struct iomap_iter *iter, const struct iomap_ops *ops)
+{
+	int ret;
+
+	trace_iomap_iter(iter, ops, _RET_IP_);
+
+	ret = iomap_iter_next(iter, &iter->iomap, &iter->srcmap,
+			ops->iomap_begin, ops->iomap_end);
+	iter->status = 0;
+	if (ret > 0)
+		iomap_iter_done(iter);
+
+	return ret;
 }
include/linux/iomap.h +85 -17

115 lines not on this page · raw message

Signature · 1 line
2.53.0
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] iomap: split iomap_iter() logic into iomap_iter_next()

Quoted 29 lines

From: "Christoph Hellwig"<[email protected]>
Date:  Wed, Jul 22, 2026, 20:49
Subject:  [PATCH 1/3] iomap: split iomap_iter() logic into iomap_iter_next()
To: <[email protected]>, "Joanne Koong"<[email protected]>, "Darrick J. Wong"<[email protected]>, "Christian Brauner"<[email protected]>
Cc: "Theodore Ts'o"<[email protected]>, "Carlos Maiolino"<[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>
From: Joanne Koong <[email protected]>

In preparation for changing iomap to use an in-iter (->iomap_next())
model, move the iomap_iter() logic out into the new iomap_iter_next()
helper function.

iomap_iter_next() is added as an inlined helper so it can be called
directly by ->iomap_next() implementations where the begin()/end()
callbacks can be direct calls.

The DEFINE_IOMAP_ITER_NEXT() and DEFINE_IOMAP_ITER_NEXT_END() macros are
also provided to generate the boilerplate ->iomap_next() wrapper
functions that simply forward to iomap_iter_next() with the appropriate
begin/end callbacks. DEFINE_IOMAP_ITER_NEXT() is for the common case
where there is no end() callback. DEFINE_IOMAP_ITER_NEXT_END() is for
the case where there is an explicit end() callback.

No functional change intended. The only code-level difference is that on
the iomap_end() error path (ret < 0 && !advanced), the old code returned
with iter.status left as the caller's last value whereas the new code
zeroes it, but this is not observable in practice as there are no in-tree
callers that read iter.status after the iteration loop.

Quoted 1 line
Quoted 289 lines

---
 fs/iomap/iter.c       | 123 +++++++++++++++++++++--------------------- include/linux/iomap.h | 102 +++++++++++++++++++++++++++++------

 2 files changed, 147 insertions(+), 78 deletions(-)

fs/iomap/iter.c +0 -0
index e4a29829591a..66ccb87441ab 100644
@@ -6,15 +6,6 @@
  #include <linux/iomap.h>
  #include "trace.h"

fs/iomap/iter.c +0 -9
-static inline void iomap_iter_clean_fbatch(struct iomap_iter *iter)
-{
-        if (iter->iomap.flags & IOMAP_F_FOLIO_BATCH) {
-                folio_batch_release(iter->fbatch);
-                folio_batch_reinit(iter->fbatch);
-                iter->iomap.flags &= ~IOMAP_F_FOLIO_BATCH;
-        }
-}
-

 /* Advance the current iterator position and decrement the remaining length */ int iomap_iter_advance(struct iomap_iter *iter, u64 count)
 {

fs/iomap/iter.c +0 -0
@@ -40,51 +31,28 @@ static inline void iomap_iter_done(struct iomap_iter *iter)
  }


 /**
- * iomap_iter - iterate over a ranges in a file
- * @iter: iteration structue
- * @ops: iomap ops provided by the file system
+ * iomap_iter_continue - decide whether iteration should continue
+ * @iter: iteration structure
+ * @iomap: the mapping that was just processed
+ * @srcmap: the source mapping that was just processed
  *
- * Iterate over filesystem-provided space mappings for the provided file range.
+ * Helper normally called via iomap_iter_next(). Called after the previous
+ * mapping has been finished to determine whether there is more of the file
+ * range left to process.
  *
- * This function handles cleanup of resources acquired for iteration when the
- * filesystem indicates there are no more space mappings, which means that this
- * function must be called in a loop that continues as long it returns a
- * positive value.  If 0 or a negative value is returned, the caller must not
- * return to the loop body.  Within a loop body, there are two ways to break out
- * of the loop body:  leave @iter.status unchanged, or set it to a negative
- * errno.
+ * Returns 1 if there is more work to do, in which case @iomap and @srcmap are
+ * cleared so the caller can produce the next mapping; zero if the range is
+ * fully consumed; or a negative errno on error. Any folio batch attached to
+ * the mapping is released before returning.
  */

fs/iomap/iter.c +2 -1
-int iomap_iter(struct iomap_iter *iter, const struct iomap_ops *ops)
+int iomap_iter_continue(const struct iomap_iter *iter, struct iomap *iomap,
+                struct iomap *srcmap, int ret)

 {
-        bool stale = iter->iomap.flags & IOMAP_F_STALE;
-        ssize_t advanced;
-        u64 olen;
-        int ret;

fs/iomap/iter.c +2 -21
-
-        trace_iomap_iter(iter, ops, _RET_IP_);
-
-        if (!iter->iomap.length)
-                goto begin;
-
-        /*
-         * Calculate how far the iter was advanced and the original length bytes
-         * for ->iomap_end().
-         */
-        advanced = iter->pos - iter->iter_start_pos;
-        olen = iter->len + advanced;
-
-        if (ops->iomap_end) {
-                ret = ops->iomap_end(iter->inode, iter->iter_start_pos,
-                                iomap_length_trim(iter, iter->iter_start_pos,
-                                                  olen),
-                                advanced, iter->flags, &iter->iomap);
-                if (ret < 0 && !advanced)
-                        return ret;
-        }
+        const bool stale = iomap->flags & IOMAP_F_STALE;
+        const ssize_t advanced = iter->pos - iter->iter_start_pos;


-        /* detect old return semantics where this would advance */
-        if (WARN_ON_ONCE(iter->status > 0))
-                iter->status = -EIO;
+        if (ret < 0 && !advanced)
+                return ret;

         /*
          * Use iter->len to determine whether to continue onto the next mapping.

fs/iomap/iter.c +4 -1
@@ -92,25 +60,58 @@ int iomap_iter(struct iomap_iter *iter, const struct iomap_ops *ops)
           * advanced at all (i.e. no work was done for some reason) unless the
           * mapping has been marked stale and needs to be reprocessed.
           */
-        if (iter->status < 0)
+        if (WARN_ON_ONCE(iter->status > 0))
+                /* detect old return semantics where this would advance */
+                ret = -EIO;
+        else if (iter->status < 0)
                  ret = iter->status;
          else if (iter->len == 0 || (!advanced && !stale))
                  ret = 0;

         else
                 ret = 1;
-        iomap_iter_clean_fbatch(iter);
-        iter->status = 0;

fs/iomap/iter.c +7 -0
+
+        if (iomap->flags & IOMAP_F_FOLIO_BATCH) {
+                folio_batch_release(iter->fbatch);
+                folio_batch_reinit(iter->fbatch);
+                iomap->flags &= ~IOMAP_F_FOLIO_BATCH;
+        }
+

         if (ret <= 0)
                 return ret;

-        memset(&iter->iomap, 0, sizeof(iter->iomap));
-        memset(&iter->srcmap, 0, sizeof(iter->srcmap));
+        memset(iomap, 0, sizeof(*iomap));
+        memset(srcmap, 0, sizeof(*srcmap));

fs/iomap/iter.c +32 -7
-begin:
-        ret = ops->iomap_begin(iter->inode, iter->pos, iter->len, iter->flags,
-                               &iter->iomap, &iter->srcmap);
-        if (ret < 0)
-                return ret;
-        iomap_iter_done(iter);
-        return 1;
+        return ret;
+}
+EXPORT_SYMBOL_GPL(iomap_iter_continue);
+
+/**
+ * iomap_iter - iterate over ranges in a file
+ * @iter: iteration structure
+ * @ops: iomap ops provided by the filesystem
+ *
+ * Iterate over filesystem-provided space mappings for the provided file range.
+ *
+ * This function handles cleanup of resources acquired for iteration when the
+ * filesystem indicates there are no more space mappings, which means that this
+ * function must be called in a loop that continues as long it returns a
+ * positive value.  If 0 or a negative value is returned, the caller must not
+ * return to the loop body.  Within a loop body, there are two ways to break out
+ * of the loop body:  leave @iter.status unchanged, or set it to a negative
+ * errno.
+ */
+int iomap_iter(struct iomap_iter *iter, const struct iomap_ops *ops)
+{
+        int ret;
+
+        trace_iomap_iter(iter, ops, _RET_IP_);
+
+        ret = iomap_iter_next(iter, &iter->iomap, &iter->srcmap,
+                        ops->iomap_begin, ops->iomap_end);
+        iter->status = 0;
+        if (ret > 0)
+                iomap_iter_done(iter);
+
+        return ret;

 }

include/linux/iomap.h +0 -0
index 3582ed1fe236..3df851d0f76b 100644
@@ -212,24 +212,27 @@ struct iomap_write_ops {
  #define IOMAP_ATOMIC                (1 << 9) /* torn-write protection */
  #define IOMAP_DONTCACHE                (1 << 10)

include/linux/iomap.h +8 -9
-struct iomap_ops {
-        /*
-         * Return the existing mapping at pos, or reserve space starting at
-         * pos for up to length, as long as we can do it as a single mapping.
-         * The actual length is returned in iomap->length.
-         */
-        int (*iomap_begin)(struct inode *inode, loff_t pos, loff_t length,
-                        unsigned flags, struct iomap *iomap,
-                        struct iomap *srcmap);
+/*
+ * Return the existing mapping at pos, or reserve space starting at pos for up
+ * to length, as long as we can do it as a single mapping.
+ * The actual length is returned in iomap->length.
+ */
+typedef int (*iomap_iter_begin_fn)(struct inode *inode, loff_t pos,
+                loff_t length, unsigned flags, struct iomap *iomap,
+                struct iomap *srcmap);


-        /*
-         * Commit and/or unreserve space previous allocated using iomap_begin.
-         * Written indicates the length of the successful write operation which
-         * needs to be commited, while the rest needs to be unreserved.
-         * Written might be zero if no data was written.
-         */
-        int (*iomap_end)(struct inode *inode, loff_t pos, loff_t length,
-                        ssize_t written, unsigned flags, struct iomap *iomap);

include/linux/iomap.h +12 -0
+/*
+ * Commit and/or unreserve space previously allocated by iomap_iter_begin_fn.
+ * Written indicates the length of the successful write operation which needs
+ * to be committed, while the rest needs to be unreserved.
+ * Written might be zero if no data was written.
+ */
+typedef int (*iomap_iter_end_fn)(struct inode *inode, loff_t pos, loff_t length,
+                ssize_t written, unsigned flags, struct iomap *iomap);
+
+struct iomap_ops {
+        iomap_iter_begin_fn iomap_begin;
+        iomap_iter_end_fn iomap_end;

 };

 /**

include/linux/iomap.h +0 -0
@@ -317,6 +320,71 @@ static inline const struct iomap *iomap_iter_srcmap(const struct iomap_iter *i)
          return &i->iomap;
  }

include/linux/iomap.h +65 -0
+int iomap_iter_continue(const struct iomap_iter *iter, struct iomap *iomap,
+                struct iomap *srcmap, int ret);
+
+/**
+ * iomap_iter_next - finish the previous mapping and produce the next one
+ * @iter: iteration structure
+ * @iomap: mapping to finish and then repopulate
+ * @srcmap: source mapping to finish and then repopulate
+ * @begin: callback that produces a mapping for the current position
+ * @end: optional callback that finishes the previous mapping, or NULL
+ *
+ * Inline helper that implements the common body of an ->iomap_next()
+ * callback: it finishes the previous mapping via @end (if present), decides
+ * via iomap_iter_continue() whether to keep going, and obtains the next
+ * mapping via @begin.
+ *
+ * This helper is marked __always_inline so that when a caller passes
+ * compile-time-constant @begin and @end callbacks, the compiler can call them
+ * directly, avoiding the indirect-call overhead.
+ *
+ * Returns 1 to continue iterating, 0 once the range is fully consumed, or a
+ * negative errno on error.
+ */
+static __always_inline int iomap_iter_next(const struct iomap_iter *iter,
+                struct iomap *iomap, struct iomap *srcmap,
+                iomap_iter_begin_fn begin, iomap_iter_end_fn end)
+{
+        int ret = 0;
+
+        if (iomap->length) {
+                if (end) {
+                        /*
+                         * Calculate how far the iter was advanced and the
+                         * original length bytes for end().
+                         */
+                        ssize_t advanced = iter->pos - iter->iter_start_pos;
+                        loff_t len;
+
+                        len = iomap_length_trim(iter, iter->iter_start_pos,
+                                        iter->len + advanced);
+
+                        ret = end(iter->inode, iter->iter_start_pos, len,
+                                        advanced, iter->flags, iomap);
+                }
+                ret = iomap_iter_continue(iter, iomap, srcmap, ret);
+                if (ret <= 0)
+                        return ret;
+        }
+
+        ret = begin(iter->inode, iter->pos, iter->len, iter->flags, iomap,
+                        srcmap);
+
+        return ret < 0 ? ret : 1;
+}
+
+#define DEFINE_IOMAP_ITER_NEXT_END(name, begin_fn, end_fn)                \
+int name(const struct iomap_iter *iter, struct iomap *iomap,                \
+                struct iomap *srcmap)                                        \
+{                                                                        \
+        return iomap_iter_next(iter, iomap, srcmap, begin_fn, end_fn);        \
+}
+
+#define DEFINE_IOMAP_ITER_NEXT(name, begin_fn)                                \
+        DEFINE_IOMAP_ITER_NEXT_END(name, begin_fn, NULL)
+

 /*
  * Return the file offset for the first unchanged block after a short write. *
--
2.53.0

#3 lore raw

PATCH 2/3 iomap: decouple simple direct I/O reads from iomap_dio_rw

In reply to Christoph Hellwig

The pending iomap_iter_next conversion creates performance issues for the new simple direct I/O read fast path, because it assumes a model where the iterator must be advanced at the end, which the direct I/O read fast path tries to avoid.

Side step this by splitting the simple path from iomap_dio_rw, and require the file systems to call into it explicitly, and pass only a ->begin callback. This allows to drop various checks for incompatible features while creating a requirement for the file system to only call the simple path for cases that it can handle.

As a side-benefit we can now inline the initial part of the simple direct I/O read fast path and let the compiler convert the indirect call to ->begin into a direct call.

---
 fs/ext4/ext4.h        |   3 +
 fs/ext4/file.c        |   4 +-
 fs/ext4/inode.c       |   2 +-
 fs/iomap/direct-io.c  | 209 ++++++++++--------------------------------
 fs/xfs/xfs_file.c     |  14 +--
 fs/xfs/xfs_iomap.c    |   2 +-
 fs/xfs/xfs_iomap.h    |   4 +
 include/linux/iomap.h |  65 +++++++++++++
 8 files changed, 133 insertions(+), 170 deletions(-)
fs/ext4/ext4.h +3 -0
index b37c136ea3ab..e134c0193e2b 100644
@@ -4007,6 +4007,9 @@ static inline void ext4_clear_io_unwritten_flag(ext4_io_end_t *io_end)
 extern const struct iomap_ops ext4_iomap_ops;
 extern const struct iomap_ops ext4_iomap_report_ops;
 
+int ext4_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
+		unsigned flags, struct iomap *iomap, struct iomap *srcmap);
+
 static inline int ext4_buffer_uptodate(struct buffer_head *bh)
 {
 	/*
fs/ext4/file.c +3 -1
index eb1a323962b1..f20d92255546 100644
@@ -91,7 +91,9 @@ static ssize_t ext4_dio_read_iter(struct kiocb *iocb, struct iov_iter *to)
 		return generic_file_read_iter(iocb, to);
 	}
 
-	ret = iomap_dio_rw(iocb, to, &ext4_iomap_ops, NULL, 0, NULL, 0);
+	ret = iomap_dio_read_simple(iocb, to, ext4_iomap_begin);
+	if (ret == -ENOTBLK)
+		ret = iomap_dio_rw(iocb, to, &ext4_iomap_ops, NULL, 0, NULL, 0);
 	inode_unlock_shared(inode);
 
 	file_accessed(iocb->ki_filp);
fs/ext4/inode.c +1 -1
index ce99807c5f5b..b48c54f3312b 100644
@@ -3771,7 +3771,7 @@ static int ext4_iomap_alloc(struct inode *inode, struct ext4_map_blocks *map,
 }
 
 
-static int ext4_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
+int ext4_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
 		unsigned flags, struct iomap *iomap, struct iomap *srcmap)
 {
 	int ret;
fs/iomap/direct-io.c +48 -161

264 lines not on this page · raw message

fs/xfs/xfs_file.c +8 -6
index 845a97c9b063..b733225d2864 100644
@@ -251,8 +251,6 @@ xfs_file_dio_read(
 	struct iov_iter		*to)
 {
 	struct xfs_inode	*ip = XFS_I(file_inode(iocb->ki_filp));
-	unsigned int		dio_flags = 0;
-	const struct iomap_dio_ops *dio_ops = NULL;
 	ssize_t			ret;
 
 	trace_xfs_file_direct_read(iocb, to);
@@ -266,11 +264,15 @@ xfs_file_dio_read(
 	if (ret)
 		return ret;
 	if (mapping_stable_writes(iocb->ki_filp->f_mapping)) {
-		dio_ops = &xfs_dio_read_bounce_ops;
-		dio_flags |= IOMAP_DIO_BOUNCE;
+		ret = iomap_dio_rw(iocb, to, &xfs_read_iomap_ops,
+				&xfs_dio_read_bounce_ops, IOMAP_DIO_BOUNCE,
+				NULL, 0);
+	} else {
+		ret = iomap_dio_read_simple(iocb, to, xfs_read_iomap_begin);
+		if (ret == -ENOTBLK)
+			ret = iomap_dio_rw(iocb, to, &xfs_read_iomap_ops, NULL,
+					0, NULL, 0);
 	}
-	ret = iomap_dio_rw(iocb, to, &xfs_read_iomap_ops, dio_ops, dio_flags,
-			NULL, 0);
 	xfs_iunlock(ip, XFS_IOLOCK_SHARED);
 
 	return ret;
fs/xfs/xfs_iomap.c +1 -1
index 225c3de88d03..0536e2aeddcc 100644
@@ -2173,7 +2173,7 @@ const struct iomap_ops xfs_buffered_write_iomap_ops = {
 	.iomap_end		= xfs_buffered_write_iomap_end,
 };
 
-static int
+int
 xfs_read_iomap_begin(
 	struct inode		*inode,
 	loff_t			offset,
fs/xfs/xfs_iomap.h +4 -0
index ebcce7d49446..cffcec532ea6 100644
@@ -49,6 +49,10 @@ xfs_aligned_fsb_count(
 	return count_fsb;
 }
 
+int xfs_read_iomap_begin(struct inode *inode, loff_t offset,
+		loff_t length, unsigned flags, struct iomap *iomap,
+		struct iomap *srcmap);
+
 extern const struct iomap_ops xfs_buffered_write_iomap_ops;
 extern const struct iomap_ops xfs_direct_write_iomap_ops;
 extern const struct iomap_ops xfs_zoned_direct_write_iomap_ops;
include/linux/iomap.h +65 -0

77 lines not on this page · raw message

Signature · 1 line
2.53.0

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw

Re: [PATCH 2/3] iomap: decouple simple direct I/O reads from iomap_dio_rw

Quoted 5 lines · On Wed, Jul 22, 2026 at 01:02:51PM +0000, [email protected] wrote:

If the underlying I/O fails, iomap_dio_simple_complete() will return a negative error code. The check above (ret <= 0 && ret != -EIOCBQUEUED) will then evaluate to true and call inode_dio_end() a second time. This can cause i_dio_count to underflow, which may lead to an indefinite hang during subsequent calls to inode_dio_wait() such as when calling truncate or fsync.

Yeah, this should fix it:

I'll respin tomorrow.

fs/iomap/direct-io.c +15 -7
index 3bdfbd0efa07..f6c8091a65ac 100644
@@ -994,18 +994,22 @@ ssize_t __iomap_dio_simple(struct kiocb *iocb, struct iov_iter *iter,
 
 	if (iomi->iomap.type != IOMAP_MAPPED ||
 	    iomi->iomap.offset + iomi->iomap.length < iomi->pos + iomi->len ||
-	    (iomi->iomap.flags & IOMAP_F_INTEGRITY))
-		return -ENOTBLK;
+	    (iomi->iomap.flags & IOMAP_F_INTEGRITY)) {
+		ret = -ENOTBLK;
+		goto out_dio_end;
+	}
 
 	alignment = iomap_dio_alignment(iomi->inode, iomi->iomap.bdev, 0);
-	if ((iomi->pos | iomi->len) & (alignment - 1))
-		return -EINVAL;
+	if ((iomi->pos | iomi->len) & (alignment - 1)) {
+		ret = -EINVAL;
+		goto out_dio_end;
+	}
 
 	if (unlikely(!iomi->inode->i_sb->s_dio_done_wq &&
 			!is_sync_kiocb(iocb))) {
 		ret = sb_init_dio_done_wq(iomi->inode->i_sb);
 		if (ret < 0)
-			return ret;
+			goto out_dio_end;
 	}
 
 	trace_iomap_dio_rw_begin(iocb, iter, 0, 0);
@@ -1013,8 +1017,10 @@ ssize_t __iomap_dio_simple(struct kiocb *iocb, struct iov_iter *iter,
 	bio = bio_alloc_bioset(iomi->iomap.bdev,
 			       bio_iov_vecs_to_alloc(iter, BIO_MAX_VECS),
 			       REQ_OP_READ, gfp, &iomap_dio_simple_pool);
-	if (!bio)
-		return -EAGAIN;
+	if (!bio) {
+		ret = -EAGAIN;
+		goto out_dio_end;
+	}
 	sr = container_of(bio, struct iomap_dio_simple, bio);
 	sr->iocb = iocb;
 	sr->dio_flags = 0;
@@ -1060,6 +1066,8 @@ ssize_t __iomap_dio_simple(struct kiocb *iocb, struct iov_iter *iter,
 	bio_release_pages(bio, false);
 out_bio_put:
 	bio_put(bio);
+out_dio_end:
+	inode_dio_end(iomi->inode);
 	return ret;
 }
 EXPORT_SYMBOL_GPL(__iomap_dio_simple);
include/linux/iomap.h +5 -4
index 810dc4b8dc94..737ca6d043c7 100644
@@ -732,11 +732,12 @@ static __always_inline ssize_t iomap_dio_read_simple(struct kiocb *iocb,
 	inode_dio_begin(iomi.inode);
 	ret = begin(iomi.inode, iomi.pos, iomi.len, iomi.flags, &iomi.iomap,
 			&iomi.srcmap);
-	if (!ret)
-		ret = __iomap_dio_simple(iocb, iter, &iomi);
-	if (ret <= 0 && ret != -EIOCBQUEUED)
+	if (ret) {
 		inode_dio_end(iomi.inode);
-	return ret;
+		return ret;
+	}
+
+	return __iomap_dio_simple(iocb, iter, &iomi);
 }
 
 #ifdef CONFIG_SWAP
#6 lore raw

Re: [PATCH 2/3] iomap: decouple simple direct I/O reads from iomap_dio_rw

In reply to Christoph Hellwig
Quoted 11 lines · Christoph Hellwig

The pending iomap_iter_next conversion creates performance issues for the new simple direct I/O read fast path, because it assumes a model where the iterator must be advanced at the end, which the direct I/O read fast path tries to avoid.

Side step this by splitting the simple path from iomap_dio_rw, and require the file systems to call into it explicitly, and pass only a ->begin callback. This allows to drop various checks for incompatible features while creating a requirement for the file system to only call the simple path for cases that it can handle.

Nice, this approach looks cleaner to me.

Quoted 32 lines

As a side-benefit we can now inline the initial part of the simple direct I/O read fast path and let the compiler convert the indirect call to ->begin into a direct call.

---
 fs/ext4/ext4.h        |   3 +
 fs/ext4/file.c        |   4 +-
 fs/ext4/inode.c       |   2 +-
 fs/iomap/direct-io.c  | 209 ++++++++++--------------------------------
 fs/xfs/xfs_file.c     |  14 +--
 fs/xfs/xfs_iomap.c    |   2 +-
 fs/xfs/xfs_iomap.h    |   4 +
 include/linux/iomap.h |  65 +++++++++++++
 8 files changed, 133 insertions(+), 170 deletions(-)

index 3df851d0f76b..810dc4b8dc94 100644

include/linux/iomap.h +11 -0
 
+/*
+ * Fast path for small, block-aligned direct I/Os that map to a single
+ * contiguous on-disk extent.
+ *
+ * @iter must describe a non-empty READ no larger than the inode block size:
+ * writes, zero-length I/O, and larger requests need the generic iomap direct
+ * I/O path.
+ *
+ * Does not support iomap_dio_ops, dio_flags, done_before or private data.
+ * The range must also stay within i_size and encrypted inodes must use the
+ * generic iomap direct I/O path.

include/linux/iomap.h struct iomap_dio *__iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, · line 698

Quoted 10 lines
include/linux/iomap.h +10 -0
+ *
+ * -ENOTBLK inidicates the generic path must be used by the caller instead.
+ * Any other errno is a real result and is propagated as-is, in particular
+ * -EAGAIN for IOCB_NOWAIT must reach the caller.
+ *
+ * The caller can only provide an iomap begin handler, and the iterator
+ * is never advanced.
+ */
+ssize_t __iomap_dio_simple(struct kiocb *iocb, struct iov_iter *iter,
+               struct iomap_iter *iomi);

Might be nice to have _read_ in this name as well, eg __iomap_dio_read_simple

Quoted 30 lines
include/linux/iomap.h +30 -0
+static __always_inline ssize_t iomap_dio_read_simple(struct kiocb *iocb,
+               struct iov_iter *iter, iomap_iter_begin_fn begin)
+{
+       struct iomap_iter iomi = {
+               .inode          = file_inode(iocb->ki_filp),
+               .pos            = iocb->ki_pos,
+               .len            = iov_iter_count(iter),
+               .flags          = IOMAP_DIRECT,
+       };
+       ssize_t ret;
+
+       if (!iomi.len)
+               return 0;
+
+       /*
+        * Simple dio is an optimization for small IO. Filter out large IO
+        * early as it's the most common case to fail for typical direct IO
+        * workloads.
+        */
+       if (iomi.len > iomi.inode->i_sb->s_blocksize)
+               return -ENOTBLK;
+       if (iocb->ki_pos + iomi.len > i_size_read(iomi.inode))
+               return -ENOTBLK;
+       if (IS_ENCRYPTED(iomi.inode))
+               return -ENOTBLK;
+
+       ret = kiocb_write_and_wait(iocb, iomi.len);
+       if (ret)
+               return ret;
+

include/linux/iomap.h struct iomap_dio *__iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, · line 738

Quoted 10 lines
include/linux/iomap.h +10 -0
+       if (iocb->ki_flags & IOCB_NOWAIT)
+               iomi.flags |= IOMAP_NOWAIT;
+
+       inode_dio_begin(iomi.inode);
+       ret = begin(iomi.inode, iomi.pos, iomi.len, iomi.flags, &iomi.iomap,
+                       &iomi.srcmap);
+       if (!ret)
+               ret = __iomap_dio_simple(iocb, iter, &iomi);
+       if (ret <= 0 && ret != -EIOCBQUEUED)
+               inode_dio_end(iomi.inode);

afaict, the inode_dio_end() error handling has to be done by __iomap_dio_simple() to properly account for the synchronous case. I ran into this earlier when doing the iomap_next_fn inlining. For the synchronous case, __iomap_dio_simple() calls iomap_dio_simple_complete() which calls inode_dio_end() even on errors.

Thanks,
Joanne

Quoted 2 lines
include/linux/iomap.h +2 -0
+       return ret;
+}
#7 lore raw

Re: [PATCH 2/3] iomap: decouple simple direct I/O reads from iomap_dio_rw

Quoted 105 lines

From: "Joanne Koong"<[email protected]>
Date:  Thu, Jul 23, 2026, 03:04
Subject:  Re: [PATCH 2/3] iomap: decouple simple direct I/O reads from iomap_dio_rw
To: "Christoph Hellwig"<[email protected]>
Cc: <[email protected]>, "Darrick J. Wong"<[email protected]>, "Christian Brauner"<[email protected]>, "Theodore Ts'o"<[email protected]>, "Carlos Maiolino"<[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>

Quoted 11 lines · Christoph Hellwig

The pending iomap_iter_next conversion creates performance issues for the new simple direct I/O read fast path, because it assumes a model where the iterator must be advanced at the end, which the direct I/O read fast path tries to avoid.

Side step this by splitting the simple path from iomap_dio_rw, and require the file systems to call into it explicitly, and pass only a ->begin callback.  This allows to drop various checks for incompatible features while creating a requirement for the file system to only call the simple path for cases that it can handle.


Nice, this approach looks cleaner to me.

Quoted 32 lines

As a side-benefit we can now inline the initial part of the simple direct I/O read fast path and let the compiler convert the indirect call to ->begin into a direct call.

---
 fs/ext4/ext4.h        |   3 +
 fs/ext4/file.c        |   4 +-
 fs/ext4/inode.c       |   2 +-
 fs/iomap/direct-io.c  | 209 ++++++++++--------------------------------

 fs/xfs/xfs_file.c     |  14 +--
 fs/xfs/xfs_iomap.c    |   2 +-
 fs/xfs/xfs_iomap.h    |   4 +
 include/linux/iomap.h |  65 +++++++++++++
 8 files changed, 133 insertions(+), 170 deletions(-)

index 3df851d0f76b..810dc4b8dc94 100644

include/linux/iomap.h +11 -0
 
+/*
+ * Fast path for small, block-aligned direct I/Os that map to a single
+ * contiguous on-disk extent.
+ *
+ * @iter must describe a non-empty READ no larger than the inode block size:
+ * writes, zero-length I/O, and larger requests need the generic iomap direct
+ * I/O path.
+ *
+ * Does not support iomap_dio_ops, dio_flags, done_before or private data.
+ * The range must also stay within i_size and encrypted inodes must use the
+ * generic iomap direct I/O path.

include/linux/iomap.h

Quoted 10 lines
include/linux/iomap.h +10 -0
+ *
+ * -ENOTBLK inidicates the generic path must be used by the caller instead.
+ * Any other errno is a real result and is propagated as-is, in particular
+ * -EAGAIN for IOCB_NOWAIT must reach the caller.
+ *
+ * The caller can only provide an iomap begin handler, and the iterator
+ * is never advanced.
+ */
+ssize_t __iomap_dio_simple(struct kiocb *iocb, struct iov_iter *iter,
+               struct iomap_iter *iomi);


Might be nice to have _read_ in this name as well, eg __iomap_dio_read_simple

Quoted 39 lines
include/linux/iomap.h +39 -0
+static __always_inline ssize_t iomap_dio_read_simple(struct kiocb *iocb,
+               struct iov_iter *iter, iomap_iter_begin_fn begin)
+{
+       struct iomap_iter iomi = {
+               .inode          = file_inode(iocb->ki_filp),
+               .pos            = iocb->ki_pos,
+               .len            = iov_iter_count(iter),
+               .flags          = IOMAP_DIRECT,
+       };
+       ssize_t ret;
+
+       if (!iomi.len)
+               return 0;
+
+       /*
+        * Simple dio is an optimization for small IO. Filter out large IO
+        * early as it's the most common case to fail for typical direct IO
+        * workloads.
+        */
+       if (iomi.len > iomi.inode->i_sb->s_blocksize)
+               return -ENOTBLK;
+       if (iocb->ki_pos + iomi.len > i_size_read(iomi.inode))
+               return -ENOTBLK;
+       if (IS_ENCRYPTED(iomi.inode))
+               return -ENOTBLK;
+
+       ret = kiocb_write_and_wait(iocb, iomi.len);
+       if (ret)
+               return ret;
+
+       if (iocb->ki_flags & IOCB_NOWAIT)
+               iomi.flags |= IOMAP_NOWAIT;
+
+       inode_dio_begin(iomi.inode);
+       ret = begin(iomi.inode, iomi.pos, iomi.len, iomi.flags, &iomi.iomap,
+                       &iomi.srcmap);
+       if (!ret)
+               ret = __iomap_dio_simple(iocb, iter, &iomi);
+       if (ret <= 0 && ret != -EIOCBQUEUED)
Quoted 8 lines
Quoted 1 line

+               inode_dio_end(iomi.inode);


afaict, the inode_dio_end() error handling has to be done by __iomap_dio_simple() to properly account for the synchronous case. I ran into this earlier when doing the iomap_next_fn inlining. For the synchronous case, __iomap_dio_simple() calls iomap_dio_simple_complete() which calls inode_dio_end() even on errors.

Yes, there is an issue with the handling of the inode_dio_end event in the synchronization scenario.
How about this ?

fs/iomap/direct-io.c +0 -0
index 3bdfbd0efa076..f6c8091a65ac9 100644
@@ -994,18 +994,22 @@ ssize_t __iomap_dio_simple(struct kiocb *iocb, struct iov_iter *iter,


         if (iomi->iomap.type != IOMAP_MAPPED ||
             iomi->iomap.offset + iomi->iomap.length < iomi->pos + iomi->len ||
-            (iomi->iomap.flags & IOMAP_F_INTEGRITY))
-                return -ENOTBLK;
+            (iomi->iomap.flags & IOMAP_F_INTEGRITY)) {
+                ret = -ENOTBLK;
+                goto out_dio_end;
+        }

         alignment = iomap_dio_alignment(iomi->inode, iomi->iomap.bdev, 0);
-        if ((iomi->pos | iomi->len) & (alignment - 1))
-                return -EINVAL;
+        if ((iomi->pos | iomi->len) & (alignment - 1)) {
+                ret = -EINVAL;
+                goto out_dio_end;
+        }

         if (unlikely(!iomi->inode->i_sb->s_dio_done_wq && !is_sync_kiocb(iocb))) {
                 ret = sb_init_dio_done_wq(iomi->inode->i_sb);
                 if (ret < 0)
-                        return ret;
+                        goto out_dio_end;
         }

         trace_iomap_dio_rw_begin(iocb, iter, 0, 0);
@@ -1013,8 +1017,10 @@ ssize_t __iomap_dio_simple(struct kiocb *iocb, struct iov_iter *iter, bio = bio_alloc_bioset(iomi->iomap.bdev,
                                bio_iov_vecs_to_alloc(iter, BIO_MAX_VECS), REQ_OP_READ, gfp, &iomap_dio_simple_pool);
-        if (!bio)
-                return -EAGAIN;
+        if (!bio) {
+                ret = -EAGAIN;
+                goto out_dio_end;
+        }
         sr = container_of(bio, struct iomap_dio_simple, bio);
         sr->iocb = iocb;
         sr->dio_flags = 0;
@@ -1060,6 +1066,8 @@ ssize_t __iomap_dio_simple(struct kiocb *iocb, struct iov_iter *iter, bio_release_pages(bio, false);
 out_bio_put:
         bio_put(bio);
+out_dio_end:
+        inode_dio_end(iomi->inode);
         return ret;
 }
 EXPORT_SYMBOL_GPL(__iomap_dio_simple);

include/linux/iomap.h +0 -0
index 810dc4b8dc94d..3cdf475059048 100644
@@ -732,11 +732,11 @@ static __always_inline ssize_t iomap_dio_read_simple(struct kiocb *iocb,

         inode_dio_begin(iomi.inode);
         ret = begin(iomi.inode, iomi.pos, iomi.len, iomi.flags, &iomi.iomap, &iomi.srcmap);
-        if (!ret)
-                ret = __iomap_dio_simple(iocb, iter, &iomi);
-        if (ret <= 0 && ret != -EIOCBQUEUED)
+        if (ret) {
                 inode_dio_end(iomi.inode);
-        return ret;
+                return ret;
+        }
+        return __iomap_dio_simple(iocb, iter, &iomi);
 }

 #ifdef CONFIG_SWAP

Quoted 7 lines


Thanks,
Joanne

Quoted 2 lines

+       return ret;
+}

#8 lore raw

Re: [PATCH 2/3] iomap: decouple simple direct I/O reads from iomap_dio_rw

Quoted 3 lines · changfengnan

Yes, there is an issue with the handling of the inode_dio_end event in the synchronization scenario.
How about this ?

Yes, minus the label naming that is exactly what I came up with yesterday and it has survived testing over night. Looks like xfstests currently never triggers the sychronous error return path, I'll see if I can increase coverage for that.

#9 lore raw

Re: [PATCH 2/3] iomap: decouple simple direct I/O reads from iomap_dio_rw

In reply to Joanne Koong
Quoted 4 lines · Joanne Koong

include/linux/iomap.h struct iomap_dio *__iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, · line 698

Quoted 2 lines
include/linux/iomap.h +2 -0
+ssize_t __iomap_dio_simple(struct kiocb *iocb, struct iov_iter *iter,
+               struct iomap_iter *iomi);

Might be nice to have _read_ in this name as well, eg __iomap_dio_read_simple

Yeah. I wanted the read out of the guts of the implementation, as most of the code is not strictly limited to reads. But with the public API needing it, we might as well be consistent in the function naming.

Quoted 11 lines

include/linux/iomap.h struct iomap_dio *__iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, · line 738

Quoted 4 lines
include/linux/iomap.h +4 -0
+       if (!ret)
+               ret = __iomap_dio_simple(iocb, iter, &iomi);
+       if (ret <= 0 && ret != -EIOCBQUEUED)
+               inode_dio_end(iomi.inode);

afaict, the inode_dio_end() error handling has to be done by __iomap_dio_simple() to properly account for the synchronous case. I ran into this earlier when doing the iomap_next_fn inlining. For the synchronous case, __iomap_dio_simple() calls iomap_dio_simple_complete() which calls inode_dio_end() even on errors.

Yes. Sashiko also reported that yesterday and I replied with a patch, but I now noticed the report and thus my reply only went to me, a sashiko-review list and Ted, but not everone else or the lists.

WTF?

#10 lore raw

Re: [PATCH 2/3] iomap: decouple simple direct I/O reads from iomap_dio_rw

Quoted 22 lines · Christoph Hellwig
Quoted 4 lines · Joanne Koong

include/linux/iomap.h struct iomap_dio *__iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, · line 698

Quoted 2 lines
include/linux/iomap.h +2 -0
+ssize_t __iomap_dio_simple(struct kiocb *iocb, struct iov_iter *iter,
+               struct iomap_iter *iomi);

Might be nice to have _read_ in this name as well, eg __iomap_dio_read_simple

Yeah. I wanted the read out of the guts of the implementation, as most of the code is not strictly limited to reads. But with the public API needing it, we might as well be consistent in the function naming.

Quoted 11 lines

include/linux/iomap.h struct iomap_dio *__iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, · line 738

Quoted 4 lines
include/linux/iomap.h +4 -0
+       if (!ret)
+               ret = __iomap_dio_simple(iocb, iter, &iomi);
+       if (ret <= 0 && ret != -EIOCBQUEUED)
+               inode_dio_end(iomi.inode);

afaict, the inode_dio_end() error handling has to be done by __iomap_dio_simple() to properly account for the synchronous case. I ran into this earlier when doing the iomap_next_fn inlining. For the synchronous case, __iomap_dio_simple() calls iomap_dio_simple_complete() which calls inode_dio_end() even on errors.

Quoted 5 lines

Yes. Sashiko also reported that yesterday and I replied with a patch, but I now noticed the report and thus my reply only went to me, a sashiko-review list and Ted, but not everone else or the lists.

WTF?

Sashiko doesn't email the lists by default, and I don't think we want to turn that on for the fsdevel firehose.

I sorta wish it did, but we all seem still to be struggling with what to do with valid complaints about existing problems from sashiko that neither were introduced by the patchset nor critically impact the new code.

In the meantime I also don't like the "private review involving someone else's dashboard" aspects either. No cake, no eating. :(

--D

maintainer
#11 lore raw

Re: [PATCH 2/3] iomap: decouple simple direct I/O reads from iomap_dio_rw

Quoted 8 lines · Darrick J. Wong
Quoted 5 lines

Yes. Sashiko also reported that yesterday and I replied with a patch, but I now noticed the report and thus my reply only went to me, a sashiko-review list and Ted, but not everone else or the lists.

WTF?

Sashiko doesn't email the lists by default, and I don't think we want to turn that on for the fsdevel firehose.

Whether or not the review goes to a mailing list is up to each subsystem to determine. Some people have violently objected to the review going to the mailing list, which is why it's optional.

I have asked to have ext4 reviews to be cc'ed to the linux-ext4 list[1]. It would be up to the VFS maintainers whether or not we want to enable it for linux-fsdevel.

[1] https://github.com/sashiko-dev/sashiko/pull/365

The XFS maintainers can request if patches cc'ed to linux-fs should get reviewed and sent back to authors and/or the maintainers and/or the linux-fs mailing list. You can either ask the Sashiko devs to edit the email_policy.toml file, or you can send a pull request yourself.

- Ted

maintainer
#12 lore raw

Re: [PATCH 2/3] iomap: decouple simple direct I/O reads from iomap_dio_rw

Quoted 18 lines · Theodore Tso
Quoted 8 lines · Darrick J. Wong
Quoted 5 lines

Yes. Sashiko also reported that yesterday and I replied with a patch, but I now noticed the report and thus my reply only went to me, a sashiko-review list and Ted, but not everone else or the lists.

WTF?

Sashiko doesn't email the lists by default, and I don't think we want to turn that on for the fsdevel firehose.

Whether or not the review goes to a mailing list is up to each subsystem to determine. Some people have violently objected to the review going to the mailing list, which is why it's optional.

I have asked to have ext4 reviews to be cc'ed to the linux-ext4 list[1]. It would be up to the VFS maintainers whether or not we want to enable it for linux-fsdevel.

Quoted 7 lines

[1] https://github.com/sashiko-dev/sashiko/pull/365

The XFS maintainers can request if patches cc'ed to linux-fs should get reviewed and sent back to authors and/or the maintainers and/or the linux-fs mailing list. You can either ask the Sashiko devs to edit the email_policy.toml file, or you can send a pull request yourself.

IIRC the discussion we had a while back was to keep the reviews emailed to authors only...

Now I wonder how feasible would be to have a "linux-xfs-review" list to send sashiko reviews to, then people opt-in to it? Would it be overkill?

#13 lore raw

selective Sashiko replies, was: Re: [PATCH 2/3] iomap: decouple simple direct I/O reads from iomap_dio_rw

Quoted 16 lines · Carlos Maiolino
Quoted 8 lines

Whether or not the review goes to a mailing list is up to each subsystem to determine. Some people have violently objected to the review going to the mailing list, which is why it's optional.

I have asked to have ext4 reviews to be cc'ed to the linux-ext4 list[1]. It would be up to the VFS maintainers whether or not we want to enable it for linux-fsdevel.

Quoted 7 lines

[1] https://github.com/sashiko-dev/sashiko/pull/365

The XFS maintainers can request if patches cc'ed to linux-fs should get reviewed and sent back to authors and/or the maintainers and/or the linux-fs mailing list. You can either ask the Sashiko devs to edit the email_policy.toml file, or you can send a pull request yourself.

Quoted 5 lines

IIRC the discussion we had a while back was to keep the reviews emailed to authors only...

Now I wonder how feasible would be to have a "linux-xfs-review" list to send sashiko reviews to, then people opt-in to it? Would it be overkill?

The main problem is that reducing the recipient list for replies is incredibly stupid. You can do that for a private offlist conversion on something sensitive, but not by default. If I get a reply, it needs to go everywhere. I have to admit I find the sashiko replies a lot less useful than the web interface, but the important bit is to be consistent.

#14 lore raw

Re: selective Sashiko replies, was: Re: [PATCH 2/3] iomap: decouple simple direct I/O reads from iomap_dio_rw

Quoted 8 lines · On Tue, 28 Jul 2026 06:01:20 +0200 Christoph Hellwig wrote:
Quoted 5 lines

IIRC the discussion we had a while back was to keep the reviews emailed to authors only...

Now I wonder how feasible would be to have a "linux-xfs-review" list to send sashiko reviews to, then people opt-in to it? Would it be overkill?

The main problem is that reducing the recipient list for replies is incredibly stupid.

+1, maybe perhaps someone wants the off-list option, dunno. But trimming the CC list of the on-list reply is a really weird idea. Submissions often CC multiple vger lists, and the bot only replies to one.

maintainer
#15 lore raw

Re: selective Sashiko replies, was: Re: [PATCH 2/3] iomap: decouple simple direct I/O reads from iomap_dio_rw

Quoted 4 lines · Jakub Kicinski

+1, maybe perhaps someone wants the off-list option, dunno. But trimming the CC list of the on-list reply is a really weird idea. Submissions often CC multiple vger lists, and the bot only replies to one.

It's not (necessarily) "just one" mailing list.

For better or for worse, there are people who have claimed that being exposed to LLM reviews would "deman their humanity". So the Sashiko maintainers have made it completely up to each subsystem whether (a) Sashiko should review the patch aat all or (b) whether the review should be sent via e-mail, or just left on sashiko.dev web site.

If it is sent via e-mail, then who it should be sent to can be configured to send it to the patch author (or not), or what e-mail addresses should be sent if the patch is qualified as relevant for a particular subsystem. This could just be the maintainer(s), or to the subsystem mailing list, etc. If a patch is relevant to (say) both the SCSI subsystem and the s390 subsystem, then it will be sent to both subsystem mailing lists. So it's not that the bot only replies to one list, but only to those lists that the subsystem maintainers have authorized.

At some level, the Sashiko developers effectively have tossed the hot potato policy decision to the subsystem maintainers. Given the megathead on the ksummit mailing lsit, I can't really blame Roman for choosing to do this ---- although I'll note the Intel zero-day bot folks chose differently; I guess automated benchmarks aren't perceived to demean the humanity of developers as much as LLM reviews, and so aren't as controversial.

Cheers,

- Ted

maintainer
#16 lore raw

Re: selective Sashiko replies, was: Re: [PATCH 2/3] iomap: decouple simple direct I/O reads from iomap_dio_rw

Quoted 10 lines · Theodore Tso
Quoted 4 lines · Jakub Kicinski

+1, maybe perhaps someone wants the off-list option, dunno. But trimming the CC list of the on-list reply is a really weird idea. Submissions often CC multiple vger lists, and the bot only replies to one.

It's not (necessarily) "just one" mailing list.

For better or for worse, there are people who have claimed that being exposed to LLM reviews would "deman their humanity".

Can I offer a slightly different perspective here? I am not one of the people who has said such things about LLM reviews, but I perhaps understand at least part of where they are coming from. It's not "being exposed" to reviews that is demeaning, it is being forced to justify one's work to a machine.

I can see how that might feel an awful lot like convincing the customer-service bot that yes, you *have* tried rebooting your router and you should be connected to a human without having to do it again. *That* can be demeaning.

The netdev folks are currently setting up this policy:

Patch authors are expected to proactively look into the AI-generated reviews and handle such feedback as any other kind of review: either debate it or address it. In both cases a reply on the mailing list is expected.
(https://lore.kernel.org/all/83360de7addb13a3b5f4d5e722148f248fdb2ae0.1784884817.git.pabeni@redhat.com/)

Without taking a position on whether this view is correct, I can certainly see why some people would balk at the idea of being forced to "debate" a machine before having their work considered.

jon

#17 lore raw

Re: selective Sashiko replies, was: Re: [PATCH 2/3] iomap: decouple simple direct I/O reads from iomap_dio_rw

Quoted 8 lines · On Tue, 28 Jul 2026 11:28:25 -0600 Jonathan Corbet wrote:
Quoted 8 lines · Jakub Kicinski
Quoted 4 lines

+1, maybe perhaps someone wants the off-list option, dunno. But trimming the CC list of the on-list reply is a really weird idea. Submissions often CC multiple vger lists, and the bot only replies to one.

It's not (necessarily) "just one" mailing list.

Quoted 8 lines
Quoted 2 lines

For better or for worse, there are people who have claimed that being exposed to LLM reviews would "deman their humanity".

Can I offer a slightly different perspective here? I am not one of the people who has said such things about LLM reviews, but I perhaps understand at least part of where they are coming from. It's not "being exposed" to reviews that is demeaning, it is being forced to justify one's work to a machine.

FWIW I think that's an entirely reasonable concern, and some people do indeed get irritated having to fight the AI slop reviews.

I thought the complaint was about the cases where the author is notified about the review, and so is at least one ML. But the CC list is cut down, so that a human reviewer doesn't see the AI output. They find the same issue as the AI. And then the author responds with "AI already told me: $lore-link". Which is really maximizing everyone's misery.

#18 lore raw

PATCH 3/3 iomap: use GFP_NOWAIT when application for iomap_dio_simple allocations

In reply to Christoph Hellwig

For non-blocking iocbs we should avoid blocking allocation where possible, so switch to a GFP_NOWAIT allocation here.

---
 fs/iomap/direct-io.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/iomap/direct-io.c +4 -1
index ca35da9e6cab..3bdfbd0efa07 100644
@@ -986,6 +986,7 @@ static void iomap_dio_simple_end_io(struct bio *bio)
 ssize_t __iomap_dio_simple(struct kiocb *iocb, struct iov_iter *iter,
 		struct iomap_iter *iomi)
 {
+	gfp_t gfp = (iomi->flags & IOMAP_NOWAIT) ? GFP_NOWAIT : GFP_KERNEL;
 	struct iomap_dio_simple *sr;
 	unsigned int alignment;
 	struct bio *bio;
@@ -1011,7 +1012,9 @@ ssize_t __iomap_dio_simple(struct kiocb *iocb, struct iov_iter *iter,
 
 	bio = bio_alloc_bioset(iomi->iomap.bdev,
 			       bio_iov_vecs_to_alloc(iter, BIO_MAX_VECS),
-			       REQ_OP_READ, GFP_KERNEL, &iomap_dio_simple_pool);
+			       REQ_OP_READ, gfp, &iomap_dio_simple_pool);
+	if (!bio)
+		return -EAGAIN;
 	sr = container_of(bio, struct iomap_dio_simple, bio);
 	sr->iocb = iocb;
 	sr->dio_flags = 0;
Signature · 1 line
2.53.0
Reviewed-by
#20 lore raw

Re: [PATCH 3/3] iomap: use GFP_NOWAIT when application for iomap_dio_simple allocations

Quoted 8 lines

From: "Joanne Koong"<[email protected]>
Date:  Thu, Jul 23, 2026, 05:02
Subject:  Re: [PATCH 3/3] iomap: use GFP_NOWAIT when application for iomap_dio_simple allocations
To: "Christoph Hellwig"<[email protected]>
Cc: <[email protected]>, "Darrick J. Wong"<[email protected]>, "Christian Brauner"<[email protected]>, "Theodore Ts'o"<[email protected]>, "Carlos Maiolino"<[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>

Quoted 1 line · Christoph Hellwig
Quoted 6 lines
Quoted 4 lines

For non-blocking iocbs we should avoid blocking allocation where possible, so switch to a GFP_NOWAIT allocation here.

Quoted 1 line