All of lore.kernel.org
 help / color / mirror / Atom feed
* clean up zoned device information
@ 2022-07-04 12:44 ` Christoph Hellwig
  0 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:44 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: dm-devel, linux-block, linux-nvme, linux-scsi

Hi all,

this cleans up the block layer zoned device information APIs and
moves all fields currently in the request_queue to the gendisk as
they aren't relevant for passthrough I/O.

Diffstat:
 block/bio.c                    |    2 
 block/blk-core.c               |   13 +--
 block/blk-merge.c              |    2 
 block/blk-mq-debugfs-zoned.c   |    6 -
 block/blk-mq.c                 |    2 
 block/blk-mq.h                 |   18 ++---
 block/blk-settings.c           |   11 +--
 block/blk-sysfs.c              |    8 --
 block/blk-zoned.c              |   95 +++++++++++++-------------
 block/blk.h                    |    8 +-
 block/genhd.c                  |    1 
 block/ioctl.c                  |    2 
 block/partitions/core.c        |    2 
 drivers/block/null_blk/zoned.c |    8 +-
 drivers/md/dm-table.c          |    6 -
 drivers/md/dm-zone.c           |   86 +++++++++++-------------
 drivers/md/dm-zoned-target.c   |   25 +++----
 drivers/md/dm.c                |    2 
 drivers/nvme/host/multipath.c  |    2 
 drivers/nvme/host/zns.c        |    6 -
 drivers/nvme/target/zns.c      |  110 +-----------------------------
 drivers/scsi/sd.c              |    6 -
 drivers/scsi/sd_zbc.c          |   10 +-
 fs/zonefs/super.c              |   17 ++--
 include/linux/blk-mq.h         |    8 +-
 include/linux/blkdev.h         |  146 ++++++++++++++++-------------------------
 26 files changed, 233 insertions(+), 369 deletions(-)

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

* [dm-devel] clean up zoned device information
@ 2022-07-04 12:44 ` Christoph Hellwig
  0 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:44 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: linux-block, dm-devel, linux-scsi, linux-nvme

Hi all,

this cleans up the block layer zoned device information APIs and
moves all fields currently in the request_queue to the gendisk as
they aren't relevant for passthrough I/O.

Diffstat:
 block/bio.c                    |    2 
 block/blk-core.c               |   13 +--
 block/blk-merge.c              |    2 
 block/blk-mq-debugfs-zoned.c   |    6 -
 block/blk-mq.c                 |    2 
 block/blk-mq.h                 |   18 ++---
 block/blk-settings.c           |   11 +--
 block/blk-sysfs.c              |    8 --
 block/blk-zoned.c              |   95 +++++++++++++-------------
 block/blk.h                    |    8 +-
 block/genhd.c                  |    1 
 block/ioctl.c                  |    2 
 block/partitions/core.c        |    2 
 drivers/block/null_blk/zoned.c |    8 +-
 drivers/md/dm-table.c          |    6 -
 drivers/md/dm-zone.c           |   86 +++++++++++-------------
 drivers/md/dm-zoned-target.c   |   25 +++----
 drivers/md/dm.c                |    2 
 drivers/nvme/host/multipath.c  |    2 
 drivers/nvme/host/zns.c        |    6 -
 drivers/nvme/target/zns.c      |  110 +-----------------------------
 drivers/scsi/sd.c              |    6 -
 drivers/scsi/sd_zbc.c          |   10 +-
 fs/zonefs/super.c              |   17 ++--
 include/linux/blk-mq.h         |    8 +-
 include/linux/blkdev.h         |  146 ++++++++++++++++-------------------------
 26 files changed, 233 insertions(+), 369 deletions(-)

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


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

* [PATCH 01/17] block: remove a superflous ifdef in blkdev.h
  2022-07-04 12:44 ` [dm-devel] " Christoph Hellwig
@ 2022-07-04 12:44   ` Christoph Hellwig
  -1 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:44 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: dm-devel, linux-block, linux-nvme, linux-scsi

It doesn't hurt to lways have the blk_zone_cond_str prototype, and the
two inlines can also be defined unconditionally.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 include/linux/blkdev.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index b9a94c53c6cd3..270cd0c552924 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -899,8 +899,6 @@ static inline struct request_queue *bdev_get_queue(struct block_device *bdev)
 	return bdev->bd_queue;	/* this is never NULL */
 }
 
-#ifdef CONFIG_BLK_DEV_ZONED
-
 /* Helper to convert BLK_ZONE_ZONE_XXX to its string format XXX */
 const char *blk_zone_cond_str(enum blk_zone_cond zone_cond);
 
@@ -915,7 +913,6 @@ static inline unsigned int bio_zone_is_seq(struct bio *bio)
 	return blk_queue_zone_is_seq(bdev_get_queue(bio->bi_bdev),
 				     bio->bi_iter.bi_sector);
 }
-#endif /* CONFIG_BLK_DEV_ZONED */
 
 /*
  * Return how much of the chunk is left to be used for I/O at a given offset.
-- 
2.30.2


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

* [dm-devel] [PATCH 01/17] block: remove a superflous ifdef in blkdev.h
@ 2022-07-04 12:44   ` Christoph Hellwig
  0 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:44 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: linux-block, dm-devel, linux-scsi, linux-nvme

It doesn't hurt to lways have the blk_zone_cond_str prototype, and the
two inlines can also be defined unconditionally.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 include/linux/blkdev.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index b9a94c53c6cd3..270cd0c552924 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -899,8 +899,6 @@ static inline struct request_queue *bdev_get_queue(struct block_device *bdev)
 	return bdev->bd_queue;	/* this is never NULL */
 }
 
-#ifdef CONFIG_BLK_DEV_ZONED
-
 /* Helper to convert BLK_ZONE_ZONE_XXX to its string format XXX */
 const char *blk_zone_cond_str(enum blk_zone_cond zone_cond);
 
@@ -915,7 +913,6 @@ static inline unsigned int bio_zone_is_seq(struct bio *bio)
 	return blk_queue_zone_is_seq(bdev_get_queue(bio->bi_bdev),
 				     bio->bi_iter.bi_sector);
 }
-#endif /* CONFIG_BLK_DEV_ZONED */
 
 /*
  * Return how much of the chunk is left to be used for I/O at a given offset.
-- 
2.30.2

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


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

* [PATCH 02/17] block: call blk_queue_free_zone_bitmaps from disk_release
  2022-07-04 12:44 ` [dm-devel] " Christoph Hellwig
@ 2022-07-04 12:44   ` Christoph Hellwig
  -1 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:44 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: dm-devel, linux-block, linux-nvme, linux-scsi

The zone bitmaps are only used for non-passthrough I/O, so free them as
soon as the disk is released.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-sysfs.c | 2 --
 block/genhd.c     | 1 +
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 58cb9cb9f48cd..7590810cf13fc 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -776,8 +776,6 @@ static void blk_release_queue(struct kobject *kobj)
 	blk_free_queue_stats(q->stats);
 	kfree(q->poll_stat);
 
-	blk_queue_free_zone_bitmaps(q);
-
 	if (queue_is_mq(q))
 		blk_mq_release(q);
 
diff --git a/block/genhd.c b/block/genhd.c
index b1fb7e058b9cc..d0bdeb93e922c 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1165,6 +1165,7 @@ static void disk_release(struct device *dev)
 
 	disk_release_events(disk);
 	kfree(disk->random);
+	blk_queue_free_zone_bitmaps(disk->queue);
 	xa_destroy(&disk->part_tbl);
 
 	disk->queue->disk = NULL;
-- 
2.30.2


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

* [dm-devel] [PATCH 02/17] block: call blk_queue_free_zone_bitmaps from disk_release
@ 2022-07-04 12:44   ` Christoph Hellwig
  0 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:44 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: linux-block, dm-devel, linux-scsi, linux-nvme

The zone bitmaps are only used for non-passthrough I/O, so free them as
soon as the disk is released.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-sysfs.c | 2 --
 block/genhd.c     | 1 +
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 58cb9cb9f48cd..7590810cf13fc 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -776,8 +776,6 @@ static void blk_release_queue(struct kobject *kobj)
 	blk_free_queue_stats(q->stats);
 	kfree(q->poll_stat);
 
-	blk_queue_free_zone_bitmaps(q);
-
 	if (queue_is_mq(q))
 		blk_mq_release(q);
 
diff --git a/block/genhd.c b/block/genhd.c
index b1fb7e058b9cc..d0bdeb93e922c 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1165,6 +1165,7 @@ static void disk_release(struct device *dev)
 
 	disk_release_events(disk);
 	kfree(disk->random);
+	blk_queue_free_zone_bitmaps(disk->queue);
 	xa_destroy(&disk->part_tbl);
 
 	disk->queue->disk = NULL;
-- 
2.30.2

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


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

* [PATCH 03/17] block: use bdev_is_zoned instead of open coding it
  2022-07-04 12:44 ` [dm-devel] " Christoph Hellwig
@ 2022-07-04 12:44   ` Christoph Hellwig
  -1 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:44 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: dm-devel, linux-block, linux-nvme, linux-scsi

Use bdev_is_zoned in all places where a block_device is available instead
of open coding it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/bio.c           | 2 +-
 block/blk-core.c      | 6 +++---
 block/blk-mq.h        | 2 +-
 block/blk-zoned.c     | 9 ++++-----
 drivers/md/dm-table.c | 2 +-
 drivers/md/dm-zone.c  | 2 +-
 drivers/md/dm.c       | 2 +-
 7 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/block/bio.c b/block/bio.c
index 933ea32109547..888ee81ea3034 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1033,7 +1033,7 @@ int bio_add_zone_append_page(struct bio *bio, struct page *page,
 	if (WARN_ON_ONCE(bio_op(bio) != REQ_OP_ZONE_APPEND))
 		return 0;
 
-	if (WARN_ON_ONCE(!blk_queue_is_zoned(q)))
+	if (WARN_ON_ONCE(!bdev_is_zoned(bio->bi_bdev)))
 		return 0;
 
 	return bio_add_hw_page(q, bio, page, len, offset,
diff --git a/block/blk-core.c b/block/blk-core.c
index 5ad7bd93077c8..6bcca0b686de4 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -569,7 +569,7 @@ static inline blk_status_t blk_check_zone_append(struct request_queue *q,
 	int nr_sectors = bio_sectors(bio);
 
 	/* Only applicable to zoned block devices */
-	if (!blk_queue_is_zoned(q))
+	if (!bdev_is_zoned(bio->bi_bdev))
 		return BLK_STS_NOTSUPP;
 
 	/* The bio sector must point to the start of a sequential zone */
@@ -775,11 +775,11 @@ void submit_bio_noacct(struct bio *bio)
 	case REQ_OP_ZONE_OPEN:
 	case REQ_OP_ZONE_CLOSE:
 	case REQ_OP_ZONE_FINISH:
-		if (!blk_queue_is_zoned(q))
+		if (!bdev_is_zoned(bio->bi_bdev))
 			goto not_supported;
 		break;
 	case REQ_OP_ZONE_RESET_ALL:
-		if (!blk_queue_is_zoned(q) || !blk_queue_zone_resetall(q))
+		if (!bdev_is_zoned(bio->bi_bdev) || !blk_queue_zone_resetall(q))
 			goto not_supported;
 		break;
 	case REQ_OP_WRITE_ZEROES:
diff --git a/block/blk-mq.h b/block/blk-mq.h
index 54e20edf0da30..31d75a83a562d 100644
--- a/block/blk-mq.h
+++ b/block/blk-mq.h
@@ -317,7 +317,7 @@ static inline struct blk_plug *blk_mq_plug(struct request_queue *q,
 	 * For regular block devices or read operations, use the context plug
 	 * which may be NULL if blk_start_plug() was not executed.
 	 */
-	if (!blk_queue_is_zoned(q) || !op_is_write(bio_op(bio)))
+	if (!bdev_is_zoned(bio->bi_bdev) || !op_is_write(bio_op(bio)))
 		return current->plug;
 
 	/* Zoned block device write operation case: do not plug the BIO */
diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 38cd840d88387..90a5c9cc80ab3 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -149,8 +149,7 @@ int blkdev_report_zones(struct block_device *bdev, sector_t sector,
 	struct gendisk *disk = bdev->bd_disk;
 	sector_t capacity = get_capacity(disk);
 
-	if (!blk_queue_is_zoned(bdev_get_queue(bdev)) ||
-	    WARN_ON_ONCE(!disk->fops->report_zones))
+	if (!bdev_is_zoned(bdev) || WARN_ON_ONCE(!disk->fops->report_zones))
 		return -EOPNOTSUPP;
 
 	if (!nr_zones || sector >= capacity)
@@ -268,7 +267,7 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op,
 	struct bio *bio = NULL;
 	int ret = 0;
 
-	if (!blk_queue_is_zoned(q))
+	if (!bdev_is_zoned(bdev))
 		return -EOPNOTSUPP;
 
 	if (bdev_read_only(bdev))
@@ -350,7 +349,7 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
 	if (!q)
 		return -ENXIO;
 
-	if (!blk_queue_is_zoned(q))
+	if (!bdev_is_zoned(bdev))
 		return -ENOTTY;
 
 	if (copy_from_user(&rep, argp, sizeof(struct blk_zone_report)))
@@ -408,7 +407,7 @@ int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
 	if (!q)
 		return -ENXIO;
 
-	if (!blk_queue_is_zoned(q))
+	if (!bdev_is_zoned(bdev))
 		return -ENOTTY;
 
 	if (!(mode & FMODE_WRITE))
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index bd539afbfe88f..b36b528e56cff 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -1623,7 +1623,7 @@ static int device_not_matches_zone_sectors(struct dm_target *ti, struct dm_dev *
 	struct request_queue *q = bdev_get_queue(dev->bdev);
 	unsigned int *zone_sectors = data;
 
-	if (!blk_queue_is_zoned(q))
+	if (!bdev_is_zoned(dev->bdev))
 		return 0;
 
 	return blk_queue_zone_sectors(q) != *zone_sectors;
diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c
index 3e7b1fe1580b9..ae616b87c91ae 100644
--- a/drivers/md/dm-zone.c
+++ b/drivers/md/dm-zone.c
@@ -270,7 +270,7 @@ static int device_not_zone_append_capable(struct dm_target *ti,
 					  struct dm_dev *dev, sector_t start,
 					  sector_t len, void *data)
 {
-	return !blk_queue_is_zoned(bdev_get_queue(dev->bdev));
+	return !bdev_is_zoned(dev->bdev);
 }
 
 static bool dm_table_supports_zone_append(struct dm_table *t)
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 8872f9c636889..33d3799bb66ec 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1033,7 +1033,7 @@ static void clone_endio(struct bio *bio)
 	}
 
 	if (static_branch_unlikely(&zoned_enabled) &&
-	    unlikely(blk_queue_is_zoned(bdev_get_queue(bio->bi_bdev))))
+	    unlikely(bdev_is_zoned(bio->bi_bdev)))
 		dm_zone_endio(io, bio);
 
 	if (endio) {
-- 
2.30.2


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

* [dm-devel] [PATCH 03/17] block: use bdev_is_zoned instead of open coding it
@ 2022-07-04 12:44   ` Christoph Hellwig
  0 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:44 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: linux-block, dm-devel, linux-scsi, linux-nvme

Use bdev_is_zoned in all places where a block_device is available instead
of open coding it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/bio.c           | 2 +-
 block/blk-core.c      | 6 +++---
 block/blk-mq.h        | 2 +-
 block/blk-zoned.c     | 9 ++++-----
 drivers/md/dm-table.c | 2 +-
 drivers/md/dm-zone.c  | 2 +-
 drivers/md/dm.c       | 2 +-
 7 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/block/bio.c b/block/bio.c
index 933ea32109547..888ee81ea3034 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1033,7 +1033,7 @@ int bio_add_zone_append_page(struct bio *bio, struct page *page,
 	if (WARN_ON_ONCE(bio_op(bio) != REQ_OP_ZONE_APPEND))
 		return 0;
 
-	if (WARN_ON_ONCE(!blk_queue_is_zoned(q)))
+	if (WARN_ON_ONCE(!bdev_is_zoned(bio->bi_bdev)))
 		return 0;
 
 	return bio_add_hw_page(q, bio, page, len, offset,
diff --git a/block/blk-core.c b/block/blk-core.c
index 5ad7bd93077c8..6bcca0b686de4 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -569,7 +569,7 @@ static inline blk_status_t blk_check_zone_append(struct request_queue *q,
 	int nr_sectors = bio_sectors(bio);
 
 	/* Only applicable to zoned block devices */
-	if (!blk_queue_is_zoned(q))
+	if (!bdev_is_zoned(bio->bi_bdev))
 		return BLK_STS_NOTSUPP;
 
 	/* The bio sector must point to the start of a sequential zone */
@@ -775,11 +775,11 @@ void submit_bio_noacct(struct bio *bio)
 	case REQ_OP_ZONE_OPEN:
 	case REQ_OP_ZONE_CLOSE:
 	case REQ_OP_ZONE_FINISH:
-		if (!blk_queue_is_zoned(q))
+		if (!bdev_is_zoned(bio->bi_bdev))
 			goto not_supported;
 		break;
 	case REQ_OP_ZONE_RESET_ALL:
-		if (!blk_queue_is_zoned(q) || !blk_queue_zone_resetall(q))
+		if (!bdev_is_zoned(bio->bi_bdev) || !blk_queue_zone_resetall(q))
 			goto not_supported;
 		break;
 	case REQ_OP_WRITE_ZEROES:
diff --git a/block/blk-mq.h b/block/blk-mq.h
index 54e20edf0da30..31d75a83a562d 100644
--- a/block/blk-mq.h
+++ b/block/blk-mq.h
@@ -317,7 +317,7 @@ static inline struct blk_plug *blk_mq_plug(struct request_queue *q,
 	 * For regular block devices or read operations, use the context plug
 	 * which may be NULL if blk_start_plug() was not executed.
 	 */
-	if (!blk_queue_is_zoned(q) || !op_is_write(bio_op(bio)))
+	if (!bdev_is_zoned(bio->bi_bdev) || !op_is_write(bio_op(bio)))
 		return current->plug;
 
 	/* Zoned block device write operation case: do not plug the BIO */
diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 38cd840d88387..90a5c9cc80ab3 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -149,8 +149,7 @@ int blkdev_report_zones(struct block_device *bdev, sector_t sector,
 	struct gendisk *disk = bdev->bd_disk;
 	sector_t capacity = get_capacity(disk);
 
-	if (!blk_queue_is_zoned(bdev_get_queue(bdev)) ||
-	    WARN_ON_ONCE(!disk->fops->report_zones))
+	if (!bdev_is_zoned(bdev) || WARN_ON_ONCE(!disk->fops->report_zones))
 		return -EOPNOTSUPP;
 
 	if (!nr_zones || sector >= capacity)
@@ -268,7 +267,7 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op,
 	struct bio *bio = NULL;
 	int ret = 0;
 
-	if (!blk_queue_is_zoned(q))
+	if (!bdev_is_zoned(bdev))
 		return -EOPNOTSUPP;
 
 	if (bdev_read_only(bdev))
@@ -350,7 +349,7 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
 	if (!q)
 		return -ENXIO;
 
-	if (!blk_queue_is_zoned(q))
+	if (!bdev_is_zoned(bdev))
 		return -ENOTTY;
 
 	if (copy_from_user(&rep, argp, sizeof(struct blk_zone_report)))
@@ -408,7 +407,7 @@ int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
 	if (!q)
 		return -ENXIO;
 
-	if (!blk_queue_is_zoned(q))
+	if (!bdev_is_zoned(bdev))
 		return -ENOTTY;
 
 	if (!(mode & FMODE_WRITE))
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index bd539afbfe88f..b36b528e56cff 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -1623,7 +1623,7 @@ static int device_not_matches_zone_sectors(struct dm_target *ti, struct dm_dev *
 	struct request_queue *q = bdev_get_queue(dev->bdev);
 	unsigned int *zone_sectors = data;
 
-	if (!blk_queue_is_zoned(q))
+	if (!bdev_is_zoned(dev->bdev))
 		return 0;
 
 	return blk_queue_zone_sectors(q) != *zone_sectors;
diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c
index 3e7b1fe1580b9..ae616b87c91ae 100644
--- a/drivers/md/dm-zone.c
+++ b/drivers/md/dm-zone.c
@@ -270,7 +270,7 @@ static int device_not_zone_append_capable(struct dm_target *ti,
 					  struct dm_dev *dev, sector_t start,
 					  sector_t len, void *data)
 {
-	return !blk_queue_is_zoned(bdev_get_queue(dev->bdev));
+	return !bdev_is_zoned(dev->bdev);
 }
 
 static bool dm_table_supports_zone_append(struct dm_table *t)
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 8872f9c636889..33d3799bb66ec 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1033,7 +1033,7 @@ static void clone_endio(struct bio *bio)
 	}
 
 	if (static_branch_unlikely(&zoned_enabled) &&
-	    unlikely(blk_queue_is_zoned(bdev_get_queue(bio->bi_bdev))))
+	    unlikely(bdev_is_zoned(bio->bi_bdev)))
 		dm_zone_endio(io, bio);
 
 	if (endio) {
-- 
2.30.2

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


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

* [PATCH 04/17] block: simplify blk_mq_plug
  2022-07-04 12:44 ` [dm-devel] " Christoph Hellwig
@ 2022-07-04 12:44   ` Christoph Hellwig
  -1 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:44 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: dm-devel, linux-block, linux-nvme, linux-scsi

Drop the unused q argument, and invert the check to move the exception
into a branch and the regular path as the normal return.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-core.c  |  2 +-
 block/blk-merge.c |  2 +-
 block/blk-mq.c    |  2 +-
 block/blk-mq.h    | 18 ++++++++----------
 4 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index 6bcca0b686de4..bc16e9bae2dc4 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -719,7 +719,7 @@ void submit_bio_noacct(struct bio *bio)
 
 	might_sleep();
 
-	plug = blk_mq_plug(q, bio);
+	plug = blk_mq_plug(bio);
 	if (plug && plug->nowait)
 		bio->bi_opf |= REQ_NOWAIT;
 
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 0f5f42ebd0bb0..5abf5aa5a5f0e 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -1051,7 +1051,7 @@ bool blk_attempt_plug_merge(struct request_queue *q, struct bio *bio,
 	struct blk_plug *plug;
 	struct request *rq;
 
-	plug = blk_mq_plug(q, bio);
+	plug = blk_mq_plug(bio);
 	if (!plug || rq_list_empty(plug->mq_list))
 		return false;
 
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 15c7c5c4ad222..dc714dff73001 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2804,7 +2804,7 @@ static void bio_set_ioprio(struct bio *bio)
 void blk_mq_submit_bio(struct bio *bio)
 {
 	struct request_queue *q = bdev_get_queue(bio->bi_bdev);
-	struct blk_plug *plug = blk_mq_plug(q, bio);
+	struct blk_plug *plug = blk_mq_plug(bio);
 	const int is_sync = op_is_sync(bio->bi_opf);
 	struct request *rq;
 	unsigned int nr_segs = 1;
diff --git a/block/blk-mq.h b/block/blk-mq.h
index 31d75a83a562d..1cc0b17d69229 100644
--- a/block/blk-mq.h
+++ b/block/blk-mq.h
@@ -294,7 +294,6 @@ static inline void blk_mq_clear_mq_map(struct blk_mq_queue_map *qmap)
 
 /*
  * blk_mq_plug() - Get caller context plug
- * @q: request queue
  * @bio : the bio being submitted by the caller context
  *
  * Plugging, by design, may delay the insertion of BIOs into the elevator in
@@ -305,23 +304,22 @@ static inline void blk_mq_clear_mq_map(struct blk_mq_queue_map *qmap)
  * order. While this is not a problem with regular block devices, this ordering
  * change can cause write BIO failures with zoned block devices as these
  * require sequential write patterns to zones. Prevent this from happening by
- * ignoring the plug state of a BIO issuing context if the target request queue
- * is for a zoned block device and the BIO to plug is a write operation.
+ * ignoring the plug state of a BIO issuing context if is for a zoned block
+ 8 device and the BIO to plug is a write operation.
  *
  * Return current->plug if the bio can be plugged and NULL otherwise
  */
-static inline struct blk_plug *blk_mq_plug(struct request_queue *q,
-					   struct bio *bio)
+static inline struct blk_plug *blk_mq_plug( struct bio *bio)
 {
+	/* Zoned block device write operation case: do not plug the BIO */
+	if (bdev_is_zoned(bio->bi_bdev) && op_is_write(bio_op(bio)))
+		return NULL;
+
 	/*
 	 * For regular block devices or read operations, use the context plug
 	 * which may be NULL if blk_start_plug() was not executed.
 	 */
-	if (!bdev_is_zoned(bio->bi_bdev) || !op_is_write(bio_op(bio)))
-		return current->plug;
-
-	/* Zoned block device write operation case: do not plug the BIO */
-	return NULL;
+	return current->plug;
 }
 
 /* Free all requests on the list */
-- 
2.30.2


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

* [dm-devel] [PATCH 04/17] block: simplify blk_mq_plug
@ 2022-07-04 12:44   ` Christoph Hellwig
  0 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:44 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: linux-block, dm-devel, linux-scsi, linux-nvme

Drop the unused q argument, and invert the check to move the exception
into a branch and the regular path as the normal return.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-core.c  |  2 +-
 block/blk-merge.c |  2 +-
 block/blk-mq.c    |  2 +-
 block/blk-mq.h    | 18 ++++++++----------
 4 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index 6bcca0b686de4..bc16e9bae2dc4 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -719,7 +719,7 @@ void submit_bio_noacct(struct bio *bio)
 
 	might_sleep();
 
-	plug = blk_mq_plug(q, bio);
+	plug = blk_mq_plug(bio);
 	if (plug && plug->nowait)
 		bio->bi_opf |= REQ_NOWAIT;
 
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 0f5f42ebd0bb0..5abf5aa5a5f0e 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -1051,7 +1051,7 @@ bool blk_attempt_plug_merge(struct request_queue *q, struct bio *bio,
 	struct blk_plug *plug;
 	struct request *rq;
 
-	plug = blk_mq_plug(q, bio);
+	plug = blk_mq_plug(bio);
 	if (!plug || rq_list_empty(plug->mq_list))
 		return false;
 
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 15c7c5c4ad222..dc714dff73001 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2804,7 +2804,7 @@ static void bio_set_ioprio(struct bio *bio)
 void blk_mq_submit_bio(struct bio *bio)
 {
 	struct request_queue *q = bdev_get_queue(bio->bi_bdev);
-	struct blk_plug *plug = blk_mq_plug(q, bio);
+	struct blk_plug *plug = blk_mq_plug(bio);
 	const int is_sync = op_is_sync(bio->bi_opf);
 	struct request *rq;
 	unsigned int nr_segs = 1;
diff --git a/block/blk-mq.h b/block/blk-mq.h
index 31d75a83a562d..1cc0b17d69229 100644
--- a/block/blk-mq.h
+++ b/block/blk-mq.h
@@ -294,7 +294,6 @@ static inline void blk_mq_clear_mq_map(struct blk_mq_queue_map *qmap)
 
 /*
  * blk_mq_plug() - Get caller context plug
- * @q: request queue
  * @bio : the bio being submitted by the caller context
  *
  * Plugging, by design, may delay the insertion of BIOs into the elevator in
@@ -305,23 +304,22 @@ static inline void blk_mq_clear_mq_map(struct blk_mq_queue_map *qmap)
  * order. While this is not a problem with regular block devices, this ordering
  * change can cause write BIO failures with zoned block devices as these
  * require sequential write patterns to zones. Prevent this from happening by
- * ignoring the plug state of a BIO issuing context if the target request queue
- * is for a zoned block device and the BIO to plug is a write operation.
+ * ignoring the plug state of a BIO issuing context if is for a zoned block
+ 8 device and the BIO to plug is a write operation.
  *
  * Return current->plug if the bio can be plugged and NULL otherwise
  */
-static inline struct blk_plug *blk_mq_plug(struct request_queue *q,
-					   struct bio *bio)
+static inline struct blk_plug *blk_mq_plug( struct bio *bio)
 {
+	/* Zoned block device write operation case: do not plug the BIO */
+	if (bdev_is_zoned(bio->bi_bdev) && op_is_write(bio_op(bio)))
+		return NULL;
+
 	/*
 	 * For regular block devices or read operations, use the context plug
 	 * which may be NULL if blk_start_plug() was not executed.
 	 */
-	if (!bdev_is_zoned(bio->bi_bdev) || !op_is_write(bio_op(bio)))
-		return current->plug;
-
-	/* Zoned block device write operation case: do not plug the BIO */
-	return NULL;
+	return current->plug;
 }
 
 /* Free all requests on the list */
-- 
2.30.2

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


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

* [PATCH 05/17] block: export blkdev_zone_mgmt_all
  2022-07-04 12:44 ` [dm-devel] " Christoph Hellwig
@ 2022-07-04 12:44   ` Christoph Hellwig
  -1 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:44 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: dm-devel, linux-block, linux-nvme, linux-scsi

Export blkdev_zone_mgmt_all so that the nvme target can use it instead
of duplicating the functionality.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-zoned.c      | 10 +++++-----
 include/linux/blkdev.h |  2 ++
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 90a5c9cc80ab3..7fbe395fa51fc 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -185,8 +185,8 @@ static int blk_zone_need_reset_cb(struct blk_zone *zone, unsigned int idx,
 	}
 }
 
-static int blkdev_zone_reset_all_emulated(struct block_device *bdev,
-					  gfp_t gfp_mask)
+int blkdev_zone_mgmt_all(struct block_device *bdev, unsigned int op,
+			 gfp_t gfp_mask)
 {
 	struct request_queue *q = bdev_get_queue(bdev);
 	sector_t capacity = get_capacity(bdev->bd_disk);
@@ -213,8 +213,7 @@ static int blkdev_zone_reset_all_emulated(struct block_device *bdev,
 			continue;
 		}
 
-		bio = blk_next_bio(bio, bdev, 0, REQ_OP_ZONE_RESET | REQ_SYNC,
-				   gfp_mask);
+		bio = blk_next_bio(bio, bdev, 0, op | REQ_SYNC, gfp_mask);
 		bio->bi_iter.bi_sector = sector;
 		sector += zone_sectors;
 
@@ -231,6 +230,7 @@ static int blkdev_zone_reset_all_emulated(struct block_device *bdev,
 	kfree(need_reset);
 	return ret;
 }
+EXPORT_SYMBOL_GPL(blkdev_zone_mgmt_all);
 
 static int blkdev_zone_reset_all(struct block_device *bdev, gfp_t gfp_mask)
 {
@@ -295,7 +295,7 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op,
 	 */
 	if (op == REQ_OP_ZONE_RESET && sector == 0 && nr_sectors == capacity) {
 		if (!blk_queue_zone_resetall(q))
-			return blkdev_zone_reset_all_emulated(bdev, gfp_mask);
+			return blkdev_zone_mgmt_all(bdev, op, gfp_mask);
 		return blkdev_zone_reset_all(bdev, gfp_mask);
 	}
 
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 270cd0c552924..b9baee910b825 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -302,6 +302,8 @@ unsigned int blkdev_nr_zones(struct gendisk *disk);
 extern int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op,
 			    sector_t sectors, sector_t nr_sectors,
 			    gfp_t gfp_mask);
+int blkdev_zone_mgmt_all(struct block_device *bdev, unsigned int op,
+			 gfp_t gfp_mask);
 int blk_revalidate_disk_zones(struct gendisk *disk,
 			      void (*update_driver_data)(struct gendisk *disk));
 
-- 
2.30.2


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

* [dm-devel] [PATCH 05/17] block: export blkdev_zone_mgmt_all
@ 2022-07-04 12:44   ` Christoph Hellwig
  0 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:44 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: linux-block, dm-devel, linux-scsi, linux-nvme

Export blkdev_zone_mgmt_all so that the nvme target can use it instead
of duplicating the functionality.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-zoned.c      | 10 +++++-----
 include/linux/blkdev.h |  2 ++
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 90a5c9cc80ab3..7fbe395fa51fc 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -185,8 +185,8 @@ static int blk_zone_need_reset_cb(struct blk_zone *zone, unsigned int idx,
 	}
 }
 
-static int blkdev_zone_reset_all_emulated(struct block_device *bdev,
-					  gfp_t gfp_mask)
+int blkdev_zone_mgmt_all(struct block_device *bdev, unsigned int op,
+			 gfp_t gfp_mask)
 {
 	struct request_queue *q = bdev_get_queue(bdev);
 	sector_t capacity = get_capacity(bdev->bd_disk);
@@ -213,8 +213,7 @@ static int blkdev_zone_reset_all_emulated(struct block_device *bdev,
 			continue;
 		}
 
-		bio = blk_next_bio(bio, bdev, 0, REQ_OP_ZONE_RESET | REQ_SYNC,
-				   gfp_mask);
+		bio = blk_next_bio(bio, bdev, 0, op | REQ_SYNC, gfp_mask);
 		bio->bi_iter.bi_sector = sector;
 		sector += zone_sectors;
 
@@ -231,6 +230,7 @@ static int blkdev_zone_reset_all_emulated(struct block_device *bdev,
 	kfree(need_reset);
 	return ret;
 }
+EXPORT_SYMBOL_GPL(blkdev_zone_mgmt_all);
 
 static int blkdev_zone_reset_all(struct block_device *bdev, gfp_t gfp_mask)
 {
@@ -295,7 +295,7 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op,
 	 */
 	if (op == REQ_OP_ZONE_RESET && sector == 0 && nr_sectors == capacity) {
 		if (!blk_queue_zone_resetall(q))
-			return blkdev_zone_reset_all_emulated(bdev, gfp_mask);
+			return blkdev_zone_mgmt_all(bdev, op, gfp_mask);
 		return blkdev_zone_reset_all(bdev, gfp_mask);
 	}
 
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 270cd0c552924..b9baee910b825 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -302,6 +302,8 @@ unsigned int blkdev_nr_zones(struct gendisk *disk);
 extern int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op,
 			    sector_t sectors, sector_t nr_sectors,
 			    gfp_t gfp_mask);
+int blkdev_zone_mgmt_all(struct block_device *bdev, unsigned int op,
+			 gfp_t gfp_mask);
 int blk_revalidate_disk_zones(struct gendisk *disk,
 			      void (*update_driver_data)(struct gendisk *disk));
 
-- 
2.30.2

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


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

* [PATCH 06/17] nvmet: use blkdev_zone_mgmt_all
  2022-07-04 12:44 ` [dm-devel] " Christoph Hellwig
@ 2022-07-04 12:44   ` Christoph Hellwig
  -1 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:44 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: dm-devel, linux-block, linux-nvme, linux-scsi

Use blkdev_zone_mgmt_all instead of a copy and pasted version.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/nvme/target/zns.c | 104 ++------------------------------------
 1 file changed, 3 insertions(+), 101 deletions(-)

diff --git a/drivers/nvme/target/zns.c b/drivers/nvme/target/zns.c
index 82b61acf7a72b..c6f0a775efdee 100644
--- a/drivers/nvme/target/zns.c
+++ b/drivers/nvme/target/zns.c
@@ -337,110 +337,12 @@ static u16 blkdev_zone_mgmt_errno_to_nvme_status(int ret)
 	}
 }
 
-struct nvmet_zone_mgmt_send_all_data {
-	unsigned long *zbitmap;
-	struct nvmet_req *req;
-};
-
-static int zmgmt_send_scan_cb(struct blk_zone *z, unsigned i, void *d)
-{
-	struct nvmet_zone_mgmt_send_all_data *data = d;
-
-	switch (zsa_req_op(data->req->cmd->zms.zsa)) {
-	case REQ_OP_ZONE_OPEN:
-		switch (z->cond) {
-		case BLK_ZONE_COND_CLOSED:
-			break;
-		default:
-			return 0;
-		}
-		break;
-	case REQ_OP_ZONE_CLOSE:
-		switch (z->cond) {
-		case BLK_ZONE_COND_IMP_OPEN:
-		case BLK_ZONE_COND_EXP_OPEN:
-			break;
-		default:
-			return 0;
-		}
-		break;
-	case REQ_OP_ZONE_FINISH:
-		switch (z->cond) {
-		case BLK_ZONE_COND_IMP_OPEN:
-		case BLK_ZONE_COND_EXP_OPEN:
-		case BLK_ZONE_COND_CLOSED:
-			break;
-		default:
-			return 0;
-		}
-		break;
-	default:
-		return -EINVAL;
-	}
-
-	set_bit(i, data->zbitmap);
-
-	return 0;
-}
-
-static u16 nvmet_bdev_zone_mgmt_emulate_all(struct nvmet_req *req)
-{
-	struct block_device *bdev = req->ns->bdev;
-	unsigned int nr_zones = blkdev_nr_zones(bdev->bd_disk);
-	struct request_queue *q = bdev_get_queue(bdev);
-	struct bio *bio = NULL;
-	sector_t sector = 0;
-	int ret;
-	struct nvmet_zone_mgmt_send_all_data d = {
-		.req = req,
-	};
-
-	d.zbitmap = kcalloc_node(BITS_TO_LONGS(nr_zones), sizeof(*(d.zbitmap)),
-				 GFP_NOIO, q->node);
-	if (!d.zbitmap) {
-		ret = -ENOMEM;
-		goto out;
-	}
-
-	/* Scan and build bitmap of the eligible zones */
-	ret = blkdev_report_zones(bdev, 0, nr_zones, zmgmt_send_scan_cb, &d);
-	if (ret != nr_zones) {
-		if (ret > 0)
-			ret = -EIO;
-		goto out;
-	} else {
-		/* We scanned all the zones */
-		ret = 0;
-	}
-
-	while (sector < get_capacity(bdev->bd_disk)) {
-		if (test_bit(blk_queue_zone_no(q, sector), d.zbitmap)) {
-			bio = blk_next_bio(bio, bdev, 0,
-				zsa_req_op(req->cmd->zms.zsa) | REQ_SYNC,
-				GFP_KERNEL);
-			bio->bi_iter.bi_sector = sector;
-			/* This may take a while, so be nice to others */
-			cond_resched();
-		}
-		sector += blk_queue_zone_sectors(q);
-	}
-
-	if (bio) {
-		ret = submit_bio_wait(bio);
-		bio_put(bio);
-	}
-
-out:
-	kfree(d.zbitmap);
-
-	return blkdev_zone_mgmt_errno_to_nvme_status(ret);
-}
-
 static u16 nvmet_bdev_execute_zmgmt_send_all(struct nvmet_req *req)
 {
+	unsigned int op = zsa_req_op(req->cmd->zms.zsa);
 	int ret;
 
-	switch (zsa_req_op(req->cmd->zms.zsa)) {
+	switch (op) {
 	case REQ_OP_ZONE_RESET:
 		ret = blkdev_zone_mgmt(req->ns->bdev, REQ_OP_ZONE_RESET, 0,
 				       get_capacity(req->ns->bdev->bd_disk),
@@ -451,7 +353,7 @@ static u16 nvmet_bdev_execute_zmgmt_send_all(struct nvmet_req *req)
 	case REQ_OP_ZONE_OPEN:
 	case REQ_OP_ZONE_CLOSE:
 	case REQ_OP_ZONE_FINISH:
-		return nvmet_bdev_zone_mgmt_emulate_all(req);
+		return blkdev_zone_mgmt_all(req->ns->bdev, op, GFP_KERNEL);
 	default:
 		/* this is needed to quiet compiler warning */
 		req->error_loc = offsetof(struct nvme_zone_mgmt_send_cmd, zsa);
-- 
2.30.2


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

* [dm-devel] [PATCH 06/17] nvmet: use blkdev_zone_mgmt_all
@ 2022-07-04 12:44   ` Christoph Hellwig
  0 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:44 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: linux-block, dm-devel, linux-scsi, linux-nvme

Use blkdev_zone_mgmt_all instead of a copy and pasted version.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/nvme/target/zns.c | 104 ++------------------------------------
 1 file changed, 3 insertions(+), 101 deletions(-)

diff --git a/drivers/nvme/target/zns.c b/drivers/nvme/target/zns.c
index 82b61acf7a72b..c6f0a775efdee 100644
--- a/drivers/nvme/target/zns.c
+++ b/drivers/nvme/target/zns.c
@@ -337,110 +337,12 @@ static u16 blkdev_zone_mgmt_errno_to_nvme_status(int ret)
 	}
 }
 
-struct nvmet_zone_mgmt_send_all_data {
-	unsigned long *zbitmap;
-	struct nvmet_req *req;
-};
-
-static int zmgmt_send_scan_cb(struct blk_zone *z, unsigned i, void *d)
-{
-	struct nvmet_zone_mgmt_send_all_data *data = d;
-
-	switch (zsa_req_op(data->req->cmd->zms.zsa)) {
-	case REQ_OP_ZONE_OPEN:
-		switch (z->cond) {
-		case BLK_ZONE_COND_CLOSED:
-			break;
-		default:
-			return 0;
-		}
-		break;
-	case REQ_OP_ZONE_CLOSE:
-		switch (z->cond) {
-		case BLK_ZONE_COND_IMP_OPEN:
-		case BLK_ZONE_COND_EXP_OPEN:
-			break;
-		default:
-			return 0;
-		}
-		break;
-	case REQ_OP_ZONE_FINISH:
-		switch (z->cond) {
-		case BLK_ZONE_COND_IMP_OPEN:
-		case BLK_ZONE_COND_EXP_OPEN:
-		case BLK_ZONE_COND_CLOSED:
-			break;
-		default:
-			return 0;
-		}
-		break;
-	default:
-		return -EINVAL;
-	}
-
-	set_bit(i, data->zbitmap);
-
-	return 0;
-}
-
-static u16 nvmet_bdev_zone_mgmt_emulate_all(struct nvmet_req *req)
-{
-	struct block_device *bdev = req->ns->bdev;
-	unsigned int nr_zones = blkdev_nr_zones(bdev->bd_disk);
-	struct request_queue *q = bdev_get_queue(bdev);
-	struct bio *bio = NULL;
-	sector_t sector = 0;
-	int ret;
-	struct nvmet_zone_mgmt_send_all_data d = {
-		.req = req,
-	};
-
-	d.zbitmap = kcalloc_node(BITS_TO_LONGS(nr_zones), sizeof(*(d.zbitmap)),
-				 GFP_NOIO, q->node);
-	if (!d.zbitmap) {
-		ret = -ENOMEM;
-		goto out;
-	}
-
-	/* Scan and build bitmap of the eligible zones */
-	ret = blkdev_report_zones(bdev, 0, nr_zones, zmgmt_send_scan_cb, &d);
-	if (ret != nr_zones) {
-		if (ret > 0)
-			ret = -EIO;
-		goto out;
-	} else {
-		/* We scanned all the zones */
-		ret = 0;
-	}
-
-	while (sector < get_capacity(bdev->bd_disk)) {
-		if (test_bit(blk_queue_zone_no(q, sector), d.zbitmap)) {
-			bio = blk_next_bio(bio, bdev, 0,
-				zsa_req_op(req->cmd->zms.zsa) | REQ_SYNC,
-				GFP_KERNEL);
-			bio->bi_iter.bi_sector = sector;
-			/* This may take a while, so be nice to others */
-			cond_resched();
-		}
-		sector += blk_queue_zone_sectors(q);
-	}
-
-	if (bio) {
-		ret = submit_bio_wait(bio);
-		bio_put(bio);
-	}
-
-out:
-	kfree(d.zbitmap);
-
-	return blkdev_zone_mgmt_errno_to_nvme_status(ret);
-}
-
 static u16 nvmet_bdev_execute_zmgmt_send_all(struct nvmet_req *req)
 {
+	unsigned int op = zsa_req_op(req->cmd->zms.zsa);
 	int ret;
 
-	switch (zsa_req_op(req->cmd->zms.zsa)) {
+	switch (op) {
 	case REQ_OP_ZONE_RESET:
 		ret = blkdev_zone_mgmt(req->ns->bdev, REQ_OP_ZONE_RESET, 0,
 				       get_capacity(req->ns->bdev->bd_disk),
@@ -451,7 +353,7 @@ static u16 nvmet_bdev_execute_zmgmt_send_all(struct nvmet_req *req)
 	case REQ_OP_ZONE_OPEN:
 	case REQ_OP_ZONE_CLOSE:
 	case REQ_OP_ZONE_FINISH:
-		return nvmet_bdev_zone_mgmt_emulate_all(req);
+		return blkdev_zone_mgmt_all(req->ns->bdev, op, GFP_KERNEL);
 	default:
 		/* this is needed to quiet compiler warning */
 		req->error_loc = offsetof(struct nvme_zone_mgmt_send_cmd, zsa);
-- 
2.30.2

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


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

* [PATCH 07/17] block: simplify blk_check_zone_append
  2022-07-04 12:44 ` [dm-devel] " Christoph Hellwig
@ 2022-07-04 12:44   ` Christoph Hellwig
  -1 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:44 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: dm-devel, linux-block, linux-nvme, linux-scsi

Use the bdev based helpers instead of open coding them.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-core.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index bc16e9bae2dc4..b530ce7b370c4 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -565,7 +565,6 @@ static int blk_partition_remap(struct bio *bio)
 static inline blk_status_t blk_check_zone_append(struct request_queue *q,
 						 struct bio *bio)
 {
-	sector_t pos = bio->bi_iter.bi_sector;
 	int nr_sectors = bio_sectors(bio);
 
 	/* Only applicable to zoned block devices */
@@ -573,8 +572,8 @@ 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 (pos & (blk_queue_zone_sectors(q) - 1) ||
-	    !blk_queue_zone_is_seq(q, pos))
+	if (bio->bi_iter.bi_sector & (bdev_zone_sectors(bio->bi_bdev) - 1) ||
+	    !bio_zone_is_seq(bio))
 		return BLK_STS_IOERR;
 
 	/*
-- 
2.30.2


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

* [dm-devel] [PATCH 07/17] block: simplify blk_check_zone_append
@ 2022-07-04 12:44   ` Christoph Hellwig
  0 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:44 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: linux-block, dm-devel, linux-scsi, linux-nvme

Use the bdev based helpers instead of open coding them.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-core.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index bc16e9bae2dc4..b530ce7b370c4 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -565,7 +565,6 @@ static int blk_partition_remap(struct bio *bio)
 static inline blk_status_t blk_check_zone_append(struct request_queue *q,
 						 struct bio *bio)
 {
-	sector_t pos = bio->bi_iter.bi_sector;
 	int nr_sectors = bio_sectors(bio);
 
 	/* Only applicable to zoned block devices */
@@ -573,8 +572,8 @@ 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 (pos & (blk_queue_zone_sectors(q) - 1) ||
-	    !blk_queue_zone_is_seq(q, pos))
+	if (bio->bi_iter.bi_sector & (bdev_zone_sectors(bio->bi_bdev) - 1) ||
+	    !bio_zone_is_seq(bio))
 		return BLK_STS_IOERR;
 
 	/*
-- 
2.30.2

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


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

* [PATCH 08/17] block: pass a gendisk to blk_queue_set_zoned
  2022-07-04 12:44 ` [dm-devel] " Christoph Hellwig
@ 2022-07-04 12:44   ` Christoph Hellwig
  -1 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:44 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: dm-devel, linux-block, linux-nvme, linux-scsi

Prepare for storing the zone related field in struct gendisk instead
of struct request_queue.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-settings.c           | 9 +++++----
 block/partitions/core.c        | 2 +-
 drivers/block/null_blk/zoned.c | 2 +-
 drivers/nvme/host/zns.c        | 2 +-
 drivers/scsi/sd.c              | 6 +++---
 drivers/scsi/sd_zbc.c          | 2 +-
 include/linux/blkdev.h         | 2 +-
 7 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/block/blk-settings.c b/block/blk-settings.c
index 6ccceb421ed2f..35b7bba306a83 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -893,18 +893,19 @@ static bool disk_has_partitions(struct gendisk *disk)
 }
 
 /**
- * blk_queue_set_zoned - configure a disk queue zoned model.
+ * disk_set_zoned - configure the zoned model for a disk
  * @disk:	the gendisk of the queue to configure
  * @model:	the zoned model to set
  *
- * Set the zoned model of the request queue of @disk according to @model.
+ * Set the zoned model of @disk to @model.
+ *
  * When @model is BLK_ZONED_HM (host managed), this should be called only
  * if zoned block device support is enabled (CONFIG_BLK_DEV_ZONED option).
  * If @model specifies BLK_ZONED_HA (host aware), the effective model used
  * depends on CONFIG_BLK_DEV_ZONED settings and on the existence of partitions
  * on the disk.
  */
-void blk_queue_set_zoned(struct gendisk *disk, enum blk_zoned_model model)
+void disk_set_zoned(struct gendisk *disk, enum blk_zoned_model model)
 {
 	struct request_queue *q = disk->queue;
 
@@ -948,7 +949,7 @@ void blk_queue_set_zoned(struct gendisk *disk, enum blk_zoned_model model)
 		blk_queue_clear_zone_settings(q);
 	}
 }
-EXPORT_SYMBOL_GPL(blk_queue_set_zoned);
+EXPORT_SYMBOL_GPL(disk_set_zoned);
 
 int bdev_alignment_offset(struct block_device *bdev)
 {
diff --git a/block/partitions/core.c b/block/partitions/core.c
index 7dc487f5b03cd..1a45b1dd64918 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -330,7 +330,7 @@ static struct block_device *add_partition(struct gendisk *disk, int partno,
 	case BLK_ZONED_HA:
 		pr_info("%s: disabling host aware zoned block device support due to partitions\n",
 			disk->disk_name);
-		blk_queue_set_zoned(disk, BLK_ZONED_NONE);
+		disk_set_zoned(disk, BLK_ZONED_NONE);
 		break;
 	case BLK_ZONED_NONE:
 		break;
diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c
index 2fdd7b20c224e..b47bbd114058d 100644
--- a/drivers/block/null_blk/zoned.c
+++ b/drivers/block/null_blk/zoned.c
@@ -159,7 +159,7 @@ int null_register_zoned_dev(struct nullb *nullb)
 	struct nullb_device *dev = nullb->dev;
 	struct request_queue *q = nullb->q;
 
-	blk_queue_set_zoned(nullb->disk, BLK_ZONED_HM);
+	disk_set_zoned(nullb->disk, BLK_ZONED_HM);
 	blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q);
 	blk_queue_required_elevator_features(q, ELEVATOR_F_ZBD_SEQ_WRITE);
 
diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c
index 9f81beb4df4ef..0ed15c2fd56de 100644
--- a/drivers/nvme/host/zns.c
+++ b/drivers/nvme/host/zns.c
@@ -109,7 +109,7 @@ int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf)
 		goto free_data;
 	}
 
-	blk_queue_set_zoned(ns->disk, BLK_ZONED_HM);
+	disk_set_zoned(ns->disk, BLK_ZONED_HM);
 	blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q);
 	blk_queue_max_open_zones(q, le32_to_cpu(id->mor) + 1);
 	blk_queue_max_active_zones(q, le32_to_cpu(id->mar) + 1);
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index cb587e488601c..eb02d939dd448 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2934,15 +2934,15 @@ static void sd_read_block_characteristics(struct scsi_disk *sdkp)
 
 	if (sdkp->device->type == TYPE_ZBC) {
 		/* Host-managed */
-		blk_queue_set_zoned(sdkp->disk, BLK_ZONED_HM);
+		disk_set_zoned(sdkp->disk, BLK_ZONED_HM);
 	} else {
 		sdkp->zoned = zoned;
 		if (sdkp->zoned == 1) {
 			/* Host-aware */
-			blk_queue_set_zoned(sdkp->disk, BLK_ZONED_HA);
+			disk_set_zoned(sdkp->disk, BLK_ZONED_HA);
 		} else {
 			/* Regular disk or drive managed disk */
-			blk_queue_set_zoned(sdkp->disk, BLK_ZONED_NONE);
+			disk_set_zoned(sdkp->disk, BLK_ZONED_NONE);
 		}
 	}
 
diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
index 6acc4f406eb8c..0f5823b674685 100644
--- a/drivers/scsi/sd_zbc.c
+++ b/drivers/scsi/sd_zbc.c
@@ -929,7 +929,7 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, u8 buf[SD_BUF_SIZE])
 		/*
 		 * This can happen for a host aware disk with partitions.
 		 * The block device zone model was already cleared by
-		 * blk_queue_set_zoned(). Only free the scsi disk zone
+		 * disk_set_zoned(). Only free the scsi disk zone
 		 * information and exit early.
 		 */
 		sd_zbc_free_zone_info(sdkp);
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index b9baee910b825..ddf8353488fc8 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -291,7 +291,7 @@ struct queue_limits {
 typedef int (*report_zones_cb)(struct blk_zone *zone, unsigned int idx,
 			       void *data);
 
-void blk_queue_set_zoned(struct gendisk *disk, enum blk_zoned_model model);
+void disk_set_zoned(struct gendisk *disk, enum blk_zoned_model model);
 
 #ifdef CONFIG_BLK_DEV_ZONED
 
-- 
2.30.2


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

* [dm-devel] [PATCH 08/17] block: pass a gendisk to blk_queue_set_zoned
@ 2022-07-04 12:44   ` Christoph Hellwig
  0 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:44 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: linux-block, dm-devel, linux-scsi, linux-nvme

Prepare for storing the zone related field in struct gendisk instead
of struct request_queue.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-settings.c           | 9 +++++----
 block/partitions/core.c        | 2 +-
 drivers/block/null_blk/zoned.c | 2 +-
 drivers/nvme/host/zns.c        | 2 +-
 drivers/scsi/sd.c              | 6 +++---
 drivers/scsi/sd_zbc.c          | 2 +-
 include/linux/blkdev.h         | 2 +-
 7 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/block/blk-settings.c b/block/blk-settings.c
index 6ccceb421ed2f..35b7bba306a83 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -893,18 +893,19 @@ static bool disk_has_partitions(struct gendisk *disk)
 }
 
 /**
- * blk_queue_set_zoned - configure a disk queue zoned model.
+ * disk_set_zoned - configure the zoned model for a disk
  * @disk:	the gendisk of the queue to configure
  * @model:	the zoned model to set
  *
- * Set the zoned model of the request queue of @disk according to @model.
+ * Set the zoned model of @disk to @model.
+ *
  * When @model is BLK_ZONED_HM (host managed), this should be called only
  * if zoned block device support is enabled (CONFIG_BLK_DEV_ZONED option).
  * If @model specifies BLK_ZONED_HA (host aware), the effective model used
  * depends on CONFIG_BLK_DEV_ZONED settings and on the existence of partitions
  * on the disk.
  */
-void blk_queue_set_zoned(struct gendisk *disk, enum blk_zoned_model model)
+void disk_set_zoned(struct gendisk *disk, enum blk_zoned_model model)
 {
 	struct request_queue *q = disk->queue;
 
@@ -948,7 +949,7 @@ void blk_queue_set_zoned(struct gendisk *disk, enum blk_zoned_model model)
 		blk_queue_clear_zone_settings(q);
 	}
 }
-EXPORT_SYMBOL_GPL(blk_queue_set_zoned);
+EXPORT_SYMBOL_GPL(disk_set_zoned);
 
 int bdev_alignment_offset(struct block_device *bdev)
 {
diff --git a/block/partitions/core.c b/block/partitions/core.c
index 7dc487f5b03cd..1a45b1dd64918 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -330,7 +330,7 @@ static struct block_device *add_partition(struct gendisk *disk, int partno,
 	case BLK_ZONED_HA:
 		pr_info("%s: disabling host aware zoned block device support due to partitions\n",
 			disk->disk_name);
-		blk_queue_set_zoned(disk, BLK_ZONED_NONE);
+		disk_set_zoned(disk, BLK_ZONED_NONE);
 		break;
 	case BLK_ZONED_NONE:
 		break;
diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c
index 2fdd7b20c224e..b47bbd114058d 100644
--- a/drivers/block/null_blk/zoned.c
+++ b/drivers/block/null_blk/zoned.c
@@ -159,7 +159,7 @@ int null_register_zoned_dev(struct nullb *nullb)
 	struct nullb_device *dev = nullb->dev;
 	struct request_queue *q = nullb->q;
 
-	blk_queue_set_zoned(nullb->disk, BLK_ZONED_HM);
+	disk_set_zoned(nullb->disk, BLK_ZONED_HM);
 	blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q);
 	blk_queue_required_elevator_features(q, ELEVATOR_F_ZBD_SEQ_WRITE);
 
diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c
index 9f81beb4df4ef..0ed15c2fd56de 100644
--- a/drivers/nvme/host/zns.c
+++ b/drivers/nvme/host/zns.c
@@ -109,7 +109,7 @@ int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf)
 		goto free_data;
 	}
 
-	blk_queue_set_zoned(ns->disk, BLK_ZONED_HM);
+	disk_set_zoned(ns->disk, BLK_ZONED_HM);
 	blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q);
 	blk_queue_max_open_zones(q, le32_to_cpu(id->mor) + 1);
 	blk_queue_max_active_zones(q, le32_to_cpu(id->mar) + 1);
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index cb587e488601c..eb02d939dd448 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2934,15 +2934,15 @@ static void sd_read_block_characteristics(struct scsi_disk *sdkp)
 
 	if (sdkp->device->type == TYPE_ZBC) {
 		/* Host-managed */
-		blk_queue_set_zoned(sdkp->disk, BLK_ZONED_HM);
+		disk_set_zoned(sdkp->disk, BLK_ZONED_HM);
 	} else {
 		sdkp->zoned = zoned;
 		if (sdkp->zoned == 1) {
 			/* Host-aware */
-			blk_queue_set_zoned(sdkp->disk, BLK_ZONED_HA);
+			disk_set_zoned(sdkp->disk, BLK_ZONED_HA);
 		} else {
 			/* Regular disk or drive managed disk */
-			blk_queue_set_zoned(sdkp->disk, BLK_ZONED_NONE);
+			disk_set_zoned(sdkp->disk, BLK_ZONED_NONE);
 		}
 	}
 
diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
index 6acc4f406eb8c..0f5823b674685 100644
--- a/drivers/scsi/sd_zbc.c
+++ b/drivers/scsi/sd_zbc.c
@@ -929,7 +929,7 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, u8 buf[SD_BUF_SIZE])
 		/*
 		 * This can happen for a host aware disk with partitions.
 		 * The block device zone model was already cleared by
-		 * blk_queue_set_zoned(). Only free the scsi disk zone
+		 * disk_set_zoned(). Only free the scsi disk zone
 		 * information and exit early.
 		 */
 		sd_zbc_free_zone_info(sdkp);
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index b9baee910b825..ddf8353488fc8 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -291,7 +291,7 @@ struct queue_limits {
 typedef int (*report_zones_cb)(struct blk_zone *zone, unsigned int idx,
 			       void *data);
 
-void blk_queue_set_zoned(struct gendisk *disk, enum blk_zoned_model model);
+void disk_set_zoned(struct gendisk *disk, enum blk_zoned_model model);
 
 #ifdef CONFIG_BLK_DEV_ZONED
 
-- 
2.30.2

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


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

* [PATCH 09/17] block: pass a gendisk to blk_queue_clear_zone_settings
  2022-07-04 12:44 ` [dm-devel] " Christoph Hellwig
@ 2022-07-04 12:44   ` Christoph Hellwig
  -1 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:44 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: dm-devel, linux-block, linux-nvme, linux-scsi

Switch to a gendisk based API in preparation for moving all zone related
fields from the request_queue to the gendisk.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-settings.c | 2 +-
 block/blk-zoned.c    | 4 +++-
 block/blk.h          | 4 ++--
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/block/blk-settings.c b/block/blk-settings.c
index 35b7bba306a83..8bb9eef5310eb 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -946,7 +946,7 @@ void disk_set_zoned(struct gendisk *disk, enum blk_zoned_model model)
 		blk_queue_zone_write_granularity(q,
 						queue_logical_block_size(q));
 	} else {
-		blk_queue_clear_zone_settings(q);
+		disk_clear_zone_settings(disk);
 	}
 }
 EXPORT_SYMBOL_GPL(disk_set_zoned);
diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 7fbe395fa51fc..5a97b48102221 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -622,8 +622,10 @@ int blk_revalidate_disk_zones(struct gendisk *disk,
 }
 EXPORT_SYMBOL_GPL(blk_revalidate_disk_zones);
 
-void blk_queue_clear_zone_settings(struct request_queue *q)
+void disk_clear_zone_settings(struct gendisk *disk)
 {
+	struct request_queue *q = disk->queue;
+
 	blk_mq_freeze_queue(q);
 
 	blk_queue_free_zone_bitmaps(q);
diff --git a/block/blk.h b/block/blk.h
index 58ad50cacd2d5..7482a3a441dd9 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -406,10 +406,10 @@ static inline int blk_iolatency_init(struct request_queue *q) { return 0; }
 
 #ifdef CONFIG_BLK_DEV_ZONED
 void blk_queue_free_zone_bitmaps(struct request_queue *q);
-void blk_queue_clear_zone_settings(struct request_queue *q);
+void disk_clear_zone_settings(struct gendisk *disk);
 #else
 static inline void blk_queue_free_zone_bitmaps(struct request_queue *q) {}
-static inline void blk_queue_clear_zone_settings(struct request_queue *q) {}
+static inline void disk_clear_zone_settings(struct gendisk *disk) {}
 #endif
 
 int blk_alloc_ext_minor(void);
-- 
2.30.2


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

* [dm-devel] [PATCH 09/17] block: pass a gendisk to blk_queue_clear_zone_settings
@ 2022-07-04 12:44   ` Christoph Hellwig
  0 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:44 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: linux-block, dm-devel, linux-scsi, linux-nvme

Switch to a gendisk based API in preparation for moving all zone related
fields from the request_queue to the gendisk.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-settings.c | 2 +-
 block/blk-zoned.c    | 4 +++-
 block/blk.h          | 4 ++--
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/block/blk-settings.c b/block/blk-settings.c
index 35b7bba306a83..8bb9eef5310eb 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -946,7 +946,7 @@ void disk_set_zoned(struct gendisk *disk, enum blk_zoned_model model)
 		blk_queue_zone_write_granularity(q,
 						queue_logical_block_size(q));
 	} else {
-		blk_queue_clear_zone_settings(q);
+		disk_clear_zone_settings(disk);
 	}
 }
 EXPORT_SYMBOL_GPL(disk_set_zoned);
diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 7fbe395fa51fc..5a97b48102221 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -622,8 +622,10 @@ int blk_revalidate_disk_zones(struct gendisk *disk,
 }
 EXPORT_SYMBOL_GPL(blk_revalidate_disk_zones);
 
-void blk_queue_clear_zone_settings(struct request_queue *q)
+void disk_clear_zone_settings(struct gendisk *disk)
 {
+	struct request_queue *q = disk->queue;
+
 	blk_mq_freeze_queue(q);
 
 	blk_queue_free_zone_bitmaps(q);
diff --git a/block/blk.h b/block/blk.h
index 58ad50cacd2d5..7482a3a441dd9 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -406,10 +406,10 @@ static inline int blk_iolatency_init(struct request_queue *q) { return 0; }
 
 #ifdef CONFIG_BLK_DEV_ZONED
 void blk_queue_free_zone_bitmaps(struct request_queue *q);
-void blk_queue_clear_zone_settings(struct request_queue *q);
+void disk_clear_zone_settings(struct gendisk *disk);
 #else
 static inline void blk_queue_free_zone_bitmaps(struct request_queue *q) {}
-static inline void blk_queue_clear_zone_settings(struct request_queue *q) {}
+static inline void disk_clear_zone_settings(struct gendisk *disk) {}
 #endif
 
 int blk_alloc_ext_minor(void);
-- 
2.30.2

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


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

* [PATCH 10/17] block: pass a gendisk to blk_queue_free_zone_bitmaps
  2022-07-04 12:44 ` [dm-devel] " Christoph Hellwig
@ 2022-07-04 12:44   ` Christoph Hellwig
  -1 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:44 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: dm-devel, linux-block, linux-nvme, linux-scsi

Switch to a gendisk based API in preparation for moving all zone related
fields from the request_queue to the gendisk.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-zoned.c | 8 +++++---
 block/blk.h       | 4 ++--
 block/genhd.c     | 2 +-
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 5a97b48102221..9085f9fb3ab42 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -449,8 +449,10 @@ int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
 	return ret;
 }
 
-void blk_queue_free_zone_bitmaps(struct request_queue *q)
+void disk_free_zone_bitmaps(struct gendisk *disk)
 {
+	struct request_queue *q = disk->queue;
+
 	kfree(q->conv_zones_bitmap);
 	q->conv_zones_bitmap = NULL;
 	kfree(q->seq_zones_wlock);
@@ -612,7 +614,7 @@ int blk_revalidate_disk_zones(struct gendisk *disk,
 		ret = 0;
 	} else {
 		pr_warn("%s: failed to revalidate zones\n", disk->disk_name);
-		blk_queue_free_zone_bitmaps(q);
+		disk_free_zone_bitmaps(disk);
 	}
 	blk_mq_unfreeze_queue(q);
 
@@ -628,7 +630,7 @@ void disk_clear_zone_settings(struct gendisk *disk)
 
 	blk_mq_freeze_queue(q);
 
-	blk_queue_free_zone_bitmaps(q);
+	disk_free_zone_bitmaps(disk);
 	blk_queue_flag_clear(QUEUE_FLAG_ZONE_RESETALL, q);
 	q->required_elevator_features &= ~ELEVATOR_F_ZBD_SEQ_WRITE;
 	q->nr_zones = 0;
diff --git a/block/blk.h b/block/blk.h
index 7482a3a441dd9..b71e22c97d773 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -405,10 +405,10 @@ static inline int blk_iolatency_init(struct request_queue *q) { return 0; }
 #endif
 
 #ifdef CONFIG_BLK_DEV_ZONED
-void blk_queue_free_zone_bitmaps(struct request_queue *q);
+void disk_free_zone_bitmaps(struct gendisk *disk);
 void disk_clear_zone_settings(struct gendisk *disk);
 #else
-static inline void blk_queue_free_zone_bitmaps(struct request_queue *q) {}
+static inline void disk_free_zone_bitmaps(struct gendisk *disk) {}
 static inline void disk_clear_zone_settings(struct gendisk *disk) {}
 #endif
 
diff --git a/block/genhd.c b/block/genhd.c
index d0bdeb93e922c..9d30f159c59ac 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1165,7 +1165,7 @@ static void disk_release(struct device *dev)
 
 	disk_release_events(disk);
 	kfree(disk->random);
-	blk_queue_free_zone_bitmaps(disk->queue);
+	disk_free_zone_bitmaps(disk);
 	xa_destroy(&disk->part_tbl);
 
 	disk->queue->disk = NULL;
-- 
2.30.2


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

* [dm-devel] [PATCH 10/17] block: pass a gendisk to blk_queue_free_zone_bitmaps
@ 2022-07-04 12:44   ` Christoph Hellwig
  0 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:44 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: linux-block, dm-devel, linux-scsi, linux-nvme

Switch to a gendisk based API in preparation for moving all zone related
fields from the request_queue to the gendisk.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-zoned.c | 8 +++++---
 block/blk.h       | 4 ++--
 block/genhd.c     | 2 +-
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 5a97b48102221..9085f9fb3ab42 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -449,8 +449,10 @@ int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
 	return ret;
 }
 
-void blk_queue_free_zone_bitmaps(struct request_queue *q)
+void disk_free_zone_bitmaps(struct gendisk *disk)
 {
+	struct request_queue *q = disk->queue;
+
 	kfree(q->conv_zones_bitmap);
 	q->conv_zones_bitmap = NULL;
 	kfree(q->seq_zones_wlock);
@@ -612,7 +614,7 @@ int blk_revalidate_disk_zones(struct gendisk *disk,
 		ret = 0;
 	} else {
 		pr_warn("%s: failed to revalidate zones\n", disk->disk_name);
-		blk_queue_free_zone_bitmaps(q);
+		disk_free_zone_bitmaps(disk);
 	}
 	blk_mq_unfreeze_queue(q);
 
@@ -628,7 +630,7 @@ void disk_clear_zone_settings(struct gendisk *disk)
 
 	blk_mq_freeze_queue(q);
 
-	blk_queue_free_zone_bitmaps(q);
+	disk_free_zone_bitmaps(disk);
 	blk_queue_flag_clear(QUEUE_FLAG_ZONE_RESETALL, q);
 	q->required_elevator_features &= ~ELEVATOR_F_ZBD_SEQ_WRITE;
 	q->nr_zones = 0;
diff --git a/block/blk.h b/block/blk.h
index 7482a3a441dd9..b71e22c97d773 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -405,10 +405,10 @@ static inline int blk_iolatency_init(struct request_queue *q) { return 0; }
 #endif
 
 #ifdef CONFIG_BLK_DEV_ZONED
-void blk_queue_free_zone_bitmaps(struct request_queue *q);
+void disk_free_zone_bitmaps(struct gendisk *disk);
 void disk_clear_zone_settings(struct gendisk *disk);
 #else
-static inline void blk_queue_free_zone_bitmaps(struct request_queue *q) {}
+static inline void disk_free_zone_bitmaps(struct gendisk *disk) {}
 static inline void disk_clear_zone_settings(struct gendisk *disk) {}
 #endif
 
diff --git a/block/genhd.c b/block/genhd.c
index d0bdeb93e922c..9d30f159c59ac 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1165,7 +1165,7 @@ static void disk_release(struct device *dev)
 
 	disk_release_events(disk);
 	kfree(disk->random);
-	blk_queue_free_zone_bitmaps(disk->queue);
+	disk_free_zone_bitmaps(disk);
 	xa_destroy(&disk->part_tbl);
 
 	disk->queue->disk = NULL;
-- 
2.30.2

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


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

* [PATCH 11/17] block: remove queue_max_open_zones and queue_max_active_zones
  2022-07-04 12:44 ` [dm-devel] " Christoph Hellwig
@ 2022-07-04 12:44   ` Christoph Hellwig
  -1 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:44 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: dm-devel, linux-block, linux-nvme, linux-scsi

Always use the bdev based helpers instead.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-sysfs.c      |  4 ++--
 include/linux/blkdev.h | 37 ++++++++++---------------------------
 2 files changed, 12 insertions(+), 29 deletions(-)

diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 7590810cf13fc..5ce72345ac666 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -330,12 +330,12 @@ static ssize_t queue_nr_zones_show(struct request_queue *q, char *page)
 
 static ssize_t queue_max_open_zones_show(struct request_queue *q, char *page)
 {
-	return queue_var_show(queue_max_open_zones(q), page);
+	return queue_var_show(bdev_max_open_zones(q->disk->part0), page);
 }
 
 static ssize_t queue_max_active_zones_show(struct request_queue *q, char *page)
 {
-	return queue_var_show(queue_max_active_zones(q), page);
+	return queue_var_show(bdev_max_active_zones(q->disk->part0), page);
 }
 
 static ssize_t queue_nomerges_show(struct request_queue *q, char *page)
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index ddf8353488fc8..a14cc3e46e6ad 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -704,21 +704,22 @@ static inline void blk_queue_max_open_zones(struct request_queue *q,
 	q->max_open_zones = max_open_zones;
 }
 
-static inline unsigned int queue_max_open_zones(const struct request_queue *q)
-{
-	return q->max_open_zones;
-}
-
 static inline void blk_queue_max_active_zones(struct request_queue *q,
 		unsigned int max_active_zones)
 {
 	q->max_active_zones = max_active_zones;
 }
 
-static inline unsigned int queue_max_active_zones(const struct request_queue *q)
+static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
+{
+	return bdev->bd_disk->queue->max_open_zones;
+}
+
+static inline unsigned int bdev_max_active_zones(struct block_device *bdev)
 {
-	return q->max_active_zones;
+	return bdev->bd_disk->queue->max_active_zones;
 }
+
 #else /* CONFIG_BLK_DEV_ZONED */
 static inline unsigned int blk_queue_nr_zones(struct request_queue *q)
 {
@@ -734,11 +735,11 @@ static inline unsigned int blk_queue_zone_no(struct request_queue *q,
 {
 	return 0;
 }
-static inline unsigned int queue_max_open_zones(const struct request_queue *q)
+static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
 {
 	return 0;
 }
-static inline unsigned int queue_max_active_zones(const struct request_queue *q)
+static inline unsigned int bdev_max_active_zones(struct block_device *bdev)
 {
 	return 0;
 }
@@ -1316,24 +1317,6 @@ static inline sector_t bdev_zone_sectors(struct block_device *bdev)
 	return 0;
 }
 
-static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
-{
-	struct request_queue *q = bdev_get_queue(bdev);
-
-	if (q)
-		return queue_max_open_zones(q);
-	return 0;
-}
-
-static inline unsigned int bdev_max_active_zones(struct block_device *bdev)
-{
-	struct request_queue *q = bdev_get_queue(bdev);
-
-	if (q)
-		return queue_max_active_zones(q);
-	return 0;
-}
-
 static inline int queue_dma_alignment(const struct request_queue *q)
 {
 	return q ? q->dma_alignment : 511;
-- 
2.30.2


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

* [dm-devel] [PATCH 11/17] block: remove queue_max_open_zones and queue_max_active_zones
@ 2022-07-04 12:44   ` Christoph Hellwig
  0 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:44 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: linux-block, dm-devel, linux-scsi, linux-nvme

Always use the bdev based helpers instead.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-sysfs.c      |  4 ++--
 include/linux/blkdev.h | 37 ++++++++++---------------------------
 2 files changed, 12 insertions(+), 29 deletions(-)

diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 7590810cf13fc..5ce72345ac666 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -330,12 +330,12 @@ static ssize_t queue_nr_zones_show(struct request_queue *q, char *page)
 
 static ssize_t queue_max_open_zones_show(struct request_queue *q, char *page)
 {
-	return queue_var_show(queue_max_open_zones(q), page);
+	return queue_var_show(bdev_max_open_zones(q->disk->part0), page);
 }
 
 static ssize_t queue_max_active_zones_show(struct request_queue *q, char *page)
 {
-	return queue_var_show(queue_max_active_zones(q), page);
+	return queue_var_show(bdev_max_active_zones(q->disk->part0), page);
 }
 
 static ssize_t queue_nomerges_show(struct request_queue *q, char *page)
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index ddf8353488fc8..a14cc3e46e6ad 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -704,21 +704,22 @@ static inline void blk_queue_max_open_zones(struct request_queue *q,
 	q->max_open_zones = max_open_zones;
 }
 
-static inline unsigned int queue_max_open_zones(const struct request_queue *q)
-{
-	return q->max_open_zones;
-}
-
 static inline void blk_queue_max_active_zones(struct request_queue *q,
 		unsigned int max_active_zones)
 {
 	q->max_active_zones = max_active_zones;
 }
 
-static inline unsigned int queue_max_active_zones(const struct request_queue *q)
+static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
+{
+	return bdev->bd_disk->queue->max_open_zones;
+}
+
+static inline unsigned int bdev_max_active_zones(struct block_device *bdev)
 {
-	return q->max_active_zones;
+	return bdev->bd_disk->queue->max_active_zones;
 }
+
 #else /* CONFIG_BLK_DEV_ZONED */
 static inline unsigned int blk_queue_nr_zones(struct request_queue *q)
 {
@@ -734,11 +735,11 @@ static inline unsigned int blk_queue_zone_no(struct request_queue *q,
 {
 	return 0;
 }
-static inline unsigned int queue_max_open_zones(const struct request_queue *q)
+static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
 {
 	return 0;
 }
-static inline unsigned int queue_max_active_zones(const struct request_queue *q)
+static inline unsigned int bdev_max_active_zones(struct block_device *bdev)
 {
 	return 0;
 }
@@ -1316,24 +1317,6 @@ static inline sector_t bdev_zone_sectors(struct block_device *bdev)
 	return 0;
 }
 
-static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
-{
-	struct request_queue *q = bdev_get_queue(bdev);
-
-	if (q)
-		return queue_max_open_zones(q);
-	return 0;
-}
-
-static inline unsigned int bdev_max_active_zones(struct block_device *bdev)
-{
-	struct request_queue *q = bdev_get_queue(bdev);
-
-	if (q)
-		return queue_max_active_zones(q);
-	return 0;
-}
-
 static inline int queue_dma_alignment(const struct request_queue *q)
 {
 	return q ? q->dma_alignment : 511;
-- 
2.30.2

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


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

* [PATCH 12/17] block: pass a gendisk to blk_queue_max_open_zones and blk_queue_max_active_zones
  2022-07-04 12:44 ` [dm-devel] " Christoph Hellwig
@ 2022-07-04 12:44   ` Christoph Hellwig
  -1 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:44 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: dm-devel, linux-block, linux-nvme, linux-scsi

Switch to a gendisk based API in preparation for moving all zone related
fields from the request_queue to the gendisk.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/block/null_blk/zoned.c | 4 ++--
 drivers/nvme/host/zns.c        | 4 ++--
 drivers/scsi/sd_zbc.c          | 6 +++---
 include/linux/blkdev.h         | 8 ++++----
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c
index b47bbd114058d..576ab3ed082a5 100644
--- a/drivers/block/null_blk/zoned.c
+++ b/drivers/block/null_blk/zoned.c
@@ -174,8 +174,8 @@ int null_register_zoned_dev(struct nullb *nullb)
 	}
 
 	blk_queue_max_zone_append_sectors(q, dev->zone_size_sects);
-	blk_queue_max_open_zones(q, dev->zone_max_open);
-	blk_queue_max_active_zones(q, dev->zone_max_active);
+	disk_set_max_open_zones(nullb->disk, dev->zone_max_open);
+	disk_set_max_active_zones(nullb->disk, dev->zone_max_active);
 
 	return 0;
 }
diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c
index 0ed15c2fd56de..12316ab51bda6 100644
--- a/drivers/nvme/host/zns.c
+++ b/drivers/nvme/host/zns.c
@@ -111,8 +111,8 @@ int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf)
 
 	disk_set_zoned(ns->disk, BLK_ZONED_HM);
 	blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q);
-	blk_queue_max_open_zones(q, le32_to_cpu(id->mor) + 1);
-	blk_queue_max_active_zones(q, le32_to_cpu(id->mar) + 1);
+	disk_set_max_open_zones(ns->disk, le32_to_cpu(id->mor) + 1);
+	disk_set_max_active_zones(ns->disk, le32_to_cpu(id->mar) + 1);
 free_data:
 	kfree(id);
 	return status;
diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
index 0f5823b674685..b4106f8997342 100644
--- a/drivers/scsi/sd_zbc.c
+++ b/drivers/scsi/sd_zbc.c
@@ -950,10 +950,10 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, u8 buf[SD_BUF_SIZE])
 	blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q);
 	blk_queue_required_elevator_features(q, ELEVATOR_F_ZBD_SEQ_WRITE);
 	if (sdkp->zones_max_open == U32_MAX)
-		blk_queue_max_open_zones(q, 0);
+		disk_set_max_open_zones(disk, 0);
 	else
-		blk_queue_max_open_zones(q, sdkp->zones_max_open);
-	blk_queue_max_active_zones(q, 0);
+		disk_set_max_open_zones(disk, sdkp->zones_max_open);
+	disk_set_max_active_zones(disk, 0);
 	nr_zones = round_up(sdkp->capacity, zone_blocks) >> ilog2(zone_blocks);
 
 	/*
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index a14cc3e46e6ad..e32c147f72868 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -698,16 +698,16 @@ static inline bool blk_queue_zone_is_seq(struct request_queue *q,
 	return !test_bit(blk_queue_zone_no(q, sector), q->conv_zones_bitmap);
 }
 
-static inline void blk_queue_max_open_zones(struct request_queue *q,
+static inline void disk_set_max_open_zones(struct gendisk *disk,
 		unsigned int max_open_zones)
 {
-	q->max_open_zones = max_open_zones;
+	disk->queue->max_open_zones = max_open_zones;
 }
 
-static inline void blk_queue_max_active_zones(struct request_queue *q,
+static inline void disk_set_max_active_zones(struct gendisk *disk,
 		unsigned int max_active_zones)
 {
-	q->max_active_zones = max_active_zones;
+	disk->queue->max_active_zones = max_active_zones;
 }
 
 static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
-- 
2.30.2


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

* [dm-devel] [PATCH 12/17] block: pass a gendisk to blk_queue_max_open_zones and blk_queue_max_active_zones
@ 2022-07-04 12:44   ` Christoph Hellwig
  0 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:44 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: linux-block, dm-devel, linux-scsi, linux-nvme

Switch to a gendisk based API in preparation for moving all zone related
fields from the request_queue to the gendisk.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/block/null_blk/zoned.c | 4 ++--
 drivers/nvme/host/zns.c        | 4 ++--
 drivers/scsi/sd_zbc.c          | 6 +++---
 include/linux/blkdev.h         | 8 ++++----
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c
index b47bbd114058d..576ab3ed082a5 100644
--- a/drivers/block/null_blk/zoned.c
+++ b/drivers/block/null_blk/zoned.c
@@ -174,8 +174,8 @@ int null_register_zoned_dev(struct nullb *nullb)
 	}
 
 	blk_queue_max_zone_append_sectors(q, dev->zone_size_sects);
-	blk_queue_max_open_zones(q, dev->zone_max_open);
-	blk_queue_max_active_zones(q, dev->zone_max_active);
+	disk_set_max_open_zones(nullb->disk, dev->zone_max_open);
+	disk_set_max_active_zones(nullb->disk, dev->zone_max_active);
 
 	return 0;
 }
diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c
index 0ed15c2fd56de..12316ab51bda6 100644
--- a/drivers/nvme/host/zns.c
+++ b/drivers/nvme/host/zns.c
@@ -111,8 +111,8 @@ int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf)
 
 	disk_set_zoned(ns->disk, BLK_ZONED_HM);
 	blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q);
-	blk_queue_max_open_zones(q, le32_to_cpu(id->mor) + 1);
-	blk_queue_max_active_zones(q, le32_to_cpu(id->mar) + 1);
+	disk_set_max_open_zones(ns->disk, le32_to_cpu(id->mor) + 1);
+	disk_set_max_active_zones(ns->disk, le32_to_cpu(id->mar) + 1);
 free_data:
 	kfree(id);
 	return status;
diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
index 0f5823b674685..b4106f8997342 100644
--- a/drivers/scsi/sd_zbc.c
+++ b/drivers/scsi/sd_zbc.c
@@ -950,10 +950,10 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, u8 buf[SD_BUF_SIZE])
 	blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q);
 	blk_queue_required_elevator_features(q, ELEVATOR_F_ZBD_SEQ_WRITE);
 	if (sdkp->zones_max_open == U32_MAX)
-		blk_queue_max_open_zones(q, 0);
+		disk_set_max_open_zones(disk, 0);
 	else
-		blk_queue_max_open_zones(q, sdkp->zones_max_open);
-	blk_queue_max_active_zones(q, 0);
+		disk_set_max_open_zones(disk, sdkp->zones_max_open);
+	disk_set_max_active_zones(disk, 0);
 	nr_zones = round_up(sdkp->capacity, zone_blocks) >> ilog2(zone_blocks);
 
 	/*
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index a14cc3e46e6ad..e32c147f72868 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -698,16 +698,16 @@ static inline bool blk_queue_zone_is_seq(struct request_queue *q,
 	return !test_bit(blk_queue_zone_no(q, sector), q->conv_zones_bitmap);
 }
 
-static inline void blk_queue_max_open_zones(struct request_queue *q,
+static inline void disk_set_max_open_zones(struct gendisk *disk,
 		unsigned int max_open_zones)
 {
-	q->max_open_zones = max_open_zones;
+	disk->queue->max_open_zones = max_open_zones;
 }
 
-static inline void blk_queue_max_active_zones(struct request_queue *q,
+static inline void disk_set_max_active_zones(struct gendisk *disk,
 		unsigned int max_active_zones)
 {
-	q->max_active_zones = max_active_zones;
+	disk->queue->max_active_zones = max_active_zones;
 }
 
 static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
-- 
2.30.2

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


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

* [PATCH 13/17] block: replace blkdev_nr_zones with bdev_nr_zones
  2022-07-04 12:44 ` [dm-devel] " Christoph Hellwig
@ 2022-07-04 12:44   ` Christoph Hellwig
  -1 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:44 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: dm-devel, linux-block, linux-nvme, linux-scsi

Pass a block_device instead of a request_queue a that is what most
callers have at hand.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-zoned.c              | 15 ++++++++-------
 block/ioctl.c                  |  2 +-
 drivers/block/null_blk/zoned.c |  2 +-
 drivers/md/dm-zone.c           |  2 +-
 drivers/md/dm-zoned-target.c   |  5 ++---
 drivers/nvme/target/zns.c      |  4 ++--
 fs/zonefs/super.c              | 17 ++++++++---------
 include/linux/blkdev.h         |  4 ++--
 8 files changed, 25 insertions(+), 26 deletions(-)

diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 9085f9fb3ab42..836b96ebfdc04 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -108,21 +108,22 @@ void __blk_req_zone_write_unlock(struct request *rq)
 EXPORT_SYMBOL_GPL(__blk_req_zone_write_unlock);
 
 /**
- * blkdev_nr_zones - Get number of zones
- * @disk:	Target gendisk
+ * bdev_nr_zones - Get number of zones
+ * @bdev:	Target device
  *
  * Return the total number of zones of a zoned block device.  For a block
  * device without zone capabilities, the number of zones is always 0.
  */
-unsigned int blkdev_nr_zones(struct gendisk *disk)
+unsigned int bdev_nr_zones(struct block_device *bdev)
 {
-	sector_t zone_sectors = blk_queue_zone_sectors(disk->queue);
+	sector_t zone_sectors = bdev_zone_sectors(bdev);
 
-	if (!blk_queue_is_zoned(disk->queue))
+	if (!blk_queue_is_zoned(bdev_get_queue(bdev)))
 		return 0;
-	return (get_capacity(disk) + zone_sectors - 1) >> ilog2(zone_sectors);
+	return (bdev_nr_sectors(bdev) + zone_sectors - 1) >>
+		ilog2(zone_sectors);
 }
-EXPORT_SYMBOL_GPL(blkdev_nr_zones);
+EXPORT_SYMBOL_GPL(bdev_nr_zones);
 
 /**
  * blkdev_report_zones - Get zones information
diff --git a/block/ioctl.c b/block/ioctl.c
index 46949f1b0dba5..60121e89052bc 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -495,7 +495,7 @@ static int blkdev_common_ioctl(struct block_device *bdev, fmode_t mode,
 	case BLKGETZONESZ:
 		return put_uint(argp, bdev_zone_sectors(bdev));
 	case BLKGETNRZONES:
-		return put_uint(argp, blkdev_nr_zones(bdev->bd_disk));
+		return put_uint(argp, bdev_nr_zones(bdev));
 	case BLKROGET:
 		return put_int(argp, bdev_read_only(bdev) != 0);
 	case BLKSSZGET: /* get block device logical block size */
diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c
index 576ab3ed082a5..e62c52e964259 100644
--- a/drivers/block/null_blk/zoned.c
+++ b/drivers/block/null_blk/zoned.c
@@ -170,7 +170,7 @@ int null_register_zoned_dev(struct nullb *nullb)
 			return ret;
 	} else {
 		blk_queue_chunk_sectors(q, dev->zone_size_sects);
-		q->nr_zones = blkdev_nr_zones(nullb->disk);
+		q->nr_zones = bdev_nr_zones(nullb->disk->part0);
 	}
 
 	blk_queue_max_zone_append_sectors(q, dev->zone_size_sects);
diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c
index ae616b87c91ae..6d105abe12415 100644
--- a/drivers/md/dm-zone.c
+++ b/drivers/md/dm-zone.c
@@ -301,7 +301,7 @@ int dm_set_zones_restrictions(struct dm_table *t, struct request_queue *q)
 	 * correct value to be exposed in sysfs queue/nr_zones.
 	 */
 	WARN_ON_ONCE(queue_is_mq(q));
-	q->nr_zones = blkdev_nr_zones(md->disk);
+	q->nr_zones = bdev_nr_zones(md->disk->part0);
 
 	/* Check if zone append is natively supported */
 	if (dm_table_supports_zone_append(t)) {
diff --git a/drivers/md/dm-zoned-target.c b/drivers/md/dm-zoned-target.c
index 0ec5d8b9b1a4e..6ba6ef44b00e2 100644
--- a/drivers/md/dm-zoned-target.c
+++ b/drivers/md/dm-zoned-target.c
@@ -793,8 +793,7 @@ static int dmz_fixup_devices(struct dm_target *ti)
 			}
 			zone_nr_sectors = blk_queue_zone_sectors(q);
 			zoned_dev->zone_nr_sectors = zone_nr_sectors;
-			zoned_dev->nr_zones =
-				blkdev_nr_zones(zoned_dev->bdev->bd_disk);
+			zoned_dev->nr_zones = bdev_nr_zones(zoned_dev->bdev);
 		}
 	} else {
 		reg_dev = NULL;
@@ -805,7 +804,7 @@ static int dmz_fixup_devices(struct dm_target *ti)
 		}
 		q = bdev_get_queue(zoned_dev->bdev);
 		zoned_dev->zone_nr_sectors = blk_queue_zone_sectors(q);
-		zoned_dev->nr_zones = blkdev_nr_zones(zoned_dev->bdev->bd_disk);
+		zoned_dev->nr_zones = bdev_nr_zones(zoned_dev->bdev);
 	}
 
 	if (reg_dev) {
diff --git a/drivers/nvme/target/zns.c b/drivers/nvme/target/zns.c
index c6f0a775efdee..c9b2ce06ca93e 100644
--- a/drivers/nvme/target/zns.c
+++ b/drivers/nvme/target/zns.c
@@ -60,7 +60,7 @@ bool nvmet_bdev_zns_enable(struct nvmet_ns *ns)
 	if (ns->bdev->bd_disk->queue->conv_zones_bitmap)
 		return false;
 
-	ret = blkdev_report_zones(ns->bdev, 0, blkdev_nr_zones(bd_disk),
+	ret = blkdev_report_zones(ns->bdev, 0, bdev_nr_zones(ns->bdev),
 				  validate_conv_zones_cb, NULL);
 	if (ret < 0)
 		return false;
@@ -241,7 +241,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 blkdev_nr_zones(req->ns->bdev->bd_disk) -
+	return bdev_nr_zones(req->ns->bdev) -
 		(sect >> ilog2(bdev_zone_sectors(req->ns->bdev)));
 }
 
diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
index 053299758deb9..9c0eef1ff32a0 100644
--- a/fs/zonefs/super.c
+++ b/fs/zonefs/super.c
@@ -1394,7 +1394,7 @@ static void zonefs_init_dir_inode(struct inode *parent, struct inode *inode,
 {
 	struct super_block *sb = parent->i_sb;
 
-	inode->i_ino = blkdev_nr_zones(sb->s_bdev->bd_disk) + type + 1;
+	inode->i_ino = bdev_nr_zones(sb->s_bdev) + type + 1;
 	inode_init_owner(&init_user_ns, inode, parent, S_IFDIR | 0555);
 	inode->i_op = &zonefs_dir_inode_operations;
 	inode->i_fop = &simple_dir_operations;
@@ -1540,7 +1540,7 @@ static int zonefs_create_zgroup(struct zonefs_zone_data *zd,
 	/*
 	 * The first zone contains the super block: skip it.
 	 */
-	end = zd->zones + blkdev_nr_zones(sb->s_bdev->bd_disk);
+	end = zd->zones + bdev_nr_zones(sb->s_bdev);
 	for (zone = &zd->zones[1]; zone < end; zone = next) {
 
 		next = zone + 1;
@@ -1635,8 +1635,8 @@ static int zonefs_get_zone_info(struct zonefs_zone_data *zd)
 	struct block_device *bdev = zd->sb->s_bdev;
 	int ret;
 
-	zd->zones = kvcalloc(blkdev_nr_zones(bdev->bd_disk),
-			     sizeof(struct blk_zone), GFP_KERNEL);
+	zd->zones = kvcalloc(bdev_nr_zones(bdev), sizeof(struct blk_zone),
+			     GFP_KERNEL);
 	if (!zd->zones)
 		return -ENOMEM;
 
@@ -1648,9 +1648,9 @@ static int zonefs_get_zone_info(struct zonefs_zone_data *zd)
 		return ret;
 	}
 
-	if (ret != blkdev_nr_zones(bdev->bd_disk)) {
+	if (ret != bdev_nr_zones(bdev)) {
 		zonefs_err(zd->sb, "Invalid zone report (%d/%u zones)\n",
-			   ret, blkdev_nr_zones(bdev->bd_disk));
+			   ret, bdev_nr_zones(bdev));
 		return -EIO;
 	}
 
@@ -1816,8 +1816,7 @@ static int zonefs_fill_super(struct super_block *sb, void *data, int silent)
 	if (ret)
 		goto cleanup;
 
-	zonefs_info(sb, "Mounting %u zones",
-		    blkdev_nr_zones(sb->s_bdev->bd_disk));
+	zonefs_info(sb, "Mounting %u zones", bdev_nr_zones(sb->s_bdev));
 
 	if (!sbi->s_max_wro_seq_files &&
 	    !sbi->s_max_active_seq_files &&
@@ -1833,7 +1832,7 @@ static int zonefs_fill_super(struct super_block *sb, void *data, int silent)
 	if (!inode)
 		goto cleanup;
 
-	inode->i_ino = blkdev_nr_zones(sb->s_bdev->bd_disk);
+	inode->i_ino = bdev_nr_zones(sb->s_bdev);
 	inode->i_mode = S_IFDIR | 0555;
 	inode->i_ctime = inode->i_mtime = inode->i_atime = current_time(inode);
 	inode->i_op = &zonefs_dir_inode_operations;
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index e32c147f72868..183aa83143fd2 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -298,7 +298,7 @@ void disk_set_zoned(struct gendisk *disk, enum blk_zoned_model model);
 #define BLK_ALL_ZONES  ((unsigned int)-1)
 int blkdev_report_zones(struct block_device *bdev, sector_t sector,
 			unsigned int nr_zones, report_zones_cb cb, void *data);
-unsigned int blkdev_nr_zones(struct gendisk *disk);
+unsigned int bdev_nr_zones(struct block_device *bdev);
 extern int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op,
 			    sector_t sectors, sector_t nr_sectors,
 			    gfp_t gfp_mask);
@@ -314,7 +314,7 @@ extern int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
 
 #else /* CONFIG_BLK_DEV_ZONED */
 
-static inline unsigned int blkdev_nr_zones(struct gendisk *disk)
+static inline unsigned int bdev_nr_zones(struct block_device *bdev)
 {
 	return 0;
 }
-- 
2.30.2


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

* [dm-devel] [PATCH 13/17] block: replace blkdev_nr_zones with bdev_nr_zones
@ 2022-07-04 12:44   ` Christoph Hellwig
  0 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:44 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: linux-block, dm-devel, linux-scsi, linux-nvme

Pass a block_device instead of a request_queue a that is what most
callers have at hand.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-zoned.c              | 15 ++++++++-------
 block/ioctl.c                  |  2 +-
 drivers/block/null_blk/zoned.c |  2 +-
 drivers/md/dm-zone.c           |  2 +-
 drivers/md/dm-zoned-target.c   |  5 ++---
 drivers/nvme/target/zns.c      |  4 ++--
 fs/zonefs/super.c              | 17 ++++++++---------
 include/linux/blkdev.h         |  4 ++--
 8 files changed, 25 insertions(+), 26 deletions(-)

diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 9085f9fb3ab42..836b96ebfdc04 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -108,21 +108,22 @@ void __blk_req_zone_write_unlock(struct request *rq)
 EXPORT_SYMBOL_GPL(__blk_req_zone_write_unlock);
 
 /**
- * blkdev_nr_zones - Get number of zones
- * @disk:	Target gendisk
+ * bdev_nr_zones - Get number of zones
+ * @bdev:	Target device
  *
  * Return the total number of zones of a zoned block device.  For a block
  * device without zone capabilities, the number of zones is always 0.
  */
-unsigned int blkdev_nr_zones(struct gendisk *disk)
+unsigned int bdev_nr_zones(struct block_device *bdev)
 {
-	sector_t zone_sectors = blk_queue_zone_sectors(disk->queue);
+	sector_t zone_sectors = bdev_zone_sectors(bdev);
 
-	if (!blk_queue_is_zoned(disk->queue))
+	if (!blk_queue_is_zoned(bdev_get_queue(bdev)))
 		return 0;
-	return (get_capacity(disk) + zone_sectors - 1) >> ilog2(zone_sectors);
+	return (bdev_nr_sectors(bdev) + zone_sectors - 1) >>
+		ilog2(zone_sectors);
 }
-EXPORT_SYMBOL_GPL(blkdev_nr_zones);
+EXPORT_SYMBOL_GPL(bdev_nr_zones);
 
 /**
  * blkdev_report_zones - Get zones information
diff --git a/block/ioctl.c b/block/ioctl.c
index 46949f1b0dba5..60121e89052bc 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -495,7 +495,7 @@ static int blkdev_common_ioctl(struct block_device *bdev, fmode_t mode,
 	case BLKGETZONESZ:
 		return put_uint(argp, bdev_zone_sectors(bdev));
 	case BLKGETNRZONES:
-		return put_uint(argp, blkdev_nr_zones(bdev->bd_disk));
+		return put_uint(argp, bdev_nr_zones(bdev));
 	case BLKROGET:
 		return put_int(argp, bdev_read_only(bdev) != 0);
 	case BLKSSZGET: /* get block device logical block size */
diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c
index 576ab3ed082a5..e62c52e964259 100644
--- a/drivers/block/null_blk/zoned.c
+++ b/drivers/block/null_blk/zoned.c
@@ -170,7 +170,7 @@ int null_register_zoned_dev(struct nullb *nullb)
 			return ret;
 	} else {
 		blk_queue_chunk_sectors(q, dev->zone_size_sects);
-		q->nr_zones = blkdev_nr_zones(nullb->disk);
+		q->nr_zones = bdev_nr_zones(nullb->disk->part0);
 	}
 
 	blk_queue_max_zone_append_sectors(q, dev->zone_size_sects);
diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c
index ae616b87c91ae..6d105abe12415 100644
--- a/drivers/md/dm-zone.c
+++ b/drivers/md/dm-zone.c
@@ -301,7 +301,7 @@ int dm_set_zones_restrictions(struct dm_table *t, struct request_queue *q)
 	 * correct value to be exposed in sysfs queue/nr_zones.
 	 */
 	WARN_ON_ONCE(queue_is_mq(q));
-	q->nr_zones = blkdev_nr_zones(md->disk);
+	q->nr_zones = bdev_nr_zones(md->disk->part0);
 
 	/* Check if zone append is natively supported */
 	if (dm_table_supports_zone_append(t)) {
diff --git a/drivers/md/dm-zoned-target.c b/drivers/md/dm-zoned-target.c
index 0ec5d8b9b1a4e..6ba6ef44b00e2 100644
--- a/drivers/md/dm-zoned-target.c
+++ b/drivers/md/dm-zoned-target.c
@@ -793,8 +793,7 @@ static int dmz_fixup_devices(struct dm_target *ti)
 			}
 			zone_nr_sectors = blk_queue_zone_sectors(q);
 			zoned_dev->zone_nr_sectors = zone_nr_sectors;
-			zoned_dev->nr_zones =
-				blkdev_nr_zones(zoned_dev->bdev->bd_disk);
+			zoned_dev->nr_zones = bdev_nr_zones(zoned_dev->bdev);
 		}
 	} else {
 		reg_dev = NULL;
@@ -805,7 +804,7 @@ static int dmz_fixup_devices(struct dm_target *ti)
 		}
 		q = bdev_get_queue(zoned_dev->bdev);
 		zoned_dev->zone_nr_sectors = blk_queue_zone_sectors(q);
-		zoned_dev->nr_zones = blkdev_nr_zones(zoned_dev->bdev->bd_disk);
+		zoned_dev->nr_zones = bdev_nr_zones(zoned_dev->bdev);
 	}
 
 	if (reg_dev) {
diff --git a/drivers/nvme/target/zns.c b/drivers/nvme/target/zns.c
index c6f0a775efdee..c9b2ce06ca93e 100644
--- a/drivers/nvme/target/zns.c
+++ b/drivers/nvme/target/zns.c
@@ -60,7 +60,7 @@ bool nvmet_bdev_zns_enable(struct nvmet_ns *ns)
 	if (ns->bdev->bd_disk->queue->conv_zones_bitmap)
 		return false;
 
-	ret = blkdev_report_zones(ns->bdev, 0, blkdev_nr_zones(bd_disk),
+	ret = blkdev_report_zones(ns->bdev, 0, bdev_nr_zones(ns->bdev),
 				  validate_conv_zones_cb, NULL);
 	if (ret < 0)
 		return false;
@@ -241,7 +241,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 blkdev_nr_zones(req->ns->bdev->bd_disk) -
+	return bdev_nr_zones(req->ns->bdev) -
 		(sect >> ilog2(bdev_zone_sectors(req->ns->bdev)));
 }
 
diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
index 053299758deb9..9c0eef1ff32a0 100644
--- a/fs/zonefs/super.c
+++ b/fs/zonefs/super.c
@@ -1394,7 +1394,7 @@ static void zonefs_init_dir_inode(struct inode *parent, struct inode *inode,
 {
 	struct super_block *sb = parent->i_sb;
 
-	inode->i_ino = blkdev_nr_zones(sb->s_bdev->bd_disk) + type + 1;
+	inode->i_ino = bdev_nr_zones(sb->s_bdev) + type + 1;
 	inode_init_owner(&init_user_ns, inode, parent, S_IFDIR | 0555);
 	inode->i_op = &zonefs_dir_inode_operations;
 	inode->i_fop = &simple_dir_operations;
@@ -1540,7 +1540,7 @@ static int zonefs_create_zgroup(struct zonefs_zone_data *zd,
 	/*
 	 * The first zone contains the super block: skip it.
 	 */
-	end = zd->zones + blkdev_nr_zones(sb->s_bdev->bd_disk);
+	end = zd->zones + bdev_nr_zones(sb->s_bdev);
 	for (zone = &zd->zones[1]; zone < end; zone = next) {
 
 		next = zone + 1;
@@ -1635,8 +1635,8 @@ static int zonefs_get_zone_info(struct zonefs_zone_data *zd)
 	struct block_device *bdev = zd->sb->s_bdev;
 	int ret;
 
-	zd->zones = kvcalloc(blkdev_nr_zones(bdev->bd_disk),
-			     sizeof(struct blk_zone), GFP_KERNEL);
+	zd->zones = kvcalloc(bdev_nr_zones(bdev), sizeof(struct blk_zone),
+			     GFP_KERNEL);
 	if (!zd->zones)
 		return -ENOMEM;
 
@@ -1648,9 +1648,9 @@ static int zonefs_get_zone_info(struct zonefs_zone_data *zd)
 		return ret;
 	}
 
-	if (ret != blkdev_nr_zones(bdev->bd_disk)) {
+	if (ret != bdev_nr_zones(bdev)) {
 		zonefs_err(zd->sb, "Invalid zone report (%d/%u zones)\n",
-			   ret, blkdev_nr_zones(bdev->bd_disk));
+			   ret, bdev_nr_zones(bdev));
 		return -EIO;
 	}
 
@@ -1816,8 +1816,7 @@ static int zonefs_fill_super(struct super_block *sb, void *data, int silent)
 	if (ret)
 		goto cleanup;
 
-	zonefs_info(sb, "Mounting %u zones",
-		    blkdev_nr_zones(sb->s_bdev->bd_disk));
+	zonefs_info(sb, "Mounting %u zones", bdev_nr_zones(sb->s_bdev));
 
 	if (!sbi->s_max_wro_seq_files &&
 	    !sbi->s_max_active_seq_files &&
@@ -1833,7 +1832,7 @@ static int zonefs_fill_super(struct super_block *sb, void *data, int silent)
 	if (!inode)
 		goto cleanup;
 
-	inode->i_ino = blkdev_nr_zones(sb->s_bdev->bd_disk);
+	inode->i_ino = bdev_nr_zones(sb->s_bdev);
 	inode->i_mode = S_IFDIR | 0555;
 	inode->i_ctime = inode->i_mtime = inode->i_atime = current_time(inode);
 	inode->i_op = &zonefs_dir_inode_operations;
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index e32c147f72868..183aa83143fd2 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -298,7 +298,7 @@ void disk_set_zoned(struct gendisk *disk, enum blk_zoned_model model);
 #define BLK_ALL_ZONES  ((unsigned int)-1)
 int blkdev_report_zones(struct block_device *bdev, sector_t sector,
 			unsigned int nr_zones, report_zones_cb cb, void *data);
-unsigned int blkdev_nr_zones(struct gendisk *disk);
+unsigned int bdev_nr_zones(struct block_device *bdev);
 extern int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op,
 			    sector_t sectors, sector_t nr_sectors,
 			    gfp_t gfp_mask);
@@ -314,7 +314,7 @@ extern int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
 
 #else /* CONFIG_BLK_DEV_ZONED */
 
-static inline unsigned int blkdev_nr_zones(struct gendisk *disk)
+static inline unsigned int bdev_nr_zones(struct block_device *bdev)
 {
 	return 0;
 }
-- 
2.30.2

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


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

* [PATCH 14/17] block: use bdev based helpers in blkdev_zone_mgmt / blkdev_zone_mgmt_all
  2022-07-04 12:44 ` [dm-devel] " Christoph Hellwig
@ 2022-07-04 12:44   ` Christoph Hellwig
  -1 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:44 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: dm-devel, linux-block, linux-nvme, linux-scsi

Use the bdev based helpers instead of the queue based ones to clean up
the code a bit and prepare for storing all zone related fields in
struct gendisk.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-zoned.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 836b96ebfdc04..ee8752f083a94 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -190,8 +190,8 @@ int blkdev_zone_mgmt_all(struct block_device *bdev, unsigned int op,
 			 gfp_t gfp_mask)
 {
 	struct request_queue *q = bdev_get_queue(bdev);
-	sector_t capacity = get_capacity(bdev->bd_disk);
-	sector_t zone_sectors = blk_queue_zone_sectors(q);
+	sector_t capacity = bdev_nr_sectors(bdev);
+	sector_t zone_sectors = bdev_zone_sectors(bdev);
 	unsigned long *need_reset;
 	struct bio *bio = NULL;
 	sector_t sector = 0;
@@ -262,8 +262,8 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op,
 		     gfp_t gfp_mask)
 {
 	struct request_queue *q = bdev_get_queue(bdev);
-	sector_t zone_sectors = blk_queue_zone_sectors(q);
-	sector_t capacity = get_capacity(bdev->bd_disk);
+	sector_t zone_sectors = bdev_zone_sectors(bdev);
+	sector_t capacity = bdev_nr_sectors(bdev);
 	sector_t end_sector = sector + nr_sectors;
 	struct bio *bio = NULL;
 	int ret = 0;
-- 
2.30.2


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

* [dm-devel] [PATCH 14/17] block: use bdev based helpers in blkdev_zone_mgmt / blkdev_zone_mgmt_all
@ 2022-07-04 12:44   ` Christoph Hellwig
  0 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:44 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: linux-block, dm-devel, linux-scsi, linux-nvme

Use the bdev based helpers instead of the queue based ones to clean up
the code a bit and prepare for storing all zone related fields in
struct gendisk.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-zoned.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 836b96ebfdc04..ee8752f083a94 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -190,8 +190,8 @@ int blkdev_zone_mgmt_all(struct block_device *bdev, unsigned int op,
 			 gfp_t gfp_mask)
 {
 	struct request_queue *q = bdev_get_queue(bdev);
-	sector_t capacity = get_capacity(bdev->bd_disk);
-	sector_t zone_sectors = blk_queue_zone_sectors(q);
+	sector_t capacity = bdev_nr_sectors(bdev);
+	sector_t zone_sectors = bdev_zone_sectors(bdev);
 	unsigned long *need_reset;
 	struct bio *bio = NULL;
 	sector_t sector = 0;
@@ -262,8 +262,8 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op,
 		     gfp_t gfp_mask)
 {
 	struct request_queue *q = bdev_get_queue(bdev);
-	sector_t zone_sectors = blk_queue_zone_sectors(q);
-	sector_t capacity = get_capacity(bdev->bd_disk);
+	sector_t zone_sectors = bdev_zone_sectors(bdev);
+	sector_t capacity = bdev_nr_sectors(bdev);
 	sector_t end_sector = sector + nr_sectors;
 	struct bio *bio = NULL;
 	int ret = 0;
-- 
2.30.2

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


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

* [PATCH 15/17] dm-zoned: cleanup dmz_fixup_devices
  2022-07-04 12:44 ` [dm-devel] " Christoph Hellwig
@ 2022-07-04 12:44   ` Christoph Hellwig
  -1 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:44 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: dm-devel, linux-block, linux-nvme, linux-scsi

Use the bdev based helpers where applicable and move the zoned_dev
into the scope where it is actually used.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/md/dm-zoned-target.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/md/dm-zoned-target.c b/drivers/md/dm-zoned-target.c
index 6ba6ef44b00e2..95b132b52f332 100644
--- a/drivers/md/dm-zoned-target.c
+++ b/drivers/md/dm-zoned-target.c
@@ -764,8 +764,7 @@ static void dmz_put_zoned_device(struct dm_target *ti)
 static int dmz_fixup_devices(struct dm_target *ti)
 {
 	struct dmz_target *dmz = ti->private;
-	struct dmz_dev *reg_dev, *zoned_dev;
-	struct request_queue *q;
+	struct dmz_dev *reg_dev = NULL;
 	sector_t zone_nr_sectors = 0;
 	int i;
 
@@ -780,31 +779,32 @@ static int dmz_fixup_devices(struct dm_target *ti)
 			return -EINVAL;
 		}
 		for (i = 1; i < dmz->nr_ddevs; i++) {
-			zoned_dev = &dmz->dev[i];
+			struct dmz_dev *zoned_dev = &dmz->dev[i];
+			struct block_device *bdev = zoned_dev->bdev;
+
 			if (zoned_dev->flags & DMZ_BDEV_REGULAR) {
 				ti->error = "Secondary disk is not a zoned device";
 				return -EINVAL;
 			}
-			q = bdev_get_queue(zoned_dev->bdev);
 			if (zone_nr_sectors &&
-			    zone_nr_sectors != blk_queue_zone_sectors(q)) {
+			    zone_nr_sectors != bdev_zone_sectors(bdev)) {
 				ti->error = "Zone nr sectors mismatch";
 				return -EINVAL;
 			}
-			zone_nr_sectors = blk_queue_zone_sectors(q);
+			zone_nr_sectors = bdev_zone_sectors(bdev);
 			zoned_dev->zone_nr_sectors = zone_nr_sectors;
-			zoned_dev->nr_zones = bdev_nr_zones(zoned_dev->bdev);
+			zoned_dev->nr_zones = bdev_nr_zones(bdev);
 		}
 	} else {
-		reg_dev = NULL;
-		zoned_dev = &dmz->dev[0];
+		struct dmz_dev *zoned_dev = &dmz->dev[0];
+		struct block_device *bdev = zoned_dev->bdev;
+
 		if (zoned_dev->flags & DMZ_BDEV_REGULAR) {
 			ti->error = "Disk is not a zoned device";
 			return -EINVAL;
 		}
-		q = bdev_get_queue(zoned_dev->bdev);
-		zoned_dev->zone_nr_sectors = blk_queue_zone_sectors(q);
-		zoned_dev->nr_zones = bdev_nr_zones(zoned_dev->bdev);
+		zoned_dev->zone_nr_sectors = bdev_zone_sectors(bdev);
+		zoned_dev->nr_zones = bdev_nr_zones(bdev);
 	}
 
 	if (reg_dev) {
-- 
2.30.2


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

* [dm-devel] [PATCH 15/17] dm-zoned: cleanup dmz_fixup_devices
@ 2022-07-04 12:44   ` Christoph Hellwig
  0 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:44 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: linux-block, dm-devel, linux-scsi, linux-nvme

Use the bdev based helpers where applicable and move the zoned_dev
into the scope where it is actually used.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/md/dm-zoned-target.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/md/dm-zoned-target.c b/drivers/md/dm-zoned-target.c
index 6ba6ef44b00e2..95b132b52f332 100644
--- a/drivers/md/dm-zoned-target.c
+++ b/drivers/md/dm-zoned-target.c
@@ -764,8 +764,7 @@ static void dmz_put_zoned_device(struct dm_target *ti)
 static int dmz_fixup_devices(struct dm_target *ti)
 {
 	struct dmz_target *dmz = ti->private;
-	struct dmz_dev *reg_dev, *zoned_dev;
-	struct request_queue *q;
+	struct dmz_dev *reg_dev = NULL;
 	sector_t zone_nr_sectors = 0;
 	int i;
 
@@ -780,31 +779,32 @@ static int dmz_fixup_devices(struct dm_target *ti)
 			return -EINVAL;
 		}
 		for (i = 1; i < dmz->nr_ddevs; i++) {
-			zoned_dev = &dmz->dev[i];
+			struct dmz_dev *zoned_dev = &dmz->dev[i];
+			struct block_device *bdev = zoned_dev->bdev;
+
 			if (zoned_dev->flags & DMZ_BDEV_REGULAR) {
 				ti->error = "Secondary disk is not a zoned device";
 				return -EINVAL;
 			}
-			q = bdev_get_queue(zoned_dev->bdev);
 			if (zone_nr_sectors &&
-			    zone_nr_sectors != blk_queue_zone_sectors(q)) {
+			    zone_nr_sectors != bdev_zone_sectors(bdev)) {
 				ti->error = "Zone nr sectors mismatch";
 				return -EINVAL;
 			}
-			zone_nr_sectors = blk_queue_zone_sectors(q);
+			zone_nr_sectors = bdev_zone_sectors(bdev);
 			zoned_dev->zone_nr_sectors = zone_nr_sectors;
-			zoned_dev->nr_zones = bdev_nr_zones(zoned_dev->bdev);
+			zoned_dev->nr_zones = bdev_nr_zones(bdev);
 		}
 	} else {
-		reg_dev = NULL;
-		zoned_dev = &dmz->dev[0];
+		struct dmz_dev *zoned_dev = &dmz->dev[0];
+		struct block_device *bdev = zoned_dev->bdev;
+
 		if (zoned_dev->flags & DMZ_BDEV_REGULAR) {
 			ti->error = "Disk is not a zoned device";
 			return -EINVAL;
 		}
-		q = bdev_get_queue(zoned_dev->bdev);
-		zoned_dev->zone_nr_sectors = blk_queue_zone_sectors(q);
-		zoned_dev->nr_zones = bdev_nr_zones(zoned_dev->bdev);
+		zoned_dev->zone_nr_sectors = bdev_zone_sectors(bdev);
+		zoned_dev->nr_zones = bdev_nr_zones(bdev);
 	}
 
 	if (reg_dev) {
-- 
2.30.2

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


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

* [PATCH 16/17] block: remove blk_queue_zone_sectors
  2022-07-04 12:44 ` [dm-devel] " Christoph Hellwig
@ 2022-07-04 12:44   ` Christoph Hellwig
  -1 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:44 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: dm-devel, linux-block, linux-nvme, linux-scsi

Always use bdev_zone_sectors instead.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/md/dm-table.c  |  4 +---
 drivers/md/dm-zone.c   | 10 ++++++----
 include/linux/blkdev.h | 11 +++--------
 3 files changed, 10 insertions(+), 15 deletions(-)

diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index b36b528e56cff..df904b7e95ce3 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -1620,13 +1620,11 @@ static bool dm_table_supports_zoned_model(struct dm_table *t,
 static int device_not_matches_zone_sectors(struct dm_target *ti, struct dm_dev *dev,
 					   sector_t start, sector_t len, void *data)
 {
-	struct request_queue *q = bdev_get_queue(dev->bdev);
 	unsigned int *zone_sectors = data;
 
 	if (!bdev_is_zoned(dev->bdev))
 		return 0;
-
-	return blk_queue_zone_sectors(q) != *zone_sectors;
+	return bdev_zone_sectors(dev->bdev) != *zone_sectors;
 }
 
 /*
diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c
index 6d105abe12415..842c31019b513 100644
--- a/drivers/md/dm-zone.c
+++ b/drivers/md/dm-zone.c
@@ -334,7 +334,7 @@ static int dm_update_zone_wp_offset_cb(struct blk_zone *zone, unsigned int idx,
 static int dm_update_zone_wp_offset(struct mapped_device *md, unsigned int zno,
 				    unsigned int *wp_ofst)
 {
-	sector_t sector = zno * blk_queue_zone_sectors(md->queue);
+	sector_t sector = zno * bdev_zone_sectors(md->disk->part0);
 	unsigned int noio_flag;
 	struct dm_table *t;
 	int srcu_idx, ret;
@@ -373,7 +373,7 @@ struct orig_bio_details {
 static bool dm_zone_map_bio_begin(struct mapped_device *md,
 				  unsigned int zno, struct bio *clone)
 {
-	sector_t zsectors = blk_queue_zone_sectors(md->queue);
+	sector_t zsectors = bdev_zone_sectors(md->disk->part0);
 	unsigned int zwp_offset = READ_ONCE(md->zwp_offset[zno]);
 
 	/*
@@ -443,7 +443,7 @@ static blk_status_t dm_zone_map_bio_end(struct mapped_device *md, unsigned int z
 		return BLK_STS_OK;
 	case REQ_OP_ZONE_FINISH:
 		WRITE_ONCE(md->zwp_offset[zno],
-			   blk_queue_zone_sectors(md->queue));
+			   bdev_zone_sectors(md->disk->part0));
 		return BLK_STS_OK;
 	case REQ_OP_WRITE_ZEROES:
 	case REQ_OP_WRITE:
@@ -593,6 +593,7 @@ void dm_zone_endio(struct dm_io *io, struct bio *clone)
 {
 	struct mapped_device *md = io->md;
 	struct request_queue *q = md->queue;
+	struct gendisk *disk = md->disk;
 	struct bio *orig_bio = io->orig_bio;
 	unsigned int zwp_offset;
 	unsigned int zno;
@@ -608,7 +609,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)blk_queue_zone_sectors(q) - 1;
+			sector_t mask =
+				(sector_t)bdev_zone_sectors(disk->part0) - 1;
 
 			orig_bio->bi_iter.bi_sector +=
 				clone->bi_iter.bi_sector & mask;
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 183aa83143fd2..f1eca3f5610eb 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -669,11 +669,6 @@ static inline bool blk_queue_is_zoned(struct request_queue *q)
 	}
 }
 
-static inline sector_t blk_queue_zone_sectors(struct request_queue *q)
-{
-	return blk_queue_is_zoned(q) ? q->limits.chunk_sectors : 0;
-}
-
 #ifdef CONFIG_BLK_DEV_ZONED
 static inline unsigned int blk_queue_nr_zones(struct request_queue *q)
 {
@@ -1312,9 +1307,9 @@ static inline sector_t bdev_zone_sectors(struct block_device *bdev)
 {
 	struct request_queue *q = bdev_get_queue(bdev);
 
-	if (q)
-		return blk_queue_zone_sectors(q);
-	return 0;
+	if (!blk_queue_is_zoned(q))
+		return 0;
+	return q->limits.chunk_sectors;
 }
 
 static inline int queue_dma_alignment(const struct request_queue *q)
-- 
2.30.2


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

* [dm-devel] [PATCH 16/17] block: remove blk_queue_zone_sectors
@ 2022-07-04 12:44   ` Christoph Hellwig
  0 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:44 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: linux-block, dm-devel, linux-scsi, linux-nvme

Always use bdev_zone_sectors instead.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/md/dm-table.c  |  4 +---
 drivers/md/dm-zone.c   | 10 ++++++----
 include/linux/blkdev.h | 11 +++--------
 3 files changed, 10 insertions(+), 15 deletions(-)

diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index b36b528e56cff..df904b7e95ce3 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -1620,13 +1620,11 @@ static bool dm_table_supports_zoned_model(struct dm_table *t,
 static int device_not_matches_zone_sectors(struct dm_target *ti, struct dm_dev *dev,
 					   sector_t start, sector_t len, void *data)
 {
-	struct request_queue *q = bdev_get_queue(dev->bdev);
 	unsigned int *zone_sectors = data;
 
 	if (!bdev_is_zoned(dev->bdev))
 		return 0;
-
-	return blk_queue_zone_sectors(q) != *zone_sectors;
+	return bdev_zone_sectors(dev->bdev) != *zone_sectors;
 }
 
 /*
diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c
index 6d105abe12415..842c31019b513 100644
--- a/drivers/md/dm-zone.c
+++ b/drivers/md/dm-zone.c
@@ -334,7 +334,7 @@ static int dm_update_zone_wp_offset_cb(struct blk_zone *zone, unsigned int idx,
 static int dm_update_zone_wp_offset(struct mapped_device *md, unsigned int zno,
 				    unsigned int *wp_ofst)
 {
-	sector_t sector = zno * blk_queue_zone_sectors(md->queue);
+	sector_t sector = zno * bdev_zone_sectors(md->disk->part0);
 	unsigned int noio_flag;
 	struct dm_table *t;
 	int srcu_idx, ret;
@@ -373,7 +373,7 @@ struct orig_bio_details {
 static bool dm_zone_map_bio_begin(struct mapped_device *md,
 				  unsigned int zno, struct bio *clone)
 {
-	sector_t zsectors = blk_queue_zone_sectors(md->queue);
+	sector_t zsectors = bdev_zone_sectors(md->disk->part0);
 	unsigned int zwp_offset = READ_ONCE(md->zwp_offset[zno]);
 
 	/*
@@ -443,7 +443,7 @@ static blk_status_t dm_zone_map_bio_end(struct mapped_device *md, unsigned int z
 		return BLK_STS_OK;
 	case REQ_OP_ZONE_FINISH:
 		WRITE_ONCE(md->zwp_offset[zno],
-			   blk_queue_zone_sectors(md->queue));
+			   bdev_zone_sectors(md->disk->part0));
 		return BLK_STS_OK;
 	case REQ_OP_WRITE_ZEROES:
 	case REQ_OP_WRITE:
@@ -593,6 +593,7 @@ void dm_zone_endio(struct dm_io *io, struct bio *clone)
 {
 	struct mapped_device *md = io->md;
 	struct request_queue *q = md->queue;
+	struct gendisk *disk = md->disk;
 	struct bio *orig_bio = io->orig_bio;
 	unsigned int zwp_offset;
 	unsigned int zno;
@@ -608,7 +609,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)blk_queue_zone_sectors(q) - 1;
+			sector_t mask =
+				(sector_t)bdev_zone_sectors(disk->part0) - 1;
 
 			orig_bio->bi_iter.bi_sector +=
 				clone->bi_iter.bi_sector & mask;
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 183aa83143fd2..f1eca3f5610eb 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -669,11 +669,6 @@ static inline bool blk_queue_is_zoned(struct request_queue *q)
 	}
 }
 
-static inline sector_t blk_queue_zone_sectors(struct request_queue *q)
-{
-	return blk_queue_is_zoned(q) ? q->limits.chunk_sectors : 0;
-}
-
 #ifdef CONFIG_BLK_DEV_ZONED
 static inline unsigned int blk_queue_nr_zones(struct request_queue *q)
 {
@@ -1312,9 +1307,9 @@ static inline sector_t bdev_zone_sectors(struct block_device *bdev)
 {
 	struct request_queue *q = bdev_get_queue(bdev);
 
-	if (q)
-		return blk_queue_zone_sectors(q);
-	return 0;
+	if (!blk_queue_is_zoned(q))
+		return 0;
+	return q->limits.chunk_sectors;
 }
 
 static inline int queue_dma_alignment(const struct request_queue *q)
-- 
2.30.2

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


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

* [PATCH 17/17] block: move zone related fields to struct gendisk
  2022-07-04 12:44 ` [dm-devel] " Christoph Hellwig
@ 2022-07-04 12:45   ` Christoph Hellwig
  -1 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:45 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: dm-devel, linux-block, linux-nvme, linux-scsi

Move the zone related fields that are currently stored in
struct request_queue to struct gendisk as these are part of the highlevel
block layer API and are only used for non-passthrough I/O that requires
the gendisk.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-mq-debugfs-zoned.c   |  6 +--
 block/blk-sysfs.c              |  2 +-
 block/blk-zoned.c              | 45 ++++++++---------
 drivers/block/null_blk/zoned.c |  2 +-
 drivers/md/dm-zone.c           | 74 +++++++++++++--------------
 drivers/nvme/host/multipath.c  |  2 +-
 drivers/nvme/target/zns.c      |  2 +-
 drivers/scsi/sd_zbc.c          |  2 +-
 include/linux/blk-mq.h         |  8 +--
 include/linux/blkdev.h         | 91 ++++++++++++++++------------------
 10 files changed, 110 insertions(+), 124 deletions(-)

diff --git a/block/blk-mq-debugfs-zoned.c b/block/blk-mq-debugfs-zoned.c
index 038cb627c8689..a77b099c34b7a 100644
--- a/block/blk-mq-debugfs-zoned.c
+++ b/block/blk-mq-debugfs-zoned.c
@@ -11,11 +11,11 @@ int queue_zone_wlock_show(void *data, struct seq_file *m)
 	struct request_queue *q = data;
 	unsigned int i;
 
-	if (!q->seq_zones_wlock)
+	if (!q->disk->seq_zones_wlock)
 		return 0;
 
-	for (i = 0; i < q->nr_zones; i++)
-		if (test_bit(i, q->seq_zones_wlock))
+	for (i = 0; i < q->disk->nr_zones; i++)
+		if (test_bit(i, q->disk->seq_zones_wlock))
 			seq_printf(m, "%u\n", i);
 
 	return 0;
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 5ce72345ac666..c0303026752d5 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -325,7 +325,7 @@ static ssize_t queue_zoned_show(struct request_queue *q, char *page)
 
 static ssize_t queue_nr_zones_show(struct request_queue *q, char *page)
 {
-	return queue_var_show(blk_queue_nr_zones(q), page);
+	return queue_var_show(disk_nr_zones(q->disk), page);
 }
 
 static ssize_t queue_max_open_zones_show(struct request_queue *q, char *page)
diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index ee8752f083a94..4826083ce9a48 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -57,10 +57,10 @@ EXPORT_SYMBOL_GPL(blk_zone_cond_str);
  */
 bool blk_req_needs_zone_write_lock(struct request *rq)
 {
-	if (!rq->q->seq_zones_wlock)
+	if (blk_rq_is_passthrough(rq))
 		return false;
 
-	if (blk_rq_is_passthrough(rq))
+	if (!rq->q->disk->seq_zones_wlock)
 		return false;
 
 	switch (req_op(rq)) {
@@ -77,7 +77,7 @@ bool blk_req_zone_write_trylock(struct request *rq)
 {
 	unsigned int zno = blk_rq_zone_no(rq);
 
-	if (test_and_set_bit(zno, rq->q->seq_zones_wlock))
+	if (test_and_set_bit(zno, rq->q->disk->seq_zones_wlock))
 		return false;
 
 	WARN_ON_ONCE(rq->rq_flags & RQF_ZONE_WRITE_LOCKED);
@@ -90,7 +90,7 @@ EXPORT_SYMBOL_GPL(blk_req_zone_write_trylock);
 void __blk_req_zone_write_lock(struct request *rq)
 {
 	if (WARN_ON_ONCE(test_and_set_bit(blk_rq_zone_no(rq),
-					  rq->q->seq_zones_wlock)))
+					  rq->q->disk->seq_zones_wlock)))
 		return;
 
 	WARN_ON_ONCE(rq->rq_flags & RQF_ZONE_WRITE_LOCKED);
@@ -101,9 +101,9 @@ EXPORT_SYMBOL_GPL(__blk_req_zone_write_lock);
 void __blk_req_zone_write_unlock(struct request *rq)
 {
 	rq->rq_flags &= ~RQF_ZONE_WRITE_LOCKED;
-	if (rq->q->seq_zones_wlock)
+	if (rq->q->disk->seq_zones_wlock)
 		WARN_ON_ONCE(!test_and_clear_bit(blk_rq_zone_no(rq),
-						 rq->q->seq_zones_wlock));
+						 rq->q->disk->seq_zones_wlock));
 }
 EXPORT_SYMBOL_GPL(__blk_req_zone_write_unlock);
 
@@ -189,7 +189,7 @@ static int blk_zone_need_reset_cb(struct blk_zone *zone, unsigned int idx,
 int blkdev_zone_mgmt_all(struct block_device *bdev, unsigned int op,
 			 gfp_t gfp_mask)
 {
-	struct request_queue *q = bdev_get_queue(bdev);
+	struct gendisk *disk = bdev->bd_disk;
 	sector_t capacity = bdev_nr_sectors(bdev);
 	sector_t zone_sectors = bdev_zone_sectors(bdev);
 	unsigned long *need_reset;
@@ -197,19 +197,18 @@ int blkdev_zone_mgmt_all(struct block_device *bdev, unsigned int op,
 	sector_t sector = 0;
 	int ret;
 
-	need_reset = blk_alloc_zone_bitmap(q->node, q->nr_zones);
+	need_reset = blk_alloc_zone_bitmap(disk->queue->node, disk->nr_zones);
 	if (!need_reset)
 		return -ENOMEM;
 
-	ret = bdev->bd_disk->fops->report_zones(bdev->bd_disk, 0,
-				q->nr_zones, blk_zone_need_reset_cb,
-				need_reset);
+	ret = disk->fops->report_zones(disk, 0, disk->nr_zones,
+				       blk_zone_need_reset_cb, need_reset);
 	if (ret < 0)
 		goto out_free_need_reset;
 
 	ret = 0;
 	while (sector < capacity) {
-		if (!test_bit(blk_queue_zone_no(q, sector), need_reset)) {
+		if (!test_bit(disk_zone_no(disk, sector), need_reset)) {
 			sector += zone_sectors;
 			continue;
 		}
@@ -452,12 +451,10 @@ int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
 
 void disk_free_zone_bitmaps(struct gendisk *disk)
 {
-	struct request_queue *q = disk->queue;
-
-	kfree(q->conv_zones_bitmap);
-	q->conv_zones_bitmap = NULL;
-	kfree(q->seq_zones_wlock);
-	q->seq_zones_wlock = NULL;
+	kfree(disk->conv_zones_bitmap);
+	disk->conv_zones_bitmap = NULL;
+	kfree(disk->seq_zones_wlock);
+	disk->seq_zones_wlock = NULL;
 }
 
 struct blk_revalidate_zone_args {
@@ -607,9 +604,9 @@ int blk_revalidate_disk_zones(struct gendisk *disk,
 	blk_mq_freeze_queue(q);
 	if (ret > 0) {
 		blk_queue_chunk_sectors(q, args.zone_sectors);
-		q->nr_zones = args.nr_zones;
-		swap(q->seq_zones_wlock, args.seq_zones_wlock);
-		swap(q->conv_zones_bitmap, args.conv_zones_bitmap);
+		disk->nr_zones = args.nr_zones;
+		swap(disk->seq_zones_wlock, args.seq_zones_wlock);
+		swap(disk->conv_zones_bitmap, args.conv_zones_bitmap);
 		if (update_driver_data)
 			update_driver_data(disk);
 		ret = 0;
@@ -634,9 +631,9 @@ void disk_clear_zone_settings(struct gendisk *disk)
 	disk_free_zone_bitmaps(disk);
 	blk_queue_flag_clear(QUEUE_FLAG_ZONE_RESETALL, q);
 	q->required_elevator_features &= ~ELEVATOR_F_ZBD_SEQ_WRITE;
-	q->nr_zones = 0;
-	q->max_open_zones = 0;
-	q->max_active_zones = 0;
+	disk->nr_zones = 0;
+	disk->max_open_zones = 0;
+	disk->max_active_zones = 0;
 	q->limits.chunk_sectors = 0;
 	q->limits.zone_write_granularity = 0;
 	q->limits.max_zone_append_sectors = 0;
diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c
index e62c52e964259..64b06caab9843 100644
--- a/drivers/block/null_blk/zoned.c
+++ b/drivers/block/null_blk/zoned.c
@@ -170,7 +170,7 @@ int null_register_zoned_dev(struct nullb *nullb)
 			return ret;
 	} else {
 		blk_queue_chunk_sectors(q, dev->zone_size_sects);
-		q->nr_zones = bdev_nr_zones(nullb->disk->part0);
+		nullb->disk->nr_zones = bdev_nr_zones(nullb->disk->part0);
 	}
 
 	blk_queue_max_zone_append_sectors(q, dev->zone_size_sects);
diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c
index 842c31019b513..2b89cde30c9e9 100644
--- a/drivers/md/dm-zone.c
+++ b/drivers/md/dm-zone.c
@@ -139,13 +139,11 @@ bool dm_is_zone_write(struct mapped_device *md, struct bio *bio)
 
 void dm_cleanup_zoned_dev(struct mapped_device *md)
 {
-	struct request_queue *q = md->queue;
-
-	if (q) {
-		kfree(q->conv_zones_bitmap);
-		q->conv_zones_bitmap = NULL;
-		kfree(q->seq_zones_wlock);
-		q->seq_zones_wlock = NULL;
+	if (md->disk) {
+		kfree(md->disk->conv_zones_bitmap);
+		md->disk->conv_zones_bitmap = NULL;
+		kfree(md->disk->seq_zones_wlock);
+		md->disk->seq_zones_wlock = NULL;
 	}
 
 	kvfree(md->zwp_offset);
@@ -179,31 +177,31 @@ static int dm_zone_revalidate_cb(struct blk_zone *zone, unsigned int idx,
 				 void *data)
 {
 	struct mapped_device *md = data;
-	struct request_queue *q = md->queue;
+	struct gendisk *disk = md->disk;
 
 	switch (zone->type) {
 	case BLK_ZONE_TYPE_CONVENTIONAL:
-		if (!q->conv_zones_bitmap) {
-			q->conv_zones_bitmap =
-				kcalloc(BITS_TO_LONGS(q->nr_zones),
+		if (!disk->conv_zones_bitmap) {
+			disk->conv_zones_bitmap =
+				kcalloc(BITS_TO_LONGS(disk->nr_zones),
 					sizeof(unsigned long), GFP_NOIO);
-			if (!q->conv_zones_bitmap)
+			if (!disk->conv_zones_bitmap)
 				return -ENOMEM;
 		}
-		set_bit(idx, q->conv_zones_bitmap);
+		set_bit(idx, disk->conv_zones_bitmap);
 		break;
 	case BLK_ZONE_TYPE_SEQWRITE_REQ:
 	case BLK_ZONE_TYPE_SEQWRITE_PREF:
-		if (!q->seq_zones_wlock) {
-			q->seq_zones_wlock =
-				kcalloc(BITS_TO_LONGS(q->nr_zones),
+		if (!disk->seq_zones_wlock) {
+			disk->seq_zones_wlock =
+				kcalloc(BITS_TO_LONGS(disk->nr_zones),
 					sizeof(unsigned long), GFP_NOIO);
-			if (!q->seq_zones_wlock)
+			if (!disk->seq_zones_wlock)
 				return -ENOMEM;
 		}
 		if (!md->zwp_offset) {
 			md->zwp_offset =
-				kvcalloc(q->nr_zones, sizeof(unsigned int),
+				kvcalloc(disk->nr_zones, sizeof(unsigned int),
 					 GFP_KERNEL);
 			if (!md->zwp_offset)
 				return -ENOMEM;
@@ -228,7 +226,7 @@ static int dm_zone_revalidate_cb(struct blk_zone *zone, unsigned int idx,
  */
 static int dm_revalidate_zones(struct mapped_device *md, struct dm_table *t)
 {
-	struct request_queue *q = md->queue;
+	struct gendisk *disk = md->disk;
 	unsigned int noio_flag;
 	int ret;
 
@@ -236,7 +234,7 @@ static int dm_revalidate_zones(struct mapped_device *md, struct dm_table *t)
 	 * Check if something changed. If yes, cleanup the current resources
 	 * and reallocate everything.
 	 */
-	if (!q->nr_zones || q->nr_zones != md->nr_zones)
+	if (!disk->nr_zones || disk->nr_zones != md->nr_zones)
 		dm_cleanup_zoned_dev(md);
 	if (md->nr_zones)
 		return 0;
@@ -246,17 +244,17 @@ static int dm_revalidate_zones(struct mapped_device *md, struct dm_table *t)
 	 * operations in this context are done as if GFP_NOIO was specified.
 	 */
 	noio_flag = memalloc_noio_save();
-	ret = dm_blk_do_report_zones(md, t, 0, q->nr_zones,
+	ret = dm_blk_do_report_zones(md, t, 0, disk->nr_zones,
 				     dm_zone_revalidate_cb, md);
 	memalloc_noio_restore(noio_flag);
 	if (ret < 0)
 		goto err;
-	if (ret != q->nr_zones) {
+	if (ret != disk->nr_zones) {
 		ret = -EIO;
 		goto err;
 	}
 
-	md->nr_zones = q->nr_zones;
+	md->nr_zones = disk->nr_zones;
 
 	return 0;
 
@@ -301,7 +299,7 @@ int dm_set_zones_restrictions(struct dm_table *t, struct request_queue *q)
 	 * correct value to be exposed in sysfs queue/nr_zones.
 	 */
 	WARN_ON_ONCE(queue_is_mq(q));
-	q->nr_zones = bdev_nr_zones(md->disk->part0);
+	md->disk->nr_zones = bdev_nr_zones(md->disk->part0);
 
 	/* Check if zone append is natively supported */
 	if (dm_table_supports_zone_append(t)) {
@@ -466,26 +464,26 @@ static blk_status_t dm_zone_map_bio_end(struct mapped_device *md, unsigned int z
 	}
 }
 
-static inline void dm_zone_lock(struct request_queue *q,
-				unsigned int zno, struct bio *clone)
+static inline void dm_zone_lock(struct gendisk *disk, unsigned int zno,
+				struct bio *clone)
 {
 	if (WARN_ON_ONCE(bio_flagged(clone, BIO_ZONE_WRITE_LOCKED)))
 		return;
 
-	wait_on_bit_lock_io(q->seq_zones_wlock, zno, TASK_UNINTERRUPTIBLE);
+	wait_on_bit_lock_io(disk->seq_zones_wlock, zno, TASK_UNINTERRUPTIBLE);
 	bio_set_flag(clone, BIO_ZONE_WRITE_LOCKED);
 }
 
-static inline void dm_zone_unlock(struct request_queue *q,
-				  unsigned int zno, struct bio *clone)
+static inline void dm_zone_unlock(struct gendisk *disk, unsigned int zno,
+				  struct bio *clone)
 {
 	if (!bio_flagged(clone, BIO_ZONE_WRITE_LOCKED))
 		return;
 
-	WARN_ON_ONCE(!test_bit(zno, q->seq_zones_wlock));
-	clear_bit_unlock(zno, q->seq_zones_wlock);
+	WARN_ON_ONCE(!test_bit(zno, disk->seq_zones_wlock));
+	clear_bit_unlock(zno, disk->seq_zones_wlock);
 	smp_mb__after_atomic();
-	wake_up_bit(q->seq_zones_wlock, zno);
+	wake_up_bit(disk->seq_zones_wlock, zno);
 
 	bio_clear_flag(clone, BIO_ZONE_WRITE_LOCKED);
 }
@@ -520,7 +518,6 @@ int dm_zone_map_bio(struct dm_target_io *tio)
 	struct dm_io *io = tio->io;
 	struct dm_target *ti = tio->ti;
 	struct mapped_device *md = io->md;
-	struct request_queue *q = md->queue;
 	struct bio *clone = &tio->clone;
 	struct orig_bio_details orig_bio_details;
 	unsigned int zno;
@@ -536,7 +533,7 @@ int dm_zone_map_bio(struct dm_target_io *tio)
 
 	/* Lock the target zone */
 	zno = bio_zone_no(clone);
-	dm_zone_lock(q, zno, clone);
+	dm_zone_lock(md->disk, zno, clone);
 
 	orig_bio_details.nr_sectors = bio_sectors(clone);
 	orig_bio_details.op = bio_op(clone);
@@ -546,7 +543,7 @@ int dm_zone_map_bio(struct dm_target_io *tio)
 	 * both valid, and if the bio is a zone append, remap it to a write.
 	 */
 	if (!dm_zone_map_bio_begin(md, zno, clone)) {
-		dm_zone_unlock(q, zno, clone);
+		dm_zone_unlock(md->disk, zno, clone);
 		return DM_MAPIO_KILL;
 	}
 
@@ -570,12 +567,12 @@ int dm_zone_map_bio(struct dm_target_io *tio)
 		sts = dm_zone_map_bio_end(md, zno, &orig_bio_details,
 					  *tio->len_ptr);
 		if (sts != BLK_STS_OK)
-			dm_zone_unlock(q, zno, clone);
+			dm_zone_unlock(md->disk, zno, clone);
 		break;
 	case DM_MAPIO_REQUEUE:
 	case DM_MAPIO_KILL:
 	default:
-		dm_zone_unlock(q, zno, clone);
+		dm_zone_unlock(md->disk, zno, clone);
 		sts = BLK_STS_IOERR;
 		break;
 	}
@@ -592,7 +589,6 @@ int dm_zone_map_bio(struct dm_target_io *tio)
 void dm_zone_endio(struct dm_io *io, struct bio *clone)
 {
 	struct mapped_device *md = io->md;
-	struct request_queue *q = md->queue;
 	struct gendisk *disk = md->disk;
 	struct bio *orig_bio = io->orig_bio;
 	unsigned int zwp_offset;
@@ -651,5 +647,5 @@ void dm_zone_endio(struct dm_io *io, struct bio *clone)
 				zwp_offset - bio_sectors(orig_bio);
 	}
 
-	dm_zone_unlock(q, zno, clone);
+	dm_zone_unlock(disk, zno, clone);
 }
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index ccf9a6da8f6e1..f26640ccb9555 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -830,7 +830,7 @@ void nvme_mpath_add_disk(struct nvme_ns *ns, struct nvme_id_ns *id)
 				   ns->head->disk->queue);
 #ifdef CONFIG_BLK_DEV_ZONED
 	if (blk_queue_is_zoned(ns->queue) && ns->head->disk)
-		ns->head->disk->queue->nr_zones = ns->queue->nr_zones;
+		ns->head->disk->nr_zones = ns->disk->nr_zones;
 #endif
 }
 
diff --git a/drivers/nvme/target/zns.c b/drivers/nvme/target/zns.c
index c9b2ce06ca93e..385f2fe2792ff 100644
--- a/drivers/nvme/target/zns.c
+++ b/drivers/nvme/target/zns.c
@@ -57,7 +57,7 @@ bool nvmet_bdev_zns_enable(struct nvmet_ns *ns)
 	 * zones, reject the device. Otherwise, use report zones to detect if
 	 * the device has conventional zones.
 	 */
-	if (ns->bdev->bd_disk->queue->conv_zones_bitmap)
+	if (ns->bdev->bd_disk->conv_zones_bitmap)
 		return false;
 
 	ret = blkdev_report_zones(ns->bdev, 0, bdev_nr_zones(ns->bdev),
diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
index b4106f8997342..b8c97456506ac 100644
--- a/drivers/scsi/sd_zbc.c
+++ b/drivers/scsi/sd_zbc.c
@@ -855,7 +855,7 @@ int sd_zbc_revalidate_zones(struct scsi_disk *sdkp)
 
 	if (sdkp->zone_info.zone_blocks == zone_blocks &&
 	    sdkp->zone_info.nr_zones == nr_zones &&
-	    disk->queue->nr_zones == nr_zones)
+	    disk->nr_zones == nr_zones)
 		goto unlock;
 
 	flags = memalloc_noio_save();
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 43aad0da3305d..1b0b753609975 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -1123,12 +1123,12 @@ void blk_dump_rq_flags(struct request *, char *);
 #ifdef CONFIG_BLK_DEV_ZONED
 static inline unsigned int blk_rq_zone_no(struct request *rq)
 {
-	return blk_queue_zone_no(rq->q, blk_rq_pos(rq));
+	return disk_zone_no(rq->q->disk, blk_rq_pos(rq));
 }
 
 static inline unsigned int blk_rq_zone_is_seq(struct request *rq)
 {
-	return blk_queue_zone_is_seq(rq->q, blk_rq_pos(rq));
+	return disk_zone_is_seq(rq->q->disk, blk_rq_pos(rq));
 }
 
 bool blk_req_needs_zone_write_lock(struct request *rq);
@@ -1150,8 +1150,8 @@ static inline void blk_req_zone_write_unlock(struct request *rq)
 
 static inline bool blk_req_zone_is_write_locked(struct request *rq)
 {
-	return rq->q->seq_zones_wlock &&
-		test_bit(blk_rq_zone_no(rq), rq->q->seq_zones_wlock);
+	return rq->q->disk->seq_zones_wlock &&
+		test_bit(blk_rq_zone_no(rq), rq->q->disk->seq_zones_wlock);
 }
 
 static inline bool blk_req_can_dispatch_to_zone(struct request *rq)
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index f1eca3f5610eb..547eb07848741 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -164,6 +164,29 @@ struct gendisk {
 #ifdef  CONFIG_BLK_DEV_INTEGRITY
 	struct kobject integrity_kobj;
 #endif	/* CONFIG_BLK_DEV_INTEGRITY */
+
+#ifdef CONFIG_BLK_DEV_ZONED
+	/*
+	 * Zoned block device information for request dispatch control.
+	 * nr_zones is the total number of zones of the device. This is always
+	 * 0 for regular block devices. conv_zones_bitmap is a bitmap of nr_zones
+	 * bits which indicates if a zone is conventional (bit set) or
+	 * sequential (bit clear). seq_zones_wlock is a bitmap of nr_zones
+	 * bits which indicates if a zone is write locked, that is, if a write
+	 * request targeting the zone was dispatched.
+	 *
+	 * Reads of this information must be protected with blk_queue_enter() /
+	 * blk_queue_exit(). Modifying this information is only allowed while
+	 * no requests are being processed. See also blk_mq_freeze_queue() and
+	 * blk_mq_unfreeze_queue().
+	 */
+	unsigned int		nr_zones;
+	unsigned int		max_open_zones;
+	unsigned int		max_active_zones;
+	unsigned long		*conv_zones_bitmap;
+	unsigned long		*seq_zones_wlock;
+#endif /* CONFIG_BLK_DEV_ZONED */
+
 #if IS_ENABLED(CONFIG_CDROM)
 	struct cdrom_device_info *cdi;
 #endif
@@ -469,31 +492,6 @@ struct request_queue {
 
 	unsigned int		required_elevator_features;
 
-#ifdef CONFIG_BLK_DEV_ZONED
-	/*
-	 * Zoned block device information for request dispatch control.
-	 * nr_zones is the total number of zones of the device. This is always
-	 * 0 for regular block devices. conv_zones_bitmap is a bitmap of nr_zones
-	 * bits which indicates if a zone is conventional (bit set) or
-	 * sequential (bit clear). seq_zones_wlock is a bitmap of nr_zones
-	 * bits which indicates if a zone is write locked, that is, if a write
-	 * request targeting the zone was dispatched. All three fields are
-	 * initialized by the low level device driver (e.g. scsi/sd.c).
-	 * Stacking drivers (device mappers) may or may not initialize
-	 * these fields.
-	 *
-	 * Reads of this information must be protected with blk_queue_enter() /
-	 * blk_queue_exit(). Modifying this information is only allowed while
-	 * no requests are being processed. See also blk_mq_freeze_queue() and
-	 * blk_mq_unfreeze_queue().
-	 */
-	unsigned int		nr_zones;
-	unsigned long		*conv_zones_bitmap;
-	unsigned long		*seq_zones_wlock;
-	unsigned int		max_open_zones;
-	unsigned int		max_active_zones;
-#endif /* CONFIG_BLK_DEV_ZONED */
-
 	int			node;
 #ifdef CONFIG_BLK_DEV_IO_TRACE
 	struct blk_trace __rcu	*blk_trace;
@@ -670,63 +668,59 @@ static inline bool blk_queue_is_zoned(struct request_queue *q)
 }
 
 #ifdef CONFIG_BLK_DEV_ZONED
-static inline unsigned int blk_queue_nr_zones(struct request_queue *q)
+static inline unsigned int disk_nr_zones(struct gendisk *disk)
 {
-	return blk_queue_is_zoned(q) ? q->nr_zones : 0;
+	return blk_queue_is_zoned(disk->queue) ? disk->nr_zones : 0;
 }
 
-static inline unsigned int blk_queue_zone_no(struct request_queue *q,
-					     sector_t sector)
+static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector)
 {
-	if (!blk_queue_is_zoned(q))
+	if (!blk_queue_is_zoned(disk->queue))
 		return 0;
-	return sector >> ilog2(q->limits.chunk_sectors);
+	return sector >> ilog2(disk->queue->limits.chunk_sectors);
 }
 
-static inline bool blk_queue_zone_is_seq(struct request_queue *q,
-					 sector_t sector)
+static inline bool disk_zone_is_seq(struct gendisk *disk, sector_t sector)
 {
-	if (!blk_queue_is_zoned(q))
+	if (!blk_queue_is_zoned(disk->queue))
 		return false;
-	if (!q->conv_zones_bitmap)
+	if (!disk->conv_zones_bitmap)
 		return true;
-	return !test_bit(blk_queue_zone_no(q, sector), q->conv_zones_bitmap);
+	return !test_bit(disk_zone_no(disk, sector), disk->conv_zones_bitmap);
 }
 
 static inline void disk_set_max_open_zones(struct gendisk *disk,
 		unsigned int max_open_zones)
 {
-	disk->queue->max_open_zones = max_open_zones;
+	disk->max_open_zones = max_open_zones;
 }
 
 static inline void disk_set_max_active_zones(struct gendisk *disk,
 		unsigned int max_active_zones)
 {
-	disk->queue->max_active_zones = max_active_zones;
+	disk->max_active_zones = max_active_zones;
 }
 
 static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
 {
-	return bdev->bd_disk->queue->max_open_zones;
+	return bdev->bd_disk->max_open_zones;
 }
 
 static inline unsigned int bdev_max_active_zones(struct block_device *bdev)
 {
-	return bdev->bd_disk->queue->max_active_zones;
+	return bdev->bd_disk->max_active_zones;
 }
 
 #else /* CONFIG_BLK_DEV_ZONED */
-static inline unsigned int blk_queue_nr_zones(struct request_queue *q)
+static inline unsigned int disk_nr_zones(struct gendisk *disk)
 {
 	return 0;
 }
-static inline bool blk_queue_zone_is_seq(struct request_queue *q,
-					 sector_t sector)
+static inline bool disk_zone_is_seq(struct gendisk *disk, sector_t sector)
 {
 	return false;
 }
-static inline unsigned int blk_queue_zone_no(struct request_queue *q,
-					     sector_t sector)
+static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector)
 {
 	return 0;
 }
@@ -734,6 +728,7 @@ static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
 {
 	return 0;
 }
+
 static inline unsigned int bdev_max_active_zones(struct block_device *bdev)
 {
 	return 0;
@@ -902,14 +897,12 @@ const char *blk_zone_cond_str(enum blk_zone_cond zone_cond);
 
 static inline unsigned int bio_zone_no(struct bio *bio)
 {
-	return blk_queue_zone_no(bdev_get_queue(bio->bi_bdev),
-				 bio->bi_iter.bi_sector);
+	return disk_zone_no(bio->bi_bdev->bd_disk, bio->bi_iter.bi_sector);
 }
 
 static inline unsigned int bio_zone_is_seq(struct bio *bio)
 {
-	return blk_queue_zone_is_seq(bdev_get_queue(bio->bi_bdev),
-				     bio->bi_iter.bi_sector);
+	return disk_zone_is_seq(bio->bi_bdev->bd_disk, bio->bi_iter.bi_sector);
 }
 
 /*
-- 
2.30.2


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

* [dm-devel] [PATCH 17/17] block: move zone related fields to struct gendisk
@ 2022-07-04 12:45   ` Christoph Hellwig
  0 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 12:45 UTC (permalink / raw)
  To: Jens Axboe, Damien Le Moal; +Cc: linux-block, dm-devel, linux-scsi, linux-nvme

Move the zone related fields that are currently stored in
struct request_queue to struct gendisk as these are part of the highlevel
block layer API and are only used for non-passthrough I/O that requires
the gendisk.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-mq-debugfs-zoned.c   |  6 +--
 block/blk-sysfs.c              |  2 +-
 block/blk-zoned.c              | 45 ++++++++---------
 drivers/block/null_blk/zoned.c |  2 +-
 drivers/md/dm-zone.c           | 74 +++++++++++++--------------
 drivers/nvme/host/multipath.c  |  2 +-
 drivers/nvme/target/zns.c      |  2 +-
 drivers/scsi/sd_zbc.c          |  2 +-
 include/linux/blk-mq.h         |  8 +--
 include/linux/blkdev.h         | 91 ++++++++++++++++------------------
 10 files changed, 110 insertions(+), 124 deletions(-)

diff --git a/block/blk-mq-debugfs-zoned.c b/block/blk-mq-debugfs-zoned.c
index 038cb627c8689..a77b099c34b7a 100644
--- a/block/blk-mq-debugfs-zoned.c
+++ b/block/blk-mq-debugfs-zoned.c
@@ -11,11 +11,11 @@ int queue_zone_wlock_show(void *data, struct seq_file *m)
 	struct request_queue *q = data;
 	unsigned int i;
 
-	if (!q->seq_zones_wlock)
+	if (!q->disk->seq_zones_wlock)
 		return 0;
 
-	for (i = 0; i < q->nr_zones; i++)
-		if (test_bit(i, q->seq_zones_wlock))
+	for (i = 0; i < q->disk->nr_zones; i++)
+		if (test_bit(i, q->disk->seq_zones_wlock))
 			seq_printf(m, "%u\n", i);
 
 	return 0;
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 5ce72345ac666..c0303026752d5 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -325,7 +325,7 @@ static ssize_t queue_zoned_show(struct request_queue *q, char *page)
 
 static ssize_t queue_nr_zones_show(struct request_queue *q, char *page)
 {
-	return queue_var_show(blk_queue_nr_zones(q), page);
+	return queue_var_show(disk_nr_zones(q->disk), page);
 }
 
 static ssize_t queue_max_open_zones_show(struct request_queue *q, char *page)
diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index ee8752f083a94..4826083ce9a48 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -57,10 +57,10 @@ EXPORT_SYMBOL_GPL(blk_zone_cond_str);
  */
 bool blk_req_needs_zone_write_lock(struct request *rq)
 {
-	if (!rq->q->seq_zones_wlock)
+	if (blk_rq_is_passthrough(rq))
 		return false;
 
-	if (blk_rq_is_passthrough(rq))
+	if (!rq->q->disk->seq_zones_wlock)
 		return false;
 
 	switch (req_op(rq)) {
@@ -77,7 +77,7 @@ bool blk_req_zone_write_trylock(struct request *rq)
 {
 	unsigned int zno = blk_rq_zone_no(rq);
 
-	if (test_and_set_bit(zno, rq->q->seq_zones_wlock))
+	if (test_and_set_bit(zno, rq->q->disk->seq_zones_wlock))
 		return false;
 
 	WARN_ON_ONCE(rq->rq_flags & RQF_ZONE_WRITE_LOCKED);
@@ -90,7 +90,7 @@ EXPORT_SYMBOL_GPL(blk_req_zone_write_trylock);
 void __blk_req_zone_write_lock(struct request *rq)
 {
 	if (WARN_ON_ONCE(test_and_set_bit(blk_rq_zone_no(rq),
-					  rq->q->seq_zones_wlock)))
+					  rq->q->disk->seq_zones_wlock)))
 		return;
 
 	WARN_ON_ONCE(rq->rq_flags & RQF_ZONE_WRITE_LOCKED);
@@ -101,9 +101,9 @@ EXPORT_SYMBOL_GPL(__blk_req_zone_write_lock);
 void __blk_req_zone_write_unlock(struct request *rq)
 {
 	rq->rq_flags &= ~RQF_ZONE_WRITE_LOCKED;
-	if (rq->q->seq_zones_wlock)
+	if (rq->q->disk->seq_zones_wlock)
 		WARN_ON_ONCE(!test_and_clear_bit(blk_rq_zone_no(rq),
-						 rq->q->seq_zones_wlock));
+						 rq->q->disk->seq_zones_wlock));
 }
 EXPORT_SYMBOL_GPL(__blk_req_zone_write_unlock);
 
@@ -189,7 +189,7 @@ static int blk_zone_need_reset_cb(struct blk_zone *zone, unsigned int idx,
 int blkdev_zone_mgmt_all(struct block_device *bdev, unsigned int op,
 			 gfp_t gfp_mask)
 {
-	struct request_queue *q = bdev_get_queue(bdev);
+	struct gendisk *disk = bdev->bd_disk;
 	sector_t capacity = bdev_nr_sectors(bdev);
 	sector_t zone_sectors = bdev_zone_sectors(bdev);
 	unsigned long *need_reset;
@@ -197,19 +197,18 @@ int blkdev_zone_mgmt_all(struct block_device *bdev, unsigned int op,
 	sector_t sector = 0;
 	int ret;
 
-	need_reset = blk_alloc_zone_bitmap(q->node, q->nr_zones);
+	need_reset = blk_alloc_zone_bitmap(disk->queue->node, disk->nr_zones);
 	if (!need_reset)
 		return -ENOMEM;
 
-	ret = bdev->bd_disk->fops->report_zones(bdev->bd_disk, 0,
-				q->nr_zones, blk_zone_need_reset_cb,
-				need_reset);
+	ret = disk->fops->report_zones(disk, 0, disk->nr_zones,
+				       blk_zone_need_reset_cb, need_reset);
 	if (ret < 0)
 		goto out_free_need_reset;
 
 	ret = 0;
 	while (sector < capacity) {
-		if (!test_bit(blk_queue_zone_no(q, sector), need_reset)) {
+		if (!test_bit(disk_zone_no(disk, sector), need_reset)) {
 			sector += zone_sectors;
 			continue;
 		}
@@ -452,12 +451,10 @@ int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
 
 void disk_free_zone_bitmaps(struct gendisk *disk)
 {
-	struct request_queue *q = disk->queue;
-
-	kfree(q->conv_zones_bitmap);
-	q->conv_zones_bitmap = NULL;
-	kfree(q->seq_zones_wlock);
-	q->seq_zones_wlock = NULL;
+	kfree(disk->conv_zones_bitmap);
+	disk->conv_zones_bitmap = NULL;
+	kfree(disk->seq_zones_wlock);
+	disk->seq_zones_wlock = NULL;
 }
 
 struct blk_revalidate_zone_args {
@@ -607,9 +604,9 @@ int blk_revalidate_disk_zones(struct gendisk *disk,
 	blk_mq_freeze_queue(q);
 	if (ret > 0) {
 		blk_queue_chunk_sectors(q, args.zone_sectors);
-		q->nr_zones = args.nr_zones;
-		swap(q->seq_zones_wlock, args.seq_zones_wlock);
-		swap(q->conv_zones_bitmap, args.conv_zones_bitmap);
+		disk->nr_zones = args.nr_zones;
+		swap(disk->seq_zones_wlock, args.seq_zones_wlock);
+		swap(disk->conv_zones_bitmap, args.conv_zones_bitmap);
 		if (update_driver_data)
 			update_driver_data(disk);
 		ret = 0;
@@ -634,9 +631,9 @@ void disk_clear_zone_settings(struct gendisk *disk)
 	disk_free_zone_bitmaps(disk);
 	blk_queue_flag_clear(QUEUE_FLAG_ZONE_RESETALL, q);
 	q->required_elevator_features &= ~ELEVATOR_F_ZBD_SEQ_WRITE;
-	q->nr_zones = 0;
-	q->max_open_zones = 0;
-	q->max_active_zones = 0;
+	disk->nr_zones = 0;
+	disk->max_open_zones = 0;
+	disk->max_active_zones = 0;
 	q->limits.chunk_sectors = 0;
 	q->limits.zone_write_granularity = 0;
 	q->limits.max_zone_append_sectors = 0;
diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c
index e62c52e964259..64b06caab9843 100644
--- a/drivers/block/null_blk/zoned.c
+++ b/drivers/block/null_blk/zoned.c
@@ -170,7 +170,7 @@ int null_register_zoned_dev(struct nullb *nullb)
 			return ret;
 	} else {
 		blk_queue_chunk_sectors(q, dev->zone_size_sects);
-		q->nr_zones = bdev_nr_zones(nullb->disk->part0);
+		nullb->disk->nr_zones = bdev_nr_zones(nullb->disk->part0);
 	}
 
 	blk_queue_max_zone_append_sectors(q, dev->zone_size_sects);
diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c
index 842c31019b513..2b89cde30c9e9 100644
--- a/drivers/md/dm-zone.c
+++ b/drivers/md/dm-zone.c
@@ -139,13 +139,11 @@ bool dm_is_zone_write(struct mapped_device *md, struct bio *bio)
 
 void dm_cleanup_zoned_dev(struct mapped_device *md)
 {
-	struct request_queue *q = md->queue;
-
-	if (q) {
-		kfree(q->conv_zones_bitmap);
-		q->conv_zones_bitmap = NULL;
-		kfree(q->seq_zones_wlock);
-		q->seq_zones_wlock = NULL;
+	if (md->disk) {
+		kfree(md->disk->conv_zones_bitmap);
+		md->disk->conv_zones_bitmap = NULL;
+		kfree(md->disk->seq_zones_wlock);
+		md->disk->seq_zones_wlock = NULL;
 	}
 
 	kvfree(md->zwp_offset);
@@ -179,31 +177,31 @@ static int dm_zone_revalidate_cb(struct blk_zone *zone, unsigned int idx,
 				 void *data)
 {
 	struct mapped_device *md = data;
-	struct request_queue *q = md->queue;
+	struct gendisk *disk = md->disk;
 
 	switch (zone->type) {
 	case BLK_ZONE_TYPE_CONVENTIONAL:
-		if (!q->conv_zones_bitmap) {
-			q->conv_zones_bitmap =
-				kcalloc(BITS_TO_LONGS(q->nr_zones),
+		if (!disk->conv_zones_bitmap) {
+			disk->conv_zones_bitmap =
+				kcalloc(BITS_TO_LONGS(disk->nr_zones),
 					sizeof(unsigned long), GFP_NOIO);
-			if (!q->conv_zones_bitmap)
+			if (!disk->conv_zones_bitmap)
 				return -ENOMEM;
 		}
-		set_bit(idx, q->conv_zones_bitmap);
+		set_bit(idx, disk->conv_zones_bitmap);
 		break;
 	case BLK_ZONE_TYPE_SEQWRITE_REQ:
 	case BLK_ZONE_TYPE_SEQWRITE_PREF:
-		if (!q->seq_zones_wlock) {
-			q->seq_zones_wlock =
-				kcalloc(BITS_TO_LONGS(q->nr_zones),
+		if (!disk->seq_zones_wlock) {
+			disk->seq_zones_wlock =
+				kcalloc(BITS_TO_LONGS(disk->nr_zones),
 					sizeof(unsigned long), GFP_NOIO);
-			if (!q->seq_zones_wlock)
+			if (!disk->seq_zones_wlock)
 				return -ENOMEM;
 		}
 		if (!md->zwp_offset) {
 			md->zwp_offset =
-				kvcalloc(q->nr_zones, sizeof(unsigned int),
+				kvcalloc(disk->nr_zones, sizeof(unsigned int),
 					 GFP_KERNEL);
 			if (!md->zwp_offset)
 				return -ENOMEM;
@@ -228,7 +226,7 @@ static int dm_zone_revalidate_cb(struct blk_zone *zone, unsigned int idx,
  */
 static int dm_revalidate_zones(struct mapped_device *md, struct dm_table *t)
 {
-	struct request_queue *q = md->queue;
+	struct gendisk *disk = md->disk;
 	unsigned int noio_flag;
 	int ret;
 
@@ -236,7 +234,7 @@ static int dm_revalidate_zones(struct mapped_device *md, struct dm_table *t)
 	 * Check if something changed. If yes, cleanup the current resources
 	 * and reallocate everything.
 	 */
-	if (!q->nr_zones || q->nr_zones != md->nr_zones)
+	if (!disk->nr_zones || disk->nr_zones != md->nr_zones)
 		dm_cleanup_zoned_dev(md);
 	if (md->nr_zones)
 		return 0;
@@ -246,17 +244,17 @@ static int dm_revalidate_zones(struct mapped_device *md, struct dm_table *t)
 	 * operations in this context are done as if GFP_NOIO was specified.
 	 */
 	noio_flag = memalloc_noio_save();
-	ret = dm_blk_do_report_zones(md, t, 0, q->nr_zones,
+	ret = dm_blk_do_report_zones(md, t, 0, disk->nr_zones,
 				     dm_zone_revalidate_cb, md);
 	memalloc_noio_restore(noio_flag);
 	if (ret < 0)
 		goto err;
-	if (ret != q->nr_zones) {
+	if (ret != disk->nr_zones) {
 		ret = -EIO;
 		goto err;
 	}
 
-	md->nr_zones = q->nr_zones;
+	md->nr_zones = disk->nr_zones;
 
 	return 0;
 
@@ -301,7 +299,7 @@ int dm_set_zones_restrictions(struct dm_table *t, struct request_queue *q)
 	 * correct value to be exposed in sysfs queue/nr_zones.
 	 */
 	WARN_ON_ONCE(queue_is_mq(q));
-	q->nr_zones = bdev_nr_zones(md->disk->part0);
+	md->disk->nr_zones = bdev_nr_zones(md->disk->part0);
 
 	/* Check if zone append is natively supported */
 	if (dm_table_supports_zone_append(t)) {
@@ -466,26 +464,26 @@ static blk_status_t dm_zone_map_bio_end(struct mapped_device *md, unsigned int z
 	}
 }
 
-static inline void dm_zone_lock(struct request_queue *q,
-				unsigned int zno, struct bio *clone)
+static inline void dm_zone_lock(struct gendisk *disk, unsigned int zno,
+				struct bio *clone)
 {
 	if (WARN_ON_ONCE(bio_flagged(clone, BIO_ZONE_WRITE_LOCKED)))
 		return;
 
-	wait_on_bit_lock_io(q->seq_zones_wlock, zno, TASK_UNINTERRUPTIBLE);
+	wait_on_bit_lock_io(disk->seq_zones_wlock, zno, TASK_UNINTERRUPTIBLE);
 	bio_set_flag(clone, BIO_ZONE_WRITE_LOCKED);
 }
 
-static inline void dm_zone_unlock(struct request_queue *q,
-				  unsigned int zno, struct bio *clone)
+static inline void dm_zone_unlock(struct gendisk *disk, unsigned int zno,
+				  struct bio *clone)
 {
 	if (!bio_flagged(clone, BIO_ZONE_WRITE_LOCKED))
 		return;
 
-	WARN_ON_ONCE(!test_bit(zno, q->seq_zones_wlock));
-	clear_bit_unlock(zno, q->seq_zones_wlock);
+	WARN_ON_ONCE(!test_bit(zno, disk->seq_zones_wlock));
+	clear_bit_unlock(zno, disk->seq_zones_wlock);
 	smp_mb__after_atomic();
-	wake_up_bit(q->seq_zones_wlock, zno);
+	wake_up_bit(disk->seq_zones_wlock, zno);
 
 	bio_clear_flag(clone, BIO_ZONE_WRITE_LOCKED);
 }
@@ -520,7 +518,6 @@ int dm_zone_map_bio(struct dm_target_io *tio)
 	struct dm_io *io = tio->io;
 	struct dm_target *ti = tio->ti;
 	struct mapped_device *md = io->md;
-	struct request_queue *q = md->queue;
 	struct bio *clone = &tio->clone;
 	struct orig_bio_details orig_bio_details;
 	unsigned int zno;
@@ -536,7 +533,7 @@ int dm_zone_map_bio(struct dm_target_io *tio)
 
 	/* Lock the target zone */
 	zno = bio_zone_no(clone);
-	dm_zone_lock(q, zno, clone);
+	dm_zone_lock(md->disk, zno, clone);
 
 	orig_bio_details.nr_sectors = bio_sectors(clone);
 	orig_bio_details.op = bio_op(clone);
@@ -546,7 +543,7 @@ int dm_zone_map_bio(struct dm_target_io *tio)
 	 * both valid, and if the bio is a zone append, remap it to a write.
 	 */
 	if (!dm_zone_map_bio_begin(md, zno, clone)) {
-		dm_zone_unlock(q, zno, clone);
+		dm_zone_unlock(md->disk, zno, clone);
 		return DM_MAPIO_KILL;
 	}
 
@@ -570,12 +567,12 @@ int dm_zone_map_bio(struct dm_target_io *tio)
 		sts = dm_zone_map_bio_end(md, zno, &orig_bio_details,
 					  *tio->len_ptr);
 		if (sts != BLK_STS_OK)
-			dm_zone_unlock(q, zno, clone);
+			dm_zone_unlock(md->disk, zno, clone);
 		break;
 	case DM_MAPIO_REQUEUE:
 	case DM_MAPIO_KILL:
 	default:
-		dm_zone_unlock(q, zno, clone);
+		dm_zone_unlock(md->disk, zno, clone);
 		sts = BLK_STS_IOERR;
 		break;
 	}
@@ -592,7 +589,6 @@ int dm_zone_map_bio(struct dm_target_io *tio)
 void dm_zone_endio(struct dm_io *io, struct bio *clone)
 {
 	struct mapped_device *md = io->md;
-	struct request_queue *q = md->queue;
 	struct gendisk *disk = md->disk;
 	struct bio *orig_bio = io->orig_bio;
 	unsigned int zwp_offset;
@@ -651,5 +647,5 @@ void dm_zone_endio(struct dm_io *io, struct bio *clone)
 				zwp_offset - bio_sectors(orig_bio);
 	}
 
-	dm_zone_unlock(q, zno, clone);
+	dm_zone_unlock(disk, zno, clone);
 }
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index ccf9a6da8f6e1..f26640ccb9555 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -830,7 +830,7 @@ void nvme_mpath_add_disk(struct nvme_ns *ns, struct nvme_id_ns *id)
 				   ns->head->disk->queue);
 #ifdef CONFIG_BLK_DEV_ZONED
 	if (blk_queue_is_zoned(ns->queue) && ns->head->disk)
-		ns->head->disk->queue->nr_zones = ns->queue->nr_zones;
+		ns->head->disk->nr_zones = ns->disk->nr_zones;
 #endif
 }
 
diff --git a/drivers/nvme/target/zns.c b/drivers/nvme/target/zns.c
index c9b2ce06ca93e..385f2fe2792ff 100644
--- a/drivers/nvme/target/zns.c
+++ b/drivers/nvme/target/zns.c
@@ -57,7 +57,7 @@ bool nvmet_bdev_zns_enable(struct nvmet_ns *ns)
 	 * zones, reject the device. Otherwise, use report zones to detect if
 	 * the device has conventional zones.
 	 */
-	if (ns->bdev->bd_disk->queue->conv_zones_bitmap)
+	if (ns->bdev->bd_disk->conv_zones_bitmap)
 		return false;
 
 	ret = blkdev_report_zones(ns->bdev, 0, bdev_nr_zones(ns->bdev),
diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
index b4106f8997342..b8c97456506ac 100644
--- a/drivers/scsi/sd_zbc.c
+++ b/drivers/scsi/sd_zbc.c
@@ -855,7 +855,7 @@ int sd_zbc_revalidate_zones(struct scsi_disk *sdkp)
 
 	if (sdkp->zone_info.zone_blocks == zone_blocks &&
 	    sdkp->zone_info.nr_zones == nr_zones &&
-	    disk->queue->nr_zones == nr_zones)
+	    disk->nr_zones == nr_zones)
 		goto unlock;
 
 	flags = memalloc_noio_save();
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 43aad0da3305d..1b0b753609975 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -1123,12 +1123,12 @@ void blk_dump_rq_flags(struct request *, char *);
 #ifdef CONFIG_BLK_DEV_ZONED
 static inline unsigned int blk_rq_zone_no(struct request *rq)
 {
-	return blk_queue_zone_no(rq->q, blk_rq_pos(rq));
+	return disk_zone_no(rq->q->disk, blk_rq_pos(rq));
 }
 
 static inline unsigned int blk_rq_zone_is_seq(struct request *rq)
 {
-	return blk_queue_zone_is_seq(rq->q, blk_rq_pos(rq));
+	return disk_zone_is_seq(rq->q->disk, blk_rq_pos(rq));
 }
 
 bool blk_req_needs_zone_write_lock(struct request *rq);
@@ -1150,8 +1150,8 @@ static inline void blk_req_zone_write_unlock(struct request *rq)
 
 static inline bool blk_req_zone_is_write_locked(struct request *rq)
 {
-	return rq->q->seq_zones_wlock &&
-		test_bit(blk_rq_zone_no(rq), rq->q->seq_zones_wlock);
+	return rq->q->disk->seq_zones_wlock &&
+		test_bit(blk_rq_zone_no(rq), rq->q->disk->seq_zones_wlock);
 }
 
 static inline bool blk_req_can_dispatch_to_zone(struct request *rq)
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index f1eca3f5610eb..547eb07848741 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -164,6 +164,29 @@ struct gendisk {
 #ifdef  CONFIG_BLK_DEV_INTEGRITY
 	struct kobject integrity_kobj;
 #endif	/* CONFIG_BLK_DEV_INTEGRITY */
+
+#ifdef CONFIG_BLK_DEV_ZONED
+	/*
+	 * Zoned block device information for request dispatch control.
+	 * nr_zones is the total number of zones of the device. This is always
+	 * 0 for regular block devices. conv_zones_bitmap is a bitmap of nr_zones
+	 * bits which indicates if a zone is conventional (bit set) or
+	 * sequential (bit clear). seq_zones_wlock is a bitmap of nr_zones
+	 * bits which indicates if a zone is write locked, that is, if a write
+	 * request targeting the zone was dispatched.
+	 *
+	 * Reads of this information must be protected with blk_queue_enter() /
+	 * blk_queue_exit(). Modifying this information is only allowed while
+	 * no requests are being processed. See also blk_mq_freeze_queue() and
+	 * blk_mq_unfreeze_queue().
+	 */
+	unsigned int		nr_zones;
+	unsigned int		max_open_zones;
+	unsigned int		max_active_zones;
+	unsigned long		*conv_zones_bitmap;
+	unsigned long		*seq_zones_wlock;
+#endif /* CONFIG_BLK_DEV_ZONED */
+
 #if IS_ENABLED(CONFIG_CDROM)
 	struct cdrom_device_info *cdi;
 #endif
@@ -469,31 +492,6 @@ struct request_queue {
 
 	unsigned int		required_elevator_features;
 
-#ifdef CONFIG_BLK_DEV_ZONED
-	/*
-	 * Zoned block device information for request dispatch control.
-	 * nr_zones is the total number of zones of the device. This is always
-	 * 0 for regular block devices. conv_zones_bitmap is a bitmap of nr_zones
-	 * bits which indicates if a zone is conventional (bit set) or
-	 * sequential (bit clear). seq_zones_wlock is a bitmap of nr_zones
-	 * bits which indicates if a zone is write locked, that is, if a write
-	 * request targeting the zone was dispatched. All three fields are
-	 * initialized by the low level device driver (e.g. scsi/sd.c).
-	 * Stacking drivers (device mappers) may or may not initialize
-	 * these fields.
-	 *
-	 * Reads of this information must be protected with blk_queue_enter() /
-	 * blk_queue_exit(). Modifying this information is only allowed while
-	 * no requests are being processed. See also blk_mq_freeze_queue() and
-	 * blk_mq_unfreeze_queue().
-	 */
-	unsigned int		nr_zones;
-	unsigned long		*conv_zones_bitmap;
-	unsigned long		*seq_zones_wlock;
-	unsigned int		max_open_zones;
-	unsigned int		max_active_zones;
-#endif /* CONFIG_BLK_DEV_ZONED */
-
 	int			node;
 #ifdef CONFIG_BLK_DEV_IO_TRACE
 	struct blk_trace __rcu	*blk_trace;
@@ -670,63 +668,59 @@ static inline bool blk_queue_is_zoned(struct request_queue *q)
 }
 
 #ifdef CONFIG_BLK_DEV_ZONED
-static inline unsigned int blk_queue_nr_zones(struct request_queue *q)
+static inline unsigned int disk_nr_zones(struct gendisk *disk)
 {
-	return blk_queue_is_zoned(q) ? q->nr_zones : 0;
+	return blk_queue_is_zoned(disk->queue) ? disk->nr_zones : 0;
 }
 
-static inline unsigned int blk_queue_zone_no(struct request_queue *q,
-					     sector_t sector)
+static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector)
 {
-	if (!blk_queue_is_zoned(q))
+	if (!blk_queue_is_zoned(disk->queue))
 		return 0;
-	return sector >> ilog2(q->limits.chunk_sectors);
+	return sector >> ilog2(disk->queue->limits.chunk_sectors);
 }
 
-static inline bool blk_queue_zone_is_seq(struct request_queue *q,
-					 sector_t sector)
+static inline bool disk_zone_is_seq(struct gendisk *disk, sector_t sector)
 {
-	if (!blk_queue_is_zoned(q))
+	if (!blk_queue_is_zoned(disk->queue))
 		return false;
-	if (!q->conv_zones_bitmap)
+	if (!disk->conv_zones_bitmap)
 		return true;
-	return !test_bit(blk_queue_zone_no(q, sector), q->conv_zones_bitmap);
+	return !test_bit(disk_zone_no(disk, sector), disk->conv_zones_bitmap);
 }
 
 static inline void disk_set_max_open_zones(struct gendisk *disk,
 		unsigned int max_open_zones)
 {
-	disk->queue->max_open_zones = max_open_zones;
+	disk->max_open_zones = max_open_zones;
 }
 
 static inline void disk_set_max_active_zones(struct gendisk *disk,
 		unsigned int max_active_zones)
 {
-	disk->queue->max_active_zones = max_active_zones;
+	disk->max_active_zones = max_active_zones;
 }
 
 static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
 {
-	return bdev->bd_disk->queue->max_open_zones;
+	return bdev->bd_disk->max_open_zones;
 }
 
 static inline unsigned int bdev_max_active_zones(struct block_device *bdev)
 {
-	return bdev->bd_disk->queue->max_active_zones;
+	return bdev->bd_disk->max_active_zones;
 }
 
 #else /* CONFIG_BLK_DEV_ZONED */
-static inline unsigned int blk_queue_nr_zones(struct request_queue *q)
+static inline unsigned int disk_nr_zones(struct gendisk *disk)
 {
 	return 0;
 }
-static inline bool blk_queue_zone_is_seq(struct request_queue *q,
-					 sector_t sector)
+static inline bool disk_zone_is_seq(struct gendisk *disk, sector_t sector)
 {
 	return false;
 }
-static inline unsigned int blk_queue_zone_no(struct request_queue *q,
-					     sector_t sector)
+static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector)
 {
 	return 0;
 }
@@ -734,6 +728,7 @@ static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
 {
 	return 0;
 }
+
 static inline unsigned int bdev_max_active_zones(struct block_device *bdev)
 {
 	return 0;
@@ -902,14 +897,12 @@ const char *blk_zone_cond_str(enum blk_zone_cond zone_cond);
 
 static inline unsigned int bio_zone_no(struct bio *bio)
 {
-	return blk_queue_zone_no(bdev_get_queue(bio->bi_bdev),
-				 bio->bi_iter.bi_sector);
+	return disk_zone_no(bio->bi_bdev->bd_disk, bio->bi_iter.bi_sector);
 }
 
 static inline unsigned int bio_zone_is_seq(struct bio *bio)
 {
-	return blk_queue_zone_is_seq(bdev_get_queue(bio->bi_bdev),
-				     bio->bi_iter.bi_sector);
+	return disk_zone_is_seq(bio->bi_bdev->bd_disk, bio->bi_iter.bi_sector);
 }
 
 /*
-- 
2.30.2

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


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

* Re: [PATCH 01/17] block: remove a superflous ifdef in blkdev.h
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-04 12:58     ` Johannes Thumshirn
  -1 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 12:58 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

On 04.07.22 14:45, Christoph Hellwig wrote:
> It doesn't hurt to lways have the blk_zone_cond_str prototype, and the
> two inlines can also be defined unconditionally.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  include/linux/blkdev.h | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index b9a94c53c6cd3..270cd0c552924 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -899,8 +899,6 @@ static inline struct request_queue *bdev_get_queue(struct block_device *bdev)
>  	return bdev->bd_queue;	/* this is never NULL */
>  }
>  
> -#ifdef CONFIG_BLK_DEV_ZONED
> -
>  /* Helper to convert BLK_ZONE_ZONE_XXX to its string format XXX */
>  const char *blk_zone_cond_str(enum blk_zone_cond zone_cond);
>  

Won't this break tracing in null_blk, which uses blk_zone_cond_str()?

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

* Re: [dm-devel] [PATCH 01/17] block: remove a superflous ifdef in blkdev.h
@ 2022-07-04 12:58     ` Johannes Thumshirn
  0 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 12:58 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

On 04.07.22 14:45, Christoph Hellwig wrote:
> It doesn't hurt to lways have the blk_zone_cond_str prototype, and the
> two inlines can also be defined unconditionally.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  include/linux/blkdev.h | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index b9a94c53c6cd3..270cd0c552924 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -899,8 +899,6 @@ static inline struct request_queue *bdev_get_queue(struct block_device *bdev)
>  	return bdev->bd_queue;	/* this is never NULL */
>  }
>  
> -#ifdef CONFIG_BLK_DEV_ZONED
> -
>  /* Helper to convert BLK_ZONE_ZONE_XXX to its string format XXX */
>  const char *blk_zone_cond_str(enum blk_zone_cond zone_cond);
>  

Won't this break tracing in null_blk, which uses blk_zone_cond_str()?


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


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

* Re: [PATCH 02/17] block: call blk_queue_free_zone_bitmaps from disk_release
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-04 13:01     ` Johannes Thumshirn
  -1 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 13:01 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

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

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

* Re: [dm-devel] [PATCH 02/17] block: call blk_queue_free_zone_bitmaps from disk_release
@ 2022-07-04 13:01     ` Johannes Thumshirn
  0 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 13:01 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

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] 140+ messages in thread

* Re: [PATCH 01/17] block: remove a superflous ifdef in blkdev.h
  2022-07-04 12:58     ` [dm-devel] " Johannes Thumshirn
@ 2022-07-04 13:01       ` Christoph Hellwig
  -1 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 13:01 UTC (permalink / raw)
  To: Johannes Thumshirn
  Cc: Christoph Hellwig, Jens Axboe, Damien Le Moal, dm-devel,
	linux-block, linux-nvme, linux-scsi

On Mon, Jul 04, 2022 at 12:58:40PM +0000, Johannes Thumshirn wrote:
> > -#ifdef CONFIG_BLK_DEV_ZONED
> > -
> >  /* Helper to convert BLK_ZONE_ZONE_XXX to its string format XXX */
> >  const char *blk_zone_cond_str(enum blk_zone_cond zone_cond);
> >  
> 
> Won't this break tracing in null_blk, which uses blk_zone_cond_str()?

How could removing an ifdef and exposing a prototype unconditionally
in a header break tracing?

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

* Re: [dm-devel] [PATCH 01/17] block: remove a superflous ifdef in blkdev.h
@ 2022-07-04 13:01       ` Christoph Hellwig
  0 siblings, 0 replies; 140+ messages in thread
From: Christoph Hellwig @ 2022-07-04 13:01 UTC (permalink / raw)
  To: Johannes Thumshirn
  Cc: Jens Axboe, linux-scsi, Damien Le Moal, linux-nvme, linux-block,
	dm-devel, Christoph Hellwig

On Mon, Jul 04, 2022 at 12:58:40PM +0000, Johannes Thumshirn wrote:
> > -#ifdef CONFIG_BLK_DEV_ZONED
> > -
> >  /* Helper to convert BLK_ZONE_ZONE_XXX to its string format XXX */
> >  const char *blk_zone_cond_str(enum blk_zone_cond zone_cond);
> >  
> 
> Won't this break tracing in null_blk, which uses blk_zone_cond_str()?

How could removing an ifdef and exposing a prototype unconditionally
in a header break tracing?

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


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

* Re: [PATCH 01/17] block: remove a superflous ifdef in blkdev.h
  2022-07-04 13:01       ` [dm-devel] " Christoph Hellwig
@ 2022-07-04 13:04         ` Johannes Thumshirn
  -1 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 13:04 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Jens Axboe, Damien Le Moal, dm-devel, linux-block, linux-nvme,
	linux-scsi

On 04.07.22 15:02, Christoph Hellwig wrote:
> On Mon, Jul 04, 2022 at 12:58:40PM +0000, Johannes Thumshirn wrote:
>>> -#ifdef CONFIG_BLK_DEV_ZONED
>>> -
>>>  /* Helper to convert BLK_ZONE_ZONE_XXX to its string format XXX */
>>>  const char *blk_zone_cond_str(enum blk_zone_cond zone_cond);
>>>  
>>
>> Won't this break tracing in null_blk, which uses blk_zone_cond_str()?
> 
> How could removing an ifdef and exposing a prototype unconditionally
> in a header break tracing?
> 

*facepalm* the trace code doesn't get compiled without CONFIG_BLK_DEV_ZONED.
My bad.

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

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

* Re: [dm-devel] [PATCH 01/17] block: remove a superflous ifdef in blkdev.h
@ 2022-07-04 13:04         ` Johannes Thumshirn
  0 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 13:04 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Jens Axboe, linux-scsi, Damien Le Moal, linux-nvme, linux-block,
	dm-devel

On 04.07.22 15:02, Christoph Hellwig wrote:
> On Mon, Jul 04, 2022 at 12:58:40PM +0000, Johannes Thumshirn wrote:
>>> -#ifdef CONFIG_BLK_DEV_ZONED
>>> -
>>>  /* Helper to convert BLK_ZONE_ZONE_XXX to its string format XXX */
>>>  const char *blk_zone_cond_str(enum blk_zone_cond zone_cond);
>>>  
>>
>> Won't this break tracing in null_blk, which uses blk_zone_cond_str()?
> 
> How could removing an ifdef and exposing a prototype unconditionally
> in a header break tracing?
> 

*facepalm* the trace code doesn't get compiled without CONFIG_BLK_DEV_ZONED.
My bad.

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] 140+ messages in thread

* Re: [PATCH 03/17] block: use bdev_is_zoned instead of open coding it
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-04 13:13     ` Johannes Thumshirn
  -1 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 13:13 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

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

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

* Re: [dm-devel] [PATCH 03/17] block: use bdev_is_zoned instead of open coding it
@ 2022-07-04 13:13     ` Johannes Thumshirn
  0 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 13:13 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

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] 140+ messages in thread

* Re: [PATCH 04/17] block: simplify blk_mq_plug
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-04 13:14     ` Johannes Thumshirn
  -1 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 13:14 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

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

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

* Re: [dm-devel] [PATCH 04/17] block: simplify blk_mq_plug
@ 2022-07-04 13:14     ` Johannes Thumshirn
  0 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 13:14 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

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] 140+ messages in thread

* Re: [PATCH 05/17] block: export blkdev_zone_mgmt_all
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-04 13:17     ` Johannes Thumshirn
  -1 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 13:17 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

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

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

* Re: [dm-devel] [PATCH 05/17] block: export blkdev_zone_mgmt_all
@ 2022-07-04 13:17     ` Johannes Thumshirn
  0 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 13:17 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

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] 140+ messages in thread

* Re: [PATCH 06/17] nvmet: use blkdev_zone_mgmt_all
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-04 13:18     ` Johannes Thumshirn
  -1 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 13:18 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

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

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

* Re: [dm-devel] [PATCH 06/17] nvmet: use blkdev_zone_mgmt_all
@ 2022-07-04 13:18     ` Johannes Thumshirn
  0 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 13:18 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

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] 140+ messages in thread

* Re: [PATCH 07/17] block: simplify blk_check_zone_append
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-04 13:21     ` Johannes Thumshirn
  -1 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 13:21 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

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

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

* Re: [dm-devel] [PATCH 07/17] block: simplify blk_check_zone_append
@ 2022-07-04 13:21     ` Johannes Thumshirn
  0 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 13:21 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

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] 140+ messages in thread

* Re: [PATCH 08/17] block: pass a gendisk to blk_queue_set_zoned
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-04 13:22     ` Johannes Thumshirn
  -1 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 13:22 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

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

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

* Re: [dm-devel] [PATCH 08/17] block: pass a gendisk to blk_queue_set_zoned
@ 2022-07-04 13:22     ` Johannes Thumshirn
  0 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 13:22 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

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] 140+ messages in thread

* Re: [PATCH 09/17] block: pass a gendisk to blk_queue_clear_zone_settings
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-04 13:23     ` Johannes Thumshirn
  -1 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 13:23 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

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

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

* Re: [dm-devel] [PATCH 09/17] block: pass a gendisk to blk_queue_clear_zone_settings
@ 2022-07-04 13:23     ` Johannes Thumshirn
  0 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 13:23 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

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] 140+ messages in thread

* Re: [PATCH 10/17] block: pass a gendisk to blk_queue_free_zone_bitmaps
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-04 13:23     ` Johannes Thumshirn
  -1 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 13:23 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

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

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

* Re: [dm-devel] [PATCH 10/17] block: pass a gendisk to blk_queue_free_zone_bitmaps
@ 2022-07-04 13:23     ` Johannes Thumshirn
  0 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 13:23 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

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] 140+ messages in thread

* Re: [PATCH 11/17] block: remove queue_max_open_zones and queue_max_active_zones
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-04 13:23     ` Johannes Thumshirn
  -1 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 13:23 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

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

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

* Re: [dm-devel] [PATCH 11/17] block: remove queue_max_open_zones and queue_max_active_zones
@ 2022-07-04 13:23     ` Johannes Thumshirn
  0 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 13:23 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

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] 140+ messages in thread

* Re: [PATCH 12/17] block: pass a gendisk to blk_queue_max_open_zones and blk_queue_max_active_zones
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-04 13:24     ` Johannes Thumshirn
  -1 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 13:24 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

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

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

* Re: [dm-devel] [PATCH 12/17] block: pass a gendisk to blk_queue_max_open_zones and blk_queue_max_active_zones
@ 2022-07-04 13:24     ` Johannes Thumshirn
  0 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 13:24 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

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] 140+ messages in thread

* Re: [PATCH 13/17] block: replace blkdev_nr_zones with bdev_nr_zones
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-04 13:27     ` Johannes Thumshirn
  -1 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 13:27 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

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

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

* Re: [dm-devel] [PATCH 13/17] block: replace blkdev_nr_zones with bdev_nr_zones
@ 2022-07-04 13:27     ` Johannes Thumshirn
  0 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 13:27 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

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] 140+ messages in thread

* Re: [dm-devel] [PATCH 14/17] block: use bdev based helpers in blkdev_zone_mgmt / blkdev_zone_mgmt_all
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-04 13:27     ` Johannes Thumshirn
  -1 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 13:27 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

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] 140+ messages in thread

* Re: [PATCH 14/17] block: use bdev based helpers in blkdev_zone_mgmt / blkdev_zone_mgmt_all
@ 2022-07-04 13:27     ` Johannes Thumshirn
  0 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 13:27 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

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

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

* Re: [PATCH 15/17] dm-zoned: cleanup dmz_fixup_devices
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-04 13:28     ` Johannes Thumshirn
  -1 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 13:28 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

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

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

* Re: [dm-devel] [PATCH 15/17] dm-zoned: cleanup dmz_fixup_devices
@ 2022-07-04 13:28     ` Johannes Thumshirn
  0 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 13:28 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

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] 140+ messages in thread

* Re: [dm-devel] [PATCH 16/17] block: remove blk_queue_zone_sectors
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-04 13:29     ` Johannes Thumshirn
  -1 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 13:29 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

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] 140+ messages in thread

* Re: [PATCH 16/17] block: remove blk_queue_zone_sectors
@ 2022-07-04 13:29     ` Johannes Thumshirn
  0 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 13:29 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

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

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

* Re: [dm-devel] [PATCH 17/17] block: move zone related fields to struct gendisk
  2022-07-04 12:45   ` [dm-devel] " Christoph Hellwig
@ 2022-07-04 13:31     ` Johannes Thumshirn
  -1 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 13:31 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

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] 140+ messages in thread

* Re: [PATCH 17/17] block: move zone related fields to struct gendisk
@ 2022-07-04 13:31     ` Johannes Thumshirn
  0 siblings, 0 replies; 140+ messages in thread
From: Johannes Thumshirn @ 2022-07-04 13:31 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

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

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

* Re: [PATCH 01/17] block: remove a superflous ifdef in blkdev.h
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-05  2:26     ` Damien Le Moal
  -1 siblings, 0 replies; 140+ messages in thread
From: Damien Le Moal @ 2022-07-05  2:26 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

On 7/4/22 21:44, Christoph Hellwig wrote:
> It doesn't hurt to lways have the blk_zone_cond_str prototype, and the

s/lways/always

> two inlines can also be defined unconditionally.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  include/linux/blkdev.h | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index b9a94c53c6cd3..270cd0c552924 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -899,8 +899,6 @@ static inline struct request_queue *bdev_get_queue(struct block_device *bdev)
>  	return bdev->bd_queue;	/* this is never NULL */
>  }
>  
> -#ifdef CONFIG_BLK_DEV_ZONED
> -
>  /* Helper to convert BLK_ZONE_ZONE_XXX to its string format XXX */
>  const char *blk_zone_cond_str(enum blk_zone_cond zone_cond);

This is defined in block/blk-zoned.c and so not compiled if
CONFIG_BLK_DEV_ZONED is not defined. But I guess this should be fine since
if there is a user of this function with !CONFIG_BLK_DEV_ZONED, a build
should fail anyway.

>  
> @@ -915,7 +913,6 @@ static inline unsigned int bio_zone_is_seq(struct bio *bio)
>  	return blk_queue_zone_is_seq(bdev_get_queue(bio->bi_bdev),
>  				     bio->bi_iter.bi_sector);
>  }
> -#endif /* CONFIG_BLK_DEV_ZONED */
>  
>  /*
>   * Return how much of the chunk is left to be used for I/O at a given offset.

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

-- 
Damien Le Moal
Western Digital Research

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

* Re: [dm-devel] [PATCH 01/17] block: remove a superflous ifdef in blkdev.h
@ 2022-07-05  2:26     ` Damien Le Moal
  0 siblings, 0 replies; 140+ messages in thread
From: Damien Le Moal @ 2022-07-05  2:26 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

On 7/4/22 21:44, Christoph Hellwig wrote:
> It doesn't hurt to lways have the blk_zone_cond_str prototype, and the

s/lways/always

> two inlines can also be defined unconditionally.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  include/linux/blkdev.h | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index b9a94c53c6cd3..270cd0c552924 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -899,8 +899,6 @@ static inline struct request_queue *bdev_get_queue(struct block_device *bdev)
>  	return bdev->bd_queue;	/* this is never NULL */
>  }
>  
> -#ifdef CONFIG_BLK_DEV_ZONED
> -
>  /* Helper to convert BLK_ZONE_ZONE_XXX to its string format XXX */
>  const char *blk_zone_cond_str(enum blk_zone_cond zone_cond);

This is defined in block/blk-zoned.c and so not compiled if
CONFIG_BLK_DEV_ZONED is not defined. But I guess this should be fine since
if there is a user of this function with !CONFIG_BLK_DEV_ZONED, a build
should fail anyway.

>  
> @@ -915,7 +913,6 @@ static inline unsigned int bio_zone_is_seq(struct bio *bio)
>  	return blk_queue_zone_is_seq(bdev_get_queue(bio->bi_bdev),
>  				     bio->bi_iter.bi_sector);
>  }
> -#endif /* CONFIG_BLK_DEV_ZONED */
>  
>  /*
>   * Return how much of the chunk is left to be used for I/O at a given offset.

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] 140+ messages in thread

* Re: [PATCH 02/17] block: call blk_queue_free_zone_bitmaps from disk_release
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-05  2:27     ` Damien Le Moal
  -1 siblings, 0 replies; 140+ messages in thread
From: Damien Le Moal @ 2022-07-05  2:27 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

On 7/4/22 21:44, Christoph Hellwig wrote:
> The zone bitmaps are only used for non-passthrough I/O, so free them as
> soon as the disk is released.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  block/blk-sysfs.c | 2 --
>  block/genhd.c     | 1 +
>  2 files changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
> index 58cb9cb9f48cd..7590810cf13fc 100644
> --- a/block/blk-sysfs.c
> +++ b/block/blk-sysfs.c
> @@ -776,8 +776,6 @@ static void blk_release_queue(struct kobject *kobj)
>  	blk_free_queue_stats(q->stats);
>  	kfree(q->poll_stat);
>  
> -	blk_queue_free_zone_bitmaps(q);
> -
>  	if (queue_is_mq(q))
>  		blk_mq_release(q);
>  
> diff --git a/block/genhd.c b/block/genhd.c
> index b1fb7e058b9cc..d0bdeb93e922c 100644
> --- a/block/genhd.c
> +++ b/block/genhd.c
> @@ -1165,6 +1165,7 @@ static void disk_release(struct device *dev)
>  
>  	disk_release_events(disk);
>  	kfree(disk->random);
> +	blk_queue_free_zone_bitmaps(disk->queue);
>  	xa_destroy(&disk->part_tbl);
>  
>  	disk->queue->disk = NULL;

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

-- 
Damien Le Moal
Western Digital Research

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

* Re: [dm-devel] [PATCH 02/17] block: call blk_queue_free_zone_bitmaps from disk_release
@ 2022-07-05  2:27     ` Damien Le Moal
  0 siblings, 0 replies; 140+ messages in thread
From: Damien Le Moal @ 2022-07-05  2:27 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

On 7/4/22 21:44, Christoph Hellwig wrote:
> The zone bitmaps are only used for non-passthrough I/O, so free them as
> soon as the disk is released.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  block/blk-sysfs.c | 2 --
>  block/genhd.c     | 1 +
>  2 files changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
> index 58cb9cb9f48cd..7590810cf13fc 100644
> --- a/block/blk-sysfs.c
> +++ b/block/blk-sysfs.c
> @@ -776,8 +776,6 @@ static void blk_release_queue(struct kobject *kobj)
>  	blk_free_queue_stats(q->stats);
>  	kfree(q->poll_stat);
>  
> -	blk_queue_free_zone_bitmaps(q);
> -
>  	if (queue_is_mq(q))
>  		blk_mq_release(q);
>  
> diff --git a/block/genhd.c b/block/genhd.c
> index b1fb7e058b9cc..d0bdeb93e922c 100644
> --- a/block/genhd.c
> +++ b/block/genhd.c
> @@ -1165,6 +1165,7 @@ static void disk_release(struct device *dev)
>  
>  	disk_release_events(disk);
>  	kfree(disk->random);
> +	blk_queue_free_zone_bitmaps(disk->queue);
>  	xa_destroy(&disk->part_tbl);
>  
>  	disk->queue->disk = NULL;

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] 140+ messages in thread

* Re: [PATCH 03/17] block: use bdev_is_zoned instead of open coding it
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-05  2:28     ` Damien Le Moal
  -1 siblings, 0 replies; 140+ messages in thread
From: Damien Le Moal @ 2022-07-05  2:28 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

On 7/4/22 21:44, Christoph Hellwig wrote:
> Use bdev_is_zoned in all places where a block_device is available instead
> of open coding it.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

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


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

* Re: [dm-devel] [PATCH 03/17] block: use bdev_is_zoned instead of open coding it
@ 2022-07-05  2:28     ` Damien Le Moal
  0 siblings, 0 replies; 140+ messages in thread
From: Damien Le Moal @ 2022-07-05  2:28 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

On 7/4/22 21:44, Christoph Hellwig wrote:
> Use bdev_is_zoned in all places where a block_device is available instead
> of open coding it.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

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

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


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

* Re: [PATCH 04/17] block: simplify blk_mq_plug
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-05  2:30     ` Damien Le Moal
  -1 siblings, 0 replies; 140+ messages in thread
From: Damien Le Moal @ 2022-07-05  2:30 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

On 7/4/22 21:44, Christoph Hellwig wrote:
> Drop the unused q argument, and invert the check to move the exception
> into a branch and the regular path as the normal return.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  block/blk-core.c  |  2 +-
>  block/blk-merge.c |  2 +-
>  block/blk-mq.c    |  2 +-
>  block/blk-mq.h    | 18 ++++++++----------
>  4 files changed, 11 insertions(+), 13 deletions(-)
> 
> diff --git a/block/blk-core.c b/block/blk-core.c
> index 6bcca0b686de4..bc16e9bae2dc4 100644
> --- a/block/blk-core.c
> +++ b/block/blk-core.c
> @@ -719,7 +719,7 @@ void submit_bio_noacct(struct bio *bio)
>  
>  	might_sleep();
>  
> -	plug = blk_mq_plug(q, bio);
> +	plug = blk_mq_plug(bio);
>  	if (plug && plug->nowait)
>  		bio->bi_opf |= REQ_NOWAIT;
>  
> diff --git a/block/blk-merge.c b/block/blk-merge.c
> index 0f5f42ebd0bb0..5abf5aa5a5f0e 100644
> --- a/block/blk-merge.c
> +++ b/block/blk-merge.c
> @@ -1051,7 +1051,7 @@ bool blk_attempt_plug_merge(struct request_queue *q, struct bio *bio,
>  	struct blk_plug *plug;
>  	struct request *rq;
>  
> -	plug = blk_mq_plug(q, bio);
> +	plug = blk_mq_plug(bio);
>  	if (!plug || rq_list_empty(plug->mq_list))
>  		return false;
>  
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index 15c7c5c4ad222..dc714dff73001 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -2804,7 +2804,7 @@ static void bio_set_ioprio(struct bio *bio)
>  void blk_mq_submit_bio(struct bio *bio)
>  {
>  	struct request_queue *q = bdev_get_queue(bio->bi_bdev);
> -	struct blk_plug *plug = blk_mq_plug(q, bio);
> +	struct blk_plug *plug = blk_mq_plug(bio);
>  	const int is_sync = op_is_sync(bio->bi_opf);
>  	struct request *rq;
>  	unsigned int nr_segs = 1;
> diff --git a/block/blk-mq.h b/block/blk-mq.h
> index 31d75a83a562d..1cc0b17d69229 100644
> --- a/block/blk-mq.h
> +++ b/block/blk-mq.h
> @@ -294,7 +294,6 @@ static inline void blk_mq_clear_mq_map(struct blk_mq_queue_map *qmap)
>  
>  /*
>   * blk_mq_plug() - Get caller context plug
> - * @q: request queue
>   * @bio : the bio being submitted by the caller context
>   *
>   * Plugging, by design, may delay the insertion of BIOs into the elevator in
> @@ -305,23 +304,22 @@ static inline void blk_mq_clear_mq_map(struct blk_mq_queue_map *qmap)
>   * order. While this is not a problem with regular block devices, this ordering
>   * change can cause write BIO failures with zoned block devices as these
>   * require sequential write patterns to zones. Prevent this from happening by
> - * ignoring the plug state of a BIO issuing context if the target request queue
> - * is for a zoned block device and the BIO to plug is a write operation.
> + * ignoring the plug state of a BIO issuing context if is for a zoned block

s/if is/if it is/

> + 8 device and the BIO to plug is a write operation.

s/8/*

>   *
>   * Return current->plug if the bio can be plugged and NULL otherwise
>   */
> -static inline struct blk_plug *blk_mq_plug(struct request_queue *q,
> -					   struct bio *bio)
> +static inline struct blk_plug *blk_mq_plug( struct bio *bio)
>  {
> +	/* Zoned block device write operation case: do not plug the BIO */
> +	if (bdev_is_zoned(bio->bi_bdev) && op_is_write(bio_op(bio)))
> +		return NULL;
> +
>  	/*
>  	 * For regular block devices or read operations, use the context plug
>  	 * which may be NULL if blk_start_plug() was not executed.
>  	 */
> -	if (!bdev_is_zoned(bio->bi_bdev) || !op_is_write(bio_op(bio)))
> -		return current->plug;
> -
> -	/* Zoned block device write operation case: do not plug the BIO */
> -	return NULL;
> +	return current->plug;
>  }
>  
>  /* Free all requests on the list */

With the typos fixed, looks good.

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

-- 
Damien Le Moal
Western Digital Research

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

* Re: [dm-devel] [PATCH 04/17] block: simplify blk_mq_plug
@ 2022-07-05  2:30     ` Damien Le Moal
  0 siblings, 0 replies; 140+ messages in thread
From: Damien Le Moal @ 2022-07-05  2:30 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

On 7/4/22 21:44, Christoph Hellwig wrote:
> Drop the unused q argument, and invert the check to move the exception
> into a branch and the regular path as the normal return.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  block/blk-core.c  |  2 +-
>  block/blk-merge.c |  2 +-
>  block/blk-mq.c    |  2 +-
>  block/blk-mq.h    | 18 ++++++++----------
>  4 files changed, 11 insertions(+), 13 deletions(-)
> 
> diff --git a/block/blk-core.c b/block/blk-core.c
> index 6bcca0b686de4..bc16e9bae2dc4 100644
> --- a/block/blk-core.c
> +++ b/block/blk-core.c
> @@ -719,7 +719,7 @@ void submit_bio_noacct(struct bio *bio)
>  
>  	might_sleep();
>  
> -	plug = blk_mq_plug(q, bio);
> +	plug = blk_mq_plug(bio);
>  	if (plug && plug->nowait)
>  		bio->bi_opf |= REQ_NOWAIT;
>  
> diff --git a/block/blk-merge.c b/block/blk-merge.c
> index 0f5f42ebd0bb0..5abf5aa5a5f0e 100644
> --- a/block/blk-merge.c
> +++ b/block/blk-merge.c
> @@ -1051,7 +1051,7 @@ bool blk_attempt_plug_merge(struct request_queue *q, struct bio *bio,
>  	struct blk_plug *plug;
>  	struct request *rq;
>  
> -	plug = blk_mq_plug(q, bio);
> +	plug = blk_mq_plug(bio);
>  	if (!plug || rq_list_empty(plug->mq_list))
>  		return false;
>  
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index 15c7c5c4ad222..dc714dff73001 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -2804,7 +2804,7 @@ static void bio_set_ioprio(struct bio *bio)
>  void blk_mq_submit_bio(struct bio *bio)
>  {
>  	struct request_queue *q = bdev_get_queue(bio->bi_bdev);
> -	struct blk_plug *plug = blk_mq_plug(q, bio);
> +	struct blk_plug *plug = blk_mq_plug(bio);
>  	const int is_sync = op_is_sync(bio->bi_opf);
>  	struct request *rq;
>  	unsigned int nr_segs = 1;
> diff --git a/block/blk-mq.h b/block/blk-mq.h
> index 31d75a83a562d..1cc0b17d69229 100644
> --- a/block/blk-mq.h
> +++ b/block/blk-mq.h
> @@ -294,7 +294,6 @@ static inline void blk_mq_clear_mq_map(struct blk_mq_queue_map *qmap)
>  
>  /*
>   * blk_mq_plug() - Get caller context plug
> - * @q: request queue
>   * @bio : the bio being submitted by the caller context
>   *
>   * Plugging, by design, may delay the insertion of BIOs into the elevator in
> @@ -305,23 +304,22 @@ static inline void blk_mq_clear_mq_map(struct blk_mq_queue_map *qmap)
>   * order. While this is not a problem with regular block devices, this ordering
>   * change can cause write BIO failures with zoned block devices as these
>   * require sequential write patterns to zones. Prevent this from happening by
> - * ignoring the plug state of a BIO issuing context if the target request queue
> - * is for a zoned block device and the BIO to plug is a write operation.
> + * ignoring the plug state of a BIO issuing context if is for a zoned block

s/if is/if it is/

> + 8 device and the BIO to plug is a write operation.

s/8/*

>   *
>   * Return current->plug if the bio can be plugged and NULL otherwise
>   */
> -static inline struct blk_plug *blk_mq_plug(struct request_queue *q,
> -					   struct bio *bio)
> +static inline struct blk_plug *blk_mq_plug( struct bio *bio)
>  {
> +	/* Zoned block device write operation case: do not plug the BIO */
> +	if (bdev_is_zoned(bio->bi_bdev) && op_is_write(bio_op(bio)))
> +		return NULL;
> +
>  	/*
>  	 * For regular block devices or read operations, use the context plug
>  	 * which may be NULL if blk_start_plug() was not executed.
>  	 */
> -	if (!bdev_is_zoned(bio->bi_bdev) || !op_is_write(bio_op(bio)))
> -		return current->plug;
> -
> -	/* Zoned block device write operation case: do not plug the BIO */
> -	return NULL;
> +	return current->plug;
>  }
>  
>  /* Free all requests on the list */

With the typos fixed, looks good.

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] 140+ messages in thread

* Re: [PATCH 05/17] block: export blkdev_zone_mgmt_all
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-05  2:31     ` Damien Le Moal
  -1 siblings, 0 replies; 140+ messages in thread
From: Damien Le Moal @ 2022-07-05  2:31 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

On 7/4/22 21:44, Christoph Hellwig wrote:
> Export blkdev_zone_mgmt_all so that the nvme target can use it instead
> of duplicating the functionality.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

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

> ---
>  block/blk-zoned.c      | 10 +++++-----
>  include/linux/blkdev.h |  2 ++
>  2 files changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/block/blk-zoned.c b/block/blk-zoned.c
> index 90a5c9cc80ab3..7fbe395fa51fc 100644
> --- a/block/blk-zoned.c
> +++ b/block/blk-zoned.c
> @@ -185,8 +185,8 @@ static int blk_zone_need_reset_cb(struct blk_zone *zone, unsigned int idx,
>  	}
>  }
>  
> -static int blkdev_zone_reset_all_emulated(struct block_device *bdev,
> -					  gfp_t gfp_mask)
> +int blkdev_zone_mgmt_all(struct block_device *bdev, unsigned int op,
> +			 gfp_t gfp_mask)
>  {
>  	struct request_queue *q = bdev_get_queue(bdev);
>  	sector_t capacity = get_capacity(bdev->bd_disk);
> @@ -213,8 +213,7 @@ static int blkdev_zone_reset_all_emulated(struct block_device *bdev,
>  			continue;
>  		}
>  
> -		bio = blk_next_bio(bio, bdev, 0, REQ_OP_ZONE_RESET | REQ_SYNC,
> -				   gfp_mask);
> +		bio = blk_next_bio(bio, bdev, 0, op | REQ_SYNC, gfp_mask);
>  		bio->bi_iter.bi_sector = sector;
>  		sector += zone_sectors;
>  
> @@ -231,6 +230,7 @@ static int blkdev_zone_reset_all_emulated(struct block_device *bdev,
>  	kfree(need_reset);
>  	return ret;
>  }
> +EXPORT_SYMBOL_GPL(blkdev_zone_mgmt_all);
>  
>  static int blkdev_zone_reset_all(struct block_device *bdev, gfp_t gfp_mask)
>  {
> @@ -295,7 +295,7 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op,
>  	 */
>  	if (op == REQ_OP_ZONE_RESET && sector == 0 && nr_sectors == capacity) {
>  		if (!blk_queue_zone_resetall(q))
> -			return blkdev_zone_reset_all_emulated(bdev, gfp_mask);
> +			return blkdev_zone_mgmt_all(bdev, op, gfp_mask);
>  		return blkdev_zone_reset_all(bdev, gfp_mask);
>  	}
>  
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index 270cd0c552924..b9baee910b825 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -302,6 +302,8 @@ unsigned int blkdev_nr_zones(struct gendisk *disk);
>  extern int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op,
>  			    sector_t sectors, sector_t nr_sectors,
>  			    gfp_t gfp_mask);
> +int blkdev_zone_mgmt_all(struct block_device *bdev, unsigned int op,
> +			 gfp_t gfp_mask);
>  int blk_revalidate_disk_zones(struct gendisk *disk,
>  			      void (*update_driver_data)(struct gendisk *disk));
>  


-- 
Damien Le Moal
Western Digital Research

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

* Re: [dm-devel] [PATCH 05/17] block: export blkdev_zone_mgmt_all
@ 2022-07-05  2:31     ` Damien Le Moal
  0 siblings, 0 replies; 140+ messages in thread
From: Damien Le Moal @ 2022-07-05  2:31 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

On 7/4/22 21:44, Christoph Hellwig wrote:
> Export blkdev_zone_mgmt_all so that the nvme target can use it instead
> of duplicating the functionality.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

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

> ---
>  block/blk-zoned.c      | 10 +++++-----
>  include/linux/blkdev.h |  2 ++
>  2 files changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/block/blk-zoned.c b/block/blk-zoned.c
> index 90a5c9cc80ab3..7fbe395fa51fc 100644
> --- a/block/blk-zoned.c
> +++ b/block/blk-zoned.c
> @@ -185,8 +185,8 @@ static int blk_zone_need_reset_cb(struct blk_zone *zone, unsigned int idx,
>  	}
>  }
>  
> -static int blkdev_zone_reset_all_emulated(struct block_device *bdev,
> -					  gfp_t gfp_mask)
> +int blkdev_zone_mgmt_all(struct block_device *bdev, unsigned int op,
> +			 gfp_t gfp_mask)
>  {
>  	struct request_queue *q = bdev_get_queue(bdev);
>  	sector_t capacity = get_capacity(bdev->bd_disk);
> @@ -213,8 +213,7 @@ static int blkdev_zone_reset_all_emulated(struct block_device *bdev,
>  			continue;
>  		}
>  
> -		bio = blk_next_bio(bio, bdev, 0, REQ_OP_ZONE_RESET | REQ_SYNC,
> -				   gfp_mask);
> +		bio = blk_next_bio(bio, bdev, 0, op | REQ_SYNC, gfp_mask);
>  		bio->bi_iter.bi_sector = sector;
>  		sector += zone_sectors;
>  
> @@ -231,6 +230,7 @@ static int blkdev_zone_reset_all_emulated(struct block_device *bdev,
>  	kfree(need_reset);
>  	return ret;
>  }
> +EXPORT_SYMBOL_GPL(blkdev_zone_mgmt_all);
>  
>  static int blkdev_zone_reset_all(struct block_device *bdev, gfp_t gfp_mask)
>  {
> @@ -295,7 +295,7 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op,
>  	 */
>  	if (op == REQ_OP_ZONE_RESET && sector == 0 && nr_sectors == capacity) {
>  		if (!blk_queue_zone_resetall(q))
> -			return blkdev_zone_reset_all_emulated(bdev, gfp_mask);
> +			return blkdev_zone_mgmt_all(bdev, op, gfp_mask);
>  		return blkdev_zone_reset_all(bdev, gfp_mask);
>  	}
>  
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index 270cd0c552924..b9baee910b825 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -302,6 +302,8 @@ unsigned int blkdev_nr_zones(struct gendisk *disk);
>  extern int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op,
>  			    sector_t sectors, sector_t nr_sectors,
>  			    gfp_t gfp_mask);
> +int blkdev_zone_mgmt_all(struct block_device *bdev, unsigned int op,
> +			 gfp_t gfp_mask);
>  int blk_revalidate_disk_zones(struct gendisk *disk,
>  			      void (*update_driver_data)(struct gendisk *disk));
>  


-- 
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] 140+ messages in thread

* Re: [PATCH 05/17] block: export blkdev_zone_mgmt_all
  2022-07-05  2:31     ` [dm-devel] " Damien Le Moal
@ 2022-07-05  2:39       ` Damien Le Moal
  -1 siblings, 0 replies; 140+ messages in thread
From: Damien Le Moal @ 2022-07-05  2:39 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

On 7/5/22 11:31, Damien Le Moal wrote:
> On 7/4/22 21:44, Christoph Hellwig wrote:
>> Export blkdev_zone_mgmt_all so that the nvme target can use it instead
>> of duplicating the functionality.
>>
>> Signed-off-by: Christoph Hellwig <hch@lst.de>
> 
> Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>

Actually, looking again at this, if we generalize
blkdev_zone_reset_all_emulated() into blkdev_zone_mgmt_all(), we should
not allocate the need_reset bitmap if op is not reset. And the emulation
for open/close/finish all is a bit tricky as we have to look at the
current state of the zones, so we still need the report. The bitmat should
this be something like "do_op" and the bits in it set using a helper for
the zone depending on the op. Then using that function as is in nvmet will
work. Otherwise, as-is, I think it will break something in nvmet.

> 
>> ---
>>  block/blk-zoned.c      | 10 +++++-----
>>  include/linux/blkdev.h |  2 ++
>>  2 files changed, 7 insertions(+), 5 deletions(-)
>>
>> diff --git a/block/blk-zoned.c b/block/blk-zoned.c
>> index 90a5c9cc80ab3..7fbe395fa51fc 100644
>> --- a/block/blk-zoned.c
>> +++ b/block/blk-zoned.c
>> @@ -185,8 +185,8 @@ static int blk_zone_need_reset_cb(struct blk_zone *zone, unsigned int idx,
>>  	}
>>  }
>>  
>> -static int blkdev_zone_reset_all_emulated(struct block_device *bdev,
>> -					  gfp_t gfp_mask)
>> +int blkdev_zone_mgmt_all(struct block_device *bdev, unsigned int op,
>> +			 gfp_t gfp_mask)
>>  {
>>  	struct request_queue *q = bdev_get_queue(bdev);
>>  	sector_t capacity = get_capacity(bdev->bd_disk);
>> @@ -213,8 +213,7 @@ static int blkdev_zone_reset_all_emulated(struct block_device *bdev,
>>  			continue;
>>  		}
>>  
>> -		bio = blk_next_bio(bio, bdev, 0, REQ_OP_ZONE_RESET | REQ_SYNC,
>> -				   gfp_mask);
>> +		bio = blk_next_bio(bio, bdev, 0, op | REQ_SYNC, gfp_mask);
>>  		bio->bi_iter.bi_sector = sector;
>>  		sector += zone_sectors;
>>  
>> @@ -231,6 +230,7 @@ static int blkdev_zone_reset_all_emulated(struct block_device *bdev,
>>  	kfree(need_reset);
>>  	return ret;
>>  }
>> +EXPORT_SYMBOL_GPL(blkdev_zone_mgmt_all);
>>  
>>  static int blkdev_zone_reset_all(struct block_device *bdev, gfp_t gfp_mask)
>>  {
>> @@ -295,7 +295,7 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op,
>>  	 */
>>  	if (op == REQ_OP_ZONE_RESET && sector == 0 && nr_sectors == capacity) {
>>  		if (!blk_queue_zone_resetall(q))
>> -			return blkdev_zone_reset_all_emulated(bdev, gfp_mask);
>> +			return blkdev_zone_mgmt_all(bdev, op, gfp_mask);
>>  		return blkdev_zone_reset_all(bdev, gfp_mask);
>>  	}
>>  
>> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
>> index 270cd0c552924..b9baee910b825 100644
>> --- a/include/linux/blkdev.h
>> +++ b/include/linux/blkdev.h
>> @@ -302,6 +302,8 @@ unsigned int blkdev_nr_zones(struct gendisk *disk);
>>  extern int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op,
>>  			    sector_t sectors, sector_t nr_sectors,
>>  			    gfp_t gfp_mask);
>> +int blkdev_zone_mgmt_all(struct block_device *bdev, unsigned int op,
>> +			 gfp_t gfp_mask);
>>  int blk_revalidate_disk_zones(struct gendisk *disk,
>>  			      void (*update_driver_data)(struct gendisk *disk));
>>  
> 
> 


-- 
Damien Le Moal
Western Digital Research

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

* Re: [dm-devel] [PATCH 05/17] block: export blkdev_zone_mgmt_all
@ 2022-07-05  2:39       ` Damien Le Moal
  0 siblings, 0 replies; 140+ messages in thread
From: Damien Le Moal @ 2022-07-05  2:39 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

On 7/5/22 11:31, Damien Le Moal wrote:
> On 7/4/22 21:44, Christoph Hellwig wrote:
>> Export blkdev_zone_mgmt_all so that the nvme target can use it instead
>> of duplicating the functionality.
>>
>> Signed-off-by: Christoph Hellwig <hch@lst.de>
> 
> Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>

Actually, looking again at this, if we generalize
blkdev_zone_reset_all_emulated() into blkdev_zone_mgmt_all(), we should
not allocate the need_reset bitmap if op is not reset. And the emulation
for open/close/finish all is a bit tricky as we have to look at the
current state of the zones, so we still need the report. The bitmat should
this be something like "do_op" and the bits in it set using a helper for
the zone depending on the op. Then using that function as is in nvmet will
work. Otherwise, as-is, I think it will break something in nvmet.

> 
>> ---
>>  block/blk-zoned.c      | 10 +++++-----
>>  include/linux/blkdev.h |  2 ++
>>  2 files changed, 7 insertions(+), 5 deletions(-)
>>
>> diff --git a/block/blk-zoned.c b/block/blk-zoned.c
>> index 90a5c9cc80ab3..7fbe395fa51fc 100644
>> --- a/block/blk-zoned.c
>> +++ b/block/blk-zoned.c
>> @@ -185,8 +185,8 @@ static int blk_zone_need_reset_cb(struct blk_zone *zone, unsigned int idx,
>>  	}
>>  }
>>  
>> -static int blkdev_zone_reset_all_emulated(struct block_device *bdev,
>> -					  gfp_t gfp_mask)
>> +int blkdev_zone_mgmt_all(struct block_device *bdev, unsigned int op,
>> +			 gfp_t gfp_mask)
>>  {
>>  	struct request_queue *q = bdev_get_queue(bdev);
>>  	sector_t capacity = get_capacity(bdev->bd_disk);
>> @@ -213,8 +213,7 @@ static int blkdev_zone_reset_all_emulated(struct block_device *bdev,
>>  			continue;
>>  		}
>>  
>> -		bio = blk_next_bio(bio, bdev, 0, REQ_OP_ZONE_RESET | REQ_SYNC,
>> -				   gfp_mask);
>> +		bio = blk_next_bio(bio, bdev, 0, op | REQ_SYNC, gfp_mask);
>>  		bio->bi_iter.bi_sector = sector;
>>  		sector += zone_sectors;
>>  
>> @@ -231,6 +230,7 @@ static int blkdev_zone_reset_all_emulated(struct block_device *bdev,
>>  	kfree(need_reset);
>>  	return ret;
>>  }
>> +EXPORT_SYMBOL_GPL(blkdev_zone_mgmt_all);
>>  
>>  static int blkdev_zone_reset_all(struct block_device *bdev, gfp_t gfp_mask)
>>  {
>> @@ -295,7 +295,7 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op,
>>  	 */
>>  	if (op == REQ_OP_ZONE_RESET && sector == 0 && nr_sectors == capacity) {
>>  		if (!blk_queue_zone_resetall(q))
>> -			return blkdev_zone_reset_all_emulated(bdev, gfp_mask);
>> +			return blkdev_zone_mgmt_all(bdev, op, gfp_mask);
>>  		return blkdev_zone_reset_all(bdev, gfp_mask);
>>  	}
>>  
>> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
>> index 270cd0c552924..b9baee910b825 100644
>> --- a/include/linux/blkdev.h
>> +++ b/include/linux/blkdev.h
>> @@ -302,6 +302,8 @@ unsigned int blkdev_nr_zones(struct gendisk *disk);
>>  extern int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op,
>>  			    sector_t sectors, sector_t nr_sectors,
>>  			    gfp_t gfp_mask);
>> +int blkdev_zone_mgmt_all(struct block_device *bdev, unsigned int op,
>> +			 gfp_t gfp_mask);
>>  int blk_revalidate_disk_zones(struct gendisk *disk,
>>  			      void (*update_driver_data)(struct gendisk *disk));
>>  
> 
> 


-- 
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] 140+ messages in thread

* Re: [PATCH 07/17] block: simplify blk_check_zone_append
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-05  2:40     ` Damien Le Moal
  -1 siblings, 0 replies; 140+ messages in thread
From: Damien Le Moal @ 2022-07-05  2:40 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

On 7/4/22 21:44, Christoph Hellwig wrote:
> Use the bdev based helpers instead of open coding them.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  block/blk-core.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/block/blk-core.c b/block/blk-core.c
> index bc16e9bae2dc4..b530ce7b370c4 100644
> --- a/block/blk-core.c
> +++ b/block/blk-core.c
> @@ -565,7 +565,6 @@ static int blk_partition_remap(struct bio *bio)
>  static inline blk_status_t blk_check_zone_append(struct request_queue *q,
>  						 struct bio *bio)
>  {
> -	sector_t pos = bio->bi_iter.bi_sector;
>  	int nr_sectors = bio_sectors(bio);
>  
>  	/* Only applicable to zoned block devices */
> @@ -573,8 +572,8 @@ 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 (pos & (blk_queue_zone_sectors(q) - 1) ||
> -	    !blk_queue_zone_is_seq(q, pos))
> +	if (bio->bi_iter.bi_sector & (bdev_zone_sectors(bio->bi_bdev) - 1) ||
> +	    !bio_zone_is_seq(bio))
>  		return BLK_STS_IOERR;
>  
>  	/*

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

-- 
Damien Le Moal
Western Digital Research

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

* Re: [dm-devel] [PATCH 07/17] block: simplify blk_check_zone_append
@ 2022-07-05  2:40     ` Damien Le Moal
  0 siblings, 0 replies; 140+ messages in thread
From: Damien Le Moal @ 2022-07-05  2:40 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

On 7/4/22 21:44, Christoph Hellwig wrote:
> Use the bdev based helpers instead of open coding them.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  block/blk-core.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/block/blk-core.c b/block/blk-core.c
> index bc16e9bae2dc4..b530ce7b370c4 100644
> --- a/block/blk-core.c
> +++ b/block/blk-core.c
> @@ -565,7 +565,6 @@ static int blk_partition_remap(struct bio *bio)
>  static inline blk_status_t blk_check_zone_append(struct request_queue *q,
>  						 struct bio *bio)
>  {
> -	sector_t pos = bio->bi_iter.bi_sector;
>  	int nr_sectors = bio_sectors(bio);
>  
>  	/* Only applicable to zoned block devices */
> @@ -573,8 +572,8 @@ 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 (pos & (blk_queue_zone_sectors(q) - 1) ||
> -	    !blk_queue_zone_is_seq(q, pos))
> +	if (bio->bi_iter.bi_sector & (bdev_zone_sectors(bio->bi_bdev) - 1) ||
> +	    !bio_zone_is_seq(bio))
>  		return BLK_STS_IOERR;
>  
>  	/*

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] 140+ messages in thread

* Re: [PATCH 08/17] block: pass a gendisk to blk_queue_set_zoned
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-05  2:41     ` Damien Le Moal
  -1 siblings, 0 replies; 140+ messages in thread
From: Damien Le Moal @ 2022-07-05  2:41 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

On 7/4/22 21:44, Christoph Hellwig wrote:
> Prepare for storing the zone related field in struct gendisk instead
> of struct request_queue.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

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

> ---
>  block/blk-settings.c           | 9 +++++----
>  block/partitions/core.c        | 2 +-
>  drivers/block/null_blk/zoned.c | 2 +-
>  drivers/nvme/host/zns.c        | 2 +-
>  drivers/scsi/sd.c              | 6 +++---
>  drivers/scsi/sd_zbc.c          | 2 +-
>  include/linux/blkdev.h         | 2 +-
>  7 files changed, 13 insertions(+), 12 deletions(-)
> 
> diff --git a/block/blk-settings.c b/block/blk-settings.c
> index 6ccceb421ed2f..35b7bba306a83 100644
> --- a/block/blk-settings.c
> +++ b/block/blk-settings.c
> @@ -893,18 +893,19 @@ static bool disk_has_partitions(struct gendisk *disk)
>  }
>  
>  /**
> - * blk_queue_set_zoned - configure a disk queue zoned model.
> + * disk_set_zoned - configure the zoned model for a disk
>   * @disk:	the gendisk of the queue to configure
>   * @model:	the zoned model to set
>   *
> - * Set the zoned model of the request queue of @disk according to @model.
> + * Set the zoned model of @disk to @model.
> + *
>   * When @model is BLK_ZONED_HM (host managed), this should be called only
>   * if zoned block device support is enabled (CONFIG_BLK_DEV_ZONED option).
>   * If @model specifies BLK_ZONED_HA (host aware), the effective model used
>   * depends on CONFIG_BLK_DEV_ZONED settings and on the existence of partitions
>   * on the disk.
>   */
> -void blk_queue_set_zoned(struct gendisk *disk, enum blk_zoned_model model)
> +void disk_set_zoned(struct gendisk *disk, enum blk_zoned_model model)
>  {
>  	struct request_queue *q = disk->queue;
>  
> @@ -948,7 +949,7 @@ void blk_queue_set_zoned(struct gendisk *disk, enum blk_zoned_model model)
>  		blk_queue_clear_zone_settings(q);
>  	}
>  }
> -EXPORT_SYMBOL_GPL(blk_queue_set_zoned);
> +EXPORT_SYMBOL_GPL(disk_set_zoned);
>  
>  int bdev_alignment_offset(struct block_device *bdev)
>  {
> diff --git a/block/partitions/core.c b/block/partitions/core.c
> index 7dc487f5b03cd..1a45b1dd64918 100644
> --- a/block/partitions/core.c
> +++ b/block/partitions/core.c
> @@ -330,7 +330,7 @@ static struct block_device *add_partition(struct gendisk *disk, int partno,
>  	case BLK_ZONED_HA:
>  		pr_info("%s: disabling host aware zoned block device support due to partitions\n",
>  			disk->disk_name);
> -		blk_queue_set_zoned(disk, BLK_ZONED_NONE);
> +		disk_set_zoned(disk, BLK_ZONED_NONE);
>  		break;
>  	case BLK_ZONED_NONE:
>  		break;
> diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c
> index 2fdd7b20c224e..b47bbd114058d 100644
> --- a/drivers/block/null_blk/zoned.c
> +++ b/drivers/block/null_blk/zoned.c
> @@ -159,7 +159,7 @@ int null_register_zoned_dev(struct nullb *nullb)
>  	struct nullb_device *dev = nullb->dev;
>  	struct request_queue *q = nullb->q;
>  
> -	blk_queue_set_zoned(nullb->disk, BLK_ZONED_HM);
> +	disk_set_zoned(nullb->disk, BLK_ZONED_HM);
>  	blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q);
>  	blk_queue_required_elevator_features(q, ELEVATOR_F_ZBD_SEQ_WRITE);
>  
> diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c
> index 9f81beb4df4ef..0ed15c2fd56de 100644
> --- a/drivers/nvme/host/zns.c
> +++ b/drivers/nvme/host/zns.c
> @@ -109,7 +109,7 @@ int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf)
>  		goto free_data;
>  	}
>  
> -	blk_queue_set_zoned(ns->disk, BLK_ZONED_HM);
> +	disk_set_zoned(ns->disk, BLK_ZONED_HM);
>  	blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q);
>  	blk_queue_max_open_zones(q, le32_to_cpu(id->mor) + 1);
>  	blk_queue_max_active_zones(q, le32_to_cpu(id->mar) + 1);
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index cb587e488601c..eb02d939dd448 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -2934,15 +2934,15 @@ static void sd_read_block_characteristics(struct scsi_disk *sdkp)
>  
>  	if (sdkp->device->type == TYPE_ZBC) {
>  		/* Host-managed */
> -		blk_queue_set_zoned(sdkp->disk, BLK_ZONED_HM);
> +		disk_set_zoned(sdkp->disk, BLK_ZONED_HM);
>  	} else {
>  		sdkp->zoned = zoned;
>  		if (sdkp->zoned == 1) {
>  			/* Host-aware */
> -			blk_queue_set_zoned(sdkp->disk, BLK_ZONED_HA);
> +			disk_set_zoned(sdkp->disk, BLK_ZONED_HA);
>  		} else {
>  			/* Regular disk or drive managed disk */
> -			blk_queue_set_zoned(sdkp->disk, BLK_ZONED_NONE);
> +			disk_set_zoned(sdkp->disk, BLK_ZONED_NONE);
>  		}
>  	}
>  
> diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
> index 6acc4f406eb8c..0f5823b674685 100644
> --- a/drivers/scsi/sd_zbc.c
> +++ b/drivers/scsi/sd_zbc.c
> @@ -929,7 +929,7 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, u8 buf[SD_BUF_SIZE])
>  		/*
>  		 * This can happen for a host aware disk with partitions.
>  		 * The block device zone model was already cleared by
> -		 * blk_queue_set_zoned(). Only free the scsi disk zone
> +		 * disk_set_zoned(). Only free the scsi disk zone
>  		 * information and exit early.
>  		 */
>  		sd_zbc_free_zone_info(sdkp);
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index b9baee910b825..ddf8353488fc8 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -291,7 +291,7 @@ struct queue_limits {
>  typedef int (*report_zones_cb)(struct blk_zone *zone, unsigned int idx,
>  			       void *data);
>  
> -void blk_queue_set_zoned(struct gendisk *disk, enum blk_zoned_model model);
> +void disk_set_zoned(struct gendisk *disk, enum blk_zoned_model model);
>  
>  #ifdef CONFIG_BLK_DEV_ZONED
>  


-- 
Damien Le Moal
Western Digital Research

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

* Re: [dm-devel] [PATCH 08/17] block: pass a gendisk to blk_queue_set_zoned
@ 2022-07-05  2:41     ` Damien Le Moal
  0 siblings, 0 replies; 140+ messages in thread
From: Damien Le Moal @ 2022-07-05  2:41 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

On 7/4/22 21:44, Christoph Hellwig wrote:
> Prepare for storing the zone related field in struct gendisk instead
> of struct request_queue.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

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

> ---
>  block/blk-settings.c           | 9 +++++----
>  block/partitions/core.c        | 2 +-
>  drivers/block/null_blk/zoned.c | 2 +-
>  drivers/nvme/host/zns.c        | 2 +-
>  drivers/scsi/sd.c              | 6 +++---
>  drivers/scsi/sd_zbc.c          | 2 +-
>  include/linux/blkdev.h         | 2 +-
>  7 files changed, 13 insertions(+), 12 deletions(-)
> 
> diff --git a/block/blk-settings.c b/block/blk-settings.c
> index 6ccceb421ed2f..35b7bba306a83 100644
> --- a/block/blk-settings.c
> +++ b/block/blk-settings.c
> @@ -893,18 +893,19 @@ static bool disk_has_partitions(struct gendisk *disk)
>  }
>  
>  /**
> - * blk_queue_set_zoned - configure a disk queue zoned model.
> + * disk_set_zoned - configure the zoned model for a disk
>   * @disk:	the gendisk of the queue to configure
>   * @model:	the zoned model to set
>   *
> - * Set the zoned model of the request queue of @disk according to @model.
> + * Set the zoned model of @disk to @model.
> + *
>   * When @model is BLK_ZONED_HM (host managed), this should be called only
>   * if zoned block device support is enabled (CONFIG_BLK_DEV_ZONED option).
>   * If @model specifies BLK_ZONED_HA (host aware), the effective model used
>   * depends on CONFIG_BLK_DEV_ZONED settings and on the existence of partitions
>   * on the disk.
>   */
> -void blk_queue_set_zoned(struct gendisk *disk, enum blk_zoned_model model)
> +void disk_set_zoned(struct gendisk *disk, enum blk_zoned_model model)
>  {
>  	struct request_queue *q = disk->queue;
>  
> @@ -948,7 +949,7 @@ void blk_queue_set_zoned(struct gendisk *disk, enum blk_zoned_model model)
>  		blk_queue_clear_zone_settings(q);
>  	}
>  }
> -EXPORT_SYMBOL_GPL(blk_queue_set_zoned);
> +EXPORT_SYMBOL_GPL(disk_set_zoned);
>  
>  int bdev_alignment_offset(struct block_device *bdev)
>  {
> diff --git a/block/partitions/core.c b/block/partitions/core.c
> index 7dc487f5b03cd..1a45b1dd64918 100644
> --- a/block/partitions/core.c
> +++ b/block/partitions/core.c
> @@ -330,7 +330,7 @@ static struct block_device *add_partition(struct gendisk *disk, int partno,
>  	case BLK_ZONED_HA:
>  		pr_info("%s: disabling host aware zoned block device support due to partitions\n",
>  			disk->disk_name);
> -		blk_queue_set_zoned(disk, BLK_ZONED_NONE);
> +		disk_set_zoned(disk, BLK_ZONED_NONE);
>  		break;
>  	case BLK_ZONED_NONE:
>  		break;
> diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c
> index 2fdd7b20c224e..b47bbd114058d 100644
> --- a/drivers/block/null_blk/zoned.c
> +++ b/drivers/block/null_blk/zoned.c
> @@ -159,7 +159,7 @@ int null_register_zoned_dev(struct nullb *nullb)
>  	struct nullb_device *dev = nullb->dev;
>  	struct request_queue *q = nullb->q;
>  
> -	blk_queue_set_zoned(nullb->disk, BLK_ZONED_HM);
> +	disk_set_zoned(nullb->disk, BLK_ZONED_HM);
>  	blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q);
>  	blk_queue_required_elevator_features(q, ELEVATOR_F_ZBD_SEQ_WRITE);
>  
> diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c
> index 9f81beb4df4ef..0ed15c2fd56de 100644
> --- a/drivers/nvme/host/zns.c
> +++ b/drivers/nvme/host/zns.c
> @@ -109,7 +109,7 @@ int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf)
>  		goto free_data;
>  	}
>  
> -	blk_queue_set_zoned(ns->disk, BLK_ZONED_HM);
> +	disk_set_zoned(ns->disk, BLK_ZONED_HM);
>  	blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q);
>  	blk_queue_max_open_zones(q, le32_to_cpu(id->mor) + 1);
>  	blk_queue_max_active_zones(q, le32_to_cpu(id->mar) + 1);
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index cb587e488601c..eb02d939dd448 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -2934,15 +2934,15 @@ static void sd_read_block_characteristics(struct scsi_disk *sdkp)
>  
>  	if (sdkp->device->type == TYPE_ZBC) {
>  		/* Host-managed */
> -		blk_queue_set_zoned(sdkp->disk, BLK_ZONED_HM);
> +		disk_set_zoned(sdkp->disk, BLK_ZONED_HM);
>  	} else {
>  		sdkp->zoned = zoned;
>  		if (sdkp->zoned == 1) {
>  			/* Host-aware */
> -			blk_queue_set_zoned(sdkp->disk, BLK_ZONED_HA);
> +			disk_set_zoned(sdkp->disk, BLK_ZONED_HA);
>  		} else {
>  			/* Regular disk or drive managed disk */
> -			blk_queue_set_zoned(sdkp->disk, BLK_ZONED_NONE);
> +			disk_set_zoned(sdkp->disk, BLK_ZONED_NONE);
>  		}
>  	}
>  
> diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
> index 6acc4f406eb8c..0f5823b674685 100644
> --- a/drivers/scsi/sd_zbc.c
> +++ b/drivers/scsi/sd_zbc.c
> @@ -929,7 +929,7 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, u8 buf[SD_BUF_SIZE])
>  		/*
>  		 * This can happen for a host aware disk with partitions.
>  		 * The block device zone model was already cleared by
> -		 * blk_queue_set_zoned(). Only free the scsi disk zone
> +		 * disk_set_zoned(). Only free the scsi disk zone
>  		 * information and exit early.
>  		 */
>  		sd_zbc_free_zone_info(sdkp);
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index b9baee910b825..ddf8353488fc8 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -291,7 +291,7 @@ struct queue_limits {
>  typedef int (*report_zones_cb)(struct blk_zone *zone, unsigned int idx,
>  			       void *data);
>  
> -void blk_queue_set_zoned(struct gendisk *disk, enum blk_zoned_model model);
> +void disk_set_zoned(struct gendisk *disk, enum blk_zoned_model model);
>  
>  #ifdef CONFIG_BLK_DEV_ZONED
>  


-- 
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] 140+ messages in thread

* Re: [PATCH 09/17] block: pass a gendisk to blk_queue_clear_zone_settings
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-05  2:41     ` Damien Le Moal
  -1 siblings, 0 replies; 140+ messages in thread
From: Damien Le Moal @ 2022-07-05  2:41 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

On 7/4/22 21:44, Christoph Hellwig wrote:
> Switch to a gendisk based API in preparation for moving all zone related
> fields from the request_queue to the gendisk.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

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

> ---
>  block/blk-settings.c | 2 +-
>  block/blk-zoned.c    | 4 +++-
>  block/blk.h          | 4 ++--
>  3 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/block/blk-settings.c b/block/blk-settings.c
> index 35b7bba306a83..8bb9eef5310eb 100644
> --- a/block/blk-settings.c
> +++ b/block/blk-settings.c
> @@ -946,7 +946,7 @@ void disk_set_zoned(struct gendisk *disk, enum blk_zoned_model model)
>  		blk_queue_zone_write_granularity(q,
>  						queue_logical_block_size(q));
>  	} else {
> -		blk_queue_clear_zone_settings(q);
> +		disk_clear_zone_settings(disk);
>  	}
>  }
>  EXPORT_SYMBOL_GPL(disk_set_zoned);
> diff --git a/block/blk-zoned.c b/block/blk-zoned.c
> index 7fbe395fa51fc..5a97b48102221 100644
> --- a/block/blk-zoned.c
> +++ b/block/blk-zoned.c
> @@ -622,8 +622,10 @@ int blk_revalidate_disk_zones(struct gendisk *disk,
>  }
>  EXPORT_SYMBOL_GPL(blk_revalidate_disk_zones);
>  
> -void blk_queue_clear_zone_settings(struct request_queue *q)
> +void disk_clear_zone_settings(struct gendisk *disk)
>  {
> +	struct request_queue *q = disk->queue;
> +
>  	blk_mq_freeze_queue(q);
>  
>  	blk_queue_free_zone_bitmaps(q);
> diff --git a/block/blk.h b/block/blk.h
> index 58ad50cacd2d5..7482a3a441dd9 100644
> --- a/block/blk.h
> +++ b/block/blk.h
> @@ -406,10 +406,10 @@ static inline int blk_iolatency_init(struct request_queue *q) { return 0; }
>  
>  #ifdef CONFIG_BLK_DEV_ZONED
>  void blk_queue_free_zone_bitmaps(struct request_queue *q);
> -void blk_queue_clear_zone_settings(struct request_queue *q);
> +void disk_clear_zone_settings(struct gendisk *disk);
>  #else
>  static inline void blk_queue_free_zone_bitmaps(struct request_queue *q) {}
> -static inline void blk_queue_clear_zone_settings(struct request_queue *q) {}
> +static inline void disk_clear_zone_settings(struct gendisk *disk) {}
>  #endif
>  
>  int blk_alloc_ext_minor(void);


-- 
Damien Le Moal
Western Digital Research

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

* Re: [dm-devel] [PATCH 09/17] block: pass a gendisk to blk_queue_clear_zone_settings
@ 2022-07-05  2:41     ` Damien Le Moal
  0 siblings, 0 replies; 140+ messages in thread
From: Damien Le Moal @ 2022-07-05  2:41 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

On 7/4/22 21:44, Christoph Hellwig wrote:
> Switch to a gendisk based API in preparation for moving all zone related
> fields from the request_queue to the gendisk.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

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

> ---
>  block/blk-settings.c | 2 +-
>  block/blk-zoned.c    | 4 +++-
>  block/blk.h          | 4 ++--
>  3 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/block/blk-settings.c b/block/blk-settings.c
> index 35b7bba306a83..8bb9eef5310eb 100644
> --- a/block/blk-settings.c
> +++ b/block/blk-settings.c
> @@ -946,7 +946,7 @@ void disk_set_zoned(struct gendisk *disk, enum blk_zoned_model model)
>  		blk_queue_zone_write_granularity(q,
>  						queue_logical_block_size(q));
>  	} else {
> -		blk_queue_clear_zone_settings(q);
> +		disk_clear_zone_settings(disk);
>  	}
>  }
>  EXPORT_SYMBOL_GPL(disk_set_zoned);
> diff --git a/block/blk-zoned.c b/block/blk-zoned.c
> index 7fbe395fa51fc..5a97b48102221 100644
> --- a/block/blk-zoned.c
> +++ b/block/blk-zoned.c
> @@ -622,8 +622,10 @@ int blk_revalidate_disk_zones(struct gendisk *disk,
>  }
>  EXPORT_SYMBOL_GPL(blk_revalidate_disk_zones);
>  
> -void blk_queue_clear_zone_settings(struct request_queue *q)
> +void disk_clear_zone_settings(struct gendisk *disk)
>  {
> +	struct request_queue *q = disk->queue;
> +
>  	blk_mq_freeze_queue(q);
>  
>  	blk_queue_free_zone_bitmaps(q);
> diff --git a/block/blk.h b/block/blk.h
> index 58ad50cacd2d5..7482a3a441dd9 100644
> --- a/block/blk.h
> +++ b/block/blk.h
> @@ -406,10 +406,10 @@ static inline int blk_iolatency_init(struct request_queue *q) { return 0; }
>  
>  #ifdef CONFIG_BLK_DEV_ZONED
>  void blk_queue_free_zone_bitmaps(struct request_queue *q);
> -void blk_queue_clear_zone_settings(struct request_queue *q);
> +void disk_clear_zone_settings(struct gendisk *disk);
>  #else
>  static inline void blk_queue_free_zone_bitmaps(struct request_queue *q) {}
> -static inline void blk_queue_clear_zone_settings(struct request_queue *q) {}
> +static inline void disk_clear_zone_settings(struct gendisk *disk) {}
>  #endif
>  
>  int blk_alloc_ext_minor(void);


-- 
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] 140+ messages in thread

* Re: [PATCH 10/17] block: pass a gendisk to blk_queue_free_zone_bitmaps
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-05  2:42     ` Damien Le Moal
  -1 siblings, 0 replies; 140+ messages in thread
From: Damien Le Moal @ 2022-07-05  2:42 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

On 7/4/22 21:44, Christoph Hellwig wrote:
> Switch to a gendisk based API in preparation for moving all zone related
> fields from the request_queue to the gendisk.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

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

> ---
>  block/blk-zoned.c | 8 +++++---
>  block/blk.h       | 4 ++--
>  block/genhd.c     | 2 +-
>  3 files changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/block/blk-zoned.c b/block/blk-zoned.c
> index 5a97b48102221..9085f9fb3ab42 100644
> --- a/block/blk-zoned.c
> +++ b/block/blk-zoned.c
> @@ -449,8 +449,10 @@ int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
>  	return ret;
>  }
>  
> -void blk_queue_free_zone_bitmaps(struct request_queue *q)
> +void disk_free_zone_bitmaps(struct gendisk *disk)
>  {
> +	struct request_queue *q = disk->queue;
> +
>  	kfree(q->conv_zones_bitmap);
>  	q->conv_zones_bitmap = NULL;
>  	kfree(q->seq_zones_wlock);
> @@ -612,7 +614,7 @@ int blk_revalidate_disk_zones(struct gendisk *disk,
>  		ret = 0;
>  	} else {
>  		pr_warn("%s: failed to revalidate zones\n", disk->disk_name);
> -		blk_queue_free_zone_bitmaps(q);
> +		disk_free_zone_bitmaps(disk);
>  	}
>  	blk_mq_unfreeze_queue(q);
>  
> @@ -628,7 +630,7 @@ void disk_clear_zone_settings(struct gendisk *disk)
>  
>  	blk_mq_freeze_queue(q);
>  
> -	blk_queue_free_zone_bitmaps(q);
> +	disk_free_zone_bitmaps(disk);
>  	blk_queue_flag_clear(QUEUE_FLAG_ZONE_RESETALL, q);
>  	q->required_elevator_features &= ~ELEVATOR_F_ZBD_SEQ_WRITE;
>  	q->nr_zones = 0;
> diff --git a/block/blk.h b/block/blk.h
> index 7482a3a441dd9..b71e22c97d773 100644
> --- a/block/blk.h
> +++ b/block/blk.h
> @@ -405,10 +405,10 @@ static inline int blk_iolatency_init(struct request_queue *q) { return 0; }
>  #endif
>  
>  #ifdef CONFIG_BLK_DEV_ZONED
> -void blk_queue_free_zone_bitmaps(struct request_queue *q);
> +void disk_free_zone_bitmaps(struct gendisk *disk);
>  void disk_clear_zone_settings(struct gendisk *disk);
>  #else
> -static inline void blk_queue_free_zone_bitmaps(struct request_queue *q) {}
> +static inline void disk_free_zone_bitmaps(struct gendisk *disk) {}
>  static inline void disk_clear_zone_settings(struct gendisk *disk) {}
>  #endif
>  
> diff --git a/block/genhd.c b/block/genhd.c
> index d0bdeb93e922c..9d30f159c59ac 100644
> --- a/block/genhd.c
> +++ b/block/genhd.c
> @@ -1165,7 +1165,7 @@ static void disk_release(struct device *dev)
>  
>  	disk_release_events(disk);
>  	kfree(disk->random);
> -	blk_queue_free_zone_bitmaps(disk->queue);
> +	disk_free_zone_bitmaps(disk);
>  	xa_destroy(&disk->part_tbl);
>  
>  	disk->queue->disk = NULL;


-- 
Damien Le Moal
Western Digital Research

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

* Re: [dm-devel] [PATCH 10/17] block: pass a gendisk to blk_queue_free_zone_bitmaps
@ 2022-07-05  2:42     ` Damien Le Moal
  0 siblings, 0 replies; 140+ messages in thread
From: Damien Le Moal @ 2022-07-05  2:42 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

On 7/4/22 21:44, Christoph Hellwig wrote:
> Switch to a gendisk based API in preparation for moving all zone related
> fields from the request_queue to the gendisk.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

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

> ---
>  block/blk-zoned.c | 8 +++++---
>  block/blk.h       | 4 ++--
>  block/genhd.c     | 2 +-
>  3 files changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/block/blk-zoned.c b/block/blk-zoned.c
> index 5a97b48102221..9085f9fb3ab42 100644
> --- a/block/blk-zoned.c
> +++ b/block/blk-zoned.c
> @@ -449,8 +449,10 @@ int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
>  	return ret;
>  }
>  
> -void blk_queue_free_zone_bitmaps(struct request_queue *q)
> +void disk_free_zone_bitmaps(struct gendisk *disk)
>  {
> +	struct request_queue *q = disk->queue;
> +
>  	kfree(q->conv_zones_bitmap);
>  	q->conv_zones_bitmap = NULL;
>  	kfree(q->seq_zones_wlock);
> @@ -612,7 +614,7 @@ int blk_revalidate_disk_zones(struct gendisk *disk,
>  		ret = 0;
>  	} else {
>  		pr_warn("%s: failed to revalidate zones\n", disk->disk_name);
> -		blk_queue_free_zone_bitmaps(q);
> +		disk_free_zone_bitmaps(disk);
>  	}
>  	blk_mq_unfreeze_queue(q);
>  
> @@ -628,7 +630,7 @@ void disk_clear_zone_settings(struct gendisk *disk)
>  
>  	blk_mq_freeze_queue(q);
>  
> -	blk_queue_free_zone_bitmaps(q);
> +	disk_free_zone_bitmaps(disk);
>  	blk_queue_flag_clear(QUEUE_FLAG_ZONE_RESETALL, q);
>  	q->required_elevator_features &= ~ELEVATOR_F_ZBD_SEQ_WRITE;
>  	q->nr_zones = 0;
> diff --git a/block/blk.h b/block/blk.h
> index 7482a3a441dd9..b71e22c97d773 100644
> --- a/block/blk.h
> +++ b/block/blk.h
> @@ -405,10 +405,10 @@ static inline int blk_iolatency_init(struct request_queue *q) { return 0; }
>  #endif
>  
>  #ifdef CONFIG_BLK_DEV_ZONED
> -void blk_queue_free_zone_bitmaps(struct request_queue *q);
> +void disk_free_zone_bitmaps(struct gendisk *disk);
>  void disk_clear_zone_settings(struct gendisk *disk);
>  #else
> -static inline void blk_queue_free_zone_bitmaps(struct request_queue *q) {}
> +static inline void disk_free_zone_bitmaps(struct gendisk *disk) {}
>  static inline void disk_clear_zone_settings(struct gendisk *disk) {}
>  #endif
>  
> diff --git a/block/genhd.c b/block/genhd.c
> index d0bdeb93e922c..9d30f159c59ac 100644
> --- a/block/genhd.c
> +++ b/block/genhd.c
> @@ -1165,7 +1165,7 @@ static void disk_release(struct device *dev)
>  
>  	disk_release_events(disk);
>  	kfree(disk->random);
> -	blk_queue_free_zone_bitmaps(disk->queue);
> +	disk_free_zone_bitmaps(disk);
>  	xa_destroy(&disk->part_tbl);
>  
>  	disk->queue->disk = NULL;


-- 
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] 140+ messages in thread

* Re: [PATCH 11/17] block: remove queue_max_open_zones and queue_max_active_zones
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-05  2:43     ` Damien Le Moal
  -1 siblings, 0 replies; 140+ messages in thread
From: Damien Le Moal @ 2022-07-05  2:43 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

On 7/4/22 21:44, Christoph Hellwig wrote:
> Always use the bdev based helpers instead.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

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


> ---
>  block/blk-sysfs.c      |  4 ++--
>  include/linux/blkdev.h | 37 ++++++++++---------------------------
>  2 files changed, 12 insertions(+), 29 deletions(-)
> 
> diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
> index 7590810cf13fc..5ce72345ac666 100644
> --- a/block/blk-sysfs.c
> +++ b/block/blk-sysfs.c
> @@ -330,12 +330,12 @@ static ssize_t queue_nr_zones_show(struct request_queue *q, char *page)
>  
>  static ssize_t queue_max_open_zones_show(struct request_queue *q, char *page)
>  {
> -	return queue_var_show(queue_max_open_zones(q), page);
> +	return queue_var_show(bdev_max_open_zones(q->disk->part0), page);
>  }
>  
>  static ssize_t queue_max_active_zones_show(struct request_queue *q, char *page)
>  {
> -	return queue_var_show(queue_max_active_zones(q), page);
> +	return queue_var_show(bdev_max_active_zones(q->disk->part0), page);
>  }
>  
>  static ssize_t queue_nomerges_show(struct request_queue *q, char *page)
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index ddf8353488fc8..a14cc3e46e6ad 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -704,21 +704,22 @@ static inline void blk_queue_max_open_zones(struct request_queue *q,
>  	q->max_open_zones = max_open_zones;
>  }
>  
> -static inline unsigned int queue_max_open_zones(const struct request_queue *q)
> -{
> -	return q->max_open_zones;
> -}
> -
>  static inline void blk_queue_max_active_zones(struct request_queue *q,
>  		unsigned int max_active_zones)
>  {
>  	q->max_active_zones = max_active_zones;
>  }
>  
> -static inline unsigned int queue_max_active_zones(const struct request_queue *q)
> +static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
> +{
> +	return bdev->bd_disk->queue->max_open_zones;
> +}
> +
> +static inline unsigned int bdev_max_active_zones(struct block_device *bdev)
>  {
> -	return q->max_active_zones;
> +	return bdev->bd_disk->queue->max_active_zones;
>  }
> +
>  #else /* CONFIG_BLK_DEV_ZONED */
>  static inline unsigned int blk_queue_nr_zones(struct request_queue *q)
>  {
> @@ -734,11 +735,11 @@ static inline unsigned int blk_queue_zone_no(struct request_queue *q,
>  {
>  	return 0;
>  }
> -static inline unsigned int queue_max_open_zones(const struct request_queue *q)
> +static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
>  {
>  	return 0;
>  }
> -static inline unsigned int queue_max_active_zones(const struct request_queue *q)
> +static inline unsigned int bdev_max_active_zones(struct block_device *bdev)
>  {
>  	return 0;
>  }
> @@ -1316,24 +1317,6 @@ static inline sector_t bdev_zone_sectors(struct block_device *bdev)
>  	return 0;
>  }
>  
> -static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
> -{
> -	struct request_queue *q = bdev_get_queue(bdev);
> -
> -	if (q)
> -		return queue_max_open_zones(q);
> -	return 0;
> -}
> -
> -static inline unsigned int bdev_max_active_zones(struct block_device *bdev)
> -{
> -	struct request_queue *q = bdev_get_queue(bdev);
> -
> -	if (q)
> -		return queue_max_active_zones(q);
> -	return 0;
> -}
> -
>  static inline int queue_dma_alignment(const struct request_queue *q)
>  {
>  	return q ? q->dma_alignment : 511;


-- 
Damien Le Moal
Western Digital Research

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

* Re: [dm-devel] [PATCH 11/17] block: remove queue_max_open_zones and queue_max_active_zones
@ 2022-07-05  2:43     ` Damien Le Moal
  0 siblings, 0 replies; 140+ messages in thread
From: Damien Le Moal @ 2022-07-05  2:43 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

On 7/4/22 21:44, Christoph Hellwig wrote:
> Always use the bdev based helpers instead.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

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


> ---
>  block/blk-sysfs.c      |  4 ++--
>  include/linux/blkdev.h | 37 ++++++++++---------------------------
>  2 files changed, 12 insertions(+), 29 deletions(-)
> 
> diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
> index 7590810cf13fc..5ce72345ac666 100644
> --- a/block/blk-sysfs.c
> +++ b/block/blk-sysfs.c
> @@ -330,12 +330,12 @@ static ssize_t queue_nr_zones_show(struct request_queue *q, char *page)
>  
>  static ssize_t queue_max_open_zones_show(struct request_queue *q, char *page)
>  {
> -	return queue_var_show(queue_max_open_zones(q), page);
> +	return queue_var_show(bdev_max_open_zones(q->disk->part0), page);
>  }
>  
>  static ssize_t queue_max_active_zones_show(struct request_queue *q, char *page)
>  {
> -	return queue_var_show(queue_max_active_zones(q), page);
> +	return queue_var_show(bdev_max_active_zones(q->disk->part0), page);
>  }
>  
>  static ssize_t queue_nomerges_show(struct request_queue *q, char *page)
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index ddf8353488fc8..a14cc3e46e6ad 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -704,21 +704,22 @@ static inline void blk_queue_max_open_zones(struct request_queue *q,
>  	q->max_open_zones = max_open_zones;
>  }
>  
> -static inline unsigned int queue_max_open_zones(const struct request_queue *q)
> -{
> -	return q->max_open_zones;
> -}
> -
>  static inline void blk_queue_max_active_zones(struct request_queue *q,
>  		unsigned int max_active_zones)
>  {
>  	q->max_active_zones = max_active_zones;
>  }
>  
> -static inline unsigned int queue_max_active_zones(const struct request_queue *q)
> +static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
> +{
> +	return bdev->bd_disk->queue->max_open_zones;
> +}
> +
> +static inline unsigned int bdev_max_active_zones(struct block_device *bdev)
>  {
> -	return q->max_active_zones;
> +	return bdev->bd_disk->queue->max_active_zones;
>  }
> +
>  #else /* CONFIG_BLK_DEV_ZONED */
>  static inline unsigned int blk_queue_nr_zones(struct request_queue *q)
>  {
> @@ -734,11 +735,11 @@ static inline unsigned int blk_queue_zone_no(struct request_queue *q,
>  {
>  	return 0;
>  }
> -static inline unsigned int queue_max_open_zones(const struct request_queue *q)
> +static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
>  {
>  	return 0;
>  }
> -static inline unsigned int queue_max_active_zones(const struct request_queue *q)
> +static inline unsigned int bdev_max_active_zones(struct block_device *bdev)
>  {
>  	return 0;
>  }
> @@ -1316,24 +1317,6 @@ static inline sector_t bdev_zone_sectors(struct block_device *bdev)
>  	return 0;
>  }
>  
> -static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
> -{
> -	struct request_queue *q = bdev_get_queue(bdev);
> -
> -	if (q)
> -		return queue_max_open_zones(q);
> -	return 0;
> -}
> -
> -static inline unsigned int bdev_max_active_zones(struct block_device *bdev)
> -{
> -	struct request_queue *q = bdev_get_queue(bdev);
> -
> -	if (q)
> -		return queue_max_active_zones(q);
> -	return 0;
> -}
> -
>  static inline int queue_dma_alignment(const struct request_queue *q)
>  {
>  	return q ? q->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] 140+ messages in thread

* Re: [PATCH 12/17] block: pass a gendisk to blk_queue_max_open_zones and blk_queue_max_active_zones
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-05  2:50     ` Damien Le Moal
  -1 siblings, 0 replies; 140+ messages in thread
From: Damien Le Moal @ 2022-07-05  2:50 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

On 7/4/22 21:44, Christoph Hellwig wrote:
> Switch to a gendisk based API in preparation for moving all zone related
> fields from the request_queue to the gendisk.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

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

> ---
>  drivers/block/null_blk/zoned.c | 4 ++--
>  drivers/nvme/host/zns.c        | 4 ++--
>  drivers/scsi/sd_zbc.c          | 6 +++---
>  include/linux/blkdev.h         | 8 ++++----
>  4 files changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c
> index b47bbd114058d..576ab3ed082a5 100644
> --- a/drivers/block/null_blk/zoned.c
> +++ b/drivers/block/null_blk/zoned.c
> @@ -174,8 +174,8 @@ int null_register_zoned_dev(struct nullb *nullb)
>  	}
>  
>  	blk_queue_max_zone_append_sectors(q, dev->zone_size_sects);
> -	blk_queue_max_open_zones(q, dev->zone_max_open);
> -	blk_queue_max_active_zones(q, dev->zone_max_active);
> +	disk_set_max_open_zones(nullb->disk, dev->zone_max_open);
> +	disk_set_max_active_zones(nullb->disk, dev->zone_max_active);
>  
>  	return 0;
>  }
> diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c
> index 0ed15c2fd56de..12316ab51bda6 100644
> --- a/drivers/nvme/host/zns.c
> +++ b/drivers/nvme/host/zns.c
> @@ -111,8 +111,8 @@ int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf)
>  
>  	disk_set_zoned(ns->disk, BLK_ZONED_HM);
>  	blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q);
> -	blk_queue_max_open_zones(q, le32_to_cpu(id->mor) + 1);
> -	blk_queue_max_active_zones(q, le32_to_cpu(id->mar) + 1);
> +	disk_set_max_open_zones(ns->disk, le32_to_cpu(id->mor) + 1);
> +	disk_set_max_active_zones(ns->disk, le32_to_cpu(id->mar) + 1);
>  free_data:
>  	kfree(id);
>  	return status;
> diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
> index 0f5823b674685..b4106f8997342 100644
> --- a/drivers/scsi/sd_zbc.c
> +++ b/drivers/scsi/sd_zbc.c
> @@ -950,10 +950,10 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, u8 buf[SD_BUF_SIZE])
>  	blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q);
>  	blk_queue_required_elevator_features(q, ELEVATOR_F_ZBD_SEQ_WRITE);
>  	if (sdkp->zones_max_open == U32_MAX)
> -		blk_queue_max_open_zones(q, 0);
> +		disk_set_max_open_zones(disk, 0);
>  	else
> -		blk_queue_max_open_zones(q, sdkp->zones_max_open);
> -	blk_queue_max_active_zones(q, 0);
> +		disk_set_max_open_zones(disk, sdkp->zones_max_open);
> +	disk_set_max_active_zones(disk, 0);
>  	nr_zones = round_up(sdkp->capacity, zone_blocks) >> ilog2(zone_blocks);
>  
>  	/*
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index a14cc3e46e6ad..e32c147f72868 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -698,16 +698,16 @@ static inline bool blk_queue_zone_is_seq(struct request_queue *q,
>  	return !test_bit(blk_queue_zone_no(q, sector), q->conv_zones_bitmap);
>  }
>  
> -static inline void blk_queue_max_open_zones(struct request_queue *q,
> +static inline void disk_set_max_open_zones(struct gendisk *disk,
>  		unsigned int max_open_zones)
>  {
> -	q->max_open_zones = max_open_zones;
> +	disk->queue->max_open_zones = max_open_zones;
>  }
>  
> -static inline void blk_queue_max_active_zones(struct request_queue *q,
> +static inline void disk_set_max_active_zones(struct gendisk *disk,
>  		unsigned int max_active_zones)
>  {
> -	q->max_active_zones = max_active_zones;
> +	disk->queue->max_active_zones = max_active_zones;
>  }
>  
>  static inline unsigned int bdev_max_open_zones(struct block_device *bdev)


-- 
Damien Le Moal
Western Digital Research

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

* Re: [dm-devel] [PATCH 12/17] block: pass a gendisk to blk_queue_max_open_zones and blk_queue_max_active_zones
@ 2022-07-05  2:50     ` Damien Le Moal
  0 siblings, 0 replies; 140+ messages in thread
From: Damien Le Moal @ 2022-07-05  2:50 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

On 7/4/22 21:44, Christoph Hellwig wrote:
> Switch to a gendisk based API in preparation for moving all zone related
> fields from the request_queue to the gendisk.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

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

> ---
>  drivers/block/null_blk/zoned.c | 4 ++--
>  drivers/nvme/host/zns.c        | 4 ++--
>  drivers/scsi/sd_zbc.c          | 6 +++---
>  include/linux/blkdev.h         | 8 ++++----
>  4 files changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c
> index b47bbd114058d..576ab3ed082a5 100644
> --- a/drivers/block/null_blk/zoned.c
> +++ b/drivers/block/null_blk/zoned.c
> @@ -174,8 +174,8 @@ int null_register_zoned_dev(struct nullb *nullb)
>  	}
>  
>  	blk_queue_max_zone_append_sectors(q, dev->zone_size_sects);
> -	blk_queue_max_open_zones(q, dev->zone_max_open);
> -	blk_queue_max_active_zones(q, dev->zone_max_active);
> +	disk_set_max_open_zones(nullb->disk, dev->zone_max_open);
> +	disk_set_max_active_zones(nullb->disk, dev->zone_max_active);
>  
>  	return 0;
>  }
> diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c
> index 0ed15c2fd56de..12316ab51bda6 100644
> --- a/drivers/nvme/host/zns.c
> +++ b/drivers/nvme/host/zns.c
> @@ -111,8 +111,8 @@ int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf)
>  
>  	disk_set_zoned(ns->disk, BLK_ZONED_HM);
>  	blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q);
> -	blk_queue_max_open_zones(q, le32_to_cpu(id->mor) + 1);
> -	blk_queue_max_active_zones(q, le32_to_cpu(id->mar) + 1);
> +	disk_set_max_open_zones(ns->disk, le32_to_cpu(id->mor) + 1);
> +	disk_set_max_active_zones(ns->disk, le32_to_cpu(id->mar) + 1);
>  free_data:
>  	kfree(id);
>  	return status;
> diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
> index 0f5823b674685..b4106f8997342 100644
> --- a/drivers/scsi/sd_zbc.c
> +++ b/drivers/scsi/sd_zbc.c
> @@ -950,10 +950,10 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, u8 buf[SD_BUF_SIZE])
>  	blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q);
>  	blk_queue_required_elevator_features(q, ELEVATOR_F_ZBD_SEQ_WRITE);
>  	if (sdkp->zones_max_open == U32_MAX)
> -		blk_queue_max_open_zones(q, 0);
> +		disk_set_max_open_zones(disk, 0);
>  	else
> -		blk_queue_max_open_zones(q, sdkp->zones_max_open);
> -	blk_queue_max_active_zones(q, 0);
> +		disk_set_max_open_zones(disk, sdkp->zones_max_open);
> +	disk_set_max_active_zones(disk, 0);
>  	nr_zones = round_up(sdkp->capacity, zone_blocks) >> ilog2(zone_blocks);
>  
>  	/*
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index a14cc3e46e6ad..e32c147f72868 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -698,16 +698,16 @@ static inline bool blk_queue_zone_is_seq(struct request_queue *q,
>  	return !test_bit(blk_queue_zone_no(q, sector), q->conv_zones_bitmap);
>  }
>  
> -static inline void blk_queue_max_open_zones(struct request_queue *q,
> +static inline void disk_set_max_open_zones(struct gendisk *disk,
>  		unsigned int max_open_zones)
>  {
> -	q->max_open_zones = max_open_zones;
> +	disk->queue->max_open_zones = max_open_zones;
>  }
>  
> -static inline void blk_queue_max_active_zones(struct request_queue *q,
> +static inline void disk_set_max_active_zones(struct gendisk *disk,
>  		unsigned int max_active_zones)
>  {
> -	q->max_active_zones = max_active_zones;
> +	disk->queue->max_active_zones = max_active_zones;
>  }
>  
>  static inline unsigned int bdev_max_open_zones(struct block_device *bdev)


-- 
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] 140+ messages in thread

* Re: [PATCH 13/17] block: replace blkdev_nr_zones with bdev_nr_zones
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-05  2:53     ` Damien Le Moal
  -1 siblings, 0 replies; 140+ messages in thread
From: Damien Le Moal @ 2022-07-05  2:53 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

On 7/4/22 21:44, Christoph Hellwig wrote:
> Pass a block_device instead of a request_queue a that is what most

s/a that/as that

> callers have at hand.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  block/blk-zoned.c              | 15 ++++++++-------
>  block/ioctl.c                  |  2 +-
>  drivers/block/null_blk/zoned.c |  2 +-
>  drivers/md/dm-zone.c           |  2 +-
>  drivers/md/dm-zoned-target.c   |  5 ++---
>  drivers/nvme/target/zns.c      |  4 ++--
>  fs/zonefs/super.c              | 17 ++++++++---------
>  include/linux/blkdev.h         |  4 ++--
>  8 files changed, 25 insertions(+), 26 deletions(-)
> 
> diff --git a/block/blk-zoned.c b/block/blk-zoned.c
> index 9085f9fb3ab42..836b96ebfdc04 100644
> --- a/block/blk-zoned.c
> +++ b/block/blk-zoned.c
> @@ -108,21 +108,22 @@ void __blk_req_zone_write_unlock(struct request *rq)
>  EXPORT_SYMBOL_GPL(__blk_req_zone_write_unlock);
>  
>  /**
> - * blkdev_nr_zones - Get number of zones
> - * @disk:	Target gendisk
> + * bdev_nr_zones - Get number of zones
> + * @bdev:	Target device
>   *
>   * Return the total number of zones of a zoned block device.  For a block
>   * device without zone capabilities, the number of zones is always 0.
>   */
> -unsigned int blkdev_nr_zones(struct gendisk *disk)
> +unsigned int bdev_nr_zones(struct block_device *bdev)
>  {
> -	sector_t zone_sectors = blk_queue_zone_sectors(disk->queue);
> +	sector_t zone_sectors = bdev_zone_sectors(bdev);
>  
> -	if (!blk_queue_is_zoned(disk->queue))
> +	if (!blk_queue_is_zoned(bdev_get_queue(bdev)))

bdev_is_zoned() ?

>  		return 0;
> -	return (get_capacity(disk) + zone_sectors - 1) >> ilog2(zone_sectors);
> +	return (bdev_nr_sectors(bdev) + zone_sectors - 1) >>
> +		ilog2(zone_sectors);
>  }
> -EXPORT_SYMBOL_GPL(blkdev_nr_zones);
> +EXPORT_SYMBOL_GPL(bdev_nr_zones);
>  
>  /**
>   * blkdev_report_zones - Get zones information
> diff --git a/block/ioctl.c b/block/ioctl.c
> index 46949f1b0dba5..60121e89052bc 100644
> --- a/block/ioctl.c
> +++ b/block/ioctl.c
> @@ -495,7 +495,7 @@ static int blkdev_common_ioctl(struct block_device *bdev, fmode_t mode,
>  	case BLKGETZONESZ:
>  		return put_uint(argp, bdev_zone_sectors(bdev));
>  	case BLKGETNRZONES:
> -		return put_uint(argp, blkdev_nr_zones(bdev->bd_disk));
> +		return put_uint(argp, bdev_nr_zones(bdev));
>  	case BLKROGET:
>  		return put_int(argp, bdev_read_only(bdev) != 0);
>  	case BLKSSZGET: /* get block device logical block size */
> diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c
> index 576ab3ed082a5..e62c52e964259 100644
> --- a/drivers/block/null_blk/zoned.c
> +++ b/drivers/block/null_blk/zoned.c
> @@ -170,7 +170,7 @@ int null_register_zoned_dev(struct nullb *nullb)
>  			return ret;
>  	} else {
>  		blk_queue_chunk_sectors(q, dev->zone_size_sects);
> -		q->nr_zones = blkdev_nr_zones(nullb->disk);
> +		q->nr_zones = bdev_nr_zones(nullb->disk->part0);
>  	}
>  
>  	blk_queue_max_zone_append_sectors(q, dev->zone_size_sects);
> diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c
> index ae616b87c91ae..6d105abe12415 100644
> --- a/drivers/md/dm-zone.c
> +++ b/drivers/md/dm-zone.c
> @@ -301,7 +301,7 @@ int dm_set_zones_restrictions(struct dm_table *t, struct request_queue *q)
>  	 * correct value to be exposed in sysfs queue/nr_zones.
>  	 */
>  	WARN_ON_ONCE(queue_is_mq(q));
> -	q->nr_zones = blkdev_nr_zones(md->disk);
> +	q->nr_zones = bdev_nr_zones(md->disk->part0);
>  
>  	/* Check if zone append is natively supported */
>  	if (dm_table_supports_zone_append(t)) {
> diff --git a/drivers/md/dm-zoned-target.c b/drivers/md/dm-zoned-target.c
> index 0ec5d8b9b1a4e..6ba6ef44b00e2 100644
> --- a/drivers/md/dm-zoned-target.c
> +++ b/drivers/md/dm-zoned-target.c
> @@ -793,8 +793,7 @@ static int dmz_fixup_devices(struct dm_target *ti)
>  			}
>  			zone_nr_sectors = blk_queue_zone_sectors(q);
>  			zoned_dev->zone_nr_sectors = zone_nr_sectors;
> -			zoned_dev->nr_zones =
> -				blkdev_nr_zones(zoned_dev->bdev->bd_disk);
> +			zoned_dev->nr_zones = bdev_nr_zones(zoned_dev->bdev);
>  		}
>  	} else {
>  		reg_dev = NULL;
> @@ -805,7 +804,7 @@ static int dmz_fixup_devices(struct dm_target *ti)
>  		}
>  		q = bdev_get_queue(zoned_dev->bdev);
>  		zoned_dev->zone_nr_sectors = blk_queue_zone_sectors(q);
> -		zoned_dev->nr_zones = blkdev_nr_zones(zoned_dev->bdev->bd_disk);
> +		zoned_dev->nr_zones = bdev_nr_zones(zoned_dev->bdev);
>  	}
>  
>  	if (reg_dev) {
> diff --git a/drivers/nvme/target/zns.c b/drivers/nvme/target/zns.c
> index c6f0a775efdee..c9b2ce06ca93e 100644
> --- a/drivers/nvme/target/zns.c
> +++ b/drivers/nvme/target/zns.c
> @@ -60,7 +60,7 @@ bool nvmet_bdev_zns_enable(struct nvmet_ns *ns)
>  	if (ns->bdev->bd_disk->queue->conv_zones_bitmap)
>  		return false;
>  
> -	ret = blkdev_report_zones(ns->bdev, 0, blkdev_nr_zones(bd_disk),
> +	ret = blkdev_report_zones(ns->bdev, 0, bdev_nr_zones(ns->bdev),
>  				  validate_conv_zones_cb, NULL);
>  	if (ret < 0)
>  		return false;
> @@ -241,7 +241,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 blkdev_nr_zones(req->ns->bdev->bd_disk) -
> +	return bdev_nr_zones(req->ns->bdev) -
>  		(sect >> ilog2(bdev_zone_sectors(req->ns->bdev)));
>  }
>  
> diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
> index 053299758deb9..9c0eef1ff32a0 100644
> --- a/fs/zonefs/super.c
> +++ b/fs/zonefs/super.c
> @@ -1394,7 +1394,7 @@ static void zonefs_init_dir_inode(struct inode *parent, struct inode *inode,
>  {
>  	struct super_block *sb = parent->i_sb;
>  
> -	inode->i_ino = blkdev_nr_zones(sb->s_bdev->bd_disk) + type + 1;
> +	inode->i_ino = bdev_nr_zones(sb->s_bdev) + type + 1;
>  	inode_init_owner(&init_user_ns, inode, parent, S_IFDIR | 0555);
>  	inode->i_op = &zonefs_dir_inode_operations;
>  	inode->i_fop = &simple_dir_operations;
> @@ -1540,7 +1540,7 @@ static int zonefs_create_zgroup(struct zonefs_zone_data *zd,
>  	/*
>  	 * The first zone contains the super block: skip it.
>  	 */
> -	end = zd->zones + blkdev_nr_zones(sb->s_bdev->bd_disk);
> +	end = zd->zones + bdev_nr_zones(sb->s_bdev);
>  	for (zone = &zd->zones[1]; zone < end; zone = next) {
>  
>  		next = zone + 1;
> @@ -1635,8 +1635,8 @@ static int zonefs_get_zone_info(struct zonefs_zone_data *zd)
>  	struct block_device *bdev = zd->sb->s_bdev;
>  	int ret;
>  
> -	zd->zones = kvcalloc(blkdev_nr_zones(bdev->bd_disk),
> -			     sizeof(struct blk_zone), GFP_KERNEL);
> +	zd->zones = kvcalloc(bdev_nr_zones(bdev), sizeof(struct blk_zone),
> +			     GFP_KERNEL);
>  	if (!zd->zones)
>  		return -ENOMEM;
>  
> @@ -1648,9 +1648,9 @@ static int zonefs_get_zone_info(struct zonefs_zone_data *zd)
>  		return ret;
>  	}
>  
> -	if (ret != blkdev_nr_zones(bdev->bd_disk)) {
> +	if (ret != bdev_nr_zones(bdev)) {
>  		zonefs_err(zd->sb, "Invalid zone report (%d/%u zones)\n",
> -			   ret, blkdev_nr_zones(bdev->bd_disk));
> +			   ret, bdev_nr_zones(bdev));
>  		return -EIO;
>  	}
>  
> @@ -1816,8 +1816,7 @@ static int zonefs_fill_super(struct super_block *sb, void *data, int silent)
>  	if (ret)
>  		goto cleanup;
>  
> -	zonefs_info(sb, "Mounting %u zones",
> -		    blkdev_nr_zones(sb->s_bdev->bd_disk));
> +	zonefs_info(sb, "Mounting %u zones", bdev_nr_zones(sb->s_bdev));
>  
>  	if (!sbi->s_max_wro_seq_files &&
>  	    !sbi->s_max_active_seq_files &&
> @@ -1833,7 +1832,7 @@ static int zonefs_fill_super(struct super_block *sb, void *data, int silent)
>  	if (!inode)
>  		goto cleanup;
>  
> -	inode->i_ino = blkdev_nr_zones(sb->s_bdev->bd_disk);
> +	inode->i_ino = bdev_nr_zones(sb->s_bdev);
>  	inode->i_mode = S_IFDIR | 0555;
>  	inode->i_ctime = inode->i_mtime = inode->i_atime = current_time(inode);
>  	inode->i_op = &zonefs_dir_inode_operations;
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index e32c147f72868..183aa83143fd2 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -298,7 +298,7 @@ void disk_set_zoned(struct gendisk *disk, enum blk_zoned_model model);
>  #define BLK_ALL_ZONES  ((unsigned int)-1)
>  int blkdev_report_zones(struct block_device *bdev, sector_t sector,
>  			unsigned int nr_zones, report_zones_cb cb, void *data);
> -unsigned int blkdev_nr_zones(struct gendisk *disk);
> +unsigned int bdev_nr_zones(struct block_device *bdev);
>  extern int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op,
>  			    sector_t sectors, sector_t nr_sectors,
>  			    gfp_t gfp_mask);
> @@ -314,7 +314,7 @@ extern int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
>  
>  #else /* CONFIG_BLK_DEV_ZONED */
>  
> -static inline unsigned int blkdev_nr_zones(struct gendisk *disk)
> +static inline unsigned int bdev_nr_zones(struct block_device *bdev)
>  {
>  	return 0;
>  }


-- 
Damien Le Moal
Western Digital Research

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

* Re: [dm-devel] [PATCH 13/17] block: replace blkdev_nr_zones with bdev_nr_zones
@ 2022-07-05  2:53     ` Damien Le Moal
  0 siblings, 0 replies; 140+ messages in thread
From: Damien Le Moal @ 2022-07-05  2:53 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

On 7/4/22 21:44, Christoph Hellwig wrote:
> Pass a block_device instead of a request_queue a that is what most

s/a that/as that

> callers have at hand.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  block/blk-zoned.c              | 15 ++++++++-------
>  block/ioctl.c                  |  2 +-
>  drivers/block/null_blk/zoned.c |  2 +-
>  drivers/md/dm-zone.c           |  2 +-
>  drivers/md/dm-zoned-target.c   |  5 ++---
>  drivers/nvme/target/zns.c      |  4 ++--
>  fs/zonefs/super.c              | 17 ++++++++---------
>  include/linux/blkdev.h         |  4 ++--
>  8 files changed, 25 insertions(+), 26 deletions(-)
> 
> diff --git a/block/blk-zoned.c b/block/blk-zoned.c
> index 9085f9fb3ab42..836b96ebfdc04 100644
> --- a/block/blk-zoned.c
> +++ b/block/blk-zoned.c
> @@ -108,21 +108,22 @@ void __blk_req_zone_write_unlock(struct request *rq)
>  EXPORT_SYMBOL_GPL(__blk_req_zone_write_unlock);
>  
>  /**
> - * blkdev_nr_zones - Get number of zones
> - * @disk:	Target gendisk
> + * bdev_nr_zones - Get number of zones
> + * @bdev:	Target device
>   *
>   * Return the total number of zones of a zoned block device.  For a block
>   * device without zone capabilities, the number of zones is always 0.
>   */
> -unsigned int blkdev_nr_zones(struct gendisk *disk)
> +unsigned int bdev_nr_zones(struct block_device *bdev)
>  {
> -	sector_t zone_sectors = blk_queue_zone_sectors(disk->queue);
> +	sector_t zone_sectors = bdev_zone_sectors(bdev);
>  
> -	if (!blk_queue_is_zoned(disk->queue))
> +	if (!blk_queue_is_zoned(bdev_get_queue(bdev)))

bdev_is_zoned() ?

>  		return 0;
> -	return (get_capacity(disk) + zone_sectors - 1) >> ilog2(zone_sectors);
> +	return (bdev_nr_sectors(bdev) + zone_sectors - 1) >>
> +		ilog2(zone_sectors);
>  }
> -EXPORT_SYMBOL_GPL(blkdev_nr_zones);
> +EXPORT_SYMBOL_GPL(bdev_nr_zones);
>  
>  /**
>   * blkdev_report_zones - Get zones information
> diff --git a/block/ioctl.c b/block/ioctl.c
> index 46949f1b0dba5..60121e89052bc 100644
> --- a/block/ioctl.c
> +++ b/block/ioctl.c
> @@ -495,7 +495,7 @@ static int blkdev_common_ioctl(struct block_device *bdev, fmode_t mode,
>  	case BLKGETZONESZ:
>  		return put_uint(argp, bdev_zone_sectors(bdev));
>  	case BLKGETNRZONES:
> -		return put_uint(argp, blkdev_nr_zones(bdev->bd_disk));
> +		return put_uint(argp, bdev_nr_zones(bdev));
>  	case BLKROGET:
>  		return put_int(argp, bdev_read_only(bdev) != 0);
>  	case BLKSSZGET: /* get block device logical block size */
> diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c
> index 576ab3ed082a5..e62c52e964259 100644
> --- a/drivers/block/null_blk/zoned.c
> +++ b/drivers/block/null_blk/zoned.c
> @@ -170,7 +170,7 @@ int null_register_zoned_dev(struct nullb *nullb)
>  			return ret;
>  	} else {
>  		blk_queue_chunk_sectors(q, dev->zone_size_sects);
> -		q->nr_zones = blkdev_nr_zones(nullb->disk);
> +		q->nr_zones = bdev_nr_zones(nullb->disk->part0);
>  	}
>  
>  	blk_queue_max_zone_append_sectors(q, dev->zone_size_sects);
> diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c
> index ae616b87c91ae..6d105abe12415 100644
> --- a/drivers/md/dm-zone.c
> +++ b/drivers/md/dm-zone.c
> @@ -301,7 +301,7 @@ int dm_set_zones_restrictions(struct dm_table *t, struct request_queue *q)
>  	 * correct value to be exposed in sysfs queue/nr_zones.
>  	 */
>  	WARN_ON_ONCE(queue_is_mq(q));
> -	q->nr_zones = blkdev_nr_zones(md->disk);
> +	q->nr_zones = bdev_nr_zones(md->disk->part0);
>  
>  	/* Check if zone append is natively supported */
>  	if (dm_table_supports_zone_append(t)) {
> diff --git a/drivers/md/dm-zoned-target.c b/drivers/md/dm-zoned-target.c
> index 0ec5d8b9b1a4e..6ba6ef44b00e2 100644
> --- a/drivers/md/dm-zoned-target.c
> +++ b/drivers/md/dm-zoned-target.c
> @@ -793,8 +793,7 @@ static int dmz_fixup_devices(struct dm_target *ti)
>  			}
>  			zone_nr_sectors = blk_queue_zone_sectors(q);
>  			zoned_dev->zone_nr_sectors = zone_nr_sectors;
> -			zoned_dev->nr_zones =
> -				blkdev_nr_zones(zoned_dev->bdev->bd_disk);
> +			zoned_dev->nr_zones = bdev_nr_zones(zoned_dev->bdev);
>  		}
>  	} else {
>  		reg_dev = NULL;
> @@ -805,7 +804,7 @@ static int dmz_fixup_devices(struct dm_target *ti)
>  		}
>  		q = bdev_get_queue(zoned_dev->bdev);
>  		zoned_dev->zone_nr_sectors = blk_queue_zone_sectors(q);
> -		zoned_dev->nr_zones = blkdev_nr_zones(zoned_dev->bdev->bd_disk);
> +		zoned_dev->nr_zones = bdev_nr_zones(zoned_dev->bdev);
>  	}
>  
>  	if (reg_dev) {
> diff --git a/drivers/nvme/target/zns.c b/drivers/nvme/target/zns.c
> index c6f0a775efdee..c9b2ce06ca93e 100644
> --- a/drivers/nvme/target/zns.c
> +++ b/drivers/nvme/target/zns.c
> @@ -60,7 +60,7 @@ bool nvmet_bdev_zns_enable(struct nvmet_ns *ns)
>  	if (ns->bdev->bd_disk->queue->conv_zones_bitmap)
>  		return false;
>  
> -	ret = blkdev_report_zones(ns->bdev, 0, blkdev_nr_zones(bd_disk),
> +	ret = blkdev_report_zones(ns->bdev, 0, bdev_nr_zones(ns->bdev),
>  				  validate_conv_zones_cb, NULL);
>  	if (ret < 0)
>  		return false;
> @@ -241,7 +241,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 blkdev_nr_zones(req->ns->bdev->bd_disk) -
> +	return bdev_nr_zones(req->ns->bdev) -
>  		(sect >> ilog2(bdev_zone_sectors(req->ns->bdev)));
>  }
>  
> diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
> index 053299758deb9..9c0eef1ff32a0 100644
> --- a/fs/zonefs/super.c
> +++ b/fs/zonefs/super.c
> @@ -1394,7 +1394,7 @@ static void zonefs_init_dir_inode(struct inode *parent, struct inode *inode,
>  {
>  	struct super_block *sb = parent->i_sb;
>  
> -	inode->i_ino = blkdev_nr_zones(sb->s_bdev->bd_disk) + type + 1;
> +	inode->i_ino = bdev_nr_zones(sb->s_bdev) + type + 1;
>  	inode_init_owner(&init_user_ns, inode, parent, S_IFDIR | 0555);
>  	inode->i_op = &zonefs_dir_inode_operations;
>  	inode->i_fop = &simple_dir_operations;
> @@ -1540,7 +1540,7 @@ static int zonefs_create_zgroup(struct zonefs_zone_data *zd,
>  	/*
>  	 * The first zone contains the super block: skip it.
>  	 */
> -	end = zd->zones + blkdev_nr_zones(sb->s_bdev->bd_disk);
> +	end = zd->zones + bdev_nr_zones(sb->s_bdev);
>  	for (zone = &zd->zones[1]; zone < end; zone = next) {
>  
>  		next = zone + 1;
> @@ -1635,8 +1635,8 @@ static int zonefs_get_zone_info(struct zonefs_zone_data *zd)
>  	struct block_device *bdev = zd->sb->s_bdev;
>  	int ret;
>  
> -	zd->zones = kvcalloc(blkdev_nr_zones(bdev->bd_disk),
> -			     sizeof(struct blk_zone), GFP_KERNEL);
> +	zd->zones = kvcalloc(bdev_nr_zones(bdev), sizeof(struct blk_zone),
> +			     GFP_KERNEL);
>  	if (!zd->zones)
>  		return -ENOMEM;
>  
> @@ -1648,9 +1648,9 @@ static int zonefs_get_zone_info(struct zonefs_zone_data *zd)
>  		return ret;
>  	}
>  
> -	if (ret != blkdev_nr_zones(bdev->bd_disk)) {
> +	if (ret != bdev_nr_zones(bdev)) {
>  		zonefs_err(zd->sb, "Invalid zone report (%d/%u zones)\n",
> -			   ret, blkdev_nr_zones(bdev->bd_disk));
> +			   ret, bdev_nr_zones(bdev));
>  		return -EIO;
>  	}
>  
> @@ -1816,8 +1816,7 @@ static int zonefs_fill_super(struct super_block *sb, void *data, int silent)
>  	if (ret)
>  		goto cleanup;
>  
> -	zonefs_info(sb, "Mounting %u zones",
> -		    blkdev_nr_zones(sb->s_bdev->bd_disk));
> +	zonefs_info(sb, "Mounting %u zones", bdev_nr_zones(sb->s_bdev));
>  
>  	if (!sbi->s_max_wro_seq_files &&
>  	    !sbi->s_max_active_seq_files &&
> @@ -1833,7 +1832,7 @@ static int zonefs_fill_super(struct super_block *sb, void *data, int silent)
>  	if (!inode)
>  		goto cleanup;
>  
> -	inode->i_ino = blkdev_nr_zones(sb->s_bdev->bd_disk);
> +	inode->i_ino = bdev_nr_zones(sb->s_bdev);
>  	inode->i_mode = S_IFDIR | 0555;
>  	inode->i_ctime = inode->i_mtime = inode->i_atime = current_time(inode);
>  	inode->i_op = &zonefs_dir_inode_operations;
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index e32c147f72868..183aa83143fd2 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -298,7 +298,7 @@ void disk_set_zoned(struct gendisk *disk, enum blk_zoned_model model);
>  #define BLK_ALL_ZONES  ((unsigned int)-1)
>  int blkdev_report_zones(struct block_device *bdev, sector_t sector,
>  			unsigned int nr_zones, report_zones_cb cb, void *data);
> -unsigned int blkdev_nr_zones(struct gendisk *disk);
> +unsigned int bdev_nr_zones(struct block_device *bdev);
>  extern int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op,
>  			    sector_t sectors, sector_t nr_sectors,
>  			    gfp_t gfp_mask);
> @@ -314,7 +314,7 @@ extern int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
>  
>  #else /* CONFIG_BLK_DEV_ZONED */
>  
> -static inline unsigned int blkdev_nr_zones(struct gendisk *disk)
> +static inline unsigned int bdev_nr_zones(struct block_device *bdev)
>  {
>  	return 0;
>  }


-- 
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] 140+ messages in thread

* Re: [PATCH 14/17] block: use bdev based helpers in blkdev_zone_mgmt / blkdev_zone_mgmt_all
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-05  2:54     ` Damien Le Moal
  -1 siblings, 0 replies; 140+ messages in thread
From: Damien Le Moal @ 2022-07-05  2:54 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

On 7/4/22 21:44, Christoph Hellwig wrote:
> Use the bdev based helpers instead of the queue based ones to clean up
> the code a bit and prepare for storing all zone related fields in
> struct gendisk.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

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

> ---
>  block/blk-zoned.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/block/blk-zoned.c b/block/blk-zoned.c
> index 836b96ebfdc04..ee8752f083a94 100644
> --- a/block/blk-zoned.c
> +++ b/block/blk-zoned.c
> @@ -190,8 +190,8 @@ int blkdev_zone_mgmt_all(struct block_device *bdev, unsigned int op,
>  			 gfp_t gfp_mask)
>  {
>  	struct request_queue *q = bdev_get_queue(bdev);
> -	sector_t capacity = get_capacity(bdev->bd_disk);
> -	sector_t zone_sectors = blk_queue_zone_sectors(q);
> +	sector_t capacity = bdev_nr_sectors(bdev);
> +	sector_t zone_sectors = bdev_zone_sectors(bdev);
>  	unsigned long *need_reset;
>  	struct bio *bio = NULL;
>  	sector_t sector = 0;
> @@ -262,8 +262,8 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op,
>  		     gfp_t gfp_mask)
>  {
>  	struct request_queue *q = bdev_get_queue(bdev);
> -	sector_t zone_sectors = blk_queue_zone_sectors(q);
> -	sector_t capacity = get_capacity(bdev->bd_disk);
> +	sector_t zone_sectors = bdev_zone_sectors(bdev);
> +	sector_t capacity = bdev_nr_sectors(bdev);
>  	sector_t end_sector = sector + nr_sectors;
>  	struct bio *bio = NULL;
>  	int ret = 0;


-- 
Damien Le Moal
Western Digital Research

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

* Re: [dm-devel] [PATCH 14/17] block: use bdev based helpers in blkdev_zone_mgmt / blkdev_zone_mgmt_all
@ 2022-07-05  2:54     ` Damien Le Moal
  0 siblings, 0 replies; 140+ messages in thread
From: Damien Le Moal @ 2022-07-05  2:54 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

On 7/4/22 21:44, Christoph Hellwig wrote:
> Use the bdev based helpers instead of the queue based ones to clean up
> the code a bit and prepare for storing all zone related fields in
> struct gendisk.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

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

> ---
>  block/blk-zoned.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/block/blk-zoned.c b/block/blk-zoned.c
> index 836b96ebfdc04..ee8752f083a94 100644
> --- a/block/blk-zoned.c
> +++ b/block/blk-zoned.c
> @@ -190,8 +190,8 @@ int blkdev_zone_mgmt_all(struct block_device *bdev, unsigned int op,
>  			 gfp_t gfp_mask)
>  {
>  	struct request_queue *q = bdev_get_queue(bdev);
> -	sector_t capacity = get_capacity(bdev->bd_disk);
> -	sector_t zone_sectors = blk_queue_zone_sectors(q);
> +	sector_t capacity = bdev_nr_sectors(bdev);
> +	sector_t zone_sectors = bdev_zone_sectors(bdev);
>  	unsigned long *need_reset;
>  	struct bio *bio = NULL;
>  	sector_t sector = 0;
> @@ -262,8 +262,8 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op,
>  		     gfp_t gfp_mask)
>  {
>  	struct request_queue *q = bdev_get_queue(bdev);
> -	sector_t zone_sectors = blk_queue_zone_sectors(q);
> -	sector_t capacity = get_capacity(bdev->bd_disk);
> +	sector_t zone_sectors = bdev_zone_sectors(bdev);
> +	sector_t capacity = bdev_nr_sectors(bdev);
>  	sector_t end_sector = sector + nr_sectors;
>  	struct bio *bio = NULL;
>  	int ret = 0;


-- 
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] 140+ messages in thread

* Re: [PATCH 15/17] dm-zoned: cleanup dmz_fixup_devices
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-05  2:54     ` Damien Le Moal
  -1 siblings, 0 replies; 140+ messages in thread
From: Damien Le Moal @ 2022-07-05  2:54 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

On 7/4/22 21:44, Christoph Hellwig wrote:
> Use the bdev based helpers where applicable and move the zoned_dev
> into the scope where it is actually used.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

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

> ---
>  drivers/md/dm-zoned-target.c | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/md/dm-zoned-target.c b/drivers/md/dm-zoned-target.c
> index 6ba6ef44b00e2..95b132b52f332 100644
> --- a/drivers/md/dm-zoned-target.c
> +++ b/drivers/md/dm-zoned-target.c
> @@ -764,8 +764,7 @@ static void dmz_put_zoned_device(struct dm_target *ti)
>  static int dmz_fixup_devices(struct dm_target *ti)
>  {
>  	struct dmz_target *dmz = ti->private;
> -	struct dmz_dev *reg_dev, *zoned_dev;
> -	struct request_queue *q;
> +	struct dmz_dev *reg_dev = NULL;
>  	sector_t zone_nr_sectors = 0;
>  	int i;
>  
> @@ -780,31 +779,32 @@ static int dmz_fixup_devices(struct dm_target *ti)
>  			return -EINVAL;
>  		}
>  		for (i = 1; i < dmz->nr_ddevs; i++) {
> -			zoned_dev = &dmz->dev[i];
> +			struct dmz_dev *zoned_dev = &dmz->dev[i];
> +			struct block_device *bdev = zoned_dev->bdev;
> +
>  			if (zoned_dev->flags & DMZ_BDEV_REGULAR) {
>  				ti->error = "Secondary disk is not a zoned device";
>  				return -EINVAL;
>  			}
> -			q = bdev_get_queue(zoned_dev->bdev);
>  			if (zone_nr_sectors &&
> -			    zone_nr_sectors != blk_queue_zone_sectors(q)) {
> +			    zone_nr_sectors != bdev_zone_sectors(bdev)) {
>  				ti->error = "Zone nr sectors mismatch";
>  				return -EINVAL;
>  			}
> -			zone_nr_sectors = blk_queue_zone_sectors(q);
> +			zone_nr_sectors = bdev_zone_sectors(bdev);
>  			zoned_dev->zone_nr_sectors = zone_nr_sectors;
> -			zoned_dev->nr_zones = bdev_nr_zones(zoned_dev->bdev);
> +			zoned_dev->nr_zones = bdev_nr_zones(bdev);
>  		}
>  	} else {
> -		reg_dev = NULL;
> -		zoned_dev = &dmz->dev[0];
> +		struct dmz_dev *zoned_dev = &dmz->dev[0];
> +		struct block_device *bdev = zoned_dev->bdev;
> +
>  		if (zoned_dev->flags & DMZ_BDEV_REGULAR) {
>  			ti->error = "Disk is not a zoned device";
>  			return -EINVAL;
>  		}
> -		q = bdev_get_queue(zoned_dev->bdev);
> -		zoned_dev->zone_nr_sectors = blk_queue_zone_sectors(q);
> -		zoned_dev->nr_zones = bdev_nr_zones(zoned_dev->bdev);
> +		zoned_dev->zone_nr_sectors = bdev_zone_sectors(bdev);
> +		zoned_dev->nr_zones = bdev_nr_zones(bdev);
>  	}
>  
>  	if (reg_dev) {


-- 
Damien Le Moal
Western Digital Research

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

* Re: [dm-devel] [PATCH 15/17] dm-zoned: cleanup dmz_fixup_devices
@ 2022-07-05  2:54     ` Damien Le Moal
  0 siblings, 0 replies; 140+ messages in thread
From: Damien Le Moal @ 2022-07-05  2:54 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

On 7/4/22 21:44, Christoph Hellwig wrote:
> Use the bdev based helpers where applicable and move the zoned_dev
> into the scope where it is actually used.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

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

> ---
>  drivers/md/dm-zoned-target.c | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/md/dm-zoned-target.c b/drivers/md/dm-zoned-target.c
> index 6ba6ef44b00e2..95b132b52f332 100644
> --- a/drivers/md/dm-zoned-target.c
> +++ b/drivers/md/dm-zoned-target.c
> @@ -764,8 +764,7 @@ static void dmz_put_zoned_device(struct dm_target *ti)
>  static int dmz_fixup_devices(struct dm_target *ti)
>  {
>  	struct dmz_target *dmz = ti->private;
> -	struct dmz_dev *reg_dev, *zoned_dev;
> -	struct request_queue *q;
> +	struct dmz_dev *reg_dev = NULL;
>  	sector_t zone_nr_sectors = 0;
>  	int i;
>  
> @@ -780,31 +779,32 @@ static int dmz_fixup_devices(struct dm_target *ti)
>  			return -EINVAL;
>  		}
>  		for (i = 1; i < dmz->nr_ddevs; i++) {
> -			zoned_dev = &dmz->dev[i];
> +			struct dmz_dev *zoned_dev = &dmz->dev[i];
> +			struct block_device *bdev = zoned_dev->bdev;
> +
>  			if (zoned_dev->flags & DMZ_BDEV_REGULAR) {
>  				ti->error = "Secondary disk is not a zoned device";
>  				return -EINVAL;
>  			}
> -			q = bdev_get_queue(zoned_dev->bdev);
>  			if (zone_nr_sectors &&
> -			    zone_nr_sectors != blk_queue_zone_sectors(q)) {
> +			    zone_nr_sectors != bdev_zone_sectors(bdev)) {
>  				ti->error = "Zone nr sectors mismatch";
>  				return -EINVAL;
>  			}
> -			zone_nr_sectors = blk_queue_zone_sectors(q);
> +			zone_nr_sectors = bdev_zone_sectors(bdev);
>  			zoned_dev->zone_nr_sectors = zone_nr_sectors;
> -			zoned_dev->nr_zones = bdev_nr_zones(zoned_dev->bdev);
> +			zoned_dev->nr_zones = bdev_nr_zones(bdev);
>  		}
>  	} else {
> -		reg_dev = NULL;
> -		zoned_dev = &dmz->dev[0];
> +		struct dmz_dev *zoned_dev = &dmz->dev[0];
> +		struct block_device *bdev = zoned_dev->bdev;
> +
>  		if (zoned_dev->flags & DMZ_BDEV_REGULAR) {
>  			ti->error = "Disk is not a zoned device";
>  			return -EINVAL;
>  		}
> -		q = bdev_get_queue(zoned_dev->bdev);
> -		zoned_dev->zone_nr_sectors = blk_queue_zone_sectors(q);
> -		zoned_dev->nr_zones = bdev_nr_zones(zoned_dev->bdev);
> +		zoned_dev->zone_nr_sectors = bdev_zone_sectors(bdev);
> +		zoned_dev->nr_zones = bdev_nr_zones(bdev);
>  	}
>  
>  	if (reg_dev) {


-- 
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] 140+ messages in thread

* Re: [PATCH 16/17] block: remove blk_queue_zone_sectors
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-05  2:55     ` Damien Le Moal
  -1 siblings, 0 replies; 140+ messages in thread
From: Damien Le Moal @ 2022-07-05  2:55 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

On 7/4/22 21:44, Christoph Hellwig wrote:
> Always use bdev_zone_sectors instead.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

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

> ---
>  drivers/md/dm-table.c  |  4 +---
>  drivers/md/dm-zone.c   | 10 ++++++----
>  include/linux/blkdev.h | 11 +++--------
>  3 files changed, 10 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
> index b36b528e56cff..df904b7e95ce3 100644
> --- a/drivers/md/dm-table.c
> +++ b/drivers/md/dm-table.c
> @@ -1620,13 +1620,11 @@ static bool dm_table_supports_zoned_model(struct dm_table *t,
>  static int device_not_matches_zone_sectors(struct dm_target *ti, struct dm_dev *dev,
>  					   sector_t start, sector_t len, void *data)
>  {
> -	struct request_queue *q = bdev_get_queue(dev->bdev);
>  	unsigned int *zone_sectors = data;
>  
>  	if (!bdev_is_zoned(dev->bdev))
>  		return 0;
> -
> -	return blk_queue_zone_sectors(q) != *zone_sectors;
> +	return bdev_zone_sectors(dev->bdev) != *zone_sectors;
>  }
>  
>  /*
> diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c
> index 6d105abe12415..842c31019b513 100644
> --- a/drivers/md/dm-zone.c
> +++ b/drivers/md/dm-zone.c
> @@ -334,7 +334,7 @@ static int dm_update_zone_wp_offset_cb(struct blk_zone *zone, unsigned int idx,
>  static int dm_update_zone_wp_offset(struct mapped_device *md, unsigned int zno,
>  				    unsigned int *wp_ofst)
>  {
> -	sector_t sector = zno * blk_queue_zone_sectors(md->queue);
> +	sector_t sector = zno * bdev_zone_sectors(md->disk->part0);
>  	unsigned int noio_flag;
>  	struct dm_table *t;
>  	int srcu_idx, ret;
> @@ -373,7 +373,7 @@ struct orig_bio_details {
>  static bool dm_zone_map_bio_begin(struct mapped_device *md,
>  				  unsigned int zno, struct bio *clone)
>  {
> -	sector_t zsectors = blk_queue_zone_sectors(md->queue);
> +	sector_t zsectors = bdev_zone_sectors(md->disk->part0);
>  	unsigned int zwp_offset = READ_ONCE(md->zwp_offset[zno]);
>  
>  	/*
> @@ -443,7 +443,7 @@ static blk_status_t dm_zone_map_bio_end(struct mapped_device *md, unsigned int z
>  		return BLK_STS_OK;
>  	case REQ_OP_ZONE_FINISH:
>  		WRITE_ONCE(md->zwp_offset[zno],
> -			   blk_queue_zone_sectors(md->queue));
> +			   bdev_zone_sectors(md->disk->part0));
>  		return BLK_STS_OK;
>  	case REQ_OP_WRITE_ZEROES:
>  	case REQ_OP_WRITE:
> @@ -593,6 +593,7 @@ void dm_zone_endio(struct dm_io *io, struct bio *clone)
>  {
>  	struct mapped_device *md = io->md;
>  	struct request_queue *q = md->queue;
> +	struct gendisk *disk = md->disk;
>  	struct bio *orig_bio = io->orig_bio;
>  	unsigned int zwp_offset;
>  	unsigned int zno;
> @@ -608,7 +609,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)blk_queue_zone_sectors(q) - 1;
> +			sector_t mask =
> +				(sector_t)bdev_zone_sectors(disk->part0) - 1;
>  
>  			orig_bio->bi_iter.bi_sector +=
>  				clone->bi_iter.bi_sector & mask;
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index 183aa83143fd2..f1eca3f5610eb 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -669,11 +669,6 @@ static inline bool blk_queue_is_zoned(struct request_queue *q)
>  	}
>  }
>  
> -static inline sector_t blk_queue_zone_sectors(struct request_queue *q)
> -{
> -	return blk_queue_is_zoned(q) ? q->limits.chunk_sectors : 0;
> -}
> -
>  #ifdef CONFIG_BLK_DEV_ZONED
>  static inline unsigned int blk_queue_nr_zones(struct request_queue *q)
>  {
> @@ -1312,9 +1307,9 @@ static inline sector_t bdev_zone_sectors(struct block_device *bdev)
>  {
>  	struct request_queue *q = bdev_get_queue(bdev);
>  
> -	if (q)
> -		return blk_queue_zone_sectors(q);
> -	return 0;
> +	if (!blk_queue_is_zoned(q))
> +		return 0;
> +	return q->limits.chunk_sectors;
>  }
>  
>  static inline int queue_dma_alignment(const struct request_queue *q)


-- 
Damien Le Moal
Western Digital Research

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

* Re: [dm-devel] [PATCH 16/17] block: remove blk_queue_zone_sectors
@ 2022-07-05  2:55     ` Damien Le Moal
  0 siblings, 0 replies; 140+ messages in thread
From: Damien Le Moal @ 2022-07-05  2:55 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

On 7/4/22 21:44, Christoph Hellwig wrote:
> Always use bdev_zone_sectors instead.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

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

> ---
>  drivers/md/dm-table.c  |  4 +---
>  drivers/md/dm-zone.c   | 10 ++++++----
>  include/linux/blkdev.h | 11 +++--------
>  3 files changed, 10 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
> index b36b528e56cff..df904b7e95ce3 100644
> --- a/drivers/md/dm-table.c
> +++ b/drivers/md/dm-table.c
> @@ -1620,13 +1620,11 @@ static bool dm_table_supports_zoned_model(struct dm_table *t,
>  static int device_not_matches_zone_sectors(struct dm_target *ti, struct dm_dev *dev,
>  					   sector_t start, sector_t len, void *data)
>  {
> -	struct request_queue *q = bdev_get_queue(dev->bdev);
>  	unsigned int *zone_sectors = data;
>  
>  	if (!bdev_is_zoned(dev->bdev))
>  		return 0;
> -
> -	return blk_queue_zone_sectors(q) != *zone_sectors;
> +	return bdev_zone_sectors(dev->bdev) != *zone_sectors;
>  }
>  
>  /*
> diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c
> index 6d105abe12415..842c31019b513 100644
> --- a/drivers/md/dm-zone.c
> +++ b/drivers/md/dm-zone.c
> @@ -334,7 +334,7 @@ static int dm_update_zone_wp_offset_cb(struct blk_zone *zone, unsigned int idx,
>  static int dm_update_zone_wp_offset(struct mapped_device *md, unsigned int zno,
>  				    unsigned int *wp_ofst)
>  {
> -	sector_t sector = zno * blk_queue_zone_sectors(md->queue);
> +	sector_t sector = zno * bdev_zone_sectors(md->disk->part0);
>  	unsigned int noio_flag;
>  	struct dm_table *t;
>  	int srcu_idx, ret;
> @@ -373,7 +373,7 @@ struct orig_bio_details {
>  static bool dm_zone_map_bio_begin(struct mapped_device *md,
>  				  unsigned int zno, struct bio *clone)
>  {
> -	sector_t zsectors = blk_queue_zone_sectors(md->queue);
> +	sector_t zsectors = bdev_zone_sectors(md->disk->part0);
>  	unsigned int zwp_offset = READ_ONCE(md->zwp_offset[zno]);
>  
>  	/*
> @@ -443,7 +443,7 @@ static blk_status_t dm_zone_map_bio_end(struct mapped_device *md, unsigned int z
>  		return BLK_STS_OK;
>  	case REQ_OP_ZONE_FINISH:
>  		WRITE_ONCE(md->zwp_offset[zno],
> -			   blk_queue_zone_sectors(md->queue));
> +			   bdev_zone_sectors(md->disk->part0));
>  		return BLK_STS_OK;
>  	case REQ_OP_WRITE_ZEROES:
>  	case REQ_OP_WRITE:
> @@ -593,6 +593,7 @@ void dm_zone_endio(struct dm_io *io, struct bio *clone)
>  {
>  	struct mapped_device *md = io->md;
>  	struct request_queue *q = md->queue;
> +	struct gendisk *disk = md->disk;
>  	struct bio *orig_bio = io->orig_bio;
>  	unsigned int zwp_offset;
>  	unsigned int zno;
> @@ -608,7 +609,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)blk_queue_zone_sectors(q) - 1;
> +			sector_t mask =
> +				(sector_t)bdev_zone_sectors(disk->part0) - 1;
>  
>  			orig_bio->bi_iter.bi_sector +=
>  				clone->bi_iter.bi_sector & mask;
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index 183aa83143fd2..f1eca3f5610eb 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -669,11 +669,6 @@ static inline bool blk_queue_is_zoned(struct request_queue *q)
>  	}
>  }
>  
> -static inline sector_t blk_queue_zone_sectors(struct request_queue *q)
> -{
> -	return blk_queue_is_zoned(q) ? q->limits.chunk_sectors : 0;
> -}
> -
>  #ifdef CONFIG_BLK_DEV_ZONED
>  static inline unsigned int blk_queue_nr_zones(struct request_queue *q)
>  {
> @@ -1312,9 +1307,9 @@ static inline sector_t bdev_zone_sectors(struct block_device *bdev)
>  {
>  	struct request_queue *q = bdev_get_queue(bdev);
>  
> -	if (q)
> -		return blk_queue_zone_sectors(q);
> -	return 0;
> +	if (!blk_queue_is_zoned(q))
> +		return 0;
> +	return q->limits.chunk_sectors;
>  }
>  
>  static inline int queue_dma_alignment(const struct request_queue *q)


-- 
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] 140+ messages in thread

* Re: [PATCH 17/17] block: move zone related fields to struct gendisk
  2022-07-04 12:45   ` [dm-devel] " Christoph Hellwig
@ 2022-07-05  2:59     ` Damien Le Moal
  -1 siblings, 0 replies; 140+ messages in thread
From: Damien Le Moal @ 2022-07-05  2:59 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

On 7/4/22 21:45, Christoph Hellwig wrote:
> Move the zone related fields that are currently stored in
> struct request_queue to struct gendisk as these are part of the highlevel
> block layer API and are only used for non-passthrough I/O that requires
> the gendisk.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

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

> ---
>  block/blk-mq-debugfs-zoned.c   |  6 +--
>  block/blk-sysfs.c              |  2 +-
>  block/blk-zoned.c              | 45 ++++++++---------
>  drivers/block/null_blk/zoned.c |  2 +-
>  drivers/md/dm-zone.c           | 74 +++++++++++++--------------
>  drivers/nvme/host/multipath.c  |  2 +-
>  drivers/nvme/target/zns.c      |  2 +-
>  drivers/scsi/sd_zbc.c          |  2 +-
>  include/linux/blk-mq.h         |  8 +--
>  include/linux/blkdev.h         | 91 ++++++++++++++++------------------
>  10 files changed, 110 insertions(+), 124 deletions(-)
> 
> diff --git a/block/blk-mq-debugfs-zoned.c b/block/blk-mq-debugfs-zoned.c
> index 038cb627c8689..a77b099c34b7a 100644
> --- a/block/blk-mq-debugfs-zoned.c
> +++ b/block/blk-mq-debugfs-zoned.c
> @@ -11,11 +11,11 @@ int queue_zone_wlock_show(void *data, struct seq_file *m)
>  	struct request_queue *q = data;
>  	unsigned int i;
>  
> -	if (!q->seq_zones_wlock)
> +	if (!q->disk->seq_zones_wlock)
>  		return 0;
>  
> -	for (i = 0; i < q->nr_zones; i++)
> -		if (test_bit(i, q->seq_zones_wlock))
> +	for (i = 0; i < q->disk->nr_zones; i++)
> +		if (test_bit(i, q->disk->seq_zones_wlock))
>  			seq_printf(m, "%u\n", i);
>  
>  	return 0;
> diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
> index 5ce72345ac666..c0303026752d5 100644
> --- a/block/blk-sysfs.c
> +++ b/block/blk-sysfs.c
> @@ -325,7 +325,7 @@ static ssize_t queue_zoned_show(struct request_queue *q, char *page)
>  
>  static ssize_t queue_nr_zones_show(struct request_queue *q, char *page)
>  {
> -	return queue_var_show(blk_queue_nr_zones(q), page);
> +	return queue_var_show(disk_nr_zones(q->disk), page);
>  }
>  
>  static ssize_t queue_max_open_zones_show(struct request_queue *q, char *page)
> diff --git a/block/blk-zoned.c b/block/blk-zoned.c
> index ee8752f083a94..4826083ce9a48 100644
> --- a/block/blk-zoned.c
> +++ b/block/blk-zoned.c
> @@ -57,10 +57,10 @@ EXPORT_SYMBOL_GPL(blk_zone_cond_str);
>   */
>  bool blk_req_needs_zone_write_lock(struct request *rq)
>  {
> -	if (!rq->q->seq_zones_wlock)
> +	if (blk_rq_is_passthrough(rq))
>  		return false;
>  
> -	if (blk_rq_is_passthrough(rq))
> +	if (!rq->q->disk->seq_zones_wlock)
>  		return false;
>  
>  	switch (req_op(rq)) {
> @@ -77,7 +77,7 @@ bool blk_req_zone_write_trylock(struct request *rq)
>  {
>  	unsigned int zno = blk_rq_zone_no(rq);
>  
> -	if (test_and_set_bit(zno, rq->q->seq_zones_wlock))
> +	if (test_and_set_bit(zno, rq->q->disk->seq_zones_wlock))
>  		return false;
>  
>  	WARN_ON_ONCE(rq->rq_flags & RQF_ZONE_WRITE_LOCKED);
> @@ -90,7 +90,7 @@ EXPORT_SYMBOL_GPL(blk_req_zone_write_trylock);
>  void __blk_req_zone_write_lock(struct request *rq)
>  {
>  	if (WARN_ON_ONCE(test_and_set_bit(blk_rq_zone_no(rq),
> -					  rq->q->seq_zones_wlock)))
> +					  rq->q->disk->seq_zones_wlock)))
>  		return;
>  
>  	WARN_ON_ONCE(rq->rq_flags & RQF_ZONE_WRITE_LOCKED);
> @@ -101,9 +101,9 @@ EXPORT_SYMBOL_GPL(__blk_req_zone_write_lock);
>  void __blk_req_zone_write_unlock(struct request *rq)
>  {
>  	rq->rq_flags &= ~RQF_ZONE_WRITE_LOCKED;
> -	if (rq->q->seq_zones_wlock)
> +	if (rq->q->disk->seq_zones_wlock)
>  		WARN_ON_ONCE(!test_and_clear_bit(blk_rq_zone_no(rq),
> -						 rq->q->seq_zones_wlock));
> +						 rq->q->disk->seq_zones_wlock));
>  }
>  EXPORT_SYMBOL_GPL(__blk_req_zone_write_unlock);
>  
> @@ -189,7 +189,7 @@ static int blk_zone_need_reset_cb(struct blk_zone *zone, unsigned int idx,
>  int blkdev_zone_mgmt_all(struct block_device *bdev, unsigned int op,
>  			 gfp_t gfp_mask)
>  {
> -	struct request_queue *q = bdev_get_queue(bdev);
> +	struct gendisk *disk = bdev->bd_disk;
>  	sector_t capacity = bdev_nr_sectors(bdev);
>  	sector_t zone_sectors = bdev_zone_sectors(bdev);
>  	unsigned long *need_reset;
> @@ -197,19 +197,18 @@ int blkdev_zone_mgmt_all(struct block_device *bdev, unsigned int op,
>  	sector_t sector = 0;
>  	int ret;
>  
> -	need_reset = blk_alloc_zone_bitmap(q->node, q->nr_zones);
> +	need_reset = blk_alloc_zone_bitmap(disk->queue->node, disk->nr_zones);
>  	if (!need_reset)
>  		return -ENOMEM;
>  
> -	ret = bdev->bd_disk->fops->report_zones(bdev->bd_disk, 0,
> -				q->nr_zones, blk_zone_need_reset_cb,
> -				need_reset);
> +	ret = disk->fops->report_zones(disk, 0, disk->nr_zones,
> +				       blk_zone_need_reset_cb, need_reset);
>  	if (ret < 0)
>  		goto out_free_need_reset;
>  
>  	ret = 0;
>  	while (sector < capacity) {
> -		if (!test_bit(blk_queue_zone_no(q, sector), need_reset)) {
> +		if (!test_bit(disk_zone_no(disk, sector), need_reset)) {
>  			sector += zone_sectors;
>  			continue;
>  		}
> @@ -452,12 +451,10 @@ int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
>  
>  void disk_free_zone_bitmaps(struct gendisk *disk)
>  {
> -	struct request_queue *q = disk->queue;
> -
> -	kfree(q->conv_zones_bitmap);
> -	q->conv_zones_bitmap = NULL;
> -	kfree(q->seq_zones_wlock);
> -	q->seq_zones_wlock = NULL;
> +	kfree(disk->conv_zones_bitmap);
> +	disk->conv_zones_bitmap = NULL;
> +	kfree(disk->seq_zones_wlock);
> +	disk->seq_zones_wlock = NULL;
>  }
>  
>  struct blk_revalidate_zone_args {
> @@ -607,9 +604,9 @@ int blk_revalidate_disk_zones(struct gendisk *disk,
>  	blk_mq_freeze_queue(q);
>  	if (ret > 0) {
>  		blk_queue_chunk_sectors(q, args.zone_sectors);
> -		q->nr_zones = args.nr_zones;
> -		swap(q->seq_zones_wlock, args.seq_zones_wlock);
> -		swap(q->conv_zones_bitmap, args.conv_zones_bitmap);
> +		disk->nr_zones = args.nr_zones;
> +		swap(disk->seq_zones_wlock, args.seq_zones_wlock);
> +		swap(disk->conv_zones_bitmap, args.conv_zones_bitmap);
>  		if (update_driver_data)
>  			update_driver_data(disk);
>  		ret = 0;
> @@ -634,9 +631,9 @@ void disk_clear_zone_settings(struct gendisk *disk)
>  	disk_free_zone_bitmaps(disk);
>  	blk_queue_flag_clear(QUEUE_FLAG_ZONE_RESETALL, q);
>  	q->required_elevator_features &= ~ELEVATOR_F_ZBD_SEQ_WRITE;
> -	q->nr_zones = 0;
> -	q->max_open_zones = 0;
> -	q->max_active_zones = 0;
> +	disk->nr_zones = 0;
> +	disk->max_open_zones = 0;
> +	disk->max_active_zones = 0;
>  	q->limits.chunk_sectors = 0;
>  	q->limits.zone_write_granularity = 0;
>  	q->limits.max_zone_append_sectors = 0;
> diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c
> index e62c52e964259..64b06caab9843 100644
> --- a/drivers/block/null_blk/zoned.c
> +++ b/drivers/block/null_blk/zoned.c
> @@ -170,7 +170,7 @@ int null_register_zoned_dev(struct nullb *nullb)
>  			return ret;
>  	} else {
>  		blk_queue_chunk_sectors(q, dev->zone_size_sects);
> -		q->nr_zones = bdev_nr_zones(nullb->disk->part0);
> +		nullb->disk->nr_zones = bdev_nr_zones(nullb->disk->part0);
>  	}
>  
>  	blk_queue_max_zone_append_sectors(q, dev->zone_size_sects);
> diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c
> index 842c31019b513..2b89cde30c9e9 100644
> --- a/drivers/md/dm-zone.c
> +++ b/drivers/md/dm-zone.c
> @@ -139,13 +139,11 @@ bool dm_is_zone_write(struct mapped_device *md, struct bio *bio)
>  
>  void dm_cleanup_zoned_dev(struct mapped_device *md)
>  {
> -	struct request_queue *q = md->queue;
> -
> -	if (q) {
> -		kfree(q->conv_zones_bitmap);
> -		q->conv_zones_bitmap = NULL;
> -		kfree(q->seq_zones_wlock);
> -		q->seq_zones_wlock = NULL;
> +	if (md->disk) {
> +		kfree(md->disk->conv_zones_bitmap);
> +		md->disk->conv_zones_bitmap = NULL;
> +		kfree(md->disk->seq_zones_wlock);
> +		md->disk->seq_zones_wlock = NULL;
>  	}
>  
>  	kvfree(md->zwp_offset);
> @@ -179,31 +177,31 @@ static int dm_zone_revalidate_cb(struct blk_zone *zone, unsigned int idx,
>  				 void *data)
>  {
>  	struct mapped_device *md = data;
> -	struct request_queue *q = md->queue;
> +	struct gendisk *disk = md->disk;
>  
>  	switch (zone->type) {
>  	case BLK_ZONE_TYPE_CONVENTIONAL:
> -		if (!q->conv_zones_bitmap) {
> -			q->conv_zones_bitmap =
> -				kcalloc(BITS_TO_LONGS(q->nr_zones),
> +		if (!disk->conv_zones_bitmap) {
> +			disk->conv_zones_bitmap =
> +				kcalloc(BITS_TO_LONGS(disk->nr_zones),
>  					sizeof(unsigned long), GFP_NOIO);
> -			if (!q->conv_zones_bitmap)
> +			if (!disk->conv_zones_bitmap)
>  				return -ENOMEM;
>  		}
> -		set_bit(idx, q->conv_zones_bitmap);
> +		set_bit(idx, disk->conv_zones_bitmap);
>  		break;
>  	case BLK_ZONE_TYPE_SEQWRITE_REQ:
>  	case BLK_ZONE_TYPE_SEQWRITE_PREF:
> -		if (!q->seq_zones_wlock) {
> -			q->seq_zones_wlock =
> -				kcalloc(BITS_TO_LONGS(q->nr_zones),
> +		if (!disk->seq_zones_wlock) {
> +			disk->seq_zones_wlock =
> +				kcalloc(BITS_TO_LONGS(disk->nr_zones),
>  					sizeof(unsigned long), GFP_NOIO);
> -			if (!q->seq_zones_wlock)
> +			if (!disk->seq_zones_wlock)
>  				return -ENOMEM;
>  		}
>  		if (!md->zwp_offset) {
>  			md->zwp_offset =
> -				kvcalloc(q->nr_zones, sizeof(unsigned int),
> +				kvcalloc(disk->nr_zones, sizeof(unsigned int),
>  					 GFP_KERNEL);
>  			if (!md->zwp_offset)
>  				return -ENOMEM;
> @@ -228,7 +226,7 @@ static int dm_zone_revalidate_cb(struct blk_zone *zone, unsigned int idx,
>   */
>  static int dm_revalidate_zones(struct mapped_device *md, struct dm_table *t)
>  {
> -	struct request_queue *q = md->queue;
> +	struct gendisk *disk = md->disk;
>  	unsigned int noio_flag;
>  	int ret;
>  
> @@ -236,7 +234,7 @@ static int dm_revalidate_zones(struct mapped_device *md, struct dm_table *t)
>  	 * Check if something changed. If yes, cleanup the current resources
>  	 * and reallocate everything.
>  	 */
> -	if (!q->nr_zones || q->nr_zones != md->nr_zones)
> +	if (!disk->nr_zones || disk->nr_zones != md->nr_zones)
>  		dm_cleanup_zoned_dev(md);
>  	if (md->nr_zones)
>  		return 0;
> @@ -246,17 +244,17 @@ static int dm_revalidate_zones(struct mapped_device *md, struct dm_table *t)
>  	 * operations in this context are done as if GFP_NOIO was specified.
>  	 */
>  	noio_flag = memalloc_noio_save();
> -	ret = dm_blk_do_report_zones(md, t, 0, q->nr_zones,
> +	ret = dm_blk_do_report_zones(md, t, 0, disk->nr_zones,
>  				     dm_zone_revalidate_cb, md);
>  	memalloc_noio_restore(noio_flag);
>  	if (ret < 0)
>  		goto err;
> -	if (ret != q->nr_zones) {
> +	if (ret != disk->nr_zones) {
>  		ret = -EIO;
>  		goto err;
>  	}
>  
> -	md->nr_zones = q->nr_zones;
> +	md->nr_zones = disk->nr_zones;
>  
>  	return 0;
>  
> @@ -301,7 +299,7 @@ int dm_set_zones_restrictions(struct dm_table *t, struct request_queue *q)
>  	 * correct value to be exposed in sysfs queue/nr_zones.
>  	 */
>  	WARN_ON_ONCE(queue_is_mq(q));
> -	q->nr_zones = bdev_nr_zones(md->disk->part0);
> +	md->disk->nr_zones = bdev_nr_zones(md->disk->part0);
>  
>  	/* Check if zone append is natively supported */
>  	if (dm_table_supports_zone_append(t)) {
> @@ -466,26 +464,26 @@ static blk_status_t dm_zone_map_bio_end(struct mapped_device *md, unsigned int z
>  	}
>  }
>  
> -static inline void dm_zone_lock(struct request_queue *q,
> -				unsigned int zno, struct bio *clone)
> +static inline void dm_zone_lock(struct gendisk *disk, unsigned int zno,
> +				struct bio *clone)
>  {
>  	if (WARN_ON_ONCE(bio_flagged(clone, BIO_ZONE_WRITE_LOCKED)))
>  		return;
>  
> -	wait_on_bit_lock_io(q->seq_zones_wlock, zno, TASK_UNINTERRUPTIBLE);
> +	wait_on_bit_lock_io(disk->seq_zones_wlock, zno, TASK_UNINTERRUPTIBLE);
>  	bio_set_flag(clone, BIO_ZONE_WRITE_LOCKED);
>  }
>  
> -static inline void dm_zone_unlock(struct request_queue *q,
> -				  unsigned int zno, struct bio *clone)
> +static inline void dm_zone_unlock(struct gendisk *disk, unsigned int zno,
> +				  struct bio *clone)
>  {
>  	if (!bio_flagged(clone, BIO_ZONE_WRITE_LOCKED))
>  		return;
>  
> -	WARN_ON_ONCE(!test_bit(zno, q->seq_zones_wlock));
> -	clear_bit_unlock(zno, q->seq_zones_wlock);
> +	WARN_ON_ONCE(!test_bit(zno, disk->seq_zones_wlock));
> +	clear_bit_unlock(zno, disk->seq_zones_wlock);
>  	smp_mb__after_atomic();
> -	wake_up_bit(q->seq_zones_wlock, zno);
> +	wake_up_bit(disk->seq_zones_wlock, zno);
>  
>  	bio_clear_flag(clone, BIO_ZONE_WRITE_LOCKED);
>  }
> @@ -520,7 +518,6 @@ int dm_zone_map_bio(struct dm_target_io *tio)
>  	struct dm_io *io = tio->io;
>  	struct dm_target *ti = tio->ti;
>  	struct mapped_device *md = io->md;
> -	struct request_queue *q = md->queue;
>  	struct bio *clone = &tio->clone;
>  	struct orig_bio_details orig_bio_details;
>  	unsigned int zno;
> @@ -536,7 +533,7 @@ int dm_zone_map_bio(struct dm_target_io *tio)
>  
>  	/* Lock the target zone */
>  	zno = bio_zone_no(clone);
> -	dm_zone_lock(q, zno, clone);
> +	dm_zone_lock(md->disk, zno, clone);
>  
>  	orig_bio_details.nr_sectors = bio_sectors(clone);
>  	orig_bio_details.op = bio_op(clone);
> @@ -546,7 +543,7 @@ int dm_zone_map_bio(struct dm_target_io *tio)
>  	 * both valid, and if the bio is a zone append, remap it to a write.
>  	 */
>  	if (!dm_zone_map_bio_begin(md, zno, clone)) {
> -		dm_zone_unlock(q, zno, clone);
> +		dm_zone_unlock(md->disk, zno, clone);
>  		return DM_MAPIO_KILL;
>  	}
>  
> @@ -570,12 +567,12 @@ int dm_zone_map_bio(struct dm_target_io *tio)
>  		sts = dm_zone_map_bio_end(md, zno, &orig_bio_details,
>  					  *tio->len_ptr);
>  		if (sts != BLK_STS_OK)
> -			dm_zone_unlock(q, zno, clone);
> +			dm_zone_unlock(md->disk, zno, clone);
>  		break;
>  	case DM_MAPIO_REQUEUE:
>  	case DM_MAPIO_KILL:
>  	default:
> -		dm_zone_unlock(q, zno, clone);
> +		dm_zone_unlock(md->disk, zno, clone);
>  		sts = BLK_STS_IOERR;
>  		break;
>  	}
> @@ -592,7 +589,6 @@ int dm_zone_map_bio(struct dm_target_io *tio)
>  void dm_zone_endio(struct dm_io *io, struct bio *clone)
>  {
>  	struct mapped_device *md = io->md;
> -	struct request_queue *q = md->queue;
>  	struct gendisk *disk = md->disk;
>  	struct bio *orig_bio = io->orig_bio;
>  	unsigned int zwp_offset;
> @@ -651,5 +647,5 @@ void dm_zone_endio(struct dm_io *io, struct bio *clone)
>  				zwp_offset - bio_sectors(orig_bio);
>  	}
>  
> -	dm_zone_unlock(q, zno, clone);
> +	dm_zone_unlock(disk, zno, clone);
>  }
> diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
> index ccf9a6da8f6e1..f26640ccb9555 100644
> --- a/drivers/nvme/host/multipath.c
> +++ b/drivers/nvme/host/multipath.c
> @@ -830,7 +830,7 @@ void nvme_mpath_add_disk(struct nvme_ns *ns, struct nvme_id_ns *id)
>  				   ns->head->disk->queue);
>  #ifdef CONFIG_BLK_DEV_ZONED
>  	if (blk_queue_is_zoned(ns->queue) && ns->head->disk)
> -		ns->head->disk->queue->nr_zones = ns->queue->nr_zones;
> +		ns->head->disk->nr_zones = ns->disk->nr_zones;
>  #endif
>  }
>  
> diff --git a/drivers/nvme/target/zns.c b/drivers/nvme/target/zns.c
> index c9b2ce06ca93e..385f2fe2792ff 100644
> --- a/drivers/nvme/target/zns.c
> +++ b/drivers/nvme/target/zns.c
> @@ -57,7 +57,7 @@ bool nvmet_bdev_zns_enable(struct nvmet_ns *ns)
>  	 * zones, reject the device. Otherwise, use report zones to detect if
>  	 * the device has conventional zones.
>  	 */
> -	if (ns->bdev->bd_disk->queue->conv_zones_bitmap)
> +	if (ns->bdev->bd_disk->conv_zones_bitmap)
>  		return false;
>  
>  	ret = blkdev_report_zones(ns->bdev, 0, bdev_nr_zones(ns->bdev),
> diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
> index b4106f8997342..b8c97456506ac 100644
> --- a/drivers/scsi/sd_zbc.c
> +++ b/drivers/scsi/sd_zbc.c
> @@ -855,7 +855,7 @@ int sd_zbc_revalidate_zones(struct scsi_disk *sdkp)
>  
>  	if (sdkp->zone_info.zone_blocks == zone_blocks &&
>  	    sdkp->zone_info.nr_zones == nr_zones &&
> -	    disk->queue->nr_zones == nr_zones)
> +	    disk->nr_zones == nr_zones)
>  		goto unlock;
>  
>  	flags = memalloc_noio_save();
> diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
> index 43aad0da3305d..1b0b753609975 100644
> --- a/include/linux/blk-mq.h
> +++ b/include/linux/blk-mq.h
> @@ -1123,12 +1123,12 @@ void blk_dump_rq_flags(struct request *, char *);
>  #ifdef CONFIG_BLK_DEV_ZONED
>  static inline unsigned int blk_rq_zone_no(struct request *rq)
>  {
> -	return blk_queue_zone_no(rq->q, blk_rq_pos(rq));
> +	return disk_zone_no(rq->q->disk, blk_rq_pos(rq));
>  }
>  
>  static inline unsigned int blk_rq_zone_is_seq(struct request *rq)
>  {
> -	return blk_queue_zone_is_seq(rq->q, blk_rq_pos(rq));
> +	return disk_zone_is_seq(rq->q->disk, blk_rq_pos(rq));
>  }
>  
>  bool blk_req_needs_zone_write_lock(struct request *rq);
> @@ -1150,8 +1150,8 @@ static inline void blk_req_zone_write_unlock(struct request *rq)
>  
>  static inline bool blk_req_zone_is_write_locked(struct request *rq)
>  {
> -	return rq->q->seq_zones_wlock &&
> -		test_bit(blk_rq_zone_no(rq), rq->q->seq_zones_wlock);
> +	return rq->q->disk->seq_zones_wlock &&
> +		test_bit(blk_rq_zone_no(rq), rq->q->disk->seq_zones_wlock);
>  }
>  
>  static inline bool blk_req_can_dispatch_to_zone(struct request *rq)
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index f1eca3f5610eb..547eb07848741 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -164,6 +164,29 @@ struct gendisk {
>  #ifdef  CONFIG_BLK_DEV_INTEGRITY
>  	struct kobject integrity_kobj;
>  #endif	/* CONFIG_BLK_DEV_INTEGRITY */
> +
> +#ifdef CONFIG_BLK_DEV_ZONED
> +	/*
> +	 * Zoned block device information for request dispatch control.
> +	 * nr_zones is the total number of zones of the device. This is always
> +	 * 0 for regular block devices. conv_zones_bitmap is a bitmap of nr_zones
> +	 * bits which indicates if a zone is conventional (bit set) or
> +	 * sequential (bit clear). seq_zones_wlock is a bitmap of nr_zones
> +	 * bits which indicates if a zone is write locked, that is, if a write
> +	 * request targeting the zone was dispatched.
> +	 *
> +	 * Reads of this information must be protected with blk_queue_enter() /
> +	 * blk_queue_exit(). Modifying this information is only allowed while
> +	 * no requests are being processed. See also blk_mq_freeze_queue() and
> +	 * blk_mq_unfreeze_queue().
> +	 */
> +	unsigned int		nr_zones;
> +	unsigned int		max_open_zones;
> +	unsigned int		max_active_zones;
> +	unsigned long		*conv_zones_bitmap;
> +	unsigned long		*seq_zones_wlock;
> +#endif /* CONFIG_BLK_DEV_ZONED */
> +
>  #if IS_ENABLED(CONFIG_CDROM)
>  	struct cdrom_device_info *cdi;
>  #endif
> @@ -469,31 +492,6 @@ struct request_queue {
>  
>  	unsigned int		required_elevator_features;
>  
> -#ifdef CONFIG_BLK_DEV_ZONED
> -	/*
> -	 * Zoned block device information for request dispatch control.
> -	 * nr_zones is the total number of zones of the device. This is always
> -	 * 0 for regular block devices. conv_zones_bitmap is a bitmap of nr_zones
> -	 * bits which indicates if a zone is conventional (bit set) or
> -	 * sequential (bit clear). seq_zones_wlock is a bitmap of nr_zones
> -	 * bits which indicates if a zone is write locked, that is, if a write
> -	 * request targeting the zone was dispatched. All three fields are
> -	 * initialized by the low level device driver (e.g. scsi/sd.c).
> -	 * Stacking drivers (device mappers) may or may not initialize
> -	 * these fields.
> -	 *
> -	 * Reads of this information must be protected with blk_queue_enter() /
> -	 * blk_queue_exit(). Modifying this information is only allowed while
> -	 * no requests are being processed. See also blk_mq_freeze_queue() and
> -	 * blk_mq_unfreeze_queue().
> -	 */
> -	unsigned int		nr_zones;
> -	unsigned long		*conv_zones_bitmap;
> -	unsigned long		*seq_zones_wlock;
> -	unsigned int		max_open_zones;
> -	unsigned int		max_active_zones;
> -#endif /* CONFIG_BLK_DEV_ZONED */
> -
>  	int			node;
>  #ifdef CONFIG_BLK_DEV_IO_TRACE
>  	struct blk_trace __rcu	*blk_trace;
> @@ -670,63 +668,59 @@ static inline bool blk_queue_is_zoned(struct request_queue *q)
>  }
>  
>  #ifdef CONFIG_BLK_DEV_ZONED
> -static inline unsigned int blk_queue_nr_zones(struct request_queue *q)
> +static inline unsigned int disk_nr_zones(struct gendisk *disk)
>  {
> -	return blk_queue_is_zoned(q) ? q->nr_zones : 0;
> +	return blk_queue_is_zoned(disk->queue) ? disk->nr_zones : 0;
>  }
>  
> -static inline unsigned int blk_queue_zone_no(struct request_queue *q,
> -					     sector_t sector)
> +static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector)
>  {
> -	if (!blk_queue_is_zoned(q))
> +	if (!blk_queue_is_zoned(disk->queue))
>  		return 0;
> -	return sector >> ilog2(q->limits.chunk_sectors);
> +	return sector >> ilog2(disk->queue->limits.chunk_sectors);
>  }
>  
> -static inline bool blk_queue_zone_is_seq(struct request_queue *q,
> -					 sector_t sector)
> +static inline bool disk_zone_is_seq(struct gendisk *disk, sector_t sector)
>  {
> -	if (!blk_queue_is_zoned(q))
> +	if (!blk_queue_is_zoned(disk->queue))
>  		return false;
> -	if (!q->conv_zones_bitmap)
> +	if (!disk->conv_zones_bitmap)
>  		return true;
> -	return !test_bit(blk_queue_zone_no(q, sector), q->conv_zones_bitmap);
> +	return !test_bit(disk_zone_no(disk, sector), disk->conv_zones_bitmap);
>  }
>  
>  static inline void disk_set_max_open_zones(struct gendisk *disk,
>  		unsigned int max_open_zones)
>  {
> -	disk->queue->max_open_zones = max_open_zones;
> +	disk->max_open_zones = max_open_zones;
>  }
>  
>  static inline void disk_set_max_active_zones(struct gendisk *disk,
>  		unsigned int max_active_zones)
>  {
> -	disk->queue->max_active_zones = max_active_zones;
> +	disk->max_active_zones = max_active_zones;
>  }
>  
>  static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
>  {
> -	return bdev->bd_disk->queue->max_open_zones;
> +	return bdev->bd_disk->max_open_zones;
>  }
>  
>  static inline unsigned int bdev_max_active_zones(struct block_device *bdev)
>  {
> -	return bdev->bd_disk->queue->max_active_zones;
> +	return bdev->bd_disk->max_active_zones;
>  }
>  
>  #else /* CONFIG_BLK_DEV_ZONED */
> -static inline unsigned int blk_queue_nr_zones(struct request_queue *q)
> +static inline unsigned int disk_nr_zones(struct gendisk *disk)
>  {
>  	return 0;
>  }
> -static inline bool blk_queue_zone_is_seq(struct request_queue *q,
> -					 sector_t sector)
> +static inline bool disk_zone_is_seq(struct gendisk *disk, sector_t sector)
>  {
>  	return false;
>  }
> -static inline unsigned int blk_queue_zone_no(struct request_queue *q,
> -					     sector_t sector)
> +static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector)
>  {
>  	return 0;
>  }
> @@ -734,6 +728,7 @@ static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
>  {
>  	return 0;
>  }
> +
>  static inline unsigned int bdev_max_active_zones(struct block_device *bdev)
>  {
>  	return 0;
> @@ -902,14 +897,12 @@ const char *blk_zone_cond_str(enum blk_zone_cond zone_cond);
>  
>  static inline unsigned int bio_zone_no(struct bio *bio)
>  {
> -	return blk_queue_zone_no(bdev_get_queue(bio->bi_bdev),
> -				 bio->bi_iter.bi_sector);
> +	return disk_zone_no(bio->bi_bdev->bd_disk, bio->bi_iter.bi_sector);
>  }
>  
>  static inline unsigned int bio_zone_is_seq(struct bio *bio)
>  {
> -	return blk_queue_zone_is_seq(bdev_get_queue(bio->bi_bdev),
> -				     bio->bi_iter.bi_sector);
> +	return disk_zone_is_seq(bio->bi_bdev->bd_disk, bio->bi_iter.bi_sector);
>  }
>  
>  /*


-- 
Damien Le Moal
Western Digital Research

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

* Re: [dm-devel] [PATCH 17/17] block: move zone related fields to struct gendisk
@ 2022-07-05  2:59     ` Damien Le Moal
  0 siblings, 0 replies; 140+ messages in thread
From: Damien Le Moal @ 2022-07-05  2:59 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

On 7/4/22 21:45, Christoph Hellwig wrote:
> Move the zone related fields that are currently stored in
> struct request_queue to struct gendisk as these are part of the highlevel
> block layer API and are only used for non-passthrough I/O that requires
> the gendisk.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

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

> ---
>  block/blk-mq-debugfs-zoned.c   |  6 +--
>  block/blk-sysfs.c              |  2 +-
>  block/blk-zoned.c              | 45 ++++++++---------
>  drivers/block/null_blk/zoned.c |  2 +-
>  drivers/md/dm-zone.c           | 74 +++++++++++++--------------
>  drivers/nvme/host/multipath.c  |  2 +-
>  drivers/nvme/target/zns.c      |  2 +-
>  drivers/scsi/sd_zbc.c          |  2 +-
>  include/linux/blk-mq.h         |  8 +--
>  include/linux/blkdev.h         | 91 ++++++++++++++++------------------
>  10 files changed, 110 insertions(+), 124 deletions(-)
> 
> diff --git a/block/blk-mq-debugfs-zoned.c b/block/blk-mq-debugfs-zoned.c
> index 038cb627c8689..a77b099c34b7a 100644
> --- a/block/blk-mq-debugfs-zoned.c
> +++ b/block/blk-mq-debugfs-zoned.c
> @@ -11,11 +11,11 @@ int queue_zone_wlock_show(void *data, struct seq_file *m)
>  	struct request_queue *q = data;
>  	unsigned int i;
>  
> -	if (!q->seq_zones_wlock)
> +	if (!q->disk->seq_zones_wlock)
>  		return 0;
>  
> -	for (i = 0; i < q->nr_zones; i++)
> -		if (test_bit(i, q->seq_zones_wlock))
> +	for (i = 0; i < q->disk->nr_zones; i++)
> +		if (test_bit(i, q->disk->seq_zones_wlock))
>  			seq_printf(m, "%u\n", i);
>  
>  	return 0;
> diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
> index 5ce72345ac666..c0303026752d5 100644
> --- a/block/blk-sysfs.c
> +++ b/block/blk-sysfs.c
> @@ -325,7 +325,7 @@ static ssize_t queue_zoned_show(struct request_queue *q, char *page)
>  
>  static ssize_t queue_nr_zones_show(struct request_queue *q, char *page)
>  {
> -	return queue_var_show(blk_queue_nr_zones(q), page);
> +	return queue_var_show(disk_nr_zones(q->disk), page);
>  }
>  
>  static ssize_t queue_max_open_zones_show(struct request_queue *q, char *page)
> diff --git a/block/blk-zoned.c b/block/blk-zoned.c
> index ee8752f083a94..4826083ce9a48 100644
> --- a/block/blk-zoned.c
> +++ b/block/blk-zoned.c
> @@ -57,10 +57,10 @@ EXPORT_SYMBOL_GPL(blk_zone_cond_str);
>   */
>  bool blk_req_needs_zone_write_lock(struct request *rq)
>  {
> -	if (!rq->q->seq_zones_wlock)
> +	if (blk_rq_is_passthrough(rq))
>  		return false;
>  
> -	if (blk_rq_is_passthrough(rq))
> +	if (!rq->q->disk->seq_zones_wlock)
>  		return false;
>  
>  	switch (req_op(rq)) {
> @@ -77,7 +77,7 @@ bool blk_req_zone_write_trylock(struct request *rq)
>  {
>  	unsigned int zno = blk_rq_zone_no(rq);
>  
> -	if (test_and_set_bit(zno, rq->q->seq_zones_wlock))
> +	if (test_and_set_bit(zno, rq->q->disk->seq_zones_wlock))
>  		return false;
>  
>  	WARN_ON_ONCE(rq->rq_flags & RQF_ZONE_WRITE_LOCKED);
> @@ -90,7 +90,7 @@ EXPORT_SYMBOL_GPL(blk_req_zone_write_trylock);
>  void __blk_req_zone_write_lock(struct request *rq)
>  {
>  	if (WARN_ON_ONCE(test_and_set_bit(blk_rq_zone_no(rq),
> -					  rq->q->seq_zones_wlock)))
> +					  rq->q->disk->seq_zones_wlock)))
>  		return;
>  
>  	WARN_ON_ONCE(rq->rq_flags & RQF_ZONE_WRITE_LOCKED);
> @@ -101,9 +101,9 @@ EXPORT_SYMBOL_GPL(__blk_req_zone_write_lock);
>  void __blk_req_zone_write_unlock(struct request *rq)
>  {
>  	rq->rq_flags &= ~RQF_ZONE_WRITE_LOCKED;
> -	if (rq->q->seq_zones_wlock)
> +	if (rq->q->disk->seq_zones_wlock)
>  		WARN_ON_ONCE(!test_and_clear_bit(blk_rq_zone_no(rq),
> -						 rq->q->seq_zones_wlock));
> +						 rq->q->disk->seq_zones_wlock));
>  }
>  EXPORT_SYMBOL_GPL(__blk_req_zone_write_unlock);
>  
> @@ -189,7 +189,7 @@ static int blk_zone_need_reset_cb(struct blk_zone *zone, unsigned int idx,
>  int blkdev_zone_mgmt_all(struct block_device *bdev, unsigned int op,
>  			 gfp_t gfp_mask)
>  {
> -	struct request_queue *q = bdev_get_queue(bdev);
> +	struct gendisk *disk = bdev->bd_disk;
>  	sector_t capacity = bdev_nr_sectors(bdev);
>  	sector_t zone_sectors = bdev_zone_sectors(bdev);
>  	unsigned long *need_reset;
> @@ -197,19 +197,18 @@ int blkdev_zone_mgmt_all(struct block_device *bdev, unsigned int op,
>  	sector_t sector = 0;
>  	int ret;
>  
> -	need_reset = blk_alloc_zone_bitmap(q->node, q->nr_zones);
> +	need_reset = blk_alloc_zone_bitmap(disk->queue->node, disk->nr_zones);
>  	if (!need_reset)
>  		return -ENOMEM;
>  
> -	ret = bdev->bd_disk->fops->report_zones(bdev->bd_disk, 0,
> -				q->nr_zones, blk_zone_need_reset_cb,
> -				need_reset);
> +	ret = disk->fops->report_zones(disk, 0, disk->nr_zones,
> +				       blk_zone_need_reset_cb, need_reset);
>  	if (ret < 0)
>  		goto out_free_need_reset;
>  
>  	ret = 0;
>  	while (sector < capacity) {
> -		if (!test_bit(blk_queue_zone_no(q, sector), need_reset)) {
> +		if (!test_bit(disk_zone_no(disk, sector), need_reset)) {
>  			sector += zone_sectors;
>  			continue;
>  		}
> @@ -452,12 +451,10 @@ int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
>  
>  void disk_free_zone_bitmaps(struct gendisk *disk)
>  {
> -	struct request_queue *q = disk->queue;
> -
> -	kfree(q->conv_zones_bitmap);
> -	q->conv_zones_bitmap = NULL;
> -	kfree(q->seq_zones_wlock);
> -	q->seq_zones_wlock = NULL;
> +	kfree(disk->conv_zones_bitmap);
> +	disk->conv_zones_bitmap = NULL;
> +	kfree(disk->seq_zones_wlock);
> +	disk->seq_zones_wlock = NULL;
>  }
>  
>  struct blk_revalidate_zone_args {
> @@ -607,9 +604,9 @@ int blk_revalidate_disk_zones(struct gendisk *disk,
>  	blk_mq_freeze_queue(q);
>  	if (ret > 0) {
>  		blk_queue_chunk_sectors(q, args.zone_sectors);
> -		q->nr_zones = args.nr_zones;
> -		swap(q->seq_zones_wlock, args.seq_zones_wlock);
> -		swap(q->conv_zones_bitmap, args.conv_zones_bitmap);
> +		disk->nr_zones = args.nr_zones;
> +		swap(disk->seq_zones_wlock, args.seq_zones_wlock);
> +		swap(disk->conv_zones_bitmap, args.conv_zones_bitmap);
>  		if (update_driver_data)
>  			update_driver_data(disk);
>  		ret = 0;
> @@ -634,9 +631,9 @@ void disk_clear_zone_settings(struct gendisk *disk)
>  	disk_free_zone_bitmaps(disk);
>  	blk_queue_flag_clear(QUEUE_FLAG_ZONE_RESETALL, q);
>  	q->required_elevator_features &= ~ELEVATOR_F_ZBD_SEQ_WRITE;
> -	q->nr_zones = 0;
> -	q->max_open_zones = 0;
> -	q->max_active_zones = 0;
> +	disk->nr_zones = 0;
> +	disk->max_open_zones = 0;
> +	disk->max_active_zones = 0;
>  	q->limits.chunk_sectors = 0;
>  	q->limits.zone_write_granularity = 0;
>  	q->limits.max_zone_append_sectors = 0;
> diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c
> index e62c52e964259..64b06caab9843 100644
> --- a/drivers/block/null_blk/zoned.c
> +++ b/drivers/block/null_blk/zoned.c
> @@ -170,7 +170,7 @@ int null_register_zoned_dev(struct nullb *nullb)
>  			return ret;
>  	} else {
>  		blk_queue_chunk_sectors(q, dev->zone_size_sects);
> -		q->nr_zones = bdev_nr_zones(nullb->disk->part0);
> +		nullb->disk->nr_zones = bdev_nr_zones(nullb->disk->part0);
>  	}
>  
>  	blk_queue_max_zone_append_sectors(q, dev->zone_size_sects);
> diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c
> index 842c31019b513..2b89cde30c9e9 100644
> --- a/drivers/md/dm-zone.c
> +++ b/drivers/md/dm-zone.c
> @@ -139,13 +139,11 @@ bool dm_is_zone_write(struct mapped_device *md, struct bio *bio)
>  
>  void dm_cleanup_zoned_dev(struct mapped_device *md)
>  {
> -	struct request_queue *q = md->queue;
> -
> -	if (q) {
> -		kfree(q->conv_zones_bitmap);
> -		q->conv_zones_bitmap = NULL;
> -		kfree(q->seq_zones_wlock);
> -		q->seq_zones_wlock = NULL;
> +	if (md->disk) {
> +		kfree(md->disk->conv_zones_bitmap);
> +		md->disk->conv_zones_bitmap = NULL;
> +		kfree(md->disk->seq_zones_wlock);
> +		md->disk->seq_zones_wlock = NULL;
>  	}
>  
>  	kvfree(md->zwp_offset);
> @@ -179,31 +177,31 @@ static int dm_zone_revalidate_cb(struct blk_zone *zone, unsigned int idx,
>  				 void *data)
>  {
>  	struct mapped_device *md = data;
> -	struct request_queue *q = md->queue;
> +	struct gendisk *disk = md->disk;
>  
>  	switch (zone->type) {
>  	case BLK_ZONE_TYPE_CONVENTIONAL:
> -		if (!q->conv_zones_bitmap) {
> -			q->conv_zones_bitmap =
> -				kcalloc(BITS_TO_LONGS(q->nr_zones),
> +		if (!disk->conv_zones_bitmap) {
> +			disk->conv_zones_bitmap =
> +				kcalloc(BITS_TO_LONGS(disk->nr_zones),
>  					sizeof(unsigned long), GFP_NOIO);
> -			if (!q->conv_zones_bitmap)
> +			if (!disk->conv_zones_bitmap)
>  				return -ENOMEM;
>  		}
> -		set_bit(idx, q->conv_zones_bitmap);
> +		set_bit(idx, disk->conv_zones_bitmap);
>  		break;
>  	case BLK_ZONE_TYPE_SEQWRITE_REQ:
>  	case BLK_ZONE_TYPE_SEQWRITE_PREF:
> -		if (!q->seq_zones_wlock) {
> -			q->seq_zones_wlock =
> -				kcalloc(BITS_TO_LONGS(q->nr_zones),
> +		if (!disk->seq_zones_wlock) {
> +			disk->seq_zones_wlock =
> +				kcalloc(BITS_TO_LONGS(disk->nr_zones),
>  					sizeof(unsigned long), GFP_NOIO);
> -			if (!q->seq_zones_wlock)
> +			if (!disk->seq_zones_wlock)
>  				return -ENOMEM;
>  		}
>  		if (!md->zwp_offset) {
>  			md->zwp_offset =
> -				kvcalloc(q->nr_zones, sizeof(unsigned int),
> +				kvcalloc(disk->nr_zones, sizeof(unsigned int),
>  					 GFP_KERNEL);
>  			if (!md->zwp_offset)
>  				return -ENOMEM;
> @@ -228,7 +226,7 @@ static int dm_zone_revalidate_cb(struct blk_zone *zone, unsigned int idx,
>   */
>  static int dm_revalidate_zones(struct mapped_device *md, struct dm_table *t)
>  {
> -	struct request_queue *q = md->queue;
> +	struct gendisk *disk = md->disk;
>  	unsigned int noio_flag;
>  	int ret;
>  
> @@ -236,7 +234,7 @@ static int dm_revalidate_zones(struct mapped_device *md, struct dm_table *t)
>  	 * Check if something changed. If yes, cleanup the current resources
>  	 * and reallocate everything.
>  	 */
> -	if (!q->nr_zones || q->nr_zones != md->nr_zones)
> +	if (!disk->nr_zones || disk->nr_zones != md->nr_zones)
>  		dm_cleanup_zoned_dev(md);
>  	if (md->nr_zones)
>  		return 0;
> @@ -246,17 +244,17 @@ static int dm_revalidate_zones(struct mapped_device *md, struct dm_table *t)
>  	 * operations in this context are done as if GFP_NOIO was specified.
>  	 */
>  	noio_flag = memalloc_noio_save();
> -	ret = dm_blk_do_report_zones(md, t, 0, q->nr_zones,
> +	ret = dm_blk_do_report_zones(md, t, 0, disk->nr_zones,
>  				     dm_zone_revalidate_cb, md);
>  	memalloc_noio_restore(noio_flag);
>  	if (ret < 0)
>  		goto err;
> -	if (ret != q->nr_zones) {
> +	if (ret != disk->nr_zones) {
>  		ret = -EIO;
>  		goto err;
>  	}
>  
> -	md->nr_zones = q->nr_zones;
> +	md->nr_zones = disk->nr_zones;
>  
>  	return 0;
>  
> @@ -301,7 +299,7 @@ int dm_set_zones_restrictions(struct dm_table *t, struct request_queue *q)
>  	 * correct value to be exposed in sysfs queue/nr_zones.
>  	 */
>  	WARN_ON_ONCE(queue_is_mq(q));
> -	q->nr_zones = bdev_nr_zones(md->disk->part0);
> +	md->disk->nr_zones = bdev_nr_zones(md->disk->part0);
>  
>  	/* Check if zone append is natively supported */
>  	if (dm_table_supports_zone_append(t)) {
> @@ -466,26 +464,26 @@ static blk_status_t dm_zone_map_bio_end(struct mapped_device *md, unsigned int z
>  	}
>  }
>  
> -static inline void dm_zone_lock(struct request_queue *q,
> -				unsigned int zno, struct bio *clone)
> +static inline void dm_zone_lock(struct gendisk *disk, unsigned int zno,
> +				struct bio *clone)
>  {
>  	if (WARN_ON_ONCE(bio_flagged(clone, BIO_ZONE_WRITE_LOCKED)))
>  		return;
>  
> -	wait_on_bit_lock_io(q->seq_zones_wlock, zno, TASK_UNINTERRUPTIBLE);
> +	wait_on_bit_lock_io(disk->seq_zones_wlock, zno, TASK_UNINTERRUPTIBLE);
>  	bio_set_flag(clone, BIO_ZONE_WRITE_LOCKED);
>  }
>  
> -static inline void dm_zone_unlock(struct request_queue *q,
> -				  unsigned int zno, struct bio *clone)
> +static inline void dm_zone_unlock(struct gendisk *disk, unsigned int zno,
> +				  struct bio *clone)
>  {
>  	if (!bio_flagged(clone, BIO_ZONE_WRITE_LOCKED))
>  		return;
>  
> -	WARN_ON_ONCE(!test_bit(zno, q->seq_zones_wlock));
> -	clear_bit_unlock(zno, q->seq_zones_wlock);
> +	WARN_ON_ONCE(!test_bit(zno, disk->seq_zones_wlock));
> +	clear_bit_unlock(zno, disk->seq_zones_wlock);
>  	smp_mb__after_atomic();
> -	wake_up_bit(q->seq_zones_wlock, zno);
> +	wake_up_bit(disk->seq_zones_wlock, zno);
>  
>  	bio_clear_flag(clone, BIO_ZONE_WRITE_LOCKED);
>  }
> @@ -520,7 +518,6 @@ int dm_zone_map_bio(struct dm_target_io *tio)
>  	struct dm_io *io = tio->io;
>  	struct dm_target *ti = tio->ti;
>  	struct mapped_device *md = io->md;
> -	struct request_queue *q = md->queue;
>  	struct bio *clone = &tio->clone;
>  	struct orig_bio_details orig_bio_details;
>  	unsigned int zno;
> @@ -536,7 +533,7 @@ int dm_zone_map_bio(struct dm_target_io *tio)
>  
>  	/* Lock the target zone */
>  	zno = bio_zone_no(clone);
> -	dm_zone_lock(q, zno, clone);
> +	dm_zone_lock(md->disk, zno, clone);
>  
>  	orig_bio_details.nr_sectors = bio_sectors(clone);
>  	orig_bio_details.op = bio_op(clone);
> @@ -546,7 +543,7 @@ int dm_zone_map_bio(struct dm_target_io *tio)
>  	 * both valid, and if the bio is a zone append, remap it to a write.
>  	 */
>  	if (!dm_zone_map_bio_begin(md, zno, clone)) {
> -		dm_zone_unlock(q, zno, clone);
> +		dm_zone_unlock(md->disk, zno, clone);
>  		return DM_MAPIO_KILL;
>  	}
>  
> @@ -570,12 +567,12 @@ int dm_zone_map_bio(struct dm_target_io *tio)
>  		sts = dm_zone_map_bio_end(md, zno, &orig_bio_details,
>  					  *tio->len_ptr);
>  		if (sts != BLK_STS_OK)
> -			dm_zone_unlock(q, zno, clone);
> +			dm_zone_unlock(md->disk, zno, clone);
>  		break;
>  	case DM_MAPIO_REQUEUE:
>  	case DM_MAPIO_KILL:
>  	default:
> -		dm_zone_unlock(q, zno, clone);
> +		dm_zone_unlock(md->disk, zno, clone);
>  		sts = BLK_STS_IOERR;
>  		break;
>  	}
> @@ -592,7 +589,6 @@ int dm_zone_map_bio(struct dm_target_io *tio)
>  void dm_zone_endio(struct dm_io *io, struct bio *clone)
>  {
>  	struct mapped_device *md = io->md;
> -	struct request_queue *q = md->queue;
>  	struct gendisk *disk = md->disk;
>  	struct bio *orig_bio = io->orig_bio;
>  	unsigned int zwp_offset;
> @@ -651,5 +647,5 @@ void dm_zone_endio(struct dm_io *io, struct bio *clone)
>  				zwp_offset - bio_sectors(orig_bio);
>  	}
>  
> -	dm_zone_unlock(q, zno, clone);
> +	dm_zone_unlock(disk, zno, clone);
>  }
> diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
> index ccf9a6da8f6e1..f26640ccb9555 100644
> --- a/drivers/nvme/host/multipath.c
> +++ b/drivers/nvme/host/multipath.c
> @@ -830,7 +830,7 @@ void nvme_mpath_add_disk(struct nvme_ns *ns, struct nvme_id_ns *id)
>  				   ns->head->disk->queue);
>  #ifdef CONFIG_BLK_DEV_ZONED
>  	if (blk_queue_is_zoned(ns->queue) && ns->head->disk)
> -		ns->head->disk->queue->nr_zones = ns->queue->nr_zones;
> +		ns->head->disk->nr_zones = ns->disk->nr_zones;
>  #endif
>  }
>  
> diff --git a/drivers/nvme/target/zns.c b/drivers/nvme/target/zns.c
> index c9b2ce06ca93e..385f2fe2792ff 100644
> --- a/drivers/nvme/target/zns.c
> +++ b/drivers/nvme/target/zns.c
> @@ -57,7 +57,7 @@ bool nvmet_bdev_zns_enable(struct nvmet_ns *ns)
>  	 * zones, reject the device. Otherwise, use report zones to detect if
>  	 * the device has conventional zones.
>  	 */
> -	if (ns->bdev->bd_disk->queue->conv_zones_bitmap)
> +	if (ns->bdev->bd_disk->conv_zones_bitmap)
>  		return false;
>  
>  	ret = blkdev_report_zones(ns->bdev, 0, bdev_nr_zones(ns->bdev),
> diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
> index b4106f8997342..b8c97456506ac 100644
> --- a/drivers/scsi/sd_zbc.c
> +++ b/drivers/scsi/sd_zbc.c
> @@ -855,7 +855,7 @@ int sd_zbc_revalidate_zones(struct scsi_disk *sdkp)
>  
>  	if (sdkp->zone_info.zone_blocks == zone_blocks &&
>  	    sdkp->zone_info.nr_zones == nr_zones &&
> -	    disk->queue->nr_zones == nr_zones)
> +	    disk->nr_zones == nr_zones)
>  		goto unlock;
>  
>  	flags = memalloc_noio_save();
> diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
> index 43aad0da3305d..1b0b753609975 100644
> --- a/include/linux/blk-mq.h
> +++ b/include/linux/blk-mq.h
> @@ -1123,12 +1123,12 @@ void blk_dump_rq_flags(struct request *, char *);
>  #ifdef CONFIG_BLK_DEV_ZONED
>  static inline unsigned int blk_rq_zone_no(struct request *rq)
>  {
> -	return blk_queue_zone_no(rq->q, blk_rq_pos(rq));
> +	return disk_zone_no(rq->q->disk, blk_rq_pos(rq));
>  }
>  
>  static inline unsigned int blk_rq_zone_is_seq(struct request *rq)
>  {
> -	return blk_queue_zone_is_seq(rq->q, blk_rq_pos(rq));
> +	return disk_zone_is_seq(rq->q->disk, blk_rq_pos(rq));
>  }
>  
>  bool blk_req_needs_zone_write_lock(struct request *rq);
> @@ -1150,8 +1150,8 @@ static inline void blk_req_zone_write_unlock(struct request *rq)
>  
>  static inline bool blk_req_zone_is_write_locked(struct request *rq)
>  {
> -	return rq->q->seq_zones_wlock &&
> -		test_bit(blk_rq_zone_no(rq), rq->q->seq_zones_wlock);
> +	return rq->q->disk->seq_zones_wlock &&
> +		test_bit(blk_rq_zone_no(rq), rq->q->disk->seq_zones_wlock);
>  }
>  
>  static inline bool blk_req_can_dispatch_to_zone(struct request *rq)
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index f1eca3f5610eb..547eb07848741 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -164,6 +164,29 @@ struct gendisk {
>  #ifdef  CONFIG_BLK_DEV_INTEGRITY
>  	struct kobject integrity_kobj;
>  #endif	/* CONFIG_BLK_DEV_INTEGRITY */
> +
> +#ifdef CONFIG_BLK_DEV_ZONED
> +	/*
> +	 * Zoned block device information for request dispatch control.
> +	 * nr_zones is the total number of zones of the device. This is always
> +	 * 0 for regular block devices. conv_zones_bitmap is a bitmap of nr_zones
> +	 * bits which indicates if a zone is conventional (bit set) or
> +	 * sequential (bit clear). seq_zones_wlock is a bitmap of nr_zones
> +	 * bits which indicates if a zone is write locked, that is, if a write
> +	 * request targeting the zone was dispatched.
> +	 *
> +	 * Reads of this information must be protected with blk_queue_enter() /
> +	 * blk_queue_exit(). Modifying this information is only allowed while
> +	 * no requests are being processed. See also blk_mq_freeze_queue() and
> +	 * blk_mq_unfreeze_queue().
> +	 */
> +	unsigned int		nr_zones;
> +	unsigned int		max_open_zones;
> +	unsigned int		max_active_zones;
> +	unsigned long		*conv_zones_bitmap;
> +	unsigned long		*seq_zones_wlock;
> +#endif /* CONFIG_BLK_DEV_ZONED */
> +
>  #if IS_ENABLED(CONFIG_CDROM)
>  	struct cdrom_device_info *cdi;
>  #endif
> @@ -469,31 +492,6 @@ struct request_queue {
>  
>  	unsigned int		required_elevator_features;
>  
> -#ifdef CONFIG_BLK_DEV_ZONED
> -	/*
> -	 * Zoned block device information for request dispatch control.
> -	 * nr_zones is the total number of zones of the device. This is always
> -	 * 0 for regular block devices. conv_zones_bitmap is a bitmap of nr_zones
> -	 * bits which indicates if a zone is conventional (bit set) or
> -	 * sequential (bit clear). seq_zones_wlock is a bitmap of nr_zones
> -	 * bits which indicates if a zone is write locked, that is, if a write
> -	 * request targeting the zone was dispatched. All three fields are
> -	 * initialized by the low level device driver (e.g. scsi/sd.c).
> -	 * Stacking drivers (device mappers) may or may not initialize
> -	 * these fields.
> -	 *
> -	 * Reads of this information must be protected with blk_queue_enter() /
> -	 * blk_queue_exit(). Modifying this information is only allowed while
> -	 * no requests are being processed. See also blk_mq_freeze_queue() and
> -	 * blk_mq_unfreeze_queue().
> -	 */
> -	unsigned int		nr_zones;
> -	unsigned long		*conv_zones_bitmap;
> -	unsigned long		*seq_zones_wlock;
> -	unsigned int		max_open_zones;
> -	unsigned int		max_active_zones;
> -#endif /* CONFIG_BLK_DEV_ZONED */
> -
>  	int			node;
>  #ifdef CONFIG_BLK_DEV_IO_TRACE
>  	struct blk_trace __rcu	*blk_trace;
> @@ -670,63 +668,59 @@ static inline bool blk_queue_is_zoned(struct request_queue *q)
>  }
>  
>  #ifdef CONFIG_BLK_DEV_ZONED
> -static inline unsigned int blk_queue_nr_zones(struct request_queue *q)
> +static inline unsigned int disk_nr_zones(struct gendisk *disk)
>  {
> -	return blk_queue_is_zoned(q) ? q->nr_zones : 0;
> +	return blk_queue_is_zoned(disk->queue) ? disk->nr_zones : 0;
>  }
>  
> -static inline unsigned int blk_queue_zone_no(struct request_queue *q,
> -					     sector_t sector)
> +static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector)
>  {
> -	if (!blk_queue_is_zoned(q))
> +	if (!blk_queue_is_zoned(disk->queue))
>  		return 0;
> -	return sector >> ilog2(q->limits.chunk_sectors);
> +	return sector >> ilog2(disk->queue->limits.chunk_sectors);
>  }
>  
> -static inline bool blk_queue_zone_is_seq(struct request_queue *q,
> -					 sector_t sector)
> +static inline bool disk_zone_is_seq(struct gendisk *disk, sector_t sector)
>  {
> -	if (!blk_queue_is_zoned(q))
> +	if (!blk_queue_is_zoned(disk->queue))
>  		return false;
> -	if (!q->conv_zones_bitmap)
> +	if (!disk->conv_zones_bitmap)
>  		return true;
> -	return !test_bit(blk_queue_zone_no(q, sector), q->conv_zones_bitmap);
> +	return !test_bit(disk_zone_no(disk, sector), disk->conv_zones_bitmap);
>  }
>  
>  static inline void disk_set_max_open_zones(struct gendisk *disk,
>  		unsigned int max_open_zones)
>  {
> -	disk->queue->max_open_zones = max_open_zones;
> +	disk->max_open_zones = max_open_zones;
>  }
>  
>  static inline void disk_set_max_active_zones(struct gendisk *disk,
>  		unsigned int max_active_zones)
>  {
> -	disk->queue->max_active_zones = max_active_zones;
> +	disk->max_active_zones = max_active_zones;
>  }
>  
>  static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
>  {
> -	return bdev->bd_disk->queue->max_open_zones;
> +	return bdev->bd_disk->max_open_zones;
>  }
>  
>  static inline unsigned int bdev_max_active_zones(struct block_device *bdev)
>  {
> -	return bdev->bd_disk->queue->max_active_zones;
> +	return bdev->bd_disk->max_active_zones;
>  }
>  
>  #else /* CONFIG_BLK_DEV_ZONED */
> -static inline unsigned int blk_queue_nr_zones(struct request_queue *q)
> +static inline unsigned int disk_nr_zones(struct gendisk *disk)
>  {
>  	return 0;
>  }
> -static inline bool blk_queue_zone_is_seq(struct request_queue *q,
> -					 sector_t sector)
> +static inline bool disk_zone_is_seq(struct gendisk *disk, sector_t sector)
>  {
>  	return false;
>  }
> -static inline unsigned int blk_queue_zone_no(struct request_queue *q,
> -					     sector_t sector)
> +static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector)
>  {
>  	return 0;
>  }
> @@ -734,6 +728,7 @@ static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
>  {
>  	return 0;
>  }
> +
>  static inline unsigned int bdev_max_active_zones(struct block_device *bdev)
>  {
>  	return 0;
> @@ -902,14 +897,12 @@ const char *blk_zone_cond_str(enum blk_zone_cond zone_cond);
>  
>  static inline unsigned int bio_zone_no(struct bio *bio)
>  {
> -	return blk_queue_zone_no(bdev_get_queue(bio->bi_bdev),
> -				 bio->bi_iter.bi_sector);
> +	return disk_zone_no(bio->bi_bdev->bd_disk, bio->bi_iter.bi_sector);
>  }
>  
>  static inline unsigned int bio_zone_is_seq(struct bio *bio)
>  {
> -	return blk_queue_zone_is_seq(bdev_get_queue(bio->bi_bdev),
> -				     bio->bi_iter.bi_sector);
> +	return disk_zone_is_seq(bio->bi_bdev->bd_disk, bio->bi_iter.bi_sector);
>  }
>  
>  /*


-- 
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] 140+ messages in thread

* Re: [PATCH 01/17] block: remove a superflous ifdef in blkdev.h
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-05  6:22     ` Chaitanya Kulkarni
  -1 siblings, 0 replies; 140+ messages in thread
From: Chaitanya Kulkarni @ 2022-07-05  6:22 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi, Jens Axboe,
	Damien Le Moal

On 7/4/2022 5:44 AM, Christoph Hellwig wrote:
> It doesn't hurt to lways have the blk_zone_cond_str prototype, and the

's/lways/always'

> two inlines can also be defined unconditionally.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

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

-ck



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

* Re: [dm-devel] [PATCH 01/17] block: remove a superflous ifdef in blkdev.h
@ 2022-07-05  6:22     ` Chaitanya Kulkarni
  0 siblings, 0 replies; 140+ messages in thread
From: Chaitanya Kulkarni @ 2022-07-05  6:22 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Jens Axboe, linux-scsi, Damien Le Moal, linux-nvme, linux-block,
	dm-devel

On 7/4/2022 5:44 AM, Christoph Hellwig wrote:
> It doesn't hurt to lways have the blk_zone_cond_str prototype, and the

's/lways/always'

> two inlines can also be defined unconditionally.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

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] 140+ messages in thread

* Re: [PATCH 02/17] block: call blk_queue_free_zone_bitmaps from disk_release
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-05  6:23     ` Chaitanya Kulkarni
  -1 siblings, 0 replies; 140+ messages in thread
From: Chaitanya Kulkarni @ 2022-07-05  6:23 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

On 7/4/2022 5:44 AM, Christoph Hellwig wrote:
> The zone bitmaps are only used for non-passthrough I/O, so free them as
> soon as the disk is released.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---


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

-ck



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

* Re: [dm-devel] [PATCH 02/17] block: call blk_queue_free_zone_bitmaps from disk_release
@ 2022-07-05  6:23     ` Chaitanya Kulkarni
  0 siblings, 0 replies; 140+ messages in thread
From: Chaitanya Kulkarni @ 2022-07-05  6:23 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

On 7/4/2022 5:44 AM, Christoph Hellwig wrote:
> The zone bitmaps are only used for non-passthrough I/O, so free them as
> soon as the disk is released.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---


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] 140+ messages in thread

* Re: [PATCH 04/17] block: simplify blk_mq_plug
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-05  6:25     ` Chaitanya Kulkarni
  -1 siblings, 0 replies; 140+ messages in thread
From: Chaitanya Kulkarni @ 2022-07-05  6:25 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: dm-devel, Jens Axboe, linux-block, linux-nvme, linux-scsi,
	Damien Le Moal

On 7/4/2022 5:44 AM, Christoph Hellwig wrote:
> Drop the unused q argument, and invert the check to move the exception
> into a branch and the regular path as the normal return.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>

with Damien's suggested comments :

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

-ck



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

* Re: [dm-devel] [PATCH 04/17] block: simplify blk_mq_plug
@ 2022-07-05  6:25     ` Chaitanya Kulkarni
  0 siblings, 0 replies; 140+ messages in thread
From: Chaitanya Kulkarni @ 2022-07-05  6:25 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Jens Axboe, linux-scsi, Damien Le Moal, linux-nvme, linux-block,
	dm-devel

On 7/4/2022 5:44 AM, Christoph Hellwig wrote:
> Drop the unused q argument, and invert the check to move the exception
> into a branch and the regular path as the normal return.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>

with Damien's suggested comments :

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] 140+ messages in thread

* Re: [PATCH 05/17] block: export blkdev_zone_mgmt_all
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-05  6:25     ` Chaitanya Kulkarni
  -1 siblings, 0 replies; 140+ messages in thread
From: Chaitanya Kulkarni @ 2022-07-05  6:25 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: dm-devel, Jens Axboe, linux-block, linux-nvme, linux-scsi,
	Damien Le Moal

On 7/4/2022 5:44 AM, Christoph Hellwig wrote:
> Export blkdev_zone_mgmt_all so that the nvme target can use it instead
> of duplicating the functionality.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

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

-ck



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

* Re: [dm-devel] [PATCH 05/17] block: export blkdev_zone_mgmt_all
@ 2022-07-05  6:25     ` Chaitanya Kulkarni
  0 siblings, 0 replies; 140+ messages in thread
From: Chaitanya Kulkarni @ 2022-07-05  6:25 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Jens Axboe, linux-scsi, Damien Le Moal, linux-nvme, linux-block,
	dm-devel

On 7/4/2022 5:44 AM, Christoph Hellwig wrote:
> Export blkdev_zone_mgmt_all so that the nvme target can use it instead
> of duplicating the functionality.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

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] 140+ messages in thread

* Re: [PATCH 07/17] block: simplify blk_check_zone_append
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-05  6:27     ` Chaitanya Kulkarni
  -1 siblings, 0 replies; 140+ messages in thread
From: Chaitanya Kulkarni @ 2022-07-05  6:27 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

On 7/4/2022 5:44 AM, Christoph Hellwig wrote:
> Use the bdev based helpers instead of open coding them.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---


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

-ck



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

* Re: [dm-devel] [PATCH 07/17] block: simplify blk_check_zone_append
@ 2022-07-05  6:27     ` Chaitanya Kulkarni
  0 siblings, 0 replies; 140+ messages in thread
From: Chaitanya Kulkarni @ 2022-07-05  6:27 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

On 7/4/2022 5:44 AM, Christoph Hellwig wrote:
> Use the bdev based helpers instead of open coding them.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---


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] 140+ messages in thread

* Re: [PATCH 08/17] block: pass a gendisk to blk_queue_set_zoned
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-05  6:28     ` Chaitanya Kulkarni
  -1 siblings, 0 replies; 140+ messages in thread
From: Chaitanya Kulkarni @ 2022-07-05  6:28 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

On 7/4/2022 5:44 AM, Christoph Hellwig wrote:
> Prepare for storing the zone related field in struct gendisk instead
> of struct request_queue.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>   block/blk-settings.c           | 9 +++++----
>   block/partitions/core.c        | 2 +-
>   drivers/block/null_blk/zoned.c | 2 +-
>   drivers/nvme/host/zns.c        | 2 +-
>   drivers/scsi/sd.c              | 6 +++---
>   drivers/scsi/sd_zbc.c          | 2 +-
>   include/linux/blkdev.h         | 2 +-
>   7 files changed, 13 insertions(+), 12 deletions(-)
> 

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

-ck



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

* Re: [dm-devel] [PATCH 08/17] block: pass a gendisk to blk_queue_set_zoned
@ 2022-07-05  6:28     ` Chaitanya Kulkarni
  0 siblings, 0 replies; 140+ messages in thread
From: Chaitanya Kulkarni @ 2022-07-05  6:28 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

On 7/4/2022 5:44 AM, Christoph Hellwig wrote:
> Prepare for storing the zone related field in struct gendisk instead
> of struct request_queue.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>   block/blk-settings.c           | 9 +++++----
>   block/partitions/core.c        | 2 +-
>   drivers/block/null_blk/zoned.c | 2 +-
>   drivers/nvme/host/zns.c        | 2 +-
>   drivers/scsi/sd.c              | 6 +++---
>   drivers/scsi/sd_zbc.c          | 2 +-
>   include/linux/blkdev.h         | 2 +-
>   7 files changed, 13 insertions(+), 12 deletions(-)
> 

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] 140+ messages in thread

* Re: [PATCH 09/17] block: pass a gendisk to blk_queue_clear_zone_settings
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-05  6:29     ` Chaitanya Kulkarni
  -1 siblings, 0 replies; 140+ messages in thread
From: Chaitanya Kulkarni @ 2022-07-05  6:29 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

On 7/4/2022 5:44 AM, Christoph Hellwig wrote:
> Switch to a gendisk based API in preparation for moving all zone related
> fields from the request_queue to the gendisk.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>   block/blk-settings.c | 2 +-
>   block/blk-zoned.c    | 4 +++-
>   block/blk.h          | 4 ++--
>   3 files changed, 6 insertions(+), 4 deletions(-)
> 

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

-ck



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

* Re: [dm-devel] [PATCH 09/17] block: pass a gendisk to blk_queue_clear_zone_settings
@ 2022-07-05  6:29     ` Chaitanya Kulkarni
  0 siblings, 0 replies; 140+ messages in thread
From: Chaitanya Kulkarni @ 2022-07-05  6:29 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

On 7/4/2022 5:44 AM, Christoph Hellwig wrote:
> Switch to a gendisk based API in preparation for moving all zone related
> fields from the request_queue to the gendisk.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>   block/blk-settings.c | 2 +-
>   block/blk-zoned.c    | 4 +++-
>   block/blk.h          | 4 ++--
>   3 files changed, 6 insertions(+), 4 deletions(-)
> 

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] 140+ messages in thread

* Re: [PATCH 10/17] block: pass a gendisk to blk_queue_free_zone_bitmaps
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-05  6:40     ` Chaitanya Kulkarni
  -1 siblings, 0 replies; 140+ messages in thread
From: Chaitanya Kulkarni @ 2022-07-05  6:40 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

On 7/4/2022 5:44 AM, Christoph Hellwig wrote:
> Switch to a gendisk based API in preparation for moving all zone related
> fields from the request_queue to the gendisk.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

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

-ck



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

* Re: [dm-devel] [PATCH 10/17] block: pass a gendisk to blk_queue_free_zone_bitmaps
@ 2022-07-05  6:40     ` Chaitanya Kulkarni
  0 siblings, 0 replies; 140+ messages in thread
From: Chaitanya Kulkarni @ 2022-07-05  6:40 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

On 7/4/2022 5:44 AM, Christoph Hellwig wrote:
> Switch to a gendisk based API in preparation for moving all zone related
> fields from the request_queue to the gendisk.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

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] 140+ messages in thread

* Re: [PATCH 11/17] block: remove queue_max_open_zones and queue_max_active_zones
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-05  6:41     ` Chaitanya Kulkarni
  -1 siblings, 0 replies; 140+ messages in thread
From: Chaitanya Kulkarni @ 2022-07-05  6:41 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

On 7/4/2022 5:44 AM, Christoph Hellwig wrote:
> Always use the bdev based helpers instead.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---


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

-ck



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

* Re: [dm-devel] [PATCH 11/17] block: remove queue_max_open_zones and queue_max_active_zones
@ 2022-07-05  6:41     ` Chaitanya Kulkarni
  0 siblings, 0 replies; 140+ messages in thread
From: Chaitanya Kulkarni @ 2022-07-05  6:41 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

On 7/4/2022 5:44 AM, Christoph Hellwig wrote:
> Always use the bdev based helpers instead.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---


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] 140+ messages in thread

* Re: [PATCH 12/17] block: pass a gendisk to blk_queue_max_open_zones and blk_queue_max_active_zones
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-05  6:41     ` Chaitanya Kulkarni
  -1 siblings, 0 replies; 140+ messages in thread
From: Chaitanya Kulkarni @ 2022-07-05  6:41 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

On 7/4/2022 5:44 AM, Christoph Hellwig wrote:
> Switch to a gendisk based API in preparation for moving all zone related
> fields from the request_queue to the gendisk.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

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

-ck



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

* Re: [dm-devel] [PATCH 12/17] block: pass a gendisk to blk_queue_max_open_zones and blk_queue_max_active_zones
@ 2022-07-05  6:41     ` Chaitanya Kulkarni
  0 siblings, 0 replies; 140+ messages in thread
From: Chaitanya Kulkarni @ 2022-07-05  6:41 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

On 7/4/2022 5:44 AM, Christoph Hellwig wrote:
> Switch to a gendisk based API in preparation for moving all zone related
> fields from the request_queue to the gendisk.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

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] 140+ messages in thread

* Re: [PATCH 13/17] block: replace blkdev_nr_zones with bdev_nr_zones
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-05  6:42     ` Chaitanya Kulkarni
  -1 siblings, 0 replies; 140+ messages in thread
From: Chaitanya Kulkarni @ 2022-07-05  6:42 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

On 7/4/2022 5:44 AM, Christoph Hellwig wrote:
> Pass a block_device instead of a request_queue a that is what most
> callers have at hand.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---


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

-ck



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

* Re: [dm-devel] [PATCH 13/17] block: replace blkdev_nr_zones with bdev_nr_zones
@ 2022-07-05  6:42     ` Chaitanya Kulkarni
  0 siblings, 0 replies; 140+ messages in thread
From: Chaitanya Kulkarni @ 2022-07-05  6:42 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

On 7/4/2022 5:44 AM, Christoph Hellwig wrote:
> Pass a block_device instead of a request_queue a that is what most
> callers have at hand.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---


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] 140+ messages in thread

* Re: [PATCH 14/17] block: use bdev based helpers in blkdev_zone_mgmt / blkdev_zone_mgmt_all
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-05  6:43     ` Chaitanya Kulkarni
  -1 siblings, 0 replies; 140+ messages in thread
From: Chaitanya Kulkarni @ 2022-07-05  6:43 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

On 7/4/2022 5:44 AM, Christoph Hellwig wrote:
> Use the bdev based helpers instead of the queue based ones to clean up
> the code a bit and prepare for storing all zone related fields in
> struct gendisk.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

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

-ck



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

* Re: [dm-devel] [PATCH 14/17] block: use bdev based helpers in blkdev_zone_mgmt / blkdev_zone_mgmt_all
@ 2022-07-05  6:43     ` Chaitanya Kulkarni
  0 siblings, 0 replies; 140+ messages in thread
From: Chaitanya Kulkarni @ 2022-07-05  6:43 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

On 7/4/2022 5:44 AM, Christoph Hellwig wrote:
> Use the bdev based helpers instead of the queue based ones to clean up
> the code a bit and prepare for storing all zone related fields in
> struct gendisk.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

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] 140+ messages in thread

* Re: [PATCH 15/17] dm-zoned: cleanup dmz_fixup_devices
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-05  6:43     ` Chaitanya Kulkarni
  -1 siblings, 0 replies; 140+ messages in thread
From: Chaitanya Kulkarni @ 2022-07-05  6:43 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

On 7/4/2022 5:44 AM, Christoph Hellwig wrote:
> Use the bdev based helpers where applicable and move the zoned_dev
> into the scope where it is actually used.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---


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

-ck



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

* Re: [dm-devel] [PATCH 15/17] dm-zoned: cleanup dmz_fixup_devices
@ 2022-07-05  6:43     ` Chaitanya Kulkarni
  0 siblings, 0 replies; 140+ messages in thread
From: Chaitanya Kulkarni @ 2022-07-05  6:43 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

On 7/4/2022 5:44 AM, Christoph Hellwig wrote:
> Use the bdev based helpers where applicable and move the zoned_dev
> into the scope where it is actually used.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---


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] 140+ messages in thread

* Re: [PATCH 16/17] block: remove blk_queue_zone_sectors
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-05  6:44     ` Chaitanya Kulkarni
  -1 siblings, 0 replies; 140+ messages in thread
From: Chaitanya Kulkarni @ 2022-07-05  6:44 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

On 7/4/2022 5:44 AM, Christoph Hellwig wrote:
> Always use bdev_zone_sectors instead.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

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

-ck



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

* Re: [dm-devel] [PATCH 16/17] block: remove blk_queue_zone_sectors
@ 2022-07-05  6:44     ` Chaitanya Kulkarni
  0 siblings, 0 replies; 140+ messages in thread
From: Chaitanya Kulkarni @ 2022-07-05  6:44 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

On 7/4/2022 5:44 AM, Christoph Hellwig wrote:
> Always use bdev_zone_sectors instead.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

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] 140+ messages in thread

* Re: [PATCH 17/17] block: move zone related fields to struct gendisk
  2022-07-04 12:45   ` [dm-devel] " Christoph Hellwig
@ 2022-07-05  6:44     ` Chaitanya Kulkarni
  -1 siblings, 0 replies; 140+ messages in thread
From: Chaitanya Kulkarni @ 2022-07-05  6:44 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

On 7/4/2022 5:45 AM, Christoph Hellwig wrote:
> Move the zone related fields that are currently stored in
> struct request_queue to struct gendisk as these are part of the highlevel
> block layer API and are only used for non-passthrough I/O that requires
> the gendisk.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---


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

-ck




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

* Re: [dm-devel] [PATCH 17/17] block: move zone related fields to struct gendisk
@ 2022-07-05  6:44     ` Chaitanya Kulkarni
  0 siblings, 0 replies; 140+ messages in thread
From: Chaitanya Kulkarni @ 2022-07-05  6:44 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

On 7/4/2022 5:45 AM, Christoph Hellwig wrote:
> Move the zone related fields that are currently stored in
> struct request_queue to struct gendisk as these are part of the highlevel
> block layer API and are only used for non-passthrough I/O that requires
> the gendisk.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---


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] 140+ messages in thread

* Re: [PATCH 03/17] block: use bdev_is_zoned instead of open coding it
  2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
@ 2022-07-05  6:45     ` Chaitanya Kulkarni
  -1 siblings, 0 replies; 140+ messages in thread
From: Chaitanya Kulkarni @ 2022-07-05  6:45 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: dm-devel, linux-block, linux-nvme, linux-scsi

On 7/4/2022 5:44 AM, Christoph Hellwig wrote:
> Use bdev_is_zoned in all places where a block_device is available instead
> of open coding it.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

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

-ck



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

* Re: [dm-devel] [PATCH 03/17] block: use bdev_is_zoned instead of open coding it
@ 2022-07-05  6:45     ` Chaitanya Kulkarni
  0 siblings, 0 replies; 140+ messages in thread
From: Chaitanya Kulkarni @ 2022-07-05  6:45 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Damien Le Moal
  Cc: linux-block, dm-devel, linux-scsi, linux-nvme

On 7/4/2022 5:44 AM, Christoph Hellwig wrote:
> Use bdev_is_zoned in all places where a block_device is available instead
> of open coding it.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

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] 140+ messages in thread

end of thread, other threads:[~2022-07-06 15:03 UTC | newest]

Thread overview: 140+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-04 12:44 clean up zoned device information Christoph Hellwig
2022-07-04 12:44 ` [dm-devel] " Christoph Hellwig
2022-07-04 12:44 ` [PATCH 01/17] block: remove a superflous ifdef in blkdev.h Christoph Hellwig
2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
2022-07-04 12:58   ` Johannes Thumshirn
2022-07-04 12:58     ` [dm-devel] " Johannes Thumshirn
2022-07-04 13:01     ` Christoph Hellwig
2022-07-04 13:01       ` [dm-devel] " Christoph Hellwig
2022-07-04 13:04       ` Johannes Thumshirn
2022-07-04 13:04         ` [dm-devel] " Johannes Thumshirn
2022-07-05  2:26   ` Damien Le Moal
2022-07-05  2:26     ` [dm-devel] " Damien Le Moal
2022-07-05  6:22   ` Chaitanya Kulkarni
2022-07-05  6:22     ` [dm-devel] " Chaitanya Kulkarni
2022-07-04 12:44 ` [PATCH 02/17] block: call blk_queue_free_zone_bitmaps from disk_release Christoph Hellwig
2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
2022-07-04 13:01   ` Johannes Thumshirn
2022-07-04 13:01     ` [dm-devel] " Johannes Thumshirn
2022-07-05  2:27   ` Damien Le Moal
2022-07-05  2:27     ` [dm-devel] " Damien Le Moal
2022-07-05  6:23   ` Chaitanya Kulkarni
2022-07-05  6:23     ` [dm-devel] " Chaitanya Kulkarni
2022-07-04 12:44 ` [PATCH 03/17] block: use bdev_is_zoned instead of open coding it Christoph Hellwig
2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
2022-07-04 13:13   ` Johannes Thumshirn
2022-07-04 13:13     ` [dm-devel] " Johannes Thumshirn
2022-07-05  2:28   ` Damien Le Moal
2022-07-05  2:28     ` [dm-devel] " Damien Le Moal
2022-07-05  6:45   ` Chaitanya Kulkarni
2022-07-05  6:45     ` [dm-devel] " Chaitanya Kulkarni
2022-07-04 12:44 ` [PATCH 04/17] block: simplify blk_mq_plug Christoph Hellwig
2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
2022-07-04 13:14   ` Johannes Thumshirn
2022-07-04 13:14     ` [dm-devel] " Johannes Thumshirn
2022-07-05  2:30   ` Damien Le Moal
2022-07-05  2:30     ` [dm-devel] " Damien Le Moal
2022-07-05  6:25   ` Chaitanya Kulkarni
2022-07-05  6:25     ` [dm-devel] " Chaitanya Kulkarni
2022-07-04 12:44 ` [PATCH 05/17] block: export blkdev_zone_mgmt_all Christoph Hellwig
2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
2022-07-04 13:17   ` Johannes Thumshirn
2022-07-04 13:17     ` [dm-devel] " Johannes Thumshirn
2022-07-05  2:31   ` Damien Le Moal
2022-07-05  2:31     ` [dm-devel] " Damien Le Moal
2022-07-05  2:39     ` Damien Le Moal
2022-07-05  2:39       ` [dm-devel] " Damien Le Moal
2022-07-05  6:25   ` Chaitanya Kulkarni
2022-07-05  6:25     ` [dm-devel] " Chaitanya Kulkarni
2022-07-04 12:44 ` [PATCH 06/17] nvmet: use blkdev_zone_mgmt_all Christoph Hellwig
2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
2022-07-04 13:18   ` Johannes Thumshirn
2022-07-04 13:18     ` [dm-devel] " Johannes Thumshirn
2022-07-04 12:44 ` [PATCH 07/17] block: simplify blk_check_zone_append Christoph Hellwig
2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
2022-07-04 13:21   ` Johannes Thumshirn
2022-07-04 13:21     ` [dm-devel] " Johannes Thumshirn
2022-07-05  2:40   ` Damien Le Moal
2022-07-05  2:40     ` [dm-devel] " Damien Le Moal
2022-07-05  6:27   ` Chaitanya Kulkarni
2022-07-05  6:27     ` [dm-devel] " Chaitanya Kulkarni
2022-07-04 12:44 ` [PATCH 08/17] block: pass a gendisk to blk_queue_set_zoned Christoph Hellwig
2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
2022-07-04 13:22   ` Johannes Thumshirn
2022-07-04 13:22     ` [dm-devel] " Johannes Thumshirn
2022-07-05  2:41   ` Damien Le Moal
2022-07-05  2:41     ` [dm-devel] " Damien Le Moal
2022-07-05  6:28   ` Chaitanya Kulkarni
2022-07-05  6:28     ` [dm-devel] " Chaitanya Kulkarni
2022-07-04 12:44 ` [PATCH 09/17] block: pass a gendisk to blk_queue_clear_zone_settings Christoph Hellwig
2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
2022-07-04 13:23   ` Johannes Thumshirn
2022-07-04 13:23     ` [dm-devel] " Johannes Thumshirn
2022-07-05  2:41   ` Damien Le Moal
2022-07-05  2:41     ` [dm-devel] " Damien Le Moal
2022-07-05  6:29   ` Chaitanya Kulkarni
2022-07-05  6:29     ` [dm-devel] " Chaitanya Kulkarni
2022-07-04 12:44 ` [PATCH 10/17] block: pass a gendisk to blk_queue_free_zone_bitmaps Christoph Hellwig
2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
2022-07-04 13:23   ` Johannes Thumshirn
2022-07-04 13:23     ` [dm-devel] " Johannes Thumshirn
2022-07-05  2:42   ` Damien Le Moal
2022-07-05  2:42     ` [dm-devel] " Damien Le Moal
2022-07-05  6:40   ` Chaitanya Kulkarni
2022-07-05  6:40     ` [dm-devel] " Chaitanya Kulkarni
2022-07-04 12:44 ` [PATCH 11/17] block: remove queue_max_open_zones and queue_max_active_zones Christoph Hellwig
2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
2022-07-04 13:23   ` Johannes Thumshirn
2022-07-04 13:23     ` [dm-devel] " Johannes Thumshirn
2022-07-05  2:43   ` Damien Le Moal
2022-07-05  2:43     ` [dm-devel] " Damien Le Moal
2022-07-05  6:41   ` Chaitanya Kulkarni
2022-07-05  6:41     ` [dm-devel] " Chaitanya Kulkarni
2022-07-04 12:44 ` [PATCH 12/17] block: pass a gendisk to blk_queue_max_open_zones and blk_queue_max_active_zones Christoph Hellwig
2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
2022-07-04 13:24   ` Johannes Thumshirn
2022-07-04 13:24     ` [dm-devel] " Johannes Thumshirn
2022-07-05  2:50   ` Damien Le Moal
2022-07-05  2:50     ` [dm-devel] " Damien Le Moal
2022-07-05  6:41   ` Chaitanya Kulkarni
2022-07-05  6:41     ` [dm-devel] " Chaitanya Kulkarni
2022-07-04 12:44 ` [PATCH 13/17] block: replace blkdev_nr_zones with bdev_nr_zones Christoph Hellwig
2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
2022-07-04 13:27   ` Johannes Thumshirn
2022-07-04 13:27     ` [dm-devel] " Johannes Thumshirn
2022-07-05  2:53   ` Damien Le Moal
2022-07-05  2:53     ` [dm-devel] " Damien Le Moal
2022-07-05  6:42   ` Chaitanya Kulkarni
2022-07-05  6:42     ` [dm-devel] " Chaitanya Kulkarni
2022-07-04 12:44 ` [PATCH 14/17] block: use bdev based helpers in blkdev_zone_mgmt / blkdev_zone_mgmt_all Christoph Hellwig
2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
2022-07-04 13:27   ` Johannes Thumshirn
2022-07-04 13:27     ` Johannes Thumshirn
2022-07-05  2:54   ` Damien Le Moal
2022-07-05  2:54     ` [dm-devel] " Damien Le Moal
2022-07-05  6:43   ` Chaitanya Kulkarni
2022-07-05  6:43     ` [dm-devel] " Chaitanya Kulkarni
2022-07-04 12:44 ` [PATCH 15/17] dm-zoned: cleanup dmz_fixup_devices Christoph Hellwig
2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
2022-07-04 13:28   ` Johannes Thumshirn
2022-07-04 13:28     ` [dm-devel] " Johannes Thumshirn
2022-07-05  2:54   ` Damien Le Moal
2022-07-05  2:54     ` [dm-devel] " Damien Le Moal
2022-07-05  6:43   ` Chaitanya Kulkarni
2022-07-05  6:43     ` [dm-devel] " Chaitanya Kulkarni
2022-07-04 12:44 ` [PATCH 16/17] block: remove blk_queue_zone_sectors Christoph Hellwig
2022-07-04 12:44   ` [dm-devel] " Christoph Hellwig
2022-07-04 13:29   ` Johannes Thumshirn
2022-07-04 13:29     ` Johannes Thumshirn
2022-07-05  2:55   ` Damien Le Moal
2022-07-05  2:55     ` [dm-devel] " Damien Le Moal
2022-07-05  6:44   ` Chaitanya Kulkarni
2022-07-05  6:44     ` [dm-devel] " Chaitanya Kulkarni
2022-07-04 12:45 ` [PATCH 17/17] block: move zone related fields to struct gendisk Christoph Hellwig
2022-07-04 12:45   ` [dm-devel] " Christoph Hellwig
2022-07-04 13:31   ` Johannes Thumshirn
2022-07-04 13:31     ` Johannes Thumshirn
2022-07-05  2:59   ` Damien Le Moal
2022-07-05  2:59     ` [dm-devel] " Damien Le Moal
2022-07-05  6:44   ` Chaitanya Kulkarni
2022-07-05  6:44     ` [dm-devel] " Chaitanya Kulkarni

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.