summaryrefslogtreecommitdiff
path: root/block/bio.c
diff options
context:
space:
mode:
authorJohn Garry <john.g.garry@oracle.com>2025-01-16 17:02:55 +0000
committerJens Axboe <axboe@kernel.dk>2025-01-17 13:13:55 -0700
commit554b22864cc79e28cd65e3a6e1d0d1dfa8581c68 (patch)
tree208c280d99920eeda42cc21dc4c9e6549854c3b3 /block/bio.c
parent6a7e17b22062c84a111d7073c67cc677c4190f32 (diff)
block: Don't trim an atomic write
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>
Diffstat (limited to 'block/bio.c')
-rw-r--r--block/bio.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/block/bio.c b/block/bio.c
index 4e1a27d312c9..f0c416e5931d 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -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;