All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/7] block zoned cleanups
       [not found] <CGME20230106083318eucas1p1a2ab71a95ab2906b4651538c63a94ae2@eucas1p1.samsung.com>
@ 2023-01-06  8:33   ` Pankaj Raghav
  0 siblings, 0 replies; 58+ messages in thread
From: Pankaj Raghav @ 2023-01-06  8:33 UTC (permalink / raw)
  To: axboe
  Cc: kernel, linux-kernel, hare, bvanassche, snitzer, dm-devel,
	damien.lemoal, linux-nvme, hch, linux-block, gost.dev,
	Pankaj Raghav

Hi Jens,
  It is still unclear whether the support for non-po2 zone size devices
  will be added anytime soon [1]. I have extracted out the cleanup
  patches that doesn't do any functional change but improves the
  readability by adding helpers. This also helps a bit to
  maintain off-tree support as there is an interest to have this feature
  in some companies.

I have retained the reviewed by tags for the commits that did not change
from the main patches I sent before[1].

[1] https://lore.kernel.org/lkml/20220923173618.6899-1-p.raghav@samsung.com/

Luis Chamberlain (1):
  dm-zoned: ensure only power of 2 zone sizes are allowed

Pankaj Raghav (6):
  block: remove superfluous check for request queue in bdev_is_zoned
  block: add a new helper bdev_{is_zone_start, offset_from_zone_start}
  nvmet: introduce bdev_zone_no helper
  zonefs: use bdev_zone_no helper to calculate the zone index
  dm-zone: use generic helpers to calculate offset from zone start
  dm: call dm_zone_endio after the target endio callback for zoned
    devices

 block/blk-core.c             |  2 +-
 block/blk-zoned.c            |  4 ++--
 drivers/md/dm-zone.c         |  8 +++-----
 drivers/md/dm-zoned-target.c |  8 ++++++++
 drivers/md/dm.c              |  8 ++++----
 drivers/nvme/target/zns.c    |  3 +--
 fs/zonefs/super.c            |  8 +++-----
 fs/zonefs/zonefs.h           |  1 -
 include/linux/blkdev.h       | 28 +++++++++++++++++++++++-----
 9 files changed, 45 insertions(+), 25 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [dm-devel] [PATCH 0/7] block zoned cleanups
@ 2023-01-06  8:33   ` Pankaj Raghav
  0 siblings, 0 replies; 58+ messages in thread
From: Pankaj Raghav @ 2023-01-06  8:33 UTC (permalink / raw)
  To: axboe
  Cc: Pankaj Raghav, bvanassche, gost.dev, damien.lemoal, snitzer,
	linux-kernel, linux-nvme, linux-block, kernel, dm-devel, hch

Hi Jens,
  It is still unclear whether the support for non-po2 zone size devices
  will be added anytime soon [1]. I have extracted out the cleanup
  patches that doesn't do any functional change but improves the
  readability by adding helpers. This also helps a bit to
  maintain off-tree support as there is an interest to have this feature
  in some companies.

I have retained the reviewed by tags for the commits that did not change
from the main patches I sent before[1].

[1] https://lore.kernel.org/lkml/20220923173618.6899-1-p.raghav@samsung.com/

Luis Chamberlain (1):
  dm-zoned: ensure only power of 2 zone sizes are allowed

Pankaj Raghav (6):
  block: remove superfluous check for request queue in bdev_is_zoned
  block: add a new helper bdev_{is_zone_start, offset_from_zone_start}
  nvmet: introduce bdev_zone_no helper
  zonefs: use bdev_zone_no helper to calculate the zone index
  dm-zone: use generic helpers to calculate offset from zone start
  dm: call dm_zone_endio after the target endio callback for zoned
    devices

 block/blk-core.c             |  2 +-
 block/blk-zoned.c            |  4 ++--
 drivers/md/dm-zone.c         |  8 +++-----
 drivers/md/dm-zoned-target.c |  8 ++++++++
 drivers/md/dm.c              |  8 ++++----
 drivers/nvme/target/zns.c    |  3 +--
 fs/zonefs/super.c            |  8 +++-----
 fs/zonefs/zonefs.h           |  1 -
 include/linux/blkdev.h       | 28 +++++++++++++++++++++++-----
 9 files changed, 45 insertions(+), 25 deletions(-)

-- 
2.25.1

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 1/7] block: remove superfluous check for request queue in bdev_is_zoned
       [not found]   ` <CGME20230106083319eucas1p1e58f4ab0d3ff59a328a2da2922d76038@eucas1p1.samsung.com>
@ 2023-01-06  8:33       ` Pankaj Raghav
  0 siblings, 0 replies; 58+ messages in thread
From: Pankaj Raghav @ 2023-01-06  8:33 UTC (permalink / raw)
  To: axboe
  Cc: kernel, linux-kernel, hare, bvanassche, snitzer, dm-devel,
	damien.lemoal, linux-nvme, hch, linux-block, gost.dev,
	Pankaj Raghav

