Skip to content

Commit aacd436

Browse files
johnpgarrybrauner
authored andcommitted
iomap: comment on atomic write checks in iomap_dio_bio_iter()
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>
1 parent d279c80 commit aacd436

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

fs/iomap/direct-io.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,11 @@ static int iomap_dio_bio_iter(struct iomap_iter *iter, struct iomap_dio *dio)
350350
bio_opf |= REQ_OP_WRITE;
351351

352352
if (iter->flags & IOMAP_ATOMIC_HW) {
353+
/*
354+
* Ensure that the mapping covers the full write
355+
* length, otherwise it won't be submitted as a single
356+
* bio, which is required to use hardware atomics.
357+
*/
353358
if (length != iter->len)
354359
return -EINVAL;
355360
bio_opf |= REQ_ATOMIC;
@@ -449,7 +454,7 @@ static int iomap_dio_bio_iter(struct iomap_iter *iter, struct iomap_dio *dio)
449454
n = bio->bi_iter.bi_size;
450455
if (WARN_ON_ONCE((bio_opf & REQ_ATOMIC) && n != length)) {
451456
/*
452-
* This bio should have covered the complete length,
457+
* An atomic write bio must cover the complete length,
453458
* which it doesn't, so error. We may need to zero out
454459
* the tail (complete FS block), similar to when
455460
* bio_iov_iter_get_pages() returns an error, above.

0 commit comments

Comments
 (0)