block: Don't trim an atomic write for-6.14/block for-6.14/block-20250118
authorJohn Garry <john.g.garry@oracle.com>
Thu, 16 Jan 2025 17:02:55 +0000 (17:02 +0000)
committerJens Axboe <axboe@kernel.dk>
Fri, 17 Jan 2025 20:13:55 +0000 (13:13 -0700)
This is disallowed.

This check will now be relevant since the device mapper personalities
will start to support atomic writes, and they use this function.

Signed-off-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Mike Snitzer <snitzer@kernel.org>
Link: https://lore.kernel.org/r/20250116170301.474130-3-john.g.garry@oracle.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/bio.c

index 4e1a27d312c9aa66c7586ea4563a6a02000200ea..f0c416e5931d97ebbc8bbf7fd41d3e7bb9dfa9a7 100644 (file)
@@ -1610,6 +1610,10 @@ EXPORT_SYMBOL(bio_split);
  */
 void bio_trim(struct bio *bio, sector_t offset, sector_t size)
 {
+       /* We should never trim an atomic write */
+       if (WARN_ON_ONCE(bio->bi_opf & REQ_ATOMIC && size))
+               return;
+
        if (WARN_ON_ONCE(offset > BIO_MAX_SECTORS || size > BIO_MAX_SECTORS ||
                         offset + size > bio_sectors(bio)))
                return;