Skip to content

Commit 415c79e

Browse files
morbidrsasnitm
authored andcommitted
dm: update original bio sector on Zone Append
Naohiro reported that issuing zone-append bios to a zoned block device underneath a dm-linear device does not work as expected. This because we forgot to reverse-map the sector the device wrote to the original bio. For zone-append bios, get the offset in the zone of the written sector from the clone bio and add that to the original bio's sector position. Fixes: 0512a75 ("block: Introduce REQ_OP_ZONE_APPEND") Cc: [email protected] Reported-by: Naohiro Aota <[email protected]> Signed-off-by: Johannes Thumshirn <[email protected]> Reviewed-by: Damien Le Moal <[email protected]> Signed-off-by: Mike Snitzer <[email protected]>
1 parent b38c0ad commit 415c79e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

drivers/md/dm.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,7 @@ static void clone_endio(struct bio *bio)
10091009
struct dm_io *io = tio->io;
10101010
struct mapped_device *md = tio->io->md;
10111011
dm_endio_fn endio = tio->ti->type->end_io;
1012+
struct bio *orig_bio = io->orig_bio;
10121013

10131014
if (unlikely(error == BLK_STS_TARGET) && md->type != DM_TYPE_NVME_BIO_BASED) {
10141015
if (bio_op(bio) == REQ_OP_DISCARD &&
@@ -1022,6 +1023,18 @@ static void clone_endio(struct bio *bio)
10221023
disable_write_zeroes(md);
10231024
}
10241025

1026+
/*
1027+
* For zone-append bios get offset in zone of the written
1028+
* sector and add that to the original bio sector pos.
1029+
*/
1030+
if (bio_op(orig_bio) == REQ_OP_ZONE_APPEND) {
1031+
sector_t written_sector = bio->bi_iter.bi_sector;
1032+
struct request_queue *q = orig_bio->bi_disk->queue;
1033+
u64 mask = (u64)blk_queue_zone_sectors(q) - 1;
1034+
1035+
orig_bio->bi_iter.bi_sector += written_sector & mask;
1036+
}
1037+
10251038
if (endio) {
10261039
int r = endio(tio->ti, bio, &error);
10271040
switch (r) {

0 commit comments

Comments
 (0)