Remove the superfluous request queue check in bdev_is_zoned() as the
bdev_get_queue can never return NULL.

Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
---
 include/linux/blkdev.h | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 43d4e073b111..0e40b014c40b 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1283,12 +1283,7 @@ static inline enum blk_zoned_model bdev_zoned_model(struct block_device *bdev)
 
 static inline bool bdev_is_zoned(struct block_device *bdev)
 {
-	struct request_queue *q = bdev_get_queue(bdev);
-
-	if (q)
-		return blk_queue_is_zoned(q);
-
-	return false;
+	return blk_queue_is_zoned(bdev_get_queue(bdev));
 }
 
 static inline bool bdev_op_is_zoned_write(struct block_device *bdev,
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [dm-devel] [PATCH 1/7] block: remove superfluous check for request queue in bdev_is_zoned
@ 2023-01-06  8:33       ` Pankaj Raghav
  0 siblings, 0 replies; 58+ messages in thread
From: Pankaj Raghav @ 2023-01-06  8:33 UTC (permalink / raw)
  To: axboe
  Cc: Pankaj Raghav, bvanassche, gost.dev, damien.lemoal, snitzer,
	linux-kernel, linux-nvme, linux-block, kernel, dm-devel, hch

Remove the superfluous request queue check in bdev_is_zoned() as the
bdev_get_queue can never return NULL.

Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
---
 include/linux/blkdev.h | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 43d4e073b111..0e40b014c40b 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1283,12 +1283,7 @@ static inline enum blk_zoned_model bdev_zoned_model(struct block_device *bdev)
 
 static inline bool bdev_is_zoned(struct block_device *bdev)
 {
-	struct request_queue *q = bdev_get_queue(bdev);
-
-	if (q)
-		return blk_queue_is_zoned(q);
-
-	return false;
+	return blk_queue_is_zoned(bdev_get_queue(bdev));
 }
 
 static inline bool bdev_op_is_zoned_write(struct block_device *bdev,
-- 
2.25.1

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 2/7] block: add a new helper bdev_{is_zone_start, offset_from_zone_start}
       [not found]   ` <CGME20230106083320eucas1p1f8de0c6ecf351738e8f0ee5f3390d94f@eucas1p1.samsung.com>
@ 2023-01-06  8:33       ` Pankaj Raghav
  0 siblings, 0 replies; 58+ messages in thread
From: Pankaj Raghav @ 2023-01-06  8:33 UTC (permalink / raw)
  To: axboe
  Cc: kernel, linux-kernel, hare, bvanassche, snitzer, dm-devel,
	damien.lemoal, linux-nvme, hch, linux-block, gost.dev,
	Pankaj Raghav

Instead of open coding to check for zone start, add a helper to improve
readability and store the logic in one place.

bdev_offset_from_zone_start() will be used later in the series.

Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
---
 block/blk-core.c       |  2 +-
 block/blk-zoned.c      |  4 ++--
 include/linux/blkdev.h | 18 ++++++++++++++++++
 3 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index 9321767470dc..0405b3144e7a 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -573,7 +573,7 @@ static inline blk_status_t blk_check_zone_append(struct request_queue *q,
 		return BLK_STS_NOTSUPP;
 
 	/* The bio sector must point to the start of a sequential zone */
-	if (bio->bi_iter.bi_sector & (bdev_zone_sectors(bio->bi_bdev) - 1) ||
+	if (!bdev_is_zone_start(bio->bi_bdev, bio->bi_iter.bi_sector) ||
 	    !bio_zone_is_seq(bio))
 		return BLK_STS_IOERR;
 
diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index db829401d8d0..614b575be899 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -277,10 +277,10 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_op op,
 		return -EINVAL;
 
 	/* Check alignment (handle eventual smaller last zone) */
-	if (sector & (zone_sectors - 1))
+	if (!bdev_is_zone_start(bdev, sector))
 		return -EINVAL;
 
-	if ((nr_sectors & (zone_sectors - 1)) && end_sector != capacity)
+	if (!bdev_is_zone_start(bdev, nr_sectors) && end_sector != capacity)
 		return -EINVAL;
 
 	/*
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 0e40b014c40b..04b7cbfd7a2a 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -715,6 +715,7 @@ static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector)
 {
 	return 0;
 }
+
 static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
 {
 	return 0;
@@ -1304,6 +1305,23 @@ static inline sector_t bdev_zone_sectors(struct block_device *bdev)
 	return q->limits.chunk_sectors;
 }
 
+static inline sector_t bdev_offset_from_zone_start(struct block_device *bdev,
+						   sector_t sec)
+{
+	if (!bdev_is_zoned(bdev))
+		return 0;
+
+	return sec & (bdev_zone_sectors(bdev) - 1);
+}
+
+static inline bool bdev_is_zone_start(struct block_device *bdev, sector_t sec)
+{
+	if (!bdev_is_zoned(bdev))
+		return false;
+
+	return bdev_offset_from_zone_start(bdev, sec) == 0;
+}
+
 static inline int queue_dma_alignment(const struct request_queue *q)
 {
 	return q ? q->limits.dma_alignment : 511;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [dm-devel] [PATCH 2/7] block: add a new helper bdev_{is_zone_start, offset_from_zone_start}
@ 2023-01-06  8:33       ` Pankaj Raghav
  0 siblings, 0 replies; 58+ messages in thread
From: Pankaj Raghav @ 2023-01-06  8:33 UTC (permalink / raw)
  To: axboe
  Cc: Pankaj Raghav, bvanassche, gost.dev, damien.lemoal, snitzer,
	linux-kernel, linux-nvme, linux-block, kernel, dm-devel, hch

Instead of open coding to check for zone start, add a helper to improve
readability and store the logic in one place.

bdev_offset_from_zone_start() will be used later in the series.

Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
---
 block/blk-core.c       |  2 +-
 block/blk-zoned.c      |  4 ++--
 include/linux/blkdev.h | 18 ++++++++++++++++++
 3 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index 9321767470dc..0405b3144e7a 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -573,7 +573,7 @@ static inline blk_status_t blk_check_zone_append(struct request_queue *q,
 		return BLK_STS_NOTSUPP;
 
 	/* The bio sector must point to the start of a sequential zone */
-	if (bio->bi_iter.bi_sector & (bdev_zone_sectors(bio->bi_bdev) - 1) ||
+	if (!bdev_is_zone_start(bio->bi_bdev, bio->bi_iter.bi_sector) ||
 	    !bio_zone_is_seq(bio))
 		return BLK_STS_IOERR;
 
diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index db829401d8d0..614b575be899 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -277,10 +277,10 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_op op,
 		return -EINVAL;
 
 	/* Check alignment (handle eventual smaller last zone) */
-	if (sector & (zone_sectors - 1))
+	if (!bdev_is_zone_start(bdev, sector))
 		return -EINVAL;
 
-	if ((nr_sectors & (zone_sectors - 1)) && end_sector != capacity)
+	if (!bdev_is_zone_start(bdev, nr_sectors) && end_sector != capacity)
 		return -EINVAL;
 
 	/*
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 0e40b014c40b..04b7cbfd7a2a 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -715,6 +715,7 @@ static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector)
 {
 	return 0;
 }
+
 static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
 {
 	return 0;
@@ -1304,6 +1305,23 @@ static inline sector_t bdev_zone_sectors(struct block_device *bdev)
 	return q->limits.chunk_sectors;
 }
 
+static inline sector_t bdev_offset_from_zone_start(struct block_device *bdev,
+						   sector_t sec)
+{
+	if (!bdev_is_zoned(bdev))
+		return 0;
+
+	return sec & (bdev_zone_sectors(bdev) - 1);
+}
+
+static inline bool bdev_is_zone_start(struct block_device *bdev, sector_t sec)
+{
+	if (!bdev_is_zoned(bdev))
+		return false;
+
+	return bdev_offset_from_zone_start(bdev, sec) == 0;
+}
+
 static inline int queue_dma_alignment(const struct request_queue *q)
 {
 	return q ? q->limits.dma_alignment : 511;
-- 
2.25.1

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 3/7] nvmet: introduce bdev_zone_no helper
       [not found]   ` <CGME20230106083320eucas1p1d23de4ad21d0a7aecb74c549ebc7757c@eucas1p1.samsung.com>
@ 2023-01-06  8:33       ` Pankaj Raghav
  0 siblings, 0 replies; 58+ messages in thread
From: Pankaj Raghav @ 2023-01-06  8:33 UTC (permalink / raw)
  To: axboe
  Cc: kernel, linux-kernel, hare, bvanassche, snitzer, dm-devel,
	damien.lemoal, linux-nvme, hch, linux-block, gost.dev,
	Pankaj Raghav

A generic bdev_zone_no() helper is added to calculate zone number for a
given sector in a block device. This helper internally uses disk_zone_no()
to find the zone number.

Use the helper bdev_zone_no() to calculate nr of zones. This let's us
make modifications to the math if needed in one place.

Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
---
 drivers/nvme/target/zns.c | 3 +--
 include/linux/blkdev.h    | 5 +++++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/target/zns.c b/drivers/nvme/target/zns.c
index 1254cf57e008..7e4292d88016 100644
--- a/drivers/nvme/target/zns.c
+++ b/drivers/nvme/target/zns.c
@@ -254,8 +254,7 @@ static unsigned long nvmet_req_nr_zones_from_slba(struct nvmet_req *req)
 {
 	unsigned int sect = nvmet_lba_to_sect(req->ns, req->cmd->zmr.slba);
 
-	return bdev_nr_zones(req->ns->bdev) -
-		(sect >> ilog2(bdev_zone_sectors(req->ns->bdev)));
+	return bdev_nr_zones(req->ns->bdev) - bdev_zone_no(req->ns->bdev, sect);
 }
 
 static unsigned long get_nr_zones_from_buf(struct nvmet_req *req, u32 bufsize)
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 04b7cbfd7a2a..669cf4fed1ad 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1287,6 +1287,11 @@ static inline bool bdev_is_zoned(struct block_device *bdev)
 	return blk_queue_is_zoned(bdev_get_queue(bdev));
 }
 
+static inline unsigned int bdev_zone_no(struct block_device *bdev, sector_t sec)
+{
+	return disk_zone_no(bdev->bd_disk, sec);
+}
+
 static inline bool bdev_op_is_zoned_write(struct block_device *bdev,
 					  blk_opf_t op)
 {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [dm-devel] [PATCH 3/7] nvmet: introduce bdev_zone_no helper
@ 2023-01-06  8:33       ` Pankaj Raghav
  0 siblings, 0 replies; 58+ messages in thread
From: Pankaj Raghav @ 2023-01-06  8:33 UTC (permalink / raw)
  To: axboe
  Cc: Pankaj Raghav, bvanassche, gost.dev, damien.lemoal, snitzer,
	linux-kernel, linux-nvme, linux-block, kernel, dm-devel, hch

A generic bdev_zone_no() helper is added to calculate zone number for a
given sector in a block device. This helper internally uses disk_zone_no()
to find the zone number.

Use the helper bdev_zone_no() to calculate nr of zones. This let's us
make modifications to the math if needed in one place.

Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
---
 drivers/nvme/target/zns.c | 3 +--
 include/linux/blkdev.h    | 5 +++++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/target/zns.c b/drivers/nvme/target/zns.c
index 1254cf57e008..7e4292d88016 100644
--- a/drivers/nvme/target/zns.c
+++ b/drivers/nvme/target/zns.c
@@ -254,8 +254,7 @@ static unsigned long nvmet_req_nr_zones_from_slba(struct nvmet_req *req)
 {
 	unsigned int sect = nvmet_lba_to_sect(req->ns, req->cmd->zmr.slba);
 
-	return bdev_nr_zones(req->ns->bdev) -
-		(sect >> ilog2(bdev_zone_sectors(req->ns->bdev)));
+	return bdev_nr_zones(req->ns->bdev) - bdev_zone_no(req->ns->bdev, sect);
 }
 
 static unsigned long get_nr_zones_from_buf(struct nvmet_req *req, u32 bufsize)
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 04b7cbfd7a2a..669cf4fed1ad 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1287,6 +1287,11 @@ static inline bool bdev_is_zoned(struct block_device *bdev)
 	return blk_queue_is_zoned(bdev_get_queue(bdev));
 }
 
+static inline unsigned int bdev_zone_no(struct block_device *bdev, sector_t sec)
+{
+	return disk_zone_no(bdev->bd_disk, sec);
+}
+
 static inline bool bdev_op_is_zoned_write(struct block_device *bdev,
 					  blk_opf_t op)
 {
-- 
2.25.1

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 4/7] zonefs: use bdev_zone_no helper to calculate the zone index
       [not found]   ` <CGME20230106083321eucas1p15e9087bcc62bc6a4f5a61467e1c98698@eucas1p1.samsung.com>
@ 2023-01-06  8:33       ` Pankaj Raghav
  0 siblings, 0 replies; 58+ messages in thread
From: Pankaj Raghav @ 2023-01-06  8:33 UTC (permalink / raw)
  To: axboe
  Cc: kernel, linux-kernel, hare, bvanassche, snitzer, dm-devel,
	damien.lemoal, linux-nvme, hch, linux-block, gost.dev,
	Pankaj Raghav

Use bdev_zone_no() helper instead of opencoding the logic to find the
zone index.

Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
---
 fs/zonefs/super.c  | 8 +++-----
 fs/zonefs/zonefs.h | 1 -
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
index 2c53fbb8d918..c2ddc62e99dc 100644
--- a/fs/zonefs/super.c
+++ b/fs/zonefs/super.c
@@ -487,7 +487,6 @@ static void __zonefs_io_error(struct inode *inode, bool write)
 {
 	struct zonefs_inode_info *zi = ZONEFS_I(inode);
 	struct super_block *sb = inode->i_sb;
-	struct zonefs_sb_info *sbi = ZONEFS_SB(sb);
 	unsigned int noio_flag;
 	unsigned int nr_zones = 1;
 	struct zonefs_ioerr_data err = {
@@ -502,8 +501,8 @@ static void __zonefs_io_error(struct inode *inode, bool write)
 	 * size is always larger than the device zone size.
 	 */
 	if (zi->i_zone_size > bdev_zone_sectors(sb->s_bdev))
-		nr_zones = zi->i_zone_size >>
-			(sbi->s_zone_sectors_shift + SECTOR_SHIFT);
+		nr_zones =
+			bdev_zone_no(sb->s_bdev, zi->i_zone_size >> SECTOR_SHIFT);
 
 	/*
 	 * Memory allocations in blkdev_report_zones() can trigger a memory
@@ -1420,7 +1419,7 @@ static int zonefs_init_file_inode(struct inode *inode, struct blk_zone *zone,
 	struct zonefs_inode_info *zi = ZONEFS_I(inode);
 	int ret = 0;
 
-	inode->i_ino = zone->start >> sbi->s_zone_sectors_shift;
+	inode->i_ino = bdev_zone_no(sb->s_bdev, zone->start);
 	inode->i_mode = S_IFREG | sbi->s_perm;
 
 	zi->i_ztype = type;
@@ -1804,7 +1803,6 @@ static int zonefs_fill_super(struct super_block *sb, void *data, int silent)
 	 * interface constraints.
 	 */
 	sb_set_blocksize(sb, bdev_zone_write_granularity(sb->s_bdev));
-	sbi->s_zone_sectors_shift = ilog2(bdev_zone_sectors(sb->s_bdev));
 	sbi->s_uid = GLOBAL_ROOT_UID;
 	sbi->s_gid = GLOBAL_ROOT_GID;
 	sbi->s_perm = 0640;
diff --git a/fs/zonefs/zonefs.h b/fs/zonefs/zonefs.h
index 1dbe78119ff1..703bc4505b29 100644
--- a/fs/zonefs/zonefs.h
+++ b/fs/zonefs/zonefs.h
@@ -179,7 +179,6 @@ struct zonefs_sb_info {
 	kgid_t			s_gid;
 	umode_t			s_perm;
 	uuid_t			s_uuid;
-	unsigned int		s_zone_sectors_shift;
 
 	unsigned int		s_nr_files[ZONEFS_ZTYPE_MAX];
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [dm-devel] [PATCH 4/7] zonefs: use bdev_zone_no helper to calculate the zone index
@ 2023-01-06  8:33       ` Pankaj Raghav
  0 siblings, 0 replies; 58+ messages in thread
From: Pankaj Raghav @ 2023-01-06  8:33 UTC (permalink / raw)
  To: axboe
  Cc: Pankaj Raghav, bvanassche, gost.dev, damien.lemoal, snitzer,
	linux-kernel, linux-nvme, linux-block, kernel, dm-devel, hch

Use bdev_zone_no() helper instead of opencoding the logic to find the
zone index.

Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
---
 fs/zonefs/super.c  | 8 +++-----
 fs/zonefs/zonefs.h | 1 -
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
index 2c53fbb8d918..c2ddc62e99dc 100644
--- a/fs/zonefs/super.c
+++ b/fs/zonefs/super.c
@@ -487,7 +487,6 @@ static void __zonefs_io_error(struct inode *inode, bool write)
 {
 	struct zonefs_inode_info *zi = ZONEFS_I(inode);
 	struct super_block *sb = inode->i_sb;
-	struct zonefs_sb_info *sbi = ZONEFS_SB(sb);
 	unsigned int noio_flag;
 	unsigned int nr_zones = 1;
 	struct zonefs_ioerr_data err = {
@@ -502,8 +501,8 @@ static void __zonefs_io_error(struct inode *inode, bool write)
 	 * size is always larger than the device zone size.
 	 */
 	if (zi->i_zone_size > bdev_zone_sectors(sb->s_bdev))
-		nr_zones = zi->i_zone_size >>
-			(sbi->s_zone_sectors_shift + SECTOR_SHIFT);
+		nr_zones =
+			bdev_zone_no(sb->s_bdev, zi->i_zone_size >> SECTOR_SHIFT);
 
 	/*
 	 * Memory allocations in blkdev_report_zones() can trigger a memory
@@ -1420,7 +1419,7 @@ static int zonefs_init_file_inode(struct inode *inode, struct blk_zone *zone,
 	struct zonefs_inode_info *zi = ZONEFS_I(inode);
 	int ret = 0;
 
-	inode->i_ino = zone->start >> sbi->s_zone_sectors_shift;
+	inode->i_ino = bdev_zone_no(sb->s_bdev, zone->start);
 	inode->i_mode = S_IFREG | sbi->s_perm;
 
 	zi->i_ztype = type;
@@ -1804,7 +1803,6 @@ static int zonefs_fill_super(struct super_block *sb, void *data, int silent)
 	 * interface constraints.
 	 */
 	sb_set_blocksize(sb, bdev_zone_write_granularity(sb->s_bdev));
-	sbi->s_zone_sectors_shift = ilog2(bdev_zone_sectors(sb->s_bdev));
 	sbi->s_uid = GLOBAL_ROOT_UID;
 	sbi->s_gid = GLOBAL_ROOT_GID;
 	sbi->s_perm = 0640;
diff --git a/fs/zonefs/zonefs.h b/fs/zonefs/zonefs.h
index 1dbe78119ff1..703bc4505b29 100644
--- a/fs/zonefs/zonefs.h
+++ b/fs/zonefs/zonefs.h
@@ -179,7 +179,6 @@ struct zonefs_sb_info {
 	kgid_t			s_gid;
 	umode_t			s_perm;
 	uuid_t			s_uuid;
-	unsigned int		s_zone_sectors_shift;
 
 	unsigned int		s_nr_files[ZONEFS_ZTYPE_MAX];
 
-- 
2.25.1

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 5/7] dm-zoned: ensure only power of 2 zone sizes are allowed
       [not found]   ` <CGME20230106083322eucas1p2414f1f7f121fbbd7a0e5e1b1b622f5c0@eucas1p2.samsung.com>
@ 2023-01-06  8:33       ` Pankaj Raghav
  0 siblings, 0 replies; 58+ messages in thread
From: Pankaj Raghav @ 2023-01-06  8:33 UTC (permalink / raw)
  To: axboe
  Cc: kernel, linux-kernel, hare, bvanassche, snitzer, dm-devel,
	damien.lemoal, linux-nvme, hch, linux-block, gost.dev,
	Luis Chamberlain, Johannes Thumshirn, Pankaj Raghav

From: Luis Chamberlain <mcgrof@kernel.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@suse.de>
Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Mike Snitzer <snitzer@kernel.org>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Signed-off-by: Pankaj Raghav <p.raghav@samsung.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


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [dm-devel] [PATCH 5/7] dm-zoned: ensure only power of 2 zone sizes are allowed
@ 2023-01-06  8:33       ` Pankaj Raghav
  0 siblings, 0 replies; 58+ messages in thread
From: Pankaj Raghav @ 2023-01-06  8:33 UTC (permalink / raw)
  To: axboe
  Cc: Pankaj Raghav, bvanassche, gost.dev, damien.lemoal, snitzer,
	linux-kernel, linux-nvme, linux-block, kernel, dm-devel,
	Johannes Thumshirn, hch, Luis Chamberlain

From: Luis Chamberlain <mcgrof@kernel.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@suse.de>
Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Mike Snitzer <snitzer@kernel.org>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Signed-off-by: Pankaj Raghav <p.raghav@samsung.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

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 6/7] dm-zone: use generic helpers to calculate offset from zone start
       [not found]   ` <CGME20230106083322eucas1p1ce3ca7b02ca87bb2be8543291e223338@eucas1p1.samsung.com>
@ 2023-01-06  8:33       ` Pankaj Raghav
  0 siblings, 0 replies; 58+ messages in thread
From: Pankaj Raghav @ 2023-01-06  8:33 UTC (permalink / raw)
  To: axboe
  Cc: kernel, linux-kernel, hare, bvanassche, snitzer, dm-devel,
	damien.lemoal, linux-nvme, hch, linux-block, gost.dev,
	Pankaj Raghav, Luis Chamberlain, Johannes Thumshirn

Use the bdev_offset_from_zone_start() helper function to calculate
the offset from zone start instead of open coding.

Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Mike Snitzer <snitzer@kernel.org>
---
 drivers/md/dm-zone.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c
index 3dafc0e8b7a9..ac6fc1293d41 100644
--- a/drivers/md/dm-zone.c
+++ b/drivers/md/dm-zone.c
@@ -390,7 +390,8 @@ static bool dm_zone_map_bio_begin(struct mapped_device *md,
 	case REQ_OP_WRITE_ZEROES:
 	case REQ_OP_WRITE:
 		/* Writes must be aligned to the zone write pointer */
-		if ((clone->bi_iter.bi_sector & (zsectors - 1)) != zwp_offset)
+		if (bdev_offset_from_zone_start(md->disk->part0,
+						clone->bi_iter.bi_sector) != zwp_offset)
 			return false;
 		break;
 	case REQ_OP_ZONE_APPEND:
@@ -602,11 +603,8 @@ void dm_zone_endio(struct dm_io *io, struct bio *clone)
 		 */
 		if (clone->bi_status == BLK_STS_OK &&
 		    bio_op(clone) == REQ_OP_ZONE_APPEND) {
-			sector_t mask =
-				(sector_t)bdev_zone_sectors(disk->part0) - 1;
-
 			orig_bio->bi_iter.bi_sector +=
-				clone->bi_iter.bi_sector & mask;
+				bdev_offset_from_zone_start(disk->part0, clone->bi_iter.bi_sector);
 		}
 
 		return;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [dm-devel] [PATCH 6/7] dm-zone: use generic helpers to calculate offset from zone start
@ 2023-01-06  8:33       ` Pankaj Raghav
  0 siblings, 0 replies; 58+ messages in thread
From: Pankaj Raghav @ 2023-01-06  8:33 UTC (permalink / raw)
  To: axboe
  Cc: Pankaj Raghav, bvanassche, gost.dev, damien.lemoal, snitzer,
	linux-kernel, linux-nvme, linux-block, kernel, dm-devel,
	Johannes Thumshirn, hch, Luis Chamberlain

Use the bdev_offset_from_zone_start() helper function to calculate
the offset from zone start instead of open coding.

Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Mike Snitzer <snitzer@kernel.org>
---
 drivers/md/dm-zone.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c
index 3dafc0e8b7a9..ac6fc1293d41 100644
--- a/drivers/md/dm-zone.c
+++ b/drivers/md/dm-zone.c
@@ -390,7 +390,8 @@ static bool dm_zone_map_bio_begin(struct mapped_device *md,
 	case REQ_OP_WRITE_ZEROES:
 	case REQ_OP_WRITE:
 		/* Writes must be aligned to the zone write pointer */
-		if ((clone->bi_iter.bi_sector & (zsectors - 1)) != zwp_offset)
+		if (bdev_offset_from_zone_start(md->disk->part0,
+						clone->bi_iter.bi_sector) != zwp_offset)
 			return false;
 		break;
 	case REQ_OP_ZONE_APPEND:
@@ -602,11 +603,8 @@ void dm_zone_endio(struct dm_io *io, struct bio *clone)
 		 */
 		if (clone->bi_status == BLK_STS_OK &&
 		    bio_op(clone) == REQ_OP_ZONE_APPEND) {
-			sector_t mask =
-				(sector_t)bdev_zone_sectors(disk->part0) - 1;
-
 			orig_bio->bi_iter.bi_sector +=
-				clone->bi_iter.bi_sector & mask;
+				bdev_offset_from_zone_start(disk->part0, clone->bi_iter.bi_sector);
 		}
 
 		return;
-- 
2.25.1

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 7/7] dm: call dm_zone_endio after the target endio callback for zoned devices
       [not found]   ` <CGME20230106083323eucas1p2f0f6d5d5c1c3713be35b841157ae463e@eucas1p2.samsung.com>
@ 2023-01-06  8:33       ` Pankaj Raghav
  0 siblings, 0 replies; 58+ messages in thread
From: Pankaj Raghav @ 2023-01-06  8:33 UTC (permalink / raw)
  To: axboe
  Cc: kernel, linux-kernel, hare, bvanassche, snitzer, dm-devel,
	damien.lemoal, linux-nvme, hch, linux-block, gost.dev,
	Pankaj Raghav

dm_zone_endio() updates the bi_sector of orig bio for zoned devices that
uses either native append or append emulation, and it is called before the
endio of the target. But target endio can still update the clone bio
after dm_zone_endio is called, thereby, the orig bio does not contain
the updated information anymore.

Currently, this is not a problem as the targets that support zoned devices
such as dm-zoned, dm-linear, and dm-crypt do not have an endio function,
and even if they do (such as dm-flakey), they don't modify the
bio->bi_iter.bi_sector of the cloned bio that is used to update the
orig_bio's bi_sector in dm_zone_endio function.

Call dm_zone_endio for zoned devices after calling the target's endio
function.

Reviewed-by: Mike Snitzer <snitzer@kernel.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
---
 drivers/md/dm.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index b424a6ee27ba..fdef74fe8bd1 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1109,10 +1109,6 @@ static void clone_endio(struct bio *bio)
 			disable_write_zeroes(md);
 	}
 
-	if (static_branch_unlikely(&zoned_enabled) &&
-	    unlikely(bdev_is_zoned(bio->bi_bdev)))
-		dm_zone_endio(io, bio);
-
 	if (endio) {
 		int r = endio(ti, bio, &error);
 		switch (r) {
@@ -1141,6 +1137,10 @@ static void clone_endio(struct bio *bio)
 		}
 	}
 
+	if (static_branch_unlikely(&zoned_enabled) &&
+	    unlikely(bdev_is_zoned(bio->bi_bdev)))
+		dm_zone_endio(io, bio);
+
 	if (static_branch_unlikely(&swap_bios_enabled) &&
 	    unlikely(swap_bios_limit(ti, bio)))
 		up(&md->swap_bios_semaphore);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [dm-devel] [PATCH 7/7] dm: call dm_zone_endio after the target endio callback for zoned devices
@ 2023-01-06  8:33       ` Pankaj Raghav
  0 siblings, 0 replies; 58+ messages in thread
From: Pankaj Raghav @ 2023-01-06  8:33 UTC (permalink / raw)
  To: axboe
  Cc: Pankaj Raghav, bvanassche, gost.dev, damien.lemoal, snitzer,
	linux-kernel, linux-nvme, linux-block, kernel, dm-devel, hch

dm_zone_endio() updates the bi_sector of orig bio for zoned devices that
uses either native append or append emulation, and it is called before the
endio of the target. But target endio can still update the clone bio
after dm_zone_endio is called, thereby, the orig bio does not contain
the updated information anymore.

Currently, this is not a problem as the targets that support zoned devices
such as dm-zoned, dm-linear, and dm-crypt do not have an endio function,
and even if they do (such as dm-flakey), they don't modify the
bio->bi_iter.bi_sector of the cloned bio that is used to update the
orig_bio's bi_sector in dm_zone_endio function.

Call dm_zone_endio for zoned devices after calling the target's endio
function.

Reviewed-by: Mike Snitzer <snitzer@kernel.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
---
 drivers/md/dm.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index b424a6ee27ba..fdef74fe8bd1 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1109,10 +1109,6 @@ static void clone_endio(struct bio *bio)
 			disable_write_zeroes(md);
 	}
 
-	if (static_branch_unlikely(&zoned_enabled) &&
-	    unlikely(bdev_is_zoned(bio->bi_bdev)))
-		dm_zone_endio(io, bio);
-
 	if (endio) {
 		int r = endio(ti, bio, &error);
 		switch (r) {
@@ -1141,6 +1137,10 @@ static void clone_endio(struct bio *bio)
 		}
 	}
 
+	if (static_branch_unlikely(&zoned_enabled) &&
+	    unlikely(bdev_is_zoned(bio->bi_bdev)))
+		dm_zone_endio(io, bio);
+
 	if (static_branch_unlikely(&swap_bios_enabled) &&
 	    unlikely(swap_bios_limit(ti, bio)))
 		up(&md->swap_bios_semaphore);
-- 
2.25.1

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* Re: [PATCH 2/7] block: add a new helper bdev_{is_zone_start, offset_from_zone_start}
  2023-01-06  8:33       ` [dm-devel] " Pankaj Raghav
@ 2023-01-06 11:00         ` Damien Le Moal
  -1 siblings, 0 replies; 58+ messages in thread
From: Damien Le Moal @ 2023-01-06 11:00 UTC (permalink / raw)
  To: Pankaj Raghav, axboe
  Cc: kernel, linux-kernel, hare, bvanassche, snitzer, dm-devel,
	linux-nvme, hch, linux-block, gost.dev

On 1/6/23 17:33, Pankaj Raghav wrote:
> Instead of open coding to check for zone start, add a helper to improve
> readability and store the logic in one place.
> 
> bdev_offset_from_zone_start() will be used later in the series.
> 
> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
> ---
>  block/blk-core.c       |  2 +-
>  block/blk-zoned.c      |  4 ++--
>  include/linux/blkdev.h | 18 ++++++++++++++++++
>  3 files changed, 21 insertions(+), 3 deletions(-)
> 
> diff --git a/block/blk-core.c b/block/blk-core.c
> index 9321767470dc..0405b3144e7a 100644
> --- a/block/blk-core.c
> +++ b/block/blk-core.c
> @@ -573,7 +573,7 @@ static inline blk_status_t blk_check_zone_append(struct request_queue *q,
>  		return BLK_STS_NOTSUPP;
>  
>  	/* The bio sector must point to the start of a sequential zone */
> -	if (bio->bi_iter.bi_sector & (bdev_zone_sectors(bio->bi_bdev) - 1) ||
> +	if (!bdev_is_zone_start(bio->bi_bdev, bio->bi_iter.bi_sector) ||
>  	    !bio_zone_is_seq(bio))
>  		return BLK_STS_IOERR;
>  
> diff --git a/block/blk-zoned.c b/block/blk-zoned.c
> index db829401d8d0..614b575be899 100644
> --- a/block/blk-zoned.c
> +++ b/block/blk-zoned.c
> @@ -277,10 +277,10 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_op op,
>  		return -EINVAL;
>  
>  	/* Check alignment (handle eventual smaller last zone) */
> -	if (sector & (zone_sectors - 1))
> +	if (!bdev_is_zone_start(bdev, sector))
>  		return -EINVAL;
>  
> -	if ((nr_sectors & (zone_sectors - 1)) && end_sector != capacity)
> +	if (!bdev_is_zone_start(bdev, nr_sectors) && end_sector != capacity)
>  		return -EINVAL;
>  
>  	/*
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index 0e40b014c40b..04b7cbfd7a2a 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -715,6 +715,7 @@ static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector)
>  {
>  	return 0;
>  }
> +

whiteline change

>  static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
>  {
>  	return 0;
> @@ -1304,6 +1305,23 @@ static inline sector_t bdev_zone_sectors(struct block_device *bdev)
>  	return q->limits.chunk_sectors;
>  }
>  
> +static inline sector_t bdev_offset_from_zone_start(struct block_device *bdev,
> +						   sector_t sec)
> +{
> +	if (!bdev_is_zoned(bdev))

this helper should never be called outside of code supporting zones. So
why this check ?

> +		return 0;
> +
> +	return sec & (bdev_zone_sectors(bdev) - 1);
> +}
> +
> +static inline bool bdev_is_zone_start(struct block_device *bdev, sector_t sec)
> +{
> +	if (!bdev_is_zoned(bdev))
> +		return false;

Same here.

> +
> +	return bdev_offset_from_zone_start(bdev, sec) == 0;
> +}
> +
>  static inline int queue_dma_alignment(const struct request_queue *q)
>  {
>  	return q ? q->limits.dma_alignment : 511;

-- 
Damien Le Moal
Western Digital Research


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [dm-devel] [PATCH 2/7] block: add a new helper bdev_{is_zone_start, offset_from_zone_start}
@ 2023-01-06 11:00         ` Damien Le Moal
  0 siblings, 0 replies; 58+ messages in thread
From: Damien Le Moal @ 2023-01-06 11:00 UTC (permalink / raw)
  To: Pankaj Raghav, axboe
  Cc: bvanassche, gost.dev, snitzer, linux-kernel, linux-nvme,
	linux-block, kernel, dm-devel, hch

On 1/6/23 17:33, Pankaj Raghav wrote:
> Instead of open coding to check for zone start, add a helper to improve
> readability and store the logic in one place.
> 
> bdev_offset_from_zone_start() will be used later in the series.
> 
> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
> ---
>  block/blk-core.c       |  2 +-
>  block/blk-zoned.c      |  4 ++--
>  include/linux/blkdev.h | 18 ++++++++++++++++++
>  3 files changed, 21 insertions(+), 3 deletions(-)
> 
> diff --git a/block/blk-core.c b/block/blk-core.c
> index 9321767470dc..0405b3144e7a 100644
> --- a/block/blk-core.c
> +++ b/block/blk-core.c
> @@ -573,7 +573,7 @@ static inline blk_status_t blk_check_zone_append(struct request_queue *q,
>  		return BLK_STS_NOTSUPP;
>  
>  	/* The bio sector must point to the start of a sequential zone */
> -	if (bio->bi_iter.bi_sector & (bdev_zone_sectors(bio->bi_bdev) - 1) ||
> +	if (!bdev_is_zone_start(bio->bi_bdev, bio->bi_iter.bi_sector) ||
>  	    !bio_zone_is_seq(bio))
>  		return BLK_STS_IOERR;
>  
> diff --git a/block/blk-zoned.c b/block/blk-zoned.c
> index db829401d8d0..614b575be899 100644
> --- a/block/blk-zoned.c
> +++ b/block/blk-zoned.c
> @@ -277,10 +277,10 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_op op,
>  		return -EINVAL;
>  
>  	/* Check alignment (handle eventual smaller last zone) */
> -	if (sector & (zone_sectors - 1))
> +	if (!bdev_is_zone_start(bdev, sector))
>  		return -EINVAL;
>  
> -	if ((nr_sectors & (zone_sectors - 1)) && end_sector != capacity)
> +	if (!bdev_is_zone_start(bdev, nr_sectors) && end_sector != capacity)
>  		return -EINVAL;
>  
>  	/*
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index 0e40b014c40b..04b7cbfd7a2a 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -715,6 +715,7 @@ static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector)
>  {
>  	return 0;
>  }
> +

whiteline change

>  static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
>  {
>  	return 0;
> @@ -1304,6 +1305,23 @@ static inline sector_t bdev_zone_sectors(struct block_device *bdev)
>  	return q->limits.chunk_sectors;
>  }
>  
> +static inline sector_t bdev_offset_from_zone_start(struct block_device *bdev,
> +						   sector_t sec)
> +{
> +	if (!bdev_is_zoned(bdev))

this helper should never be called outside of code supporting zones. So
why this check ?

> +		return 0;
> +
> +	return sec & (bdev_zone_sectors(bdev) - 1);
> +}
> +
> +static inline bool bdev_is_zone_start(struct block_device *bdev, sector_t sec)
> +{
> +	if (!bdev_is_zoned(bdev))
> +		return false;

Same here.

> +
> +	return bdev_offset_from_zone_start(bdev, sec) == 0;
> +}
> +
>  static inline int queue_dma_alignment(const struct request_queue *q)
>  {
>  	return q ? q->limits.dma_alignment : 511;

-- 
Damien Le Moal
Western Digital Research

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 1/7] block: remove superfluous check for request queue in bdev_is_zoned
  2023-01-06  8:33       ` [dm-devel] " Pankaj Raghav
@ 2023-01-06 11:01         ` Damien Le Moal
  -1 siblings, 0 replies; 58+ messages in thread
From: Damien Le Moal @ 2023-01-06 11:01 UTC (permalink / raw)
  To: Pankaj Raghav, axboe
  Cc: kernel, linux-kernel, hare, bvanassche, snitzer, dm-devel,
	linux-nvme, hch, linux-block, gost.dev

On 1/6/23 17:33, Pankaj Raghav wrote:
> Remove the superfluous request queue check in bdev_is_zoned() as the
> bdev_get_queue can never return NULL.
> 
> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
> ---
>  include/linux/blkdev.h | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index 43d4e073b111..0e40b014c40b 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -1283,12 +1283,7 @@ static inline enum blk_zoned_model bdev_zoned_model(struct block_device *bdev)
>  
>  static inline bool bdev_is_zoned(struct block_device *bdev)
>  {
> -	struct request_queue *q = bdev_get_queue(bdev);
> -
> -	if (q)
> -		return blk_queue_is_zoned(q);
> -
> -	return false;
> +	return blk_queue_is_zoned(bdev_get_queue(bdev));
>  }
>  
>  static inline bool bdev_op_is_zoned_write(struct block_device *bdev,

Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>

-- 
Damien Le Moal
Western Digital Research


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [dm-devel] [PATCH 1/7] block: remove superfluous check for request queue in bdev_is_zoned
@ 2023-01-06 11:01         ` Damien Le Moal
  0 siblings, 0 replies; 58+ messages in thread
From: Damien Le Moal @ 2023-01-06 11:01 UTC (permalink / raw)
  To: Pankaj Raghav, axboe
  Cc: bvanassche, gost.dev, snitzer, linux-kernel, linux-nvme,
	linux-block, kernel, dm-devel, hch

On 1/6/23 17:33, Pankaj Raghav wrote:
> Remove the superfluous request queue check in bdev_is_zoned() as the
> bdev_get_queue can never return NULL.
> 
> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
> ---
>  include/linux/blkdev.h | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index 43d4e073b111..0e40b014c40b 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -1283,12 +1283,7 @@ static inline enum blk_zoned_model bdev_zoned_model(struct block_device *bdev)
>  
>  static inline bool bdev_is_zoned(struct block_device *bdev)
>  {
> -	struct request_queue *q = bdev_get_queue(bdev);
> -
> -	if (q)
> -		return blk_queue_is_zoned(q);
> -
> -	return false;
> +	return blk_queue_is_zoned(bdev_get_queue(bdev));
>  }
>  
>  static inline bool bdev_op_is_zoned_write(struct block_device *bdev,

Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>

-- 
Damien Le Moal
Western Digital Research

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 3/7] nvmet: introduce bdev_zone_no helper
  2023-01-06  8:33       ` [dm-devel] " Pankaj Raghav
@ 2023-01-06 11:02         ` Damien Le Moal
  -1 siblings, 0 replies; 58+ messages in thread
From: Damien Le Moal @ 2023-01-06 11:02 UTC (permalink / raw)
  To: Pankaj Raghav, axboe
  Cc: kernel, linux-kernel, hare, bvanassche, snitzer, dm-devel,
	linux-nvme, hch, linux-block, gost.dev

On 1/6/23 17:33, Pankaj Raghav wrote:
> A generic bdev_zone_no() helper is added to calculate zone number for a
> given sector in a block device. This helper internally uses disk_zone_no()
> to find the zone number.
> 
> Use the helper bdev_zone_no() to calculate nr of zones. This let's us
> make modifications to the math if needed in one place.
> 
> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>

Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>

-- 
Damien Le Moal
Western Digital Research


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [dm-devel] [PATCH 3/7] nvmet: introduce bdev_zone_no helper
@ 2023-01-06 11:02         ` Damien Le Moal
  0 siblings, 0 replies; 58+ messages in thread
From: Damien Le Moal @ 2023-01-06 11:02 UTC (permalink / raw)
  To: Pankaj Raghav, axboe
  Cc: bvanassche, gost.dev, snitzer, linux-kernel, linux-nvme,
	linux-block, kernel, dm-devel, hch

On 1/6/23 17:33, Pankaj Raghav wrote:
> A generic bdev_zone_no() helper is added to calculate zone number for a
> given sector in a block device. This helper internally uses disk_zone_no()
> to find the zone number.
> 
> Use the helper bdev_zone_no() to calculate nr of zones. This let's us
> make modifications to the math if needed in one place.
> 
> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>

Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>

-- 
Damien Le Moal
Western Digital Research

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 4/7] zonefs: use bdev_zone_no helper to calculate the zone index
  2023-01-06  8:33       ` [dm-devel] " Pankaj Raghav
@ 2023-01-06 11:05         ` Damien Le Moal
  -1 siblings, 0 replies; 58+ messages in thread
From: Damien Le Moal @ 2023-01-06 11:05 UTC (permalink / raw)
  To: Pankaj Raghav, axboe
  Cc: kernel, linux-kernel, hare, bvanassche, snitzer, dm-devel,
	linux-nvme, hch, linux-block, gost.dev

On 1/6/23 17:33, Pankaj Raghav wrote:
> Use bdev_zone_no() helper instead of opencoding the logic to find the
> zone index.
> 
> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
> ---
>  fs/zonefs/super.c  | 8 +++-----
>  fs/zonefs/zonefs.h | 1 -
>  2 files changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
> index 2c53fbb8d918..c2ddc62e99dc 100644
> --- a/fs/zonefs/super.c
> +++ b/fs/zonefs/super.c
> @@ -487,7 +487,6 @@ static void __zonefs_io_error(struct inode *inode, bool write)
>  {
>  	struct zonefs_inode_info *zi = ZONEFS_I(inode);
>  	struct super_block *sb = inode->i_sb;
> -	struct zonefs_sb_info *sbi = ZONEFS_SB(sb);
>  	unsigned int noio_flag;
>  	unsigned int nr_zones = 1;
>  	struct zonefs_ioerr_data err = {
> @@ -502,8 +501,8 @@ static void __zonefs_io_error(struct inode *inode, bool write)
>  	 * size is always larger than the device zone size.
>  	 */
>  	if (zi->i_zone_size > bdev_zone_sectors(sb->s_bdev))
> -		nr_zones = zi->i_zone_size >>
> -			(sbi->s_zone_sectors_shift + SECTOR_SHIFT);
> +		nr_zones =
> +			bdev_zone_no(sb->s_bdev, zi->i_zone_size >> SECTOR_SHIFT);

This is a number of zones, not a zone number. So this at least needs a
comment to make clear. Otherwise, I find this confusing.

I would also prefer you hold on this patch. I am about to post a big
series reworking many things in zonefs. That will conflict.

>  
>  	/*
>  	 * Memory allocations in blkdev_report_zones() can trigger a memory
> @@ -1420,7 +1419,7 @@ static int zonefs_init_file_inode(struct inode *inode, struct blk_zone *zone,
>  	struct zonefs_inode_info *zi = ZONEFS_I(inode);
>  	int ret = 0;
>  
> -	inode->i_ino = zone->start >> sbi->s_zone_sectors_shift;
> +	inode->i_ino = bdev_zone_no(sb->s_bdev, zone->start);
>  	inode->i_mode = S_IFREG | sbi->s_perm;
>  
>  	zi->i_ztype = type;
> @@ -1804,7 +1803,6 @@ static int zonefs_fill_super(struct super_block *sb, void *data, int silent)
>  	 * interface constraints.
>  	 */
>  	sb_set_blocksize(sb, bdev_zone_write_granularity(sb->s_bdev));
> -	sbi->s_zone_sectors_shift = ilog2(bdev_zone_sectors(sb->s_bdev));
>  	sbi->s_uid = GLOBAL_ROOT_UID;
>  	sbi->s_gid = GLOBAL_ROOT_GID;
>  	sbi->s_perm = 0640;
> diff --git a/fs/zonefs/zonefs.h b/fs/zonefs/zonefs.h
> index 1dbe78119ff1..703bc4505b29 100644
> --- a/fs/zonefs/zonefs.h
> +++ b/fs/zonefs/zonefs.h
> @@ -179,7 +179,6 @@ struct zonefs_sb_info {
>  	kgid_t			s_gid;
>  	umode_t			s_perm;
>  	uuid_t			s_uuid;
> -	unsigned int		s_zone_sectors_shift;
>  
>  	unsigned int		s_nr_files[ZONEFS_ZTYPE_MAX];
>  

-- 
Damien Le Moal
Western Digital Research


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [dm-devel] [PATCH 4/7] zonefs: use bdev_zone_no helper to calculate the zone index
@ 2023-01-06 11:05         ` Damien Le Moal
  0 siblings, 0 replies; 58+ messages in thread
From: Damien Le Moal @ 2023-01-06 11:05 UTC (permalink / raw)
  To: Pankaj Raghav, axboe
  Cc: bvanassche, gost.dev, snitzer, linux-kernel, linux-nvme,
	linux-block, kernel, dm-devel, hch

On 1/6/23 17:33, Pankaj Raghav wrote:
> Use bdev_zone_no() helper instead of opencoding the logic to find the
> zone index.
> 
> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
> ---
>  fs/zonefs/super.c  | 8 +++-----
>  fs/zonefs/zonefs.h | 1 -
>  2 files changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
> index 2c53fbb8d918..c2ddc62e99dc 100644
> --- a/fs/zonefs/super.c
> +++ b/fs/zonefs/super.c
> @@ -487,7 +487,6 @@ static void __zonefs_io_error(struct inode *inode, bool write)
>  {
>  	struct zonefs_inode_info *zi = ZONEFS_I(inode);
>  	struct super_block *sb = inode->i_sb;
> -	struct zonefs_sb_info *sbi = ZONEFS_SB(sb);
>  	unsigned int noio_flag;
>  	unsigned int nr_zones = 1;
>  	struct zonefs_ioerr_data err = {
> @@ -502,8 +501,8 @@ static void __zonefs_io_error(struct inode *inode, bool write)
>  	 * size is always larger than the device zone size.
>  	 */
>  	if (zi->i_zone_size > bdev_zone_sectors(sb->s_bdev))
> -		nr_zones = zi->i_zone_size >>
> -			(sbi->s_zone_sectors_shift + SECTOR_SHIFT);
> +		nr_zones =
> +			bdev_zone_no(sb->s_bdev, zi->i_zone_size >> SECTOR_SHIFT);

This is a number of zones, not a zone number. So this at least needs a
comment to make clear. Otherwise, I find this confusing.

I would also prefer you hold on this patch. I am about to post a big
series reworking many things in zonefs. That will conflict.

>  
>  	/*
>  	 * Memory allocations in blkdev_report_zones() can trigger a memory
> @@ -1420,7 +1419,7 @@ static int zonefs_init_file_inode(struct inode *inode, struct blk_zone *zone,
>  	struct zonefs_inode_info *zi = ZONEFS_I(inode);
>  	int ret = 0;
>  
> -	inode->i_ino = zone->start >> sbi->s_zone_sectors_shift;
> +	inode->i_ino = bdev_zone_no(sb->s_bdev, zone->start);
>  	inode->i_mode = S_IFREG | sbi->s_perm;
>  
>  	zi->i_ztype = type;
> @@ -1804,7 +1803,6 @@ static int zonefs_fill_super(struct super_block *sb, void *data, int silent)
>  	 * interface constraints.
>  	 */
>  	sb_set_blocksize(sb, bdev_zone_write_granularity(sb->s_bdev));
> -	sbi->s_zone_sectors_shift = ilog2(bdev_zone_sectors(sb->s_bdev));
>  	sbi->s_uid = GLOBAL_ROOT_UID;
>  	sbi->s_gid = GLOBAL_ROOT_GID;
>  	sbi->s_perm = 0640;
> diff --git a/fs/zonefs/zonefs.h b/fs/zonefs/zonefs.h
> index 1dbe78119ff1..703bc4505b29 100644
> --- a/fs/zonefs/zonefs.h
> +++ b/fs/zonefs/zonefs.h
> @@ -179,7 +179,6 @@ struct zonefs_sb_info {
>  	kgid_t			s_gid;
>  	umode_t			s_perm;
>  	uuid_t			s_uuid;
> -	unsigned int		s_zone_sectors_shift;
>  
>  	unsigned int		s_nr_files[ZONEFS_ZTYPE_MAX];
>  

-- 
Damien Le Moal
Western Digital Research

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 1/7] block: remove superfluous check for request queue in bdev_is_zoned
  2023-01-06  8:33       ` [dm-devel] " Pankaj Raghav
@ 2023-01-06 22:34         ` Bart Van Assche
  -1 siblings, 0 replies; 58+ messages in thread
From: Bart Van Assche @ 2023-01-06 22:34 UTC (permalink / raw)
  To: Pankaj Raghav, axboe
  Cc: kernel, linux-kernel, hare, snitzer, dm-devel, damien.lemoal,
	linux-nvme, hch, linux-block, gost.dev

On 1/6/23 00:33, Pankaj Raghav wrote:
> Remove the superfluous request queue check in bdev_is_zoned() as the
> bdev_get_queue can never return NULL.

the bdev_get_queue -> bdev_get_queue()

Anyway:

Reviewed-by: Bart Van Assche <bvanassche@acm.org>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [dm-devel] [PATCH 1/7] block: remove superfluous check for request queue in bdev_is_zoned
@ 2023-01-06 22:34         ` Bart Van Assche
  0 siblings, 0 replies; 58+ messages in thread
From: Bart Van Assche @ 2023-01-06 22:34 UTC (permalink / raw)
  To: Pankaj Raghav, axboe
  Cc: gost.dev, damien.lemoal, snitzer, linux-kernel, linux-nvme,
	linux-block, kernel, dm-devel, hch

On 1/6/23 00:33, Pankaj Raghav wrote:
> Remove the superfluous request queue check in bdev_is_zoned() as the
> bdev_get_queue can never return NULL.

the bdev_get_queue -> bdev_get_queue()

Anyway:

Reviewed-by: Bart Van Assche <bvanassche@acm.org>

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 2/7] block: add a new helper bdev_{is_zone_start, offset_from_zone_start}
  2023-01-06  8:33       ` [dm-devel] " Pankaj Raghav
@ 2023-01-06 22:36         ` Bart Van Assche
  -1 siblings, 0 replies; 58+ messages in thread
From: Bart Van Assche @ 2023-01-06 22:36 UTC (permalink / raw)
  To: Pankaj Raghav, axboe
  Cc: kernel, linux-kernel, hare, snitzer, dm-devel, damien.lemoal,
	linux-nvme, hch, linux-block, gost.dev

On 1/6/23 00:33, Pankaj Raghav wrote:
> +static inline sector_t bdev_offset_from_zone_start(struct block_device *bdev,
> +						   sector_t sec)
> +{
> +	if (!bdev_is_zoned(bdev))
> +		return 0;
> +
> +	return sec & (bdev_zone_sectors(bdev) - 1);
> +}
> +
> +static inline bool bdev_is_zone_start(struct block_device *bdev, sector_t sec)
> +{
> +	if (!bdev_is_zoned(bdev))
> +		return false;
> +
> +	return bdev_offset_from_zone_start(bdev, sec) == 0;
> +}

A nit: 'sector_t sector' is much more common in the block layer than 
'sector_t sec'. Please consider changing 'sec' into 'sector'.

Thanks,

Bart.


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [dm-devel] [PATCH 2/7] block: add a new helper bdev_{is_zone_start, offset_from_zone_start}
@ 2023-01-06 22:36         ` Bart Van Assche
  0 siblings, 0 replies; 58+ messages in thread
From: Bart Van Assche @ 2023-01-06 22:36 UTC (permalink / raw)
  To: Pankaj Raghav, axboe
  Cc: gost.dev, damien.lemoal, snitzer, linux-kernel, linux-nvme,
	linux-block, kernel, dm-devel, hch

On 1/6/23 00:33, Pankaj Raghav wrote:
> +static inline sector_t bdev_offset_from_zone_start(struct block_device *bdev,
> +						   sector_t sec)
> +{
> +	if (!bdev_is_zoned(bdev))
> +		return 0;
> +
> +	return sec & (bdev_zone_sectors(bdev) - 1);
> +}
> +
> +static inline bool bdev_is_zone_start(struct block_device *bdev, sector_t sec)
> +{
> +	if (!bdev_is_zoned(bdev))
> +		return false;
> +
> +	return bdev_offset_from_zone_start(bdev, sec) == 0;
> +}

A nit: 'sector_t sector' is much more common in the block layer than 
'sector_t sec'. Please consider changing 'sec' into 'sector'.

Thanks,

Bart.

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 3/7] nvmet: introduce bdev_zone_no helper
  2023-01-06  8:33       ` [dm-devel] " Pankaj Raghav
@ 2023-01-06 22:39         ` Bart Van Assche
  -1 siblings, 0 replies; 58+ messages in thread
From: Bart Van Assche @ 2023-01-06 22:39 UTC (permalink / raw)
  To: Pankaj Raghav, axboe
  Cc: kernel, linux-kernel, hare, snitzer, dm-devel, damien.lemoal,
	linux-nvme, hch, linux-block, gost.dev

On 1/6/23 00:33, Pankaj Raghav wrote:
> A generic bdev_zone_no() helper is added to calculate zone number for a
> given sector in a block device. This helper internally uses disk_zone_no()
> to find the zone number.
> 
> Use the helper bdev_zone_no() to calculate nr of zones. This let's us
> make modifications to the math if needed in one place.

Please use the imperative mood in patch descriptions (... is added -> 
add ...).

let's -> lets

If these two issues are addressed, please add:

Reviewed-by: Bart Van Assche <bvanassche@acm.org>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [dm-devel] [PATCH 3/7] nvmet: introduce bdev_zone_no helper
@ 2023-01-06 22:39         ` Bart Van Assche
  0 siblings, 0 replies; 58+ messages in thread
From: Bart Van Assche @ 2023-01-06 22:39 UTC (permalink / raw)
  To: Pankaj Raghav, axboe
  Cc: gost.dev, damien.lemoal, snitzer, linux-kernel, linux-nvme,
	linux-block, kernel, dm-devel, hch

On 1/6/23 00:33, Pankaj Raghav wrote:
> A generic bdev_zone_no() helper is added to calculate zone number for a
> given sector in a block device. This helper internally uses disk_zone_no()
> to find the zone number.
> 
> Use the helper bdev_zone_no() to calculate nr of zones. This let's us
> make modifications to the math if needed in one place.

Please use the imperative mood in patch descriptions (... is added -> 
add ...).

let's -> lets

If these two issues are addressed, please add:

Reviewed-by: Bart Van Assche <bvanassche@acm.org>

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 1/7] block: remove superfluous check for request queue in bdev_is_zoned
  2023-01-06  8:33       ` [dm-devel] " Pankaj Raghav
@ 2023-01-09  7:41         ` Chaitanya Kulkarni
  -1 siblings, 0 replies; 58+ messages in thread
From: Chaitanya Kulkarni @ 2023-01-09  7:41 UTC (permalink / raw)
  To: Pankaj Raghav, axboe
  Cc: kernel, linux-kernel, hare, bvanassche, snitzer, dm-devel,
	damien.lemoal, linux-nvme, hch, linux-block, gost.dev

On 1/6/23 00:33, Pankaj Raghav wrote:
> Remove the superfluous request queue check in bdev_is_zoned() as the
> bdev_get_queue can never return NULL.
> 
> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
> ---

Looks good.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>

-ck



^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [dm-devel] [PATCH 1/7] block: remove superfluous check for request queue in bdev_is_zoned
@ 2023-01-09  7:41         ` Chaitanya Kulkarni
  0 siblings, 0 replies; 58+ messages in thread
From: Chaitanya Kulkarni @ 2023-01-09  7:41 UTC (permalink / raw)
  To: Pankaj Raghav, axboe
  Cc: bvanassche, gost.dev, damien.lemoal, snitzer, linux-kernel,
	linux-nvme, linux-block, kernel, dm-devel, hch

On 1/6/23 00:33, Pankaj Raghav wrote:
> Remove the superfluous request queue check in bdev_is_zoned() as the
> bdev_get_queue can never return NULL.
> 
> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
> ---

Looks good.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>

-ck


--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 2/7] block: add a new helper bdev_{is_zone_start, offset_from_zone_start}
  2023-01-06  8:33       ` [dm-devel] " Pankaj Raghav
@ 2023-01-09  7:42         ` Chaitanya Kulkarni
  -1 siblings, 0 replies; 58+ messages in thread
From: Chaitanya Kulkarni @ 2023-01-09  7:42 UTC (permalink / raw)
  To: Pankaj Raghav, axboe
  Cc: kernel, linux-kernel, hare, bvanassche, snitzer, dm-devel,
	damien.lemoal, linux-nvme, hch, linux-block, gost.dev

On 1/6/23 00:33, Pankaj Raghav wrote:
> Instead of open coding to check for zone start, add a helper to improve
> readability and store the logic in one place.
> 
> bdev_offset_from_zone_start() will be used later in the series.
> 
> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>


Looks good.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>

-ck



^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [dm-devel] [PATCH 2/7] block: add a new helper bdev_{is_zone_start, offset_from_zone_start}
@ 2023-01-09  7:42         ` Chaitanya Kulkarni
  0 siblings, 0 replies; 58+ messages in thread
From: Chaitanya Kulkarni @ 2023-01-09  7:42 UTC (permalink / raw)
  To: Pankaj Raghav, axboe
  Cc: bvanassche, gost.dev, damien.lemoal, snitzer, linux-kernel,
	linux-nvme, linux-block, kernel, dm-devel, hch

On 1/6/23 00:33, Pankaj Raghav wrote:
> Instead of open coding to check for zone start, add a helper to improve
> readability and store the logic in one place.
> 
> bdev_offset_from_zone_start() will be used later in the series.
> 
> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>


Looks good.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>

-ck


--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 3/7] nvmet: introduce bdev_zone_no helper
  2023-01-06  8:33       ` [dm-devel] " Pankaj Raghav
@ 2023-01-09  7:42         ` Chaitanya Kulkarni
  -1 siblings, 0 replies; 58+ messages in thread
From: Chaitanya Kulkarni @ 2023-01-09  7:42 UTC (permalink / raw)
  To: Pankaj Raghav, axboe
  Cc: kernel, linux-kernel, hare, bvanassche, snitzer, dm-devel,
	damien.lemoal, linux-nvme, hch, linux-block, gost.dev

On 1/6/23 00:33, Pankaj Raghav wrote:
> A generic bdev_zone_no() helper is added to calculate zone number for a
> given sector in a block device. This helper internally uses disk_zone_no()
> to find the zone number.
> 
> Use the helper bdev_zone_no() to calculate nr of zones. This let's us
> make modifications to the math if needed in one place.
> 
> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>

with Bart's comments fixed...

looks good....

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>

-ck



^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [dm-devel] [PATCH 3/7] nvmet: introduce bdev_zone_no helper
@ 2023-01-09  7:42         ` Chaitanya Kulkarni
  0 siblings, 0 replies; 58+ messages in thread
From: Chaitanya Kulkarni @ 2023-01-09  7:42 UTC (permalink / raw)
  To: Pankaj Raghav, axboe
  Cc: bvanassche, gost.dev, damien.lemoal, snitzer, linux-kernel,
	linux-nvme, linux-block, kernel, dm-devel, hch

On 1/6/23 00:33, Pankaj Raghav wrote:
> A generic bdev_zone_no() helper is added to calculate zone number for a
> given sector in a block device. This helper internally uses disk_zone_no()
> to find the zone number.
> 
> Use the helper bdev_zone_no() to calculate nr of zones. This let's us
> make modifications to the math if needed in one place.
> 
> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>

with Bart's comments fixed...

looks good....

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>

-ck


--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 1/7] block: remove superfluous check for request queue in bdev_is_zoned
  2023-01-06  8:33       ` [dm-devel] " Pankaj Raghav
@ 2023-01-09  8:55         ` Johannes Thumshirn
  -1 siblings, 0 replies; 58+ messages in thread
From: Johannes Thumshirn @ 2023-01-09  8:55 UTC (permalink / raw)
  To: Pankaj Raghav, axboe
  Cc: kernel, linux-kernel, hare, bvanassche, snitzer, dm-devel,
	damien.lemoal, linux-nvme, hch, linux-block, gost.dev

On 06.01.23 09:34, Pankaj Raghav wrote:
> Remove the superfluous request queue check in bdev_is_zoned() as the

minus the last 'the'

Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [dm-devel] [PATCH 1/7] block: remove superfluous check for request queue in bdev_is_zoned
@ 2023-01-09  8:55         ` Johannes Thumshirn
  0 siblings, 0 replies; 58+ messages in thread
From: Johannes Thumshirn @ 2023-01-09  8:55 UTC (permalink / raw)
  To: Pankaj Raghav, axboe
  Cc: bvanassche, gost.dev, damien.lemoal, snitzer, linux-kernel,
	linux-nvme, linux-block, kernel, dm-devel, hch

On 06.01.23 09:34, Pankaj Raghav wrote:
> Remove the superfluous request queue check in bdev_is_zoned() as the

minus the last 'the'

Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 1/7] block: remove superfluous check for request queue in bdev_is_zoned
  2023-01-06  8:33       ` [dm-devel] " Pankaj Raghav
@ 2023-01-10  6:52         ` Christoph Hellwig
  -1 siblings, 0 replies; 58+ messages in thread
From: Christoph Hellwig @ 2023-01-10  6:52 UTC (permalink / raw)
  To: Pankaj Raghav
  Cc: axboe, kernel, linux-kernel, hare, bvanassche, snitzer, dm-devel,
	damien.lemoal, linux-nvme, hch, linux-block, gost.dev

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [dm-devel] [PATCH 1/7] block: remove superfluous check for request queue in bdev_is_zoned
@ 2023-01-10  6:52         ` Christoph Hellwig
  0 siblings, 0 replies; 58+ messages in thread
From: Christoph Hellwig @ 2023-01-10  6:52 UTC (permalink / raw)
  To: Pankaj Raghav
  Cc: axboe, bvanassche, gost.dev, damien.lemoal, snitzer,
	linux-kernel, linux-nvme, linux-block, kernel, dm-devel, hch

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 2/7] block: add a new helper bdev_{is_zone_start, offset_from_zone_start}
  2023-01-06  8:33       ` [dm-devel] " Pankaj Raghav
@ 2023-01-10  6:54         ` Christoph Hellwig
  -1 siblings, 0 replies; 58+ messages in thread
From: Christoph Hellwig @ 2023-01-10  6:54 UTC (permalink / raw)
  To: Pankaj Raghav
  Cc: axboe, kernel, linux-kernel, hare, bvanassche, snitzer, dm-devel,
	damien.lemoal, linux-nvme, hch, linux-block, gost.dev

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [dm-devel] [PATCH 2/7] block: add a new helper bdev_{is_zone_start, offset_from_zone_start}
@ 2023-01-10  6:54         ` Christoph Hellwig
  0 siblings, 0 replies; 58+ messages in thread
From: Christoph Hellwig @ 2023-01-10  6:54 UTC (permalink / raw)
  To: Pankaj Raghav
  Cc: axboe, bvanassche, gost.dev, damien.lemoal, snitzer,
	linux-kernel, linux-nvme, linux-block, kernel, dm-devel, hch

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 3/7] nvmet: introduce bdev_zone_no helper
  2023-01-06  8:33       ` [dm-devel] " Pankaj Raghav
@ 2023-01-10  6:55         ` Christoph Hellwig
  -1 siblings, 0 replies; 58+ messages in thread
From: Christoph Hellwig @ 2023-01-10  6:55 UTC (permalink / raw)
  To: Pankaj Raghav
  Cc: axboe, kernel, linux-kernel, hare, bvanassche, snitzer, dm-devel,
	damien.lemoal, linux-nvme, hch, linux-block, gost.dev

s/nvmet/block/ in the Subject.

Otherwise:

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [dm-devel] [PATCH 3/7] nvmet: introduce bdev_zone_no helper
@ 2023-01-10  6:55         ` Christoph Hellwig
  0 siblings, 0 replies; 58+ messages in thread
From: Christoph Hellwig @ 2023-01-10  6:55 UTC (permalink / raw)
  To: Pankaj Raghav
  Cc: axboe, bvanassche, gost.dev, damien.lemoal, snitzer,
	linux-kernel, linux-nvme, linux-block, kernel, dm-devel, hch

s/nvmet/block/ in the Subject.

Otherwise:

Reviewed-by: Christoph Hellwig <hch@lst.de>

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 5/7] dm-zoned: ensure only power of 2 zone sizes are allowed
  2023-01-06  8:33       ` [dm-devel] " Pankaj Raghav
@ 2023-01-10  6:56         ` Christoph Hellwig
  -1 siblings, 0 replies; 58+ messages in thread
From: Christoph Hellwig @ 2023-01-10  6:56 UTC (permalink / raw)
  To: Pankaj Raghav
  Cc: axboe, kernel, linux-kernel, hare, bvanassche, snitzer, dm-devel,
	damien.lemoal, linux-nvme, hch, linux-block, gost.dev,
	Luis Chamberlain, Johannes Thumshirn

Given that we don't even support the non pow of 2 zones in the block
layer I don't see why this is needed.  But either way it doesn't really
seem to fit into this series.

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [dm-devel] [PATCH 5/7] dm-zoned: ensure only power of 2 zone sizes are allowed
@ 2023-01-10  6:56         ` Christoph Hellwig
  0 siblings, 0 replies; 58+ messages in thread
From: Christoph Hellwig @ 2023-01-10  6:56 UTC (permalink / raw)
  To: Pankaj Raghav
  Cc: axboe, bvanassche, gost.dev, damien.lemoal, snitzer,
	linux-kernel, linux-nvme, linux-block, kernel, dm-devel,
	Johannes Thumshirn, hch, Luis Chamberlain

Given that we don't even support the non pow of 2 zones in the block
layer I don't see why this is needed.  But either way it doesn't really
seem to fit into this series.

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 6/7] dm-zone: use generic helpers to calculate offset from zone start
  2023-01-06  8:33       ` [dm-devel] " Pankaj Raghav
@ 2023-01-10  6:57         ` Christoph Hellwig
  -1 siblings, 0 replies; 58+ messages in thread
From: Christoph Hellwig @ 2023-01-10  6:57 UTC (permalink / raw)
  To: Pankaj Raghav
  Cc: axboe, kernel, linux-kernel, hare, bvanassche, snitzer, dm-devel,
	damien.lemoal, linux-nvme, hch, linux-block, gost.dev,
	Luis Chamberlain, Johannes Thumshirn

On Fri, Jan 06, 2023 at 09:33:16AM +0100, Pankaj Raghav wrote:
> Use the bdev_offset_from_zone_start() helper function to calculate
> the offset from zone start instead of open coding.
> 
> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
> Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
> Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
> Reviewed-by: Bart Van Assche <bvanassche@acm.org>
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> Reviewed-by: Mike Snitzer <snitzer@kernel.org>
> ---
>  drivers/md/dm-zone.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c
> index 3dafc0e8b7a9..ac6fc1293d41 100644
> --- a/drivers/md/dm-zone.c
> +++ b/drivers/md/dm-zone.c
> @@ -390,7 +390,8 @@ static bool dm_zone_map_bio_begin(struct mapped_device *md,
>  	case REQ_OP_WRITE_ZEROES:
>  	case REQ_OP_WRITE:
>  		/* Writes must be aligned to the zone write pointer */
> -		if ((clone->bi_iter.bi_sector & (zsectors - 1)) != zwp_offset)
> +		if (bdev_offset_from_zone_start(md->disk->part0,
> +						clone->bi_iter.bi_sector) != zwp_offset)

I can't see how this actually cleans antyhing up, while it does add an
overly long line.

>  		if (clone->bi_status == BLK_STS_OK &&
>  		    bio_op(clone) == REQ_OP_ZONE_APPEND) {
>  			orig_bio->bi_iter.bi_sector +=
> -				clone->bi_iter.bi_sector & mask;
> +				bdev_offset_from_zone_start(disk->part0, clone->bi_iter.bi_sector);

Same here.

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [dm-devel] [PATCH 6/7] dm-zone: use generic helpers to calculate offset from zone start
@ 2023-01-10  6:57         ` Christoph Hellwig
  0 siblings, 0 replies; 58+ messages in thread
From: Christoph Hellwig @ 2023-01-10  6:57 UTC (permalink / raw)
  To: Pankaj Raghav
  Cc: axboe, bvanassche, gost.dev, damien.lemoal, snitzer,
	linux-kernel, linux-nvme, linux-block, kernel, dm-devel,
	Johannes Thumshirn, hch, Luis Chamberlain

On Fri, Jan 06, 2023 at 09:33:16AM +0100, Pankaj Raghav wrote:
> Use the bdev_offset_from_zone_start() helper function to calculate
> the offset from zone start instead of open coding.
> 
> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
> Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
> Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
> Reviewed-by: Bart Van Assche <bvanassche@acm.org>
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> Reviewed-by: Mike Snitzer <snitzer@kernel.org>
> ---
>  drivers/md/dm-zone.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c
> index 3dafc0e8b7a9..ac6fc1293d41 100644
> --- a/drivers/md/dm-zone.c
> +++ b/drivers/md/dm-zone.c
> @@ -390,7 +390,8 @@ static bool dm_zone_map_bio_begin(struct mapped_device *md,
>  	case REQ_OP_WRITE_ZEROES:
>  	case REQ_OP_WRITE:
>  		/* Writes must be aligned to the zone write pointer */
> -		if ((clone->bi_iter.bi_sector & (zsectors - 1)) != zwp_offset)
> +		if (bdev_offset_from_zone_start(md->disk->part0,
> +						clone->bi_iter.bi_sector) != zwp_offset)

I can't see how this actually cleans antyhing up, while it does add an
overly long line.

>  		if (clone->bi_status == BLK_STS_OK &&
>  		    bio_op(clone) == REQ_OP_ZONE_APPEND) {
>  			orig_bio->bi_iter.bi_sector +=
> -				clone->bi_iter.bi_sector & mask;
> +				bdev_offset_from_zone_start(disk->part0, clone->bi_iter.bi_sector);

Same here.

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 7/7] dm: call dm_zone_endio after the target endio callback for zoned devices
  2023-01-06  8:33       ` [dm-devel] " Pankaj Raghav
@ 2023-01-10  6:58         ` Christoph Hellwig
  -1 siblings, 0 replies; 58+ messages in thread
From: Christoph Hellwig @ 2023-01-10  6:58 UTC (permalink / raw)
  To: Pankaj Raghav
  Cc: axboe, kernel, linux-kernel, hare, bvanassche, snitzer, dm-devel,
	damien.lemoal, linux-nvme, hch, linux-block, gost.dev

On Fri, Jan 06, 2023 at 09:33:17AM +0100, Pankaj Raghav wrote:
> dm_zone_endio() updates the bi_sector of orig bio for zoned devices that
> uses either native append or append emulation, and it is called before the
> endio of the target. But target endio can still update the clone bio
> after dm_zone_endio is called, thereby, the orig bio does not contain
> the updated information anymore.
> 
> Currently, this is not a problem as the targets that support zoned devices
> such as dm-zoned, dm-linear, and dm-crypt do not have an endio function,
> and even if they do (such as dm-flakey), they don't modify the
> bio->bi_iter.bi_sector of the cloned bio that is used to update the
> orig_bio's bi_sector in dm_zone_endio function.
> 
> Call dm_zone_endio for zoned devices after calling the target's endio
> function.

This looks sensible, but I fail to see why we need this or how it fits
into the earlier block layer part of the series.


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [dm-devel] [PATCH 7/7] dm: call dm_zone_endio after the target endio callback for zoned devices
@ 2023-01-10  6:58         ` Christoph Hellwig
  0 siblings, 0 replies; 58+ messages in thread
From: Christoph Hellwig @ 2023-01-10  6:58 UTC (permalink / raw)
  To: Pankaj Raghav
  Cc: axboe, bvanassche, gost.dev, damien.lemoal, snitzer,
	linux-kernel, linux-nvme, linux-block, kernel, dm-devel, hch

On Fri, Jan 06, 2023 at 09:33:17AM +0100, Pankaj Raghav wrote:
> dm_zone_endio() updates the bi_sector of orig bio for zoned devices that
> uses either native append or append emulation, and it is called before the
> endio of the target. But target endio can still update the clone bio
> after dm_zone_endio is called, thereby, the orig bio does not contain
> the updated information anymore.
> 
> Currently, this is not a problem as the targets that support zoned devices
> such as dm-zoned, dm-linear, and dm-crypt do not have an endio function,
> and even if they do (such as dm-flakey), they don't modify the
> bio->bi_iter.bi_sector of the cloned bio that is used to update the
> orig_bio's bi_sector in dm_zone_endio function.
> 
> Call dm_zone_endio for zoned devices after calling the target's endio
> function.

This looks sensible, but I fail to see why we need this or how it fits
into the earlier block layer part of the series.

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 5/7] dm-zoned: ensure only power of 2 zone sizes are allowed
  2023-01-10  6:56         ` [dm-devel] " Christoph Hellwig
@ 2023-01-10  8:39           ` Pankaj Raghav
  -1 siblings, 0 replies; 58+ messages in thread
From: Pankaj Raghav @ 2023-01-10  8:39 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: axboe, kernel, linux-kernel, hare, bvanassche, snitzer, dm-devel,
	damien.lemoal, linux-nvme, linux-block, gost.dev,
	Luis Chamberlain, Johannes Thumshirn

On 2023-01-10 07:56, Christoph Hellwig wrote:
> Given that we don't even support the non pow of 2 zones in the block
> layer I don't see why this is needed.  But either way it doesn't really
> seem to fit into this series.

You are right. It is just an extra stop gap, but it is not needed as block
layer does not support pow of 2 anyway! I will remove this patch in the
next version.

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [dm-devel] [PATCH 5/7] dm-zoned: ensure only power of 2 zone sizes are allowed
@ 2023-01-10  8:39           ` Pankaj Raghav
  0 siblings, 0 replies; 58+ messages in thread
From: Pankaj Raghav @ 2023-01-10  8:39 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: axboe, bvanassche, gost.dev, damien.lemoal, snitzer,
	linux-kernel, linux-nvme, linux-block, kernel, dm-devel,
	Johannes Thumshirn, Luis Chamberlain

On 2023-01-10 07:56, Christoph Hellwig wrote:
> Given that we don't even support the non pow of 2 zones in the block
> layer I don't see why this is needed.  But either way it doesn't really
> seem to fit into this series.

You are right. It is just an extra stop gap, but it is not needed as block
layer does not support pow of 2 anyway! I will remove this patch in the
next version.

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 6/7] dm-zone: use generic helpers to calculate offset from zone start
  2023-01-10  6:57         ` [dm-devel] " Christoph Hellwig
@ 2023-01-10  9:06           ` Pankaj Raghav
  -1 siblings, 0 replies; 58+ messages in thread
From: Pankaj Raghav @ 2023-01-10  9:06 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: axboe, kernel, linux-kernel, hare, bvanassche, snitzer, dm-devel,
	damien.lemoal, linux-nvme, linux-block, gost.dev,
	Luis Chamberlain, Johannes Thumshirn

On 2023-01-10 07:57, Christoph Hellwig wrote:
> On Fri, Jan 06, 2023 at 09:33:16AM +0100, Pankaj Raghav wrote:
>> Use the bdev_offset_from_zone_start() helper function to calculate
>> the offset from zone start instead of open coding.
>>
>> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
>> Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
>> Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
>> Reviewed-by: Bart Van Assche <bvanassche@acm.org>
>> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
>> Reviewed-by: Mike Snitzer <snitzer@kernel.org>
>> ---
>>  drivers/md/dm-zone.c | 8 +++-----
>>  1 file changed, 3 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c
>> index 3dafc0e8b7a9..ac6fc1293d41 100644
>> --- a/drivers/md/dm-zone.c
>> +++ b/drivers/md/dm-zone.c
>> @@ -390,7 +390,8 @@ static bool dm_zone_map_bio_begin(struct mapped_device *md,
>>  	case REQ_OP_WRITE_ZEROES:
>>  	case REQ_OP_WRITE:
>>  		/* Writes must be aligned to the zone write pointer */
>> -		if ((clone->bi_iter.bi_sector & (zsectors - 1)) != zwp_offset)
>> +		if (bdev_offset_from_zone_start(md->disk->part0,
>> +						clone->bi_iter.bi_sector) != zwp_offset)
> 
> I can't see how this actually cleans antyhing up, while it does add an
> overly long line.
>
While I do agree with the overly long line comment, I feel it makes the
intent more clear, as it is easy to overlook this math operation.

>>  		if (clone->bi_status == BLK_STS_OK &&
>>  		    bio_op(clone) == REQ_OP_ZONE_APPEND) {
>>  			orig_bio->bi_iter.bi_sector +=
>> -				clone->bi_iter.bi_sector & mask;
>> +				bdev_offset_from_zone_start(disk->part0, clone->bi_iter.bi_sector);
> 
> Same here.

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [dm-devel] [PATCH 6/7] dm-zone: use generic helpers to calculate offset from zone start
@ 2023-01-10  9:06           ` Pankaj Raghav
  0 siblings, 0 replies; 58+ messages in thread
From: Pankaj Raghav @ 2023-01-10  9:06 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: axboe, bvanassche, gost.dev, damien.lemoal, snitzer,
	linux-kernel, linux-nvme, linux-block, kernel, dm-devel,
	Johannes Thumshirn, Luis Chamberlain

On 2023-01-10 07:57, Christoph Hellwig wrote:
> On Fri, Jan 06, 2023 at 09:33:16AM +0100, Pankaj Raghav wrote:
>> Use the bdev_offset_from_zone_start() helper function to calculate
>> the offset from zone start instead of open coding.
>>
>> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
>> Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
>> Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
>> Reviewed-by: Bart Van Assche <bvanassche@acm.org>
>> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
>> Reviewed-by: Mike Snitzer <snitzer@kernel.org>
>> ---
>>  drivers/md/dm-zone.c | 8 +++-----
>>  1 file changed, 3 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c
>> index 3dafc0e8b7a9..ac6fc1293d41 100644
>> --- a/drivers/md/dm-zone.c
>> +++ b/drivers/md/dm-zone.c
>> @@ -390,7 +390,8 @@ static bool dm_zone_map_bio_begin(struct mapped_device *md,
>>  	case REQ_OP_WRITE_ZEROES:
>>  	case REQ_OP_WRITE:
>>  		/* Writes must be aligned to the zone write pointer */
>> -		if ((clone->bi_iter.bi_sector & (zsectors - 1)) != zwp_offset)
>> +		if (bdev_offset_from_zone_start(md->disk->part0,
>> +						clone->bi_iter.bi_sector) != zwp_offset)
> 
> I can't see how this actually cleans antyhing up, while it does add an
> overly long line.
>
While I do agree with the overly long line comment, I feel it makes the
intent more clear, as it is easy to overlook this math operation.

>>  		if (clone->bi_status == BLK_STS_OK &&
>>  		    bio_op(clone) == REQ_OP_ZONE_APPEND) {
>>  			orig_bio->bi_iter.bi_sector +=
>> -				clone->bi_iter.bi_sector & mask;
>> +				bdev_offset_from_zone_start(disk->part0, clone->bi_iter.bi_sector);
> 
> Same here.

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 7/7] dm: call dm_zone_endio after the target endio callback for zoned devices
  2023-01-10  6:58         ` [dm-devel] " Christoph Hellwig
@ 2023-01-10  9:07           ` Pankaj Raghav
  -1 siblings, 0 replies; 58+ messages in thread
From: Pankaj Raghav @ 2023-01-10  9:07 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: axboe, kernel, linux-kernel, hare, bvanassche, snitzer, dm-devel,
	damien.lemoal, linux-nvme, linux-block, gost.dev

On 2023-01-10 07:58, Christoph Hellwig wrote:
> On Fri, Jan 06, 2023 at 09:33:17AM +0100, Pankaj Raghav wrote:
>> dm_zone_endio() updates the bi_sector of orig bio for zoned devices that
>> uses either native append or append emulation, and it is called before the
>> endio of the target. But target endio can still update the clone bio
>> after dm_zone_endio is called, thereby, the orig bio does not contain
>> the updated information anymore.
>>
>> Currently, this is not a problem as the targets that support zoned devices
>> such as dm-zoned, dm-linear, and dm-crypt do not have an endio function,
>> and even if they do (such as dm-flakey), they don't modify the
>> bio->bi_iter.bi_sector of the cloned bio that is used to update the
>> orig_bio's bi_sector in dm_zone_endio function.
>>
>> Call dm_zone_endio for zoned devices after calling the target's endio
>> function.
> 
> This looks sensible, but I fail to see why we need this or how it fits
> into the earlier block layer part of the series.
>


I just extracted the cleanup from my old series. Do you think it is better
to send it as a separate patch instead of adding it along in this series?


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [dm-devel] [PATCH 7/7] dm: call dm_zone_endio after the target endio callback for zoned devices
@ 2023-01-10  9:07           ` Pankaj Raghav
  0 siblings, 0 replies; 58+ messages in thread
From: Pankaj Raghav @ 2023-01-10  9:07 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: axboe, bvanassche, gost.dev, damien.lemoal, snitzer,
	linux-kernel, linux-nvme, linux-block, kernel, dm-devel

On 2023-01-10 07:58, Christoph Hellwig wrote:
> On Fri, Jan 06, 2023 at 09:33:17AM +0100, Pankaj Raghav wrote:
>> dm_zone_endio() updates the bi_sector of orig bio for zoned devices that
>> uses either native append or append emulation, and it is called before the
>> endio of the target. But target endio can still update the clone bio
>> after dm_zone_endio is called, thereby, the orig bio does not contain
>> the updated information anymore.
>>
>> Currently, this is not a problem as the targets that support zoned devices
>> such as dm-zoned, dm-linear, and dm-crypt do not have an endio function,
>> and even if they do (such as dm-flakey), they don't modify the
>> bio->bi_iter.bi_sector of the cloned bio that is used to update the
>> orig_bio's bi_sector in dm_zone_endio function.
>>
>> Call dm_zone_endio for zoned devices after calling the target's endio
>> function.
> 
> This looks sensible, but I fail to see why we need this or how it fits
> into the earlier block layer part of the series.
>


I just extracted the cleanup from my old series. Do you think it is better
to send it as a separate patch instead of adding it along in this series?

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 7/7] dm: call dm_zone_endio after the target endio callback for zoned devices
  2023-01-10  9:07           ` [dm-devel] " Pankaj Raghav
@ 2023-01-10  9:43             ` Christoph Hellwig
  -1 siblings, 0 replies; 58+ messages in thread
From: Christoph Hellwig @ 2023-01-10  9:43 UTC (permalink / raw)
  To: Pankaj Raghav
  Cc: Christoph Hellwig, axboe, kernel, linux-kernel, hare, bvanassche,
	snitzer, dm-devel, damien.lemoal, linux-nvme, linux-block,
	gost.dev

On Tue, Jan 10, 2023 at 10:07:39AM +0100, Pankaj Raghav wrote:
> I just extracted the cleanup from my old series. Do you think it is better
> to send it as a separate patch instead of adding it along in this series?

dm and block have different maintainers.  So unless there is a
dependency it's better to split the patches out.

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [dm-devel] [PATCH 7/7] dm: call dm_zone_endio after the target endio callback for zoned devices
@ 2023-01-10  9:43             ` Christoph Hellwig
  0 siblings, 0 replies; 58+ messages in thread
From: Christoph Hellwig @ 2023-01-10  9:43 UTC (permalink / raw)
  To: Pankaj Raghav
  Cc: axboe, bvanassche, gost.dev, damien.lemoal, snitzer,
	linux-kernel, linux-nvme, linux-block, kernel, dm-devel,
	Christoph Hellwig

On Tue, Jan 10, 2023 at 10:07:39AM +0100, Pankaj Raghav wrote:
> I just extracted the cleanup from my old series. Do you think it is better
> to send it as a separate patch instead of adding it along in this series?

dm and block have different maintainers.  So unless there is a
dependency it's better to split the patches out.

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 58+ messages in thread

end of thread, other threads:[~2023-01-10  9:43 UTC | newest]

Thread overview: 58+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20230106083318eucas1p1a2ab71a95ab2906b4651538c63a94ae2@eucas1p1.samsung.com>
2023-01-06  8:33 ` [PATCH 0/7] block zoned cleanups Pankaj Raghav
2023-01-06  8:33   ` [dm-devel] " Pankaj Raghav
     [not found]   ` <CGME20230106083319eucas1p1e58f4ab0d3ff59a328a2da2922d76038@eucas1p1.samsung.com>
2023-01-06  8:33     ` [PATCH 1/7] block: remove superfluous check for request queue in bdev_is_zoned Pankaj Raghav
2023-01-06  8:33       ` [dm-devel] " Pankaj Raghav
2023-01-06 11:01       ` Damien Le Moal
2023-01-06 11:01         ` [dm-devel] " Damien Le Moal
2023-01-06 22:34       ` Bart Van Assche
2023-01-06 22:34         ` [dm-devel] " Bart Van Assche
2023-01-09  7:41       ` Chaitanya Kulkarni
2023-01-09  7:41         ` [dm-devel] " Chaitanya Kulkarni
2023-01-09  8:55       ` Johannes Thumshirn
2023-01-09  8:55         ` [dm-devel] " Johannes Thumshirn
2023-01-10  6:52       ` Christoph Hellwig
2023-01-10  6:52         ` [dm-devel] " Christoph Hellwig
     [not found]   ` <CGME20230106083320eucas1p1f8de0c6ecf351738e8f0ee5f3390d94f@eucas1p1.samsung.com>
2023-01-06  8:33     ` [PATCH 2/7] block: add a new helper bdev_{is_zone_start, offset_from_zone_start} Pankaj Raghav
2023-01-06  8:33       ` [dm-devel] " Pankaj Raghav
2023-01-06 11:00       ` Damien Le Moal
2023-01-06 11:00         ` [dm-devel] " Damien Le Moal
2023-01-06 22:36       ` Bart Van Assche
2023-01-06 22:36         ` [dm-devel] " Bart Van Assche
2023-01-09  7:42       ` Chaitanya Kulkarni
2023-01-09  7:42         ` [dm-devel] " Chaitanya Kulkarni
2023-01-10  6:54       ` Christoph Hellwig
2023-01-10  6:54         ` [dm-devel] " Christoph Hellwig
     [not found]   ` <CGME20230106083320eucas1p1d23de4ad21d0a7aecb74c549ebc7757c@eucas1p1.samsung.com>
2023-01-06  8:33     ` [PATCH 3/7] nvmet: introduce bdev_zone_no helper Pankaj Raghav
2023-01-06  8:33       ` [dm-devel] " Pankaj Raghav
2023-01-06 11:02       ` Damien Le Moal
2023-01-06 11:02         ` [dm-devel] " Damien Le Moal
2023-01-06 22:39       ` Bart Van Assche
2023-01-06 22:39         ` [dm-devel] " Bart Van Assche
2023-01-09  7:42       ` Chaitanya Kulkarni
2023-01-09  7:42         ` [dm-devel] " Chaitanya Kulkarni
2023-01-10  6:55       ` Christoph Hellwig
2023-01-10  6:55         ` [dm-devel] " Christoph Hellwig
     [not found]   ` <CGME20230106083321eucas1p15e9087bcc62bc6a4f5a61467e1c98698@eucas1p1.samsung.com>
2023-01-06  8:33     ` [PATCH 4/7] zonefs: use bdev_zone_no helper to calculate the zone index Pankaj Raghav
2023-01-06  8:33       ` [dm-devel] " Pankaj Raghav
2023-01-06 11:05       ` Damien Le Moal
2023-01-06 11:05         ` [dm-devel] " Damien Le Moal
     [not found]   ` <CGME20230106083322eucas1p2414f1f7f121fbbd7a0e5e1b1b622f5c0@eucas1p2.samsung.com>
2023-01-06  8:33     ` [PATCH 5/7] dm-zoned: ensure only power of 2 zone sizes are allowed Pankaj Raghav
2023-01-06  8:33       ` [dm-devel] " Pankaj Raghav
2023-01-10  6:56       ` Christoph Hellwig
2023-01-10  6:56         ` [dm-devel] " Christoph Hellwig
2023-01-10  8:39         ` Pankaj Raghav
2023-01-10  8:39           ` [dm-devel] " Pankaj Raghav
     [not found]   ` <CGME20230106083322eucas1p1ce3ca7b02ca87bb2be8543291e223338@eucas1p1.samsung.com>
2023-01-06  8:33     ` [PATCH 6/7] dm-zone: use generic helpers to calculate offset from zone start Pankaj Raghav
2023-01-06  8:33       ` [dm-devel] " Pankaj Raghav
2023-01-10  6:57       ` Christoph Hellwig
2023-01-10  6:57         ` [dm-devel] " Christoph Hellwig
2023-01-10  9:06         ` Pankaj Raghav
2023-01-10  9:06           ` [dm-devel] " Pankaj Raghav
     [not found]   ` <CGME20230106083323eucas1p2f0f6d5d5c1c3713be35b841157ae463e@eucas1p2.samsung.com>
2023-01-06  8:33     ` [PATCH 7/7] dm: call dm_zone_endio after the target endio callback for zoned devices Pankaj Raghav
2023-01-06  8:33       ` [dm-devel] " Pankaj Raghav
2023-01-10  6:58       ` Christoph Hellwig
2023-01-10  6:58         ` [dm-devel] " Christoph Hellwig
2023-01-10  9:07         ` Pankaj Raghav
2023-01-10  9:07           ` [dm-devel] " Pankaj Raghav
2023-01-10  9:43           ` Christoph Hellwig
2023-01-10  9:43             ` [dm-devel] " Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.