Skip to contentSkip to conversation

iomap: Don't fall back to bufferred write if the write is atomic

RFC New Ojaswin Mujoo 1 participant 1 message Nov 30, 2023 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

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

#1 lore raw

RFC 1/7 iomap: Don't fall back to bufferred write if the write is atomic

Currently, iomap only supports atomic writes for direct IOs and there is no guarantees that a bufferred IO will be atomic. Hence, if the user has explicitly requested the direct write to be atomic and there's a failure, return -EIO instead of falling back to bufferred IO.

---
 fs/iomap/direct-io.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
fs/iomap/direct-io.c +7 -1
index 6ef25e26f1a1..d7e6c6eacbf7 100644
@@ -662,7 +662,13 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
 			if (ret != -EAGAIN) {
 				trace_iomap_dio_invalidate_fail(inode, iomi.pos,
 								iomi.len);
-				ret = -ENOTBLK;
+				/*
+				 * if this write was supposed to be atomic,
+				 * return the err rather than trying to fall
+				 * back to bufferred IO.
+				 */
+				if (!atomic_write)
+					ret = -ENOTBLK;
 			}
 			goto out_free_dio;
 		}
Signature · 1 line
2.39.3