[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230106083317.93938-6-p.raghav@samsung.com>
Date: Fri, 6 Jan 2023 09:33:15 +0100
From: Pankaj Raghav <p.raghav@...sung.com>
To: axboe@...nel.dk
Cc: kernel@...kajraghav.com, linux-kernel@...r.kernel.org,
hare@...e.de, bvanassche@....org, snitzer@...nel.org,
dm-devel@...hat.com, damien.lemoal@...nsource.wdc.com,
linux-nvme@...ts.infradead.org, hch@....de,
linux-block@...r.kernel.org, gost.dev@...sung.com,
Luis Chamberlain <mcgrof@...nel.org>,
Johannes Thumshirn <johannes.thumshirn@....com>,
Pankaj Raghav <p.raghav@...sung.com>
Subject: [PATCH 5/7] dm-zoned: ensure only power of 2 zone sizes are allowed
From: Luis Chamberlain <mcgrof@...nel.org>
dm-zoned relies on the assumption that the zone size is a
power-of-2(po2) and the zone capacity is same as the zone size.
Ensure only po2 devices can be used as dm-zoned target until a native
support for zoned devices with non-po2 zone size is added.
Reviewed-by: Hannes Reinecke <hare@...e.de>
Reviewed-by: Damien Le Moal <damien.lemoal@...nsource.wdc.com>
Reviewed-by: Bart Van Assche <bvanassche@....org>
Reviewed-by: Mike Snitzer <snitzer@...nel.org>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@....com>
Signed-off-by: Luis Chamberlain <mcgrof@...nel.org>
Signed-off-by: Pankaj Raghav <p.raghav@...sung.com>
---
drivers/md/dm-zoned-target.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/md/dm-zoned-target.c b/drivers/md/dm-zoned-target.c
index 95b132b52f33..9325bf5dee81 100644
--- a/drivers/md/dm-zoned-target.c
+++ b/drivers/md/dm-zoned-target.c
@@ -792,6 +792,10 @@ static int dmz_fixup_devices(struct dm_target *ti)
return -EINVAL;
}
zone_nr_sectors = bdev_zone_sectors(bdev);
+ if (!is_power_of_2(zone_nr_sectors)) {
+ ti->error = "Zone size is not a power-of-2 number of sectors";
+ return -EINVAL;
+ }
zoned_dev->zone_nr_sectors = zone_nr_sectors;
zoned_dev->nr_zones = bdev_nr_zones(bdev);
}
@@ -804,6 +808,10 @@ static int dmz_fixup_devices(struct dm_target *ti)
return -EINVAL;
}
zoned_dev->zone_nr_sectors = bdev_zone_sectors(bdev);
+ if (!is_power_of_2(zoned_dev->zone_nr_sectors)) {
+ ti->error = "Zone size is not a power-of-2 number of sectors";
+ return -EINVAL;
+ }
zoned_dev->nr_zones = bdev_nr_zones(bdev);
}
--
2.25.1
Powered by blists - more mailing lists