From 730dba4d11910193dfbafd91dff42ee065c44428 Mon Sep 17 00:00:00 2001 From: Pankaj Raghav Date: Fri, 23 Sep 2022 19:36:16 +0200 Subject: [PATCH] FROMLIST: dm: call dm_zone_endio after the target endio callback for zoned devices dm_zone_endio() updates the bi_sector of orig bio for zoned devices that uses either native append or append emulation, and it is called before the endio of the target. But target endio can still update the clone bio after dm_zone_endio is called, thereby, the orig bio does not contain the updated information anymore. Currently, this is not a problem as the targets that support zoned devices such as dm-zoned, dm-linear, and dm-crypt do not have an endio function, and even if they do (such as dm-flakey), they don't modify the bio->bi_iter.bi_sector of the cloned bio that is used to update the orig_bio's bi_sector in dm_zone_endio function. This is a prep patch for the new dm-po2zoned target as it modifies bi_sector in the endio callback. Call dm_zone_endio for zoned devices after calling the target's endio function. Reviewed-by: Mike Snitzer Signed-off-by: Pankaj Raghav Bug: 197782466 Bug: 269471019 Link: https://lore.kernel.org/linux-block/20220923173618.6899-12-p.raghav@samsung.com/ Change-Id: Ia7a96aac805a040f8ab109e6cfdf50ad9895e2ee Signed-off-by: Bart Van Assche --- drivers/md/dm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index de206ddaac20..4ca96c3c7231 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -921,9 +921,6 @@ static void clone_endio(struct bio *bio) disable_write_zeroes(md); } - if (blk_queue_is_zoned(q)) - dm_zone_endio(io, bio); - if (endio) { int r = endio(tio->ti, bio, &error); switch (r) { @@ -949,6 +946,9 @@ static void clone_endio(struct bio *bio) } } + if (blk_queue_is_zoned(q)) + dm_zone_endio(io, bio); + if (unlikely(swap_bios_limit(tio->ti, bio))) { struct mapped_device *md = io->md; up(&md->swap_bios_semaphore);