Commit 554b2286 authored by John Garry's avatar John Garry Committed by Jens Axboe
Browse files

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: default avatarJohn Garry <john.g.garry@oracle.com>
Reviewed-by: default avatarMike Snitzer <snitzer@kernel.org>
Link: https://lore.kernel.org/r/20250116170301.474130-3-john.g.garry@oracle.com


Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 6a7e17b2
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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;