]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
iomap: comment on atomic write checks in iomap_dio_bio_iter()
authorJohn Garry <john.g.garry@oracle.com>
Thu, 20 Mar 2025 12:02:49 +0000 (12:02 +0000)
committerChristian Brauner <brauner@kernel.org>
Thu, 20 Mar 2025 14:16:03 +0000 (15:16 +0100)
Help explain the code.

Also clarify the comment for bio size check.

Signed-off-by: John Garry <john.g.garry@oracle.com>
Link: https://lore.kernel.org/r/20250320120250.4087011-3-john.g.garry@oracle.com
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/iomap/direct-io.c

index 8c1bec4735868b45edca73bc6ea437cdb44196b0..b9f59ca43c1509bf5b6fe4159d22721f5598281f 100644 (file)
@@ -350,6 +350,11 @@ static int iomap_dio_bio_iter(struct iomap_iter *iter, struct iomap_dio *dio)
                bio_opf |= REQ_OP_WRITE;
 
                if (iter->flags & IOMAP_ATOMIC_HW) {
+                       /*
+                        * Ensure that the mapping covers the full write
+                        * length, otherwise it won't be submitted as a single
+                        * bio, which is required to use hardware atomics.
+                        */
                        if (length != iter->len)
                                return -EINVAL;
                        bio_opf |= REQ_ATOMIC;
@@ -449,7 +454,7 @@ static int iomap_dio_bio_iter(struct iomap_iter *iter, struct iomap_dio *dio)
                n = bio->bi_iter.bi_size;
                if (WARN_ON_ONCE((bio_opf & REQ_ATOMIC) && n != length)) {
                        /*
-                        * This bio should have covered the complete length,
+                        * An atomic write bio must cover the complete length,
                         * which it doesn't, so error. We may need to zero out
                         * the tail (complete FS block), similar to when
                         * bio_iov_iter_get_pages() returns an error, above.