Skip to content

Commit 7392c0a

Browse files
author
Ming Lei
committed
dm: Check for forbidden splitting of zone write operations
JIRA: https://issues.redhat.com/browse/RHEL-97177 commit 409f928 Author: Damien Le Moal <dlemoal@kernel.org> Date: Wed Jun 25 18:33:27 2025 +0900 dm: Check for forbidden splitting of zone write operations DM targets must not split zone append and write operations using dm_accept_partial_bio() as doing so is forbidden for zone append BIOs, breaks zone append emulation using regular write BIOs and potentially creates deadlock situations with queue freeze operations. Modify dm_accept_partial_bio() to add missing BUG_ON() checks for all these cases, that is, check that the BIO is a write or write zeroes operation. This change packs all the zone related checks together under a static_branch_unlikely(&zoned_enabled) and done only if the target is a zoned device. Fixes: f211268 ("dm: Use the block layer zone append emulation") Cc: stable@vger.kernel.org Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Mikulas Patocka <mpatocka@redhat.com> Link: https://lore.kernel.org/r/20250625093327.548866-6-dlemoal@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Ming Lei <ming.lei@redhat.com>
1 parent e68f64a commit 7392c0a

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

drivers/md/dm.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,8 +1309,9 @@ static size_t dm_dax_recovery_write(struct dax_device *dax_dev, pgoff_t pgoff,
13091309
/*
13101310
* A target may call dm_accept_partial_bio only from the map routine. It is
13111311
* allowed for all bio types except REQ_PREFLUSH, REQ_OP_ZONE_* zone management
1312-
* operations, REQ_OP_ZONE_APPEND (zone append writes) and any bio serviced by
1313-
* __send_duplicate_bios().
1312+
* operations, zone append writes (native with REQ_OP_ZONE_APPEND or emulated
1313+
* with write BIOs flagged with BIO_EMULATES_ZONE_APPEND) and any bio serviced
1314+
* by __send_duplicate_bios().
13141315
*
13151316
* dm_accept_partial_bio informs the dm that the target only wants to process
13161317
* additional n_sectors sectors of the bio and the rest of the data should be
@@ -1343,11 +1344,19 @@ void dm_accept_partial_bio(struct bio *bio, unsigned int n_sectors)
13431344
unsigned int bio_sectors = bio_sectors(bio);
13441345

13451346
BUG_ON(dm_tio_flagged(tio, DM_TIO_IS_DUPLICATE_BIO));
1346-
BUG_ON(op_is_zone_mgmt(bio_op(bio)));
1347-
BUG_ON(bio_op(bio) == REQ_OP_ZONE_APPEND);
13481347
BUG_ON(bio_sectors > *tio->len_ptr);
13491348
BUG_ON(n_sectors > bio_sectors);
13501349

1350+
if (static_branch_unlikely(&zoned_enabled) &&
1351+
unlikely(bdev_is_zoned(bio->bi_bdev))) {
1352+
enum req_op op = bio_op(bio);
1353+
1354+
BUG_ON(op_is_zone_mgmt(op));
1355+
BUG_ON(op == REQ_OP_WRITE);
1356+
BUG_ON(op == REQ_OP_WRITE_ZEROES);
1357+
BUG_ON(op == REQ_OP_ZONE_APPEND);
1358+
}
1359+
13511360
*tio->len_ptr -= bio_sectors - n_sectors;
13521361
bio->bi_iter.bi_size = n_sectors << SECTOR_SHIFT;
13531362

0 commit comments

Comments
 (0)