dm: fix report zone remapping to account for partition offset
authorDamien Le Moal <damien.lemoal@wdc.com>
Tue, 9 Oct 2018 05:24:31 +0000 (14:24 +0900)
committerMike Snitzer <snitzer@redhat.com>
Tue, 9 Oct 2018 18:20:13 +0000 (14:20 -0400)
commit9864cd5dc54cade89fd4b0954c2e522841aa247c
tree39eecc836833ef8bdefb6fefc8ff00866f4d6390
parentc7cd55504a5b0fc826a2cd9540845979d24ae542
dm: fix report zone remapping to account for partition offset

If dm-linear or dm-flakey are layered on top of a partition of a zoned
block device, remapping of the start sector and write pointer position
of the zones reported by a report zones BIO must be modified to account
for the target table entry mapping (start offset within the device and
entry mapping with the dm device).  If the target's backing device is a
partition of a whole disk, the start sector on the physical device of
the partition must also be accounted for when modifying the zone
information.  However, dm_remap_zone_report() was not considering this
last case, resulting in incorrect zone information remapping with
targets using disk partitions.

Fix this by calculating the target backing device start sector using
the position of the completed report zones BIO and the unchanged
position and size of the original report zone BIO. With this value
calculated, the start sector and write pointer position of the target
zones can be correctly remapped.

Fixes: 10999307c14e ("dm: introduce dm_remap_zone_report()")
Cc: stable@vger.kernel.org
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
drivers/md/dm.c