From 79d615bb54d0904dda9d3788a73a205e4ac59541 Mon Sep 17 00:00:00 2001
From: Pankaj Raghav
Date: Fri, 23 Sep 2022 19:36:15 +0200
Subject: [PATCH] FROMLIST: dm-table: allow zoned devices with non power-of-2
zone sizes
Allow dm to support zoned devices with non power-of-2(po2) zone sizes as
the block layer now supports it.
Signed-off-by: Pankaj Raghav
Reviewed-by: Bart Van Assche
Reviewed-by: Damien Le Moal
Reviewed-by: Johannes Thumshirn
Reviewed-by: Mike Snitzer
Bug: 197782466
Bug: 269471019
Link: https://lore.kernel.org/linux-block/20220923173618.6899-11-p.raghav@samsung.com/
Change-Id: I837811b17aacecc74fc2fd9d4009ad7e66917fb8
Signed-off-by: Bart Van Assche
---
drivers/md/dm-table.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index d9e65611aef7..cb394e497f74 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -252,7 +252,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
if (bdev_is_zoned(bdev)) {
unsigned int zone_sectors = bdev_zone_sectors(bdev);
- if (start & (zone_sectors - 1)) {
+ if (!bdev_is_zone_start(bdev, start)) {
DMWARN("%s: start=%llu not aligned to h/w zone size %u of %s",
dm_device_name(ti->table->md),
(unsigned long long)start,
@@ -269,7 +269,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
* devices do not end up with a smaller zone in the middle of
* the sector range.
*/
- if (len & (zone_sectors - 1)) {
+ if (!bdev_is_zone_start(bdev, len)) {
DMWARN("%s: len=%llu not aligned to h/w zone size %u of %s",
dm_device_name(ti->table->md),
(unsigned long long)len,
@@ -1691,8 +1691,7 @@ static int validate_hardware_zoned_model(struct dm_table *table,
return -EINVAL;
}
- /* Check zone size validity and compatibility */
- if (!zone_sectors || !is_power_of_2(zone_sectors))
+ if (!zone_sectors)
return -EINVAL;
if (dm_table_any_dev_attr(table, device_not_matches_zone_sectors, &zone_sectors)) {