Commit fabed68c authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

dm-zoned: cleanup dmz_fixup_devices

Use the bdev based helpers where applicable and move the zoned_dev
into the scope where it is actually used.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarChaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Link: https://lore.kernel.org/r/20220706070350.1703384-15-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent a239145a
...@@ -764,8 +764,7 @@ static void dmz_put_zoned_device(struct dm_target *ti) ...@@ -764,8 +764,7 @@ static void dmz_put_zoned_device(struct dm_target *ti)
static int dmz_fixup_devices(struct dm_target *ti) static int dmz_fixup_devices(struct dm_target *ti)
{ {
struct dmz_target *dmz = ti->private; struct dmz_target *dmz = ti->private;
struct dmz_dev *reg_dev, *zoned_dev; struct dmz_dev *reg_dev = NULL;
struct request_queue *q;
sector_t zone_nr_sectors = 0; sector_t zone_nr_sectors = 0;
int i; int i;
...@@ -780,31 +779,32 @@ static int dmz_fixup_devices(struct dm_target *ti) ...@@ -780,31 +779,32 @@ static int dmz_fixup_devices(struct dm_target *ti)
return -EINVAL; return -EINVAL;
} }
for (i = 1; i < dmz->nr_ddevs; i++) { for (i = 1; i < dmz->nr_ddevs; i++) {
zoned_dev = &dmz->dev[i]; struct dmz_dev *zoned_dev = &dmz->dev[i];
struct block_device *bdev = zoned_dev->bdev;
if (zoned_dev->flags & DMZ_BDEV_REGULAR) { if (zoned_dev->flags & DMZ_BDEV_REGULAR) {
ti->error = "Secondary disk is not a zoned device"; ti->error = "Secondary disk is not a zoned device";
return -EINVAL; return -EINVAL;
} }
q = bdev_get_queue(zoned_dev->bdev);
if (zone_nr_sectors && if (zone_nr_sectors &&
zone_nr_sectors != blk_queue_zone_sectors(q)) { zone_nr_sectors != bdev_zone_sectors(bdev)) {
ti->error = "Zone nr sectors mismatch"; ti->error = "Zone nr sectors mismatch";
return -EINVAL; return -EINVAL;
} }
zone_nr_sectors = blk_queue_zone_sectors(q); zone_nr_sectors = bdev_zone_sectors(bdev);
zoned_dev->zone_nr_sectors = zone_nr_sectors; zoned_dev->zone_nr_sectors = zone_nr_sectors;
zoned_dev->nr_zones = bdev_nr_zones(zoned_dev->bdev); zoned_dev->nr_zones = bdev_nr_zones(bdev);
} }
} else { } else {
reg_dev = NULL; struct dmz_dev *zoned_dev = &dmz->dev[0];
zoned_dev = &dmz->dev[0]; struct block_device *bdev = zoned_dev->bdev;
if (zoned_dev->flags & DMZ_BDEV_REGULAR) { if (zoned_dev->flags & DMZ_BDEV_REGULAR) {
ti->error = "Disk is not a zoned device"; ti->error = "Disk is not a zoned device";
return -EINVAL; return -EINVAL;
} }
q = bdev_get_queue(zoned_dev->bdev); zoned_dev->zone_nr_sectors = bdev_zone_sectors(bdev);
zoned_dev->zone_nr_sectors = blk_queue_zone_sectors(q); zoned_dev->nr_zones = bdev_nr_zones(bdev);
zoned_dev->nr_zones = bdev_nr_zones(zoned_dev->bdev);
} }
if (reg_dev) { if (reg_dev) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment