diff mbox series

[v12,12/13] dm: introduce DM_EMULATED_ZONES target type

Message ID 20220823121859.163903-13-p.raghav@samsung.com (mailing list archive)
State New, archived
Headers show
Series [v12,01/13] block: make bdev_nr_zones and disk_zone_no generic for npo2 zone size | expand

Commit Message

Pankaj Raghav Aug. 23, 2022, 12:18 p.m. UTC
Introduce a new target type DM_EMULATED_ZONES for targets with
a different number of sectors per zone (aka zone size) than the underlying
device zone size.

This target type is introduced as the existing zoned targets assume
that the target and the underlying device have the same zone size.
The new target: dm-po2zone will use this new target
type as it emulates the zone boundary that is different from the
underlying zoned device.

Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
---
 drivers/md/dm-table.c         | 13 ++++++++++---
 include/linux/device-mapper.h |  9 +++++++++
 2 files changed, 19 insertions(+), 3 deletions(-)

Comments

Mike Snitzer Sept. 2, 2022, 12:28 a.m. UTC | #1
On Tue, Aug 23 2022 at  8:18P -0400,
Pankaj Raghav <p.raghav@samsung.com> wrote:

> Introduce a new target type DM_EMULATED_ZONES for targets with
> a different number of sectors per zone (aka zone size) than the underlying
> device zone size.
> 
> This target type is introduced as the existing zoned targets assume
> that the target and the underlying device have the same zone size.
> The new target: dm-po2zone will use this new target
> type as it emulates the zone boundary that is different from the
> underlying zoned device.
> 
> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
> Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>

This patch's use of "target type" jargon isn't valid. 

Please say "target feature flag" and rename DM_EMULATED_ZONES to
DM_TARGET_EMULATED_ZONES in the subject and header.

But, with those fixed:

Signed-off-by: Mike Snitzer <snitzer@kernel.org>

(fyi, I'll review patch 13, the dm-po2zone target, tomorrow)
Pankaj Raghav Sept. 2, 2022, 12:02 p.m. UTC | #2
On 2022-09-02 02:28, Mike Snitzer wrote:
> On Tue, Aug 23 2022 at  8:18P -0400,
> Pankaj Raghav <p.raghav@samsung.com> wrote:
> 
>> Introduce a new target type DM_EMULATED_ZONES for targets with
>> a different number of sectors per zone (aka zone size) than the underlying
>> device zone size.
>>
>> This target type is introduced as the existing zoned targets assume
>> that the target and the underlying device have the same zone size.
>> The new target: dm-po2zone will use this new target
>> type as it emulates the zone boundary that is different from the
>> underlying zoned device.
>>
>> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
>> Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
> 
> This patch's use of "target type" jargon isn't valid. 
> 
> Please say "target feature flag" and rename DM_EMULATED_ZONES to
> DM_TARGET_EMULATED_ZONES in the subject and header.
> Good catch. I will fix it up for the next version.
> But, with those fixed:
> 
> Signed-off-by: Mike Snitzer <snitzer@kernel.org>
> 
You mean <Reviewed-By> ? :)
> (fyi, I'll review patch 13, the dm-po2zone target, tomorrow)
> 
Thanks.
Mike Snitzer Sept. 2, 2022, 6:43 p.m. UTC | #3
On Fri, Sep 02 2022 at  8:02P -0400,
Pankaj Raghav <p.raghav@samsung.com> wrote:

> On 2022-09-02 02:28, Mike Snitzer wrote:
> > On Tue, Aug 23 2022 at  8:18P -0400,
> > Pankaj Raghav <p.raghav@samsung.com> wrote:
> > 
> >> Introduce a new target type DM_EMULATED_ZONES for targets with
> >> a different number of sectors per zone (aka zone size) than the underlying
> >> device zone size.
> >>
> >> This target type is introduced as the existing zoned targets assume
> >> that the target and the underlying device have the same zone size.
> >> The new target: dm-po2zone will use this new target
> >> type as it emulates the zone boundary that is different from the
> >> underlying zoned device.
> >>
> >> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
> >> Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
> > 
> > This patch's use of "target type" jargon isn't valid. 
> > 
> > Please say "target feature flag" and rename DM_EMULATED_ZONES to
> > DM_TARGET_EMULATED_ZONES in the subject and header.
> > Good catch. I will fix it up for the next version.
> > But, with those fixed:
> > 
> > Signed-off-by: Mike Snitzer <snitzer@kernel.org>
> > 
> You mean <Reviewed-By> ? :)

Ah, yes Reviewed-By, force of habit ;)
diff mbox series

Patch

diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 31eb1d29d136..b37991ea3ffb 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -1614,13 +1614,20 @@  static bool dm_table_supports_zoned_model(struct dm_table *t,
 	return true;
 }
 
-static int device_not_matches_zone_sectors(struct dm_target *ti, struct dm_dev *dev,
+/*
+ * Callback function to check for device zone sector across devices. If the
+ * DM_TARGET_EMULATED_ZONES target feature flag is not set, then the target
+ * should have the same zone sector as the underlying devices.
+ */
+static int check_valid_device_zone_sectors(struct dm_target *ti, struct dm_dev *dev,
 					   sector_t start, sector_t len, void *data)
 {
 	unsigned int *zone_sectors = data;
 
-	if (!bdev_is_zoned(dev->bdev))
+	if (!bdev_is_zoned(dev->bdev) ||
+	    dm_target_supports_emulated_zones(ti->type))
 		return 0;
+
 	return bdev_zone_sectors(dev->bdev) != *zone_sectors;
 }
 
@@ -1645,7 +1652,7 @@  static int validate_hardware_zoned_model(struct dm_table *t,
 	if (!zone_sectors)
 		return -EINVAL;
 
-	if (dm_table_any_dev_attr(t, device_not_matches_zone_sectors, &zone_sectors)) {
+	if (dm_table_any_dev_attr(t, check_valid_device_zone_sectors, &zone_sectors)) {
 		DMERR("%s: zone sectors is not consistent across all zoned devices",
 		      dm_device_name(t->md));
 		return -EINVAL;
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h
index 04c6acf7faaa..83e20de264c9 100644
--- a/include/linux/device-mapper.h
+++ b/include/linux/device-mapper.h
@@ -294,6 +294,15 @@  struct target_type {
 #define dm_target_supports_mixed_zoned_model(type) (false)
 #endif
 
+#ifdef CONFIG_BLK_DEV_ZONED
+#define DM_TARGET_EMULATED_ZONES	0x00000400
+#define dm_target_supports_emulated_zones(type) \
+	((type)->features & DM_TARGET_EMULATED_ZONES)
+#else
+#define DM_TARGET_EMULATED_ZONES	0x00000000
+#define dm_target_supports_emulated_zones(type) (false)
+#endif
+
 struct dm_target {
 	struct dm_table *table;
 	struct target_type *type;