From: Damien Le Moal <damien.lemoal@xxxxxxx> If a target maps to a zoned block device, check that the device area is aligned on zone boundaries to avoid problems with REQ_OP_ZONE_RESET operations (resetting a partially mapped sequential zone would not be possible). This also greatly facilitate the processing of zone report with REQ_OP_ZONE_REPORT bios. Signed-off-by: Damien Le Moal <damien.lemoal@xxxxxxx> Reviewed-by: Hannes Reinecke <hare@xxxxxxxx> Reviewed-by: Bart Van Assche <bart.vanassche@xxxxxxxxxxx> --- drivers/md/dm-table.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 6a7e200..3949897 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -340,6 +340,33 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev, return 1; } + /* + * If the target is mapped to a zoned block device, check + * that the device zones are not partially mapped. + */ + if (bdev_zoned_model(bdev) != BLK_ZONED_NONE) { + unsigned int zone_sectors = bdev_zone_sectors(bdev); + + if (start & (zone_sectors - 1)) { + DMWARN("%s: start=%llu not aligned to h/w " + "zone size %u of %s", + dm_device_name(ti->table->md), + (unsigned long long)start, + zone_sectors, bdevname(bdev, b)); + return 1; + } + + if (start + len < dev_size && + len & (zone_sectors - 1)) { + DMWARN("%s: len=%llu not aligned to h/w " + "zone size %u of %s", + dm_device_name(ti->table->md), + (unsigned long long)start, + zone_sectors, bdevname(bdev, b)); + return 1; + } + } + return 0; } -- 2.9.3 -- dm-devel mailing list dm-devel@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/dm-devel