1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00

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>
This commit is contained in:
John Garry 2025-01-16 17:02:55 +00:00 committed by Jens Axboe
parent 6a7e17b220
commit 554b22864c

View 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;