mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 05:44:45 +01:00
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: f211268ed1 ("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>
This commit is contained in:
parent
e549663849
commit
409f9287da
1 changed files with 13 additions and 4 deletions
|
|
@ -1293,8 +1293,9 @@ out:
|
|||
/*
|
||||
* A target may call dm_accept_partial_bio only from the map routine. It is
|
||||
* allowed for all bio types except REQ_PREFLUSH, REQ_OP_ZONE_* zone management
|
||||
* operations, REQ_OP_ZONE_APPEND (zone append writes) and any bio serviced by
|
||||
* __send_duplicate_bios().
|
||||
* operations, zone append writes (native with REQ_OP_ZONE_APPEND or emulated
|
||||
* with write BIOs flagged with BIO_EMULATES_ZONE_APPEND) and any bio serviced
|
||||
* by __send_duplicate_bios().
|
||||
*
|
||||
* dm_accept_partial_bio informs the dm that the target only wants to process
|
||||
* additional n_sectors sectors of the bio and the rest of the data should be
|
||||
|
|
@ -1327,11 +1328,19 @@ void dm_accept_partial_bio(struct bio *bio, unsigned int n_sectors)
|
|||
unsigned int bio_sectors = bio_sectors(bio);
|
||||
|
||||
BUG_ON(dm_tio_flagged(tio, DM_TIO_IS_DUPLICATE_BIO));
|
||||
BUG_ON(op_is_zone_mgmt(bio_op(bio)));
|
||||
BUG_ON(bio_op(bio) == REQ_OP_ZONE_APPEND);
|
||||
BUG_ON(bio_sectors > *tio->len_ptr);
|
||||
BUG_ON(n_sectors > bio_sectors);
|
||||
|
||||
if (static_branch_unlikely(&zoned_enabled) &&
|
||||
unlikely(bdev_is_zoned(bio->bi_bdev))) {
|
||||
enum req_op op = bio_op(bio);
|
||||
|
||||
BUG_ON(op_is_zone_mgmt(op));
|
||||
BUG_ON(op == REQ_OP_WRITE);
|
||||
BUG_ON(op == REQ_OP_WRITE_ZEROES);
|
||||
BUG_ON(op == REQ_OP_ZONE_APPEND);
|
||||
}
|
||||
|
||||
*tio->len_ptr -= bio_sectors - n_sectors;
|
||||
bio->bi_iter.bi_size = n_sectors << SECTOR_SHIFT;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue