linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 00/21] block: add and use init tagset helper
@ 2022-10-05  3:22 Chaitanya Kulkarni
  2022-10-05  3:22 ` [RFC PATCH 01/21] " Chaitanya Kulkarni
                   ` (21 more replies)
  0 siblings, 22 replies; 27+ messages in thread
From: Chaitanya Kulkarni @ 2022-10-05  3:22 UTC (permalink / raw)
  To: linux-block, linux-kernel, linux-omap, linux-remoteproc,
	linux-mmc, linux-mtd, linux-arm-kernel, linux-nvme, linux-s390,
	linux-scsi
  Cc: axboe, efremov, josef, idryomov, dongsheng.yang, haris.iqbal,
	jinpu.wang, mst, jasowang, pbonzini, stefanha, ohad, andersson,
	baolin.wang, ulf.hansson, richard, miquel.raynal, vigneshr,
	marcan, sven, alyssa, kbusch, hch, sagi, sth, hoeppner, hca, gor,
	agordeev, borntraeger, svens, jejb, martin.petersen, hare, kch,
	bhelgaas, john.garry, mcgrof, christophe.jaillet, vaibhavgupta40,
	wsa+renesas, damien.lemoal, johannes.thumshirn, bvanassche,
	ming.lei, shinichiro.kawasaki, vincent.fu, christoph.boehmwalder,
	joel, vincent.whitchurch, nbd, ceph-devel, virtualization, asahi

Hi,

Add and use the helper to initialize the common fields of the tag_set
such as blk_mq_ops, number of h/w queues, queue depth, command size,
numa_node, timeout, BLK_MQ_F_XXX flags, driver data. This initialization
is spread all over the block drivers. This avoids repetation of
inialization code of the tag set in current block drivers and any future
ones.

P.S. I'm aware of the EXPORT_SYMBOL_GPL() checkpatch warn just to make
get some feedback to so I can remove the RFC tag.

-ck

Chaitanya Kulkarni (21):
  block: add and use init tagset helper
  loop: use lib tagset init helper
  nbd: use lib tagset init helper
  rnbd: use lib tagset init helper
  bsg-lib: use lib tagset init helper
  rnbd-clt: use lib tagset init helper
  virtio-blk: use lib tagset init helper
  scsi: use lib tagset init helper
  block: use lib tagset init helper
  amiflop: use lib tagset init helper
  floppy: use lib tagset init helper
  mtip32xx: use lib tagset init helper
  z3ram: use lib tagset init helper
  scm_blk: use lib tagset init helper
  ubi: use lib tagset init helper
  mmc: core: use lib tagset init helper
  dasd: use lib tagset init helper
  nvme-core: use lib tagset init helper for I/O q
  nvme-core: use lib tagset init helper for adminq
  nvme-apple: use lib tagset init helper
  nvme-pci: use lib tagset init helper

 block/blk-mq.c                    | 27 ++++++++++++++++++++++-----
 block/bsg-lib.c                   |  9 +++------
 drivers/block/amiflop.c           |  8 +++-----
 drivers/block/floppy.c            |  7 ++-----
 drivers/block/loop.c              | 12 ++++--------
 drivers/block/mtip32xx/mtip32xx.c | 13 ++++---------
 drivers/block/nbd.c               | 11 +++--------
 drivers/block/null_blk/main.c     | 10 +++-------
 drivers/block/rbd.c               | 11 +++++------
 drivers/block/rnbd/rnbd-clt.c     | 25 +++++++++++--------------
 drivers/block/virtio_blk.c        | 14 +++++---------
 drivers/block/z2ram.c             |  7 ++-----
 drivers/mmc/core/queue.c          |  9 +++------
 drivers/mtd/ubi/block.c           | 11 +++--------
 drivers/nvme/host/apple.c         | 25 ++++++++-----------------
 drivers/nvme/host/core.c          | 21 +++++----------------
 drivers/nvme/host/pci.c           | 25 +++++++------------------
 drivers/s390/block/dasd_genhd.c   |  9 +++------
 drivers/s390/block/scm_blk.c      | 10 +++-------
 drivers/scsi/scsi_lib.c           | 13 +++++--------
 include/linux/blk-mq.h            |  5 +++++
 21 files changed, 109 insertions(+), 173 deletions(-)

-- 
2.29.0


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

* [RFC PATCH 01/21] block: add and use init tagset helper
  2022-10-05  3:22 [RFC PATCH 00/21] block: add and use init tagset helper Chaitanya Kulkarni
@ 2022-10-05  3:22 ` Chaitanya Kulkarni
  2022-10-05  5:11   ` Damien Le Moal
  2022-10-05  3:22 ` [RFC PATCH 02/21] loop: use lib tagset init helper Chaitanya Kulkarni
                   ` (20 subsequent siblings)
  21 siblings, 1 reply; 27+ messages in thread
From: Chaitanya Kulkarni @ 2022-10-05  3:22 UTC (permalink / raw)
  To: linux-block, linux-kernel, linux-omap, linux-remoteproc,
	linux-mmc, linux-mtd, linux-arm-kernel, linux-nvme, linux-s390,
	linux-scsi
  Cc: axboe, efremov, josef, idryomov, dongsheng.yang, haris.iqbal,
	jinpu.wang, mst, jasowang, pbonzini, stefanha, ohad, andersson,
	baolin.wang, ulf.hansson, richard, miquel.raynal, vigneshr,
	marcan, sven, alyssa, kbusch, hch, sagi, sth, hoeppner, hca, gor,
	agordeev, borntraeger, svens, jejb, martin.petersen, hare, kch,
	bhelgaas, john.garry, mcgrof, christophe.jaillet, vaibhavgupta40,
	wsa+renesas, damien.lemoal, johannes.thumshirn, bvanassche,
	ming.lei, shinichiro.kawasaki, vincent.fu, christoph.boehmwalder,
	joel, vincent.whitchurch, nbd, ceph-devel, virtualization, asahi

Add and use the helper to initialize the common fields of the tag_set
such as blk_mq_ops, number of h/w queues, queue depth, command size,
numa_node, timeout, BLK_MQ_F_XXX flags, driver data. This initialization
is spread all over the block drivers. This avoids the code repetation of
the inialization code of the tag set in current block drivers and any
future ones.

Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
---
 block/blk-mq.c                | 20 ++++++++++++++++++++
 drivers/block/null_blk/main.c | 10 +++-------
 include/linux/blk-mq.h        |  5 +++++
 3 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 8070b6c10e8d..e3a8dd81bbe2 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -4341,6 +4341,26 @@ static int blk_mq_alloc_tag_set_tags(struct blk_mq_tag_set *set,
 	return blk_mq_realloc_tag_set_tags(set, 0, new_nr_hw_queues);
 }
 
+void blk_mq_init_tag_set(struct blk_mq_tag_set *set,
+		const struct blk_mq_ops *ops, unsigned int nr_hw_queues,
+		unsigned int queue_depth, unsigned int cmd_size, int numa_node,
+		unsigned int timeout, unsigned int flags, void *driver_data)
+{
+	if (!set)
+		return;
+
+	set->ops = ops;
+	set->nr_hw_queues = nr_hw_queues;
+	set->queue_depth = queue_depth;
+	set->cmd_size = cmd_size;
+	set->numa_node = numa_node;
+	set->timeout = timeout;
+	set->flags = flags;
+	set->driver_data = driver_data;
+}
+
+EXPORT_SYMBOL_GPL(blk_mq_init_tag_set);
+
 /*
  * Alloc a tag set to be associated with one or more request queues.
  * May fail with EINVAL for various error conditions. May adjust the
diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
index 1f154f92f4c2..0b07aab980c4 100644
--- a/drivers/block/null_blk/main.c
+++ b/drivers/block/null_blk/main.c
@@ -1926,13 +1926,9 @@ static int null_init_tag_set(struct nullb *nullb, struct blk_mq_tag_set *set)
 			flags |= BLK_MQ_F_BLOCKING;
 	}
 
-	set->ops = &null_mq_ops;
-	set->cmd_size	= sizeof(struct nullb_cmd);
-	set->flags = flags;
-	set->driver_data = nullb;
-	set->nr_hw_queues = hw_queues;
-	set->queue_depth = queue_depth;
-	set->numa_node = numa_node;
+	blk_mq_init_tag_set(set, &null_mq_ops, hw_queues, queue_depth,
+			sizeof(struct nullb_cmd), numa_node, 0, flags, nullb);
+
 	if (poll_queues) {
 		set->nr_hw_queues += poll_queues;
 		set->nr_maps = 3;
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index ba18e9bdb799..06087a8e4398 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -708,6 +708,11 @@ int blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
 		struct request_queue *q);
 void blk_mq_destroy_queue(struct request_queue *);
 
+
+void blk_mq_init_tag_set(struct blk_mq_tag_set *set,
+		const struct blk_mq_ops *ops, unsigned int nr_hw_queues,
+		unsigned int queue_depth, unsigned int cmd_size, int numa_node,
+		unsigned int timeout, unsigned int flags, void *driver_data);
 int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set);
 int blk_mq_alloc_sq_tag_set(struct blk_mq_tag_set *set,
 		const struct blk_mq_ops *ops, unsigned int queue_depth,
-- 
2.29.0


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

* [RFC PATCH 02/21] loop: use lib tagset init helper
  2022-10-05  3:22 [RFC PATCH 00/21] block: add and use init tagset helper Chaitanya Kulkarni
  2022-10-05  3:22 ` [RFC PATCH 01/21] " Chaitanya Kulkarni
@ 2022-10-05  3:22 ` Chaitanya Kulkarni
  2022-10-05  3:22 ` [RFC PATCH 03/21] nbd: " Chaitanya Kulkarni
                   ` (19 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Chaitanya Kulkarni @ 2022-10-05  3:22 UTC (permalink / raw)
  To: linux-block, linux-kernel, linux-omap, linux-remoteproc,
	linux-mmc, linux-mtd, linux-arm-kernel, linux-nvme, linux-s390,
	linux-scsi
  Cc: axboe, efremov, josef, idryomov, dongsheng.yang, haris.iqbal,
	jinpu.wang, mst, jasowang, pbonzini, stefanha, ohad, andersson,
	baolin.wang, ulf.hansson, richard, miquel.raynal, vigneshr,
	marcan, sven, alyssa, kbusch, hch, sagi, sth, hoeppner, hca, gor,
	agordeev, borntraeger, svens, jejb, martin.petersen, hare, kch,
	bhelgaas, john.garry, mcgrof, christophe.jaillet, vaibhavgupta40,
	wsa+renesas, damien.lemoal, johannes.thumshirn, bvanassche,
	ming.lei, shinichiro.kawasaki, vincent.fu, christoph.boehmwalder,
	joel, vincent.whitchurch, nbd, ceph-devel, virtualization, asahi

Use the block layer helper to initialize the common fields of tag_set
such as blk_mq_ops, number of h/w queues, queue depth, command size,
numa_node, timeout, BLK_MQ_F_XXX flags, driver data. This initialization
is spread all over the block drivers. This avoids the code repetation of
the inialization code of the tag set in current block drivers and any
future ones.

Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
---
 drivers/block/loop.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index ad92192c7d61..a915f25b4410 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1937,6 +1937,8 @@ static const struct blk_mq_ops loop_mq_ops = {
 
 static int loop_add(int i)
 {
+	unsigned int flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_STACKING |
+		BLK_MQ_F_NO_SCHED_BY_DEFAULT;
 	struct loop_device *lo;
 	struct gendisk *disk;
 	int err;
@@ -1967,14 +1969,8 @@ static int loop_add(int i)
 		goto out_free_dev;
 	i = err;
 
-	lo->tag_set.ops = &loop_mq_ops;
-	lo->tag_set.nr_hw_queues = 1;
-	lo->tag_set.queue_depth = hw_queue_depth;
-	lo->tag_set.numa_node = NUMA_NO_NODE;
-	lo->tag_set.cmd_size = sizeof(struct loop_cmd);
-	lo->tag_set.flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_STACKING |
-		BLK_MQ_F_NO_SCHED_BY_DEFAULT;
-	lo->tag_set.driver_data = lo;
+	blk_mq_init_tag_set(&lo->tag_set, &loop_mq_ops, 1, hw_queue_depth,
+			sizeof(struct loop_cmd), NUMA_NO_NODE, 0, flags, lo);
 
 	err = blk_mq_alloc_tag_set(&lo->tag_set);
 	if (err)
-- 
2.29.0


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

* [RFC PATCH 03/21] nbd: use lib tagset init helper
  2022-10-05  3:22 [RFC PATCH 00/21] block: add and use init tagset helper Chaitanya Kulkarni
  2022-10-05  3:22 ` [RFC PATCH 01/21] " Chaitanya Kulkarni
  2022-10-05  3:22 ` [RFC PATCH 02/21] loop: use lib tagset init helper Chaitanya Kulkarni
@ 2022-10-05  3:22 ` Chaitanya Kulkarni
  2022-10-05  3:22 ` [RFC PATCH 04/21] rnbd: " Chaitanya Kulkarni
                   ` (18 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Chaitanya Kulkarni @ 2022-10-05  3:22 UTC (permalink / raw)
  To: linux-block, linux-kernel, linux-omap, linux-remoteproc,
	linux-mmc, linux-mtd, linux-arm-kernel, linux-nvme, linux-s390,
	linux-scsi
  Cc: axboe, efremov, josef, idryomov, dongsheng.yang, haris.iqbal,
	jinpu.wang, mst, jasowang, pbonzini, stefanha, ohad, andersson,
	baolin.wang, ulf.hansson, richard, miquel.raynal, vigneshr,
	marcan, sven, alyssa, kbusch, hch, sagi, sth, hoeppner, hca, gor,
	agordeev, borntraeger, svens, jejb, martin.petersen, hare, kch,
	bhelgaas, john.garry, mcgrof, christophe.jaillet, vaibhavgupta40,
	wsa+renesas, damien.lemoal, johannes.thumshirn, bvanassche,
	ming.lei, shinichiro.kawasaki, vincent.fu, christoph.boehmwalder,
	joel, vincent.whitchurch, nbd, ceph-devel, virtualization, asahi

Use the block layer helper to initialize the common fields of tag_set
such as blk_mq_ops, number of h/w queues, queue depth, command size,
numa_node, timeout, BLK_MQ_F_XXX flags, driver data. This initialization
is spread all over the block drivers. This avoids the code repetation of
the inialization code of the tag set in current block drivers and any
future ones.

Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
---
 drivers/block/nbd.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 2a2a1d996a57..01be68d1f722 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -1749,14 +1749,9 @@ static struct nbd_device *nbd_dev_add(int index, unsigned int refs)
 	if (!nbd)
 		goto out;
 
-	nbd->tag_set.ops = &nbd_mq_ops;
-	nbd->tag_set.nr_hw_queues = 1;
-	nbd->tag_set.queue_depth = 128;
-	nbd->tag_set.numa_node = NUMA_NO_NODE;
-	nbd->tag_set.cmd_size = sizeof(struct nbd_cmd);
-	nbd->tag_set.flags = BLK_MQ_F_SHOULD_MERGE |
-		BLK_MQ_F_BLOCKING;
-	nbd->tag_set.driver_data = nbd;
+	blk_mq_init_tag_set(&nbd->tag_set, &nbd_mq_ops, 1, 128,
+			sizeof(struct nbd_cmd), NUMA_NO_NODE, 0,
+			BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_BLOCKING, nbd);
 	INIT_WORK(&nbd->remove_work, nbd_dev_remove_work);
 	nbd->backend = NULL;
 
-- 
2.29.0


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

* [RFC PATCH 04/21] rnbd: use lib tagset init helper
  2022-10-05  3:22 [RFC PATCH 00/21] block: add and use init tagset helper Chaitanya Kulkarni
                   ` (2 preceding siblings ...)
  2022-10-05  3:22 ` [RFC PATCH 03/21] nbd: " Chaitanya Kulkarni
@ 2022-10-05  3:22 ` Chaitanya Kulkarni
  2022-10-05  3:22 ` [RFC PATCH 05/21] bsg-lib: " Chaitanya Kulkarni
                   ` (17 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Chaitanya Kulkarni @ 2022-10-05  3:22 UTC (permalink / raw)
  To: linux-block, linux-kernel, linux-omap, linux-remoteproc,
	linux-mmc, linux-mtd, linux-arm-kernel, linux-nvme, linux-s390,
	linux-scsi
  Cc: axboe, efremov, josef, idryomov, dongsheng.yang, haris.iqbal,
	jinpu.wang, mst, jasowang, pbonzini, stefanha, ohad, andersson,
	baolin.wang, ulf.hansson, richard, miquel.raynal, vigneshr,
	marcan, sven, alyssa, kbusch, hch, sagi, sth, hoeppner, hca, gor,
	agordeev, borntraeger, svens, jejb, martin.petersen, hare, kch,
	bhelgaas, john.garry, mcgrof, christophe.jaillet, vaibhavgupta40,
	wsa+renesas, damien.lemoal, johannes.thumshirn, bvanassche,
	ming.lei, shinichiro.kawasaki, vincent.fu, christoph.boehmwalder,
	joel, vincent.whitchurch, nbd, ceph-devel, virtualization, asahi

Use the block layer helper to initialize the common fields of tag_set
such as blk_mq_ops, number of h/w queues, queue depth, command size,
numa_node, timeout, BLK_MQ_F_XXX flags, driver data. This initialization
is spread all over the block drivers. This avoids the code repetation of
the inialization code of the tag set in current block drivers and any
future ones.

Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
---
 drivers/block/rbd.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index f9e39301c4af..c666692955cd 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -4901,12 +4901,11 @@ static int rbd_init_disk(struct rbd_device *rbd_dev)
 	int err;
 
 	memset(&rbd_dev->tag_set, 0, sizeof(rbd_dev->tag_set));
-	rbd_dev->tag_set.ops = &rbd_mq_ops;
-	rbd_dev->tag_set.queue_depth = rbd_dev->opts->queue_depth;
-	rbd_dev->tag_set.numa_node = NUMA_NO_NODE;
-	rbd_dev->tag_set.flags = BLK_MQ_F_SHOULD_MERGE;
-	rbd_dev->tag_set.nr_hw_queues = num_present_cpus();
-	rbd_dev->tag_set.cmd_size = sizeof(struct rbd_img_request);
+
+	blk_mq_init_tag_set(&rbd_dev->tag_set, &rbd_mq_ops, num_present_cpus(),
+			rbd_dev->opts->queue_depth,
+			sizeof(struct rbd_img_request), NUMA_NO_NODE, 0,
+			BLK_MQ_F_SHOULD_MERGE, NULL);
 
 	err = blk_mq_alloc_tag_set(&rbd_dev->tag_set);
 	if (err)
-- 
2.29.0


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

* [RFC PATCH 05/21] bsg-lib: use lib tagset init helper
  2022-10-05  3:22 [RFC PATCH 00/21] block: add and use init tagset helper Chaitanya Kulkarni
                   ` (3 preceding siblings ...)
  2022-10-05  3:22 ` [RFC PATCH 04/21] rnbd: " Chaitanya Kulkarni
@ 2022-10-05  3:22 ` Chaitanya Kulkarni
  2022-10-05  3:22 ` [RFC PATCH 06/21] rnbd-clt: " Chaitanya Kulkarni
                   ` (16 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Chaitanya Kulkarni @ 2022-10-05  3:22 UTC (permalink / raw)
  To: linux-block, linux-kernel, linux-omap, linux-remoteproc,
	linux-mmc, linux-mtd, linux-arm-kernel, linux-nvme, linux-s390,
	linux-scsi
  Cc: axboe, efremov, josef, idryomov, dongsheng.yang, haris.iqbal,
	jinpu.wang, mst, jasowang, pbonzini, stefanha, ohad, andersson,
	baolin.wang, ulf.hansson, richard, miquel.raynal, vigneshr,
	marcan, sven, alyssa, kbusch, hch, sagi, sth, hoeppner, hca, gor,
	agordeev, borntraeger, svens, jejb, martin.petersen, hare, kch,
	bhelgaas, john.garry, mcgrof, christophe.jaillet, vaibhavgupta40,
	wsa+renesas, damien.lemoal, johannes.thumshirn, bvanassche,
	ming.lei, shinichiro.kawasaki, vincent.fu, christoph.boehmwalder,
	joel, vincent.whitchurch, nbd, ceph-devel, virtualization, asahi

Use the block layer helper to initialize the common fields of tag_set
such as blk_mq_ops, number of h/w queues, queue depth, command size,
numa_node, timeout, BLK_MQ_F_XXX flags, driver data. This initialization
is spread all over the block drivers. This avoids the code repetation of
the inialization code of the tag set in current block drivers and any
future ones.

Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
---
 block/bsg-lib.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/block/bsg-lib.c b/block/bsg-lib.c
index d6f5dcdce748..3f28e24faa50 100644
--- a/block/bsg-lib.c
+++ b/block/bsg-lib.c
@@ -373,12 +373,9 @@ struct request_queue *bsg_setup_queue(struct device *dev, const char *name,
 	bset->timeout_fn = timeout;
 
 	set = &bset->tag_set;
-	set->ops = &bsg_mq_ops;
-	set->nr_hw_queues = 1;
-	set->queue_depth = 128;
-	set->numa_node = NUMA_NO_NODE;
-	set->cmd_size = sizeof(struct bsg_job) + dd_job_size;
-	set->flags = BLK_MQ_F_NO_SCHED | BLK_MQ_F_BLOCKING;
+	blk_mq_init_tag_set(set, &bsg_mq_ops, 1, 128,
+			sizeof(struct bsg_job) + dd_job_size, NUMA_NO_NODE,
+			0, BLK_MQ_F_NO_SCHED | BLK_MQ_F_BLOCKING, NULL);
 	if (blk_mq_alloc_tag_set(set))
 		goto out_tag_set;
 
-- 
2.29.0


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

* [RFC PATCH 06/21] rnbd-clt: use lib tagset init helper
  2022-10-05  3:22 [RFC PATCH 00/21] block: add and use init tagset helper Chaitanya Kulkarni
                   ` (4 preceding siblings ...)
  2022-10-05  3:22 ` [RFC PATCH 05/21] bsg-lib: " Chaitanya Kulkarni
@ 2022-10-05  3:22 ` Chaitanya Kulkarni
  2022-10-05  3:22 ` [RFC PATCH 07/21] virtio-blk: " Chaitanya Kulkarni
                   ` (15 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Chaitanya Kulkarni @ 2022-10-05  3:22 UTC (permalink / raw)
  To: linux-block, linux-kernel, linux-omap, linux-remoteproc,
	linux-mmc, linux-mtd, linux-arm-kernel, linux-nvme, linux-s390,
	linux-scsi
  Cc: axboe, efremov, josef, idryomov, dongsheng.yang, haris.iqbal,
	jinpu.wang, mst, jasowang, pbonzini, stefanha, ohad, andersson,
	baolin.wang, ulf.hansson, richard, miquel.raynal, vigneshr,
	marcan, sven, alyssa, kbusch, hch, sagi, sth, hoeppner, hca, gor,
	agordeev, borntraeger, svens, jejb, martin.petersen, hare, kch,
	bhelgaas, john.garry, mcgrof, christophe.jaillet, vaibhavgupta40,
	wsa+renesas, damien.lemoal, johannes.thumshirn, bvanassche,
	ming.lei, shinichiro.kawasaki, vincent.fu, christoph.boehmwalder,
	joel, vincent.whitchurch, nbd, ceph-devel, virtualization, asahi

Use the block layer helper to initialize the common fields of tag_set
such as blk_mq_ops, number of h/w queues, queue depth, command size,
numa_node, timeout, BLK_MQ_F_XXX flags, driver data. This initialization
is spread all over the block drivers. This avoids the code repetation of
the inialization code of the tag set in current block drivers and any
future ones.

Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
---
 drivers/block/rnbd/rnbd-clt.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c
index 78334da74d8b..8f67a7e5299a 100644
--- a/drivers/block/rnbd/rnbd-clt.c
+++ b/drivers/block/rnbd/rnbd-clt.c
@@ -1203,25 +1203,22 @@ static struct blk_mq_ops rnbd_mq_ops = {
 
 static int setup_mq_tags(struct rnbd_clt_session *sess)
 {
-	struct blk_mq_tag_set *tag_set = &sess->tag_set;
-
-	memset(tag_set, 0, sizeof(*tag_set));
-	tag_set->ops		= &rnbd_mq_ops;
-	tag_set->queue_depth	= sess->queue_depth;
-	tag_set->numa_node		= NUMA_NO_NODE;
-	tag_set->flags		= BLK_MQ_F_SHOULD_MERGE |
-				  BLK_MQ_F_TAG_QUEUE_SHARED;
-	tag_set->cmd_size	= sizeof(struct rnbd_iu) + RNBD_RDMA_SGL_SIZE;
-
-	/* for HCTX_TYPE_DEFAULT, HCTX_TYPE_READ, HCTX_TYPE_POLL */
-	tag_set->nr_maps        = sess->nr_poll_queues ? HCTX_MAX_TYPES : 2;
 	/*
 	 * HCTX_TYPE_DEFAULT and HCTX_TYPE_READ share one set of queues
 	 * others are for HCTX_TYPE_POLL
 	 */
-	tag_set->nr_hw_queues	= num_online_cpus() + sess->nr_poll_queues;
-	tag_set->driver_data    = sess;
+	unsigned int nr_hw_queue = num_online_cpus() + sess->nr_poll_queues;
+	struct blk_mq_tag_set *tag_set = &sess->tag_set;
 
+	memset(tag_set, 0, sizeof(*tag_set));
+	blk_mq_init_tag_set(tag_set, &rnbd_mq_ops, nr_hw_queue,
+			sess->queue_depth,
+			sizeof(struct rnbd_iu) + RNBD_RDMA_SGL_SIZE,
+			NUMA_NO_NODE, 0,
+			BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_TAG_QUEUE_SHARED, sess);
+	/* for HCTX_TYPE_DEFAULT, HCTX_TYPE_READ, HCTX_TYPE_POLL */
+
+	tag_set->nr_maps        = sess->nr_poll_queues ? HCTX_MAX_TYPES : 2;
 	return blk_mq_alloc_tag_set(tag_set);
 }
 
-- 
2.29.0


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

* [RFC PATCH 07/21] virtio-blk: use lib tagset init helper
  2022-10-05  3:22 [RFC PATCH 00/21] block: add and use init tagset helper Chaitanya Kulkarni
                   ` (5 preceding siblings ...)
  2022-10-05  3:22 ` [RFC PATCH 06/21] rnbd-clt: " Chaitanya Kulkarni
@ 2022-10-05  3:22 ` Chaitanya Kulkarni
  2022-10-05  3:22 ` [RFC PATCH 08/21] scsi: " Chaitanya Kulkarni
                   ` (14 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Chaitanya Kulkarni @ 2022-10-05  3:22 UTC (permalink / raw)
  To: linux-block, linux-kernel, linux-omap, linux-remoteproc,
	linux-mmc, linux-mtd, linux-arm-kernel, linux-nvme, linux-s390,
	linux-scsi
  Cc: axboe, efremov, josef, idryomov, dongsheng.yang, haris.iqbal,
	jinpu.wang, mst, jasowang, pbonzini, stefanha, ohad, andersson,
	baolin.wang, ulf.hansson, richard, miquel.raynal, vigneshr,
	marcan, sven, alyssa, kbusch, hch, sagi, sth, hoeppner, hca, gor,
	agordeev, borntraeger, svens, jejb, martin.petersen, hare, kch,
	bhelgaas, john.garry, mcgrof, christophe.jaillet, vaibhavgupta40,
	wsa+renesas, damien.lemoal, johannes.thumshirn, bvanassche,
	ming.lei, shinichiro.kawasaki, vincent.fu, christoph.boehmwalder,
	joel, vincent.whitchurch, nbd, ceph-devel, virtualization, asahi

Use the block layer helper to initialize the common fields of tag_set
such as blk_mq_ops, number of h/w queues, queue depth, command size,
numa_node, timeout, BLK_MQ_F_XXX flags, driver data. This initialization
is spread all over the block drivers. This avoids the code repetation of
the inialization code of the tag set in current block drivers and any
future ones.

Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
---
 drivers/block/virtio_blk.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 23c5a1239520..975b4a8213af 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -885,6 +885,8 @@ static int virtblk_probe(struct virtio_device *vdev)
 	struct virtio_blk *vblk;
 	struct request_queue *q;
 	int err, index;
+	unsigned int cmd_size = sizeof(struct virtblk_req) +
+		sizeof(struct scatterlist) * VIRTIO_BLK_INLINE_SG_CNT;
 
 	u32 v, blk_size, max_size, sg_elems, opt_io_size;
 	u16 min_io_size;
@@ -942,15 +944,9 @@ static int virtblk_probe(struct virtio_device *vdev)
 	}
 
 	memset(&vblk->tag_set, 0, sizeof(vblk->tag_set));
-	vblk->tag_set.ops = &virtio_mq_ops;
-	vblk->tag_set.queue_depth = queue_depth;
-	vblk->tag_set.numa_node = NUMA_NO_NODE;
-	vblk->tag_set.flags = BLK_MQ_F_SHOULD_MERGE;
-	vblk->tag_set.cmd_size =
-		sizeof(struct virtblk_req) +
-		sizeof(struct scatterlist) * VIRTIO_BLK_INLINE_SG_CNT;
-	vblk->tag_set.driver_data = vblk;
-	vblk->tag_set.nr_hw_queues = vblk->num_vqs;
+	blk_mq_init_tag_set(&vblk->tag_set, &virtio_mq_ops, vblk->num_vqs,
+			queue_depth, cmd_size, NUMA_NO_NODE, 0,
+			BLK_MQ_F_SHOULD_MERGE, vblk);
 	vblk->tag_set.nr_maps = 1;
 	if (vblk->io_queues[HCTX_TYPE_POLL])
 		vblk->tag_set.nr_maps = 3;
-- 
2.29.0


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

* [RFC PATCH 08/21] scsi: use lib tagset init helper
  2022-10-05  3:22 [RFC PATCH 00/21] block: add and use init tagset helper Chaitanya Kulkarni
                   ` (6 preceding siblings ...)
  2022-10-05  3:22 ` [RFC PATCH 07/21] virtio-blk: " Chaitanya Kulkarni
@ 2022-10-05  3:22 ` Chaitanya Kulkarni
  2022-10-05  3:22 ` [RFC PATCH 09/21] block: " Chaitanya Kulkarni
                   ` (13 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Chaitanya Kulkarni @ 2022-10-05  3:22 UTC (permalink / raw)
  To: linux-block, linux-kernel, linux-omap, linux-remoteproc,
	linux-mmc, linux-mtd, linux-arm-kernel, linux-nvme, linux-s390,
	linux-scsi
  Cc: axboe, efremov, josef, idryomov, dongsheng.yang, haris.iqbal,
	jinpu.wang, mst, jasowang, pbonzini, stefanha, ohad, andersson,
	baolin.wang, ulf.hansson, richard, miquel.raynal, vigneshr,
	marcan, sven, alyssa, kbusch, hch, sagi, sth, hoeppner, hca, gor,
	agordeev, borntraeger, svens, jejb, martin.petersen, hare, kch,
	bhelgaas, john.garry, mcgrof, christophe.jaillet, vaibhavgupta40,
	wsa+renesas, damien.lemoal, johannes.thumshirn, bvanassche,
	ming.lei, shinichiro.kawasaki, vincent.fu, christoph.boehmwalder,
	joel, vincent.whitchurch, nbd, ceph-devel, virtualization, asahi

Use the block layer helper to initialize the common fields of tag_set
such as blk_mq_ops, number of h/w queues, queue depth, command size,
numa_node, timeout, BLK_MQ_F_XXX flags, driver data. This initialization
is spread all over the block drivers. This avoids the code repetation of
the inialization code of the tag set in current block drivers and any
future ones.

Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
---
 drivers/scsi/scsi_lib.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index d7ec4ab2b111..121f292ba0d8 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1955,6 +1955,8 @@ int scsi_mq_setup_tags(struct Scsi_Host *shost)
 {
 	unsigned int cmd_size, sgl_size;
 	struct blk_mq_tag_set *tag_set = &shost->tag_set;
+	unsigned int flags = BLK_MQ_F_SHOULD_MERGE |
+		BLK_ALLOC_POLICY_TO_MQ_FLAG(shost->hostt->tag_alloc_policy);
 
 	sgl_size = max_t(unsigned int, sizeof(struct scatterlist),
 				scsi_mq_inline_sgl_size(shost));
@@ -1964,19 +1966,14 @@ int scsi_mq_setup_tags(struct Scsi_Host *shost)
 			sizeof(struct scatterlist) * SCSI_INLINE_PROT_SG_CNT;
 
 	memset(tag_set, 0, sizeof(*tag_set));
+	blk_mq_init_tag_set(tag_set, NULL, shost->nr_hw_queues ? : 1,
+			shost->can_queue, cmd_size, dev_to_node(shost->dma_dev),
+			0, flags, shost);
 	if (shost->hostt->commit_rqs)
 		tag_set->ops = &scsi_mq_ops;
 	else
 		tag_set->ops = &scsi_mq_ops_no_commit;
-	tag_set->nr_hw_queues = shost->nr_hw_queues ? : 1;
 	tag_set->nr_maps = shost->nr_maps ? : 1;
-	tag_set->queue_depth = shost->can_queue;
-	tag_set->cmd_size = cmd_size;
-	tag_set->numa_node = dev_to_node(shost->dma_dev);
-	tag_set->flags = BLK_MQ_F_SHOULD_MERGE;
-	tag_set->flags |=
-		BLK_ALLOC_POLICY_TO_MQ_FLAG(shost->hostt->tag_alloc_policy);
-	tag_set->driver_data = shost;
 	if (shost->host_tagset)
 		tag_set->flags |= BLK_MQ_F_TAG_HCTX_SHARED;
 
-- 
2.29.0


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

* [RFC PATCH 09/21] block: use lib tagset init helper
  2022-10-05  3:22 [RFC PATCH 00/21] block: add and use init tagset helper Chaitanya Kulkarni
                   ` (7 preceding siblings ...)
  2022-10-05  3:22 ` [RFC PATCH 08/21] scsi: " Chaitanya Kulkarni
@ 2022-10-05  3:22 ` Chaitanya Kulkarni
  2022-10-05  3:22 ` [RFC PATCH 10/21] amiflop: " Chaitanya Kulkarni
                   ` (12 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Chaitanya Kulkarni @ 2022-10-05  3:22 UTC (permalink / raw)
  To: linux-block, linux-kernel, linux-omap, linux-remoteproc,
	linux-mmc, linux-mtd, linux-arm-kernel, linux-nvme, linux-s390,
	linux-scsi
  Cc: axboe, efremov, josef, idryomov, dongsheng.yang, haris.iqbal,
	jinpu.wang, mst, jasowang, pbonzini, stefanha, ohad, andersson,
	baolin.wang, ulf.hansson, richard, miquel.raynal, vigneshr,
	marcan, sven, alyssa, kbusch, hch, sagi, sth, hoeppner, hca, gor,
	agordeev, borntraeger, svens, jejb, martin.petersen, hare, kch,
	bhelgaas, john.garry, mcgrof, christophe.jaillet, vaibhavgupta40,
	wsa+renesas, damien.lemoal, johannes.thumshirn, bvanassche,
	ming.lei, shinichiro.kawasaki, vincent.fu, christoph.boehmwalder,
	joel, vincent.whitchurch, nbd, ceph-devel, virtualization, asahi

Use the block layer helper to initialize the common fields of tag_set
such as blk_mq_ops, number of h/w queues, queue depth, command size,
numa_node, timeout, BLK_MQ_F_XXX flags, driver data. This initialization
is spread all over the block drivers. This avoids the code repetation of
the inialization code of the tag set in current block drivers and any
future ones.

Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
---
 block/blk-mq.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index e3a8dd81bbe2..d4cb5c44a53d 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -4455,12 +4455,9 @@ int blk_mq_alloc_sq_tag_set(struct blk_mq_tag_set *set,
 		unsigned int set_flags)
 {
 	memset(set, 0, sizeof(*set));
-	set->ops = ops;
-	set->nr_hw_queues = 1;
+	blk_mq_init_tag_set(set, ops, 1, queue_depth, 0, NUMA_NO_NODE, 0,
+			set_flags, NULL);
 	set->nr_maps = 1;
-	set->queue_depth = queue_depth;
-	set->numa_node = NUMA_NO_NODE;
-	set->flags = set_flags;
 	return blk_mq_alloc_tag_set(set);
 }
 EXPORT_SYMBOL_GPL(blk_mq_alloc_sq_tag_set);
-- 
2.29.0


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

* [RFC PATCH 10/21] amiflop: use lib tagset init helper
  2022-10-05  3:22 [RFC PATCH 00/21] block: add and use init tagset helper Chaitanya Kulkarni
                   ` (8 preceding siblings ...)
  2022-10-05  3:22 ` [RFC PATCH 09/21] block: " Chaitanya Kulkarni
@ 2022-10-05  3:22 ` Chaitanya Kulkarni
  2022-10-05  3:22 ` [RFC PATCH 11/21] floppy: " Chaitanya Kulkarni
                   ` (11 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Chaitanya Kulkarni @ 2022-10-05  3:22 UTC (permalink / raw)
  To: linux-block, linux-kernel, linux-omap, linux-remoteproc,
	linux-mmc, linux-mtd, linux-arm-kernel, linux-nvme, linux-s390,
	linux-scsi
  Cc: axboe, efremov, josef, idryomov, dongsheng.yang, haris.iqbal,
	jinpu.wang, mst, jasowang, pbonzini, stefanha, ohad, andersson,
	baolin.wang, ulf.hansson, richard, miquel.raynal, vigneshr,
	marcan, sven, alyssa, kbusch, hch, sagi, sth, hoeppner, hca, gor,
	agordeev, borntraeger, svens, jejb, martin.petersen, hare, kch,
	bhelgaas, john.garry, mcgrof, christophe.jaillet, vaibhavgupta40,
	wsa+renesas, damien.lemoal, johannes.thumshirn, bvanassche,
	ming.lei, shinichiro.kawasaki, vincent.fu, christoph.boehmwalder,
	joel, vincent.whitchurch, nbd, ceph-devel, virtualization, asahi

Use the block layer helper to initialize the common fields of tag_set
such as blk_mq_ops, number of h/w queues, queue depth, command size,
numa_node, timeout, BLK_MQ_F_XXX flags, driver data. This initialization
is spread all over the block drivers. This avoids the code repetation of
the inialization code of the tag set in current block drivers and any
future ones.

Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
---
 drivers/block/amiflop.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c
index 4c8b2ba579ee..af3f9a4b46ab 100644
--- a/drivers/block/amiflop.c
+++ b/drivers/block/amiflop.c
@@ -1813,12 +1813,10 @@ static int fd_alloc_drive(int drive)
 		goto out;
 
 	memset(&unit[drive].tag_set, 0, sizeof(unit[drive].tag_set));
-	unit[drive].tag_set.ops = &amiflop_mq_ops;
-	unit[drive].tag_set.nr_hw_queues = 1;
+	blk_mq_init_tag_set(&unit[drive].tag_set, &amiflop_mq_ops, 1, 2, 0,
+			NUMA_NO_NODE, 0, BLK_MQ_F_SHOULD_MERGE, NULL);
 	unit[drive].tag_set.nr_maps = 1;
-	unit[drive].tag_set.queue_depth = 2;
-	unit[drive].tag_set.numa_node = NUMA_NO_NODE;
-	unit[drive].tag_set.flags = BLK_MQ_F_SHOULD_MERGE;
+
 	if (blk_mq_alloc_tag_set(&unit[drive].tag_set))
 		goto out_cleanup_trackbuf;
 
-- 
2.29.0


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

* [RFC PATCH 11/21] floppy: use lib tagset init helper
  2022-10-05  3:22 [RFC PATCH 00/21] block: add and use init tagset helper Chaitanya Kulkarni
                   ` (9 preceding siblings ...)
  2022-10-05  3:22 ` [RFC PATCH 10/21] amiflop: " Chaitanya Kulkarni
@ 2022-10-05  3:22 ` Chaitanya Kulkarni
  2022-10-05  3:22 ` [RFC PATCH 12/21] mtip32xx: " Chaitanya Kulkarni
                   ` (10 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Chaitanya Kulkarni @ 2022-10-05  3:22 UTC (permalink / raw)
  To: linux-block, linux-kernel, linux-omap, linux-remoteproc,
	linux-mmc, linux-mtd, linux-arm-kernel, linux-nvme, linux-s390,
	linux-scsi
  Cc: axboe, efremov, josef, idryomov, dongsheng.yang, haris.iqbal,
	jinpu.wang, mst, jasowang, pbonzini, stefanha, ohad, andersson,
	baolin.wang, ulf.hansson, richard, miquel.raynal, vigneshr,
	marcan, sven, alyssa, kbusch, hch, sagi, sth, hoeppner, hca, gor,
	agordeev, borntraeger, svens, jejb, martin.petersen, hare, kch,
	bhelgaas, john.garry, mcgrof, christophe.jaillet, vaibhavgupta40,
	wsa+renesas, damien.lemoal, johannes.thumshirn, bvanassche,
	ming.lei, shinichiro.kawasaki, vincent.fu, christoph.boehmwalder,
	joel, vincent.whitchurch, nbd, ceph-devel, virtualization, asahi

Use the block layer helper to initialize the common fields of tag_set
such as blk_mq_ops, number of h/w queues, queue depth, command size,
numa_node, timeout, BLK_MQ_F_XXX flags, driver data. This initialization
is spread all over the block drivers. This avoids the code repetation of
the inialization code of the tag set in current block drivers and any
future ones.

Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
---
 drivers/block/floppy.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index ccad3d7b3ddd..3a3260e6ac5c 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -4582,12 +4582,9 @@ static int __init do_floppy_init(void)
 
 	for (drive = 0; drive < N_DRIVE; drive++) {
 		memset(&tag_sets[drive], 0, sizeof(tag_sets[drive]));
-		tag_sets[drive].ops = &floppy_mq_ops;
-		tag_sets[drive].nr_hw_queues = 1;
+		blk_mq_init_tag_set(&tag_sets[drive], &floppy_mq_ops, 1, 2,
+				0, NUMA_NO_NODE, 0, BLK_MQ_F_SHOULD_MERGE, NULL);
 		tag_sets[drive].nr_maps = 1;
-		tag_sets[drive].queue_depth = 2;
-		tag_sets[drive].numa_node = NUMA_NO_NODE;
-		tag_sets[drive].flags = BLK_MQ_F_SHOULD_MERGE;
 		err = blk_mq_alloc_tag_set(&tag_sets[drive]);
 		if (err)
 			goto out_put_disk;
-- 
2.29.0


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

* [RFC PATCH 12/21] mtip32xx: use lib tagset init helper
  2022-10-05  3:22 [RFC PATCH 00/21] block: add and use init tagset helper Chaitanya Kulkarni
                   ` (10 preceding siblings ...)
  2022-10-05  3:22 ` [RFC PATCH 11/21] floppy: " Chaitanya Kulkarni
@ 2022-10-05  3:22 ` Chaitanya Kulkarni
  2022-10-05  3:22 ` [RFC PATCH 13/21] z3ram: " Chaitanya Kulkarni
                   ` (9 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Chaitanya Kulkarni @ 2022-10-05  3:22 UTC (permalink / raw)
  To: linux-block, linux-kernel, linux-omap, linux-remoteproc,
	linux-mmc, linux-mtd, linux-arm-kernel, linux-nvme, linux-s390,
	linux-scsi
  Cc: axboe, efremov, josef, idryomov, dongsheng.yang, haris.iqbal,
	jinpu.wang, mst, jasowang, pbonzini, stefanha, ohad, andersson,
	baolin.wang, ulf.hansson, richard, miquel.raynal, vigneshr,
	marcan, sven, alyssa, kbusch, hch, sagi, sth, hoeppner, hca, gor,
	agordeev, borntraeger, svens, jejb, martin.petersen, hare, kch,
	bhelgaas, john.garry, mcgrof, christophe.jaillet, vaibhavgupta40,
	wsa+renesas, damien.lemoal, johannes.thumshirn, bvanassche,
	ming.lei, shinichiro.kawasaki, vincent.fu, christoph.boehmwalder,
	joel, vincent.whitchurch, nbd, ceph-devel, virtualization, asahi

Use the block layer helper to initialize the common fields of tag_set
such as blk_mq_ops, number of h/w queues, queue depth, command size,
numa_node, timeout, BLK_MQ_F_XXX flags, driver data. This initialization
is spread all over the block drivers. This avoids the code repetation of
the inialization code of the tag set in current block drivers and any
future ones.

Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
---
 drivers/block/mtip32xx/mtip32xx.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index 815d77ba6381..43727c526edd 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -3414,16 +3414,11 @@ static int mtip_block_initialize(struct driver_data *dd)
 	}
 
 	memset(&dd->tags, 0, sizeof(dd->tags));
-	dd->tags.ops = &mtip_mq_ops;
-	dd->tags.nr_hw_queues = 1;
-	dd->tags.queue_depth = MTIP_MAX_COMMAND_SLOTS;
+	blk_mq_init_tag_set(&dd->tags, &mtip_mq_ops, 1,
+			MTIP_MAX_COMMAND_SLOTS, sizeof(struct mtip_cmd),
+			dd->numa_node, MTIP_NCQ_CMD_TIMEOUT_MS,
+			BLK_MQ_F_SHOULD_MERGE, dd);
 	dd->tags.reserved_tags = 1;
-	dd->tags.cmd_size = sizeof(struct mtip_cmd);
-	dd->tags.numa_node = dd->numa_node;
-	dd->tags.flags = BLK_MQ_F_SHOULD_MERGE;
-	dd->tags.driver_data = dd;
-	dd->tags.timeout = MTIP_NCQ_CMD_TIMEOUT_MS;
-
 	rv = blk_mq_alloc_tag_set(&dd->tags);
 	if (rv) {
 		dev_err(&dd->pdev->dev,
-- 
2.29.0


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

* [RFC PATCH 13/21] z3ram: use lib tagset init helper
  2022-10-05  3:22 [RFC PATCH 00/21] block: add and use init tagset helper Chaitanya Kulkarni
                   ` (11 preceding siblings ...)
  2022-10-05  3:22 ` [RFC PATCH 12/21] mtip32xx: " Chaitanya Kulkarni
@ 2022-10-05  3:22 ` Chaitanya Kulkarni
  2022-10-05  3:22 ` [RFC PATCH 14/21] scm_blk: " Chaitanya Kulkarni
                   ` (8 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Chaitanya Kulkarni @ 2022-10-05  3:22 UTC (permalink / raw)
  To: linux-block, linux-kernel, linux-omap, linux-remoteproc,
	linux-mmc, linux-mtd, linux-arm-kernel, linux-nvme, linux-s390,
	linux-scsi
  Cc: axboe, efremov, josef, idryomov, dongsheng.yang, haris.iqbal,
	jinpu.wang, mst, jasowang, pbonzini, stefanha, ohad, andersson,
	baolin.wang, ulf.hansson, richard, miquel.raynal, vigneshr,
	marcan, sven, alyssa, kbusch, hch, sagi, sth, hoeppner, hca, gor,
	agordeev, borntraeger, svens, jejb, martin.petersen, hare, kch,
	bhelgaas, john.garry, mcgrof, christophe.jaillet, vaibhavgupta40,
	wsa+renesas, damien.lemoal, johannes.thumshirn, bvanassche,
	ming.lei, shinichiro.kawasaki, vincent.fu, christoph.boehmwalder,
	joel, vincent.whitchurch, nbd, ceph-devel, virtualization, asahi

Use the block layer helper to initialize the common fields of tag_set
such as blk_mq_ops, number of h/w queues, queue depth, command size,
numa_node, timeout, BLK_MQ_F_XXX flags, driver data. This initialization
is spread all over the block drivers. This avoids the code repetation of
the inialization code of the tag set in current block drivers and any
future ones.

Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
---
 drivers/block/z2ram.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c
index c1e85f356e4d..b381d652d911 100644
--- a/drivers/block/z2ram.c
+++ b/drivers/block/z2ram.c
@@ -351,12 +351,9 @@ static int __init z2_init(void)
 	if (register_blkdev(Z2RAM_MAJOR, DEVICE_NAME))
 		return -EBUSY;
 
-	tag_set.ops = &z2_mq_ops;
-	tag_set.nr_hw_queues = 1;
 	tag_set.nr_maps = 1;
-	tag_set.queue_depth = 16;
-	tag_set.numa_node = NUMA_NO_NODE;
-	tag_set.flags = BLK_MQ_F_SHOULD_MERGE;
+	blk_mq_init_tag_set(&tag_set, &z2_mq_ops, 1, 18, 0, NUMA_NO_NODE, 0,
+			BLK_MQ_F_SHOULD_MERGE, NULL);
 	ret = blk_mq_alloc_tag_set(&tag_set);
 	if (ret)
 		goto out_unregister_blkdev;
-- 
2.29.0


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

* [RFC PATCH 14/21] scm_blk: use lib tagset init helper
  2022-10-05  3:22 [RFC PATCH 00/21] block: add and use init tagset helper Chaitanya Kulkarni
                   ` (12 preceding siblings ...)
  2022-10-05  3:22 ` [RFC PATCH 13/21] z3ram: " Chaitanya Kulkarni
@ 2022-10-05  3:22 ` Chaitanya Kulkarni
  2022-10-05  3:22 ` [RFC PATCH 15/21] ubi: " Chaitanya Kulkarni
                   ` (7 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Chaitanya Kulkarni @ 2022-10-05  3:22 UTC (permalink / raw)
  To: linux-block, linux-kernel, linux-omap, linux-remoteproc,
	linux-mmc, linux-mtd, linux-arm-kernel, linux-nvme, linux-s390,
	linux-scsi
  Cc: axboe, efremov, josef, idryomov, dongsheng.yang, haris.iqbal,
	jinpu.wang, mst, jasowang, pbonzini, stefanha, ohad, andersson,
	baolin.wang, ulf.hansson, richard, miquel.raynal, vigneshr,
	marcan, sven, alyssa, kbusch, hch, sagi, sth, hoeppner, hca, gor,
	agordeev, borntraeger, svens, jejb, martin.petersen, hare, kch,
	bhelgaas, john.garry, mcgrof, christophe.jaillet, vaibhavgupta40,
	wsa+renesas, damien.lemoal, johannes.thumshirn, bvanassche,
	ming.lei, shinichiro.kawasaki, vincent.fu, christoph.boehmwalder,
	joel, vincent.whitchurch, nbd, ceph-devel, virtualization, asahi

Use the block layer helper to initialize the common fields of tag_set
such as blk_mq_ops, number of h/w queues, queue depth, command size,
numa_node, timeout, BLK_MQ_F_XXX flags, driver data. This initialization
is spread all over the block drivers. This avoids the code repetation of
the inialization code of the tag set in current block drivers and any
future ones.

Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
---
 drivers/s390/block/scm_blk.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/s390/block/scm_blk.c b/drivers/s390/block/scm_blk.c
index 0c1df1d5f1ac..4b1653fd71a5 100644
--- a/drivers/s390/block/scm_blk.c
+++ b/drivers/s390/block/scm_blk.c
@@ -450,13 +450,9 @@ int scm_blk_dev_setup(struct scm_blk_dev *bdev, struct scm_device *scmdev)
 	spin_lock_init(&bdev->lock);
 	atomic_set(&bdev->queued_reqs, 0);
 
-	bdev->tag_set.ops = &scm_mq_ops;
-	bdev->tag_set.cmd_size = sizeof(blk_status_t);
-	bdev->tag_set.nr_hw_queues = nr_requests;
-	bdev->tag_set.queue_depth = nr_requests_per_io * nr_requests;
-	bdev->tag_set.flags = BLK_MQ_F_SHOULD_MERGE;
-	bdev->tag_set.numa_node = NUMA_NO_NODE;
-
+	blk_mq_init_tag_set(&bdev->tag_set, nr_requests,
+			nr_requests_per_io * nr_requests, sizeof(blk_status_t),
+			NUMA_NO_NODE, BLK_MQ_F_SHOULD_MERGE, NULL);
 	ret = blk_mq_alloc_tag_set(&bdev->tag_set);
 	if (ret)
 		goto out;
-- 
2.29.0


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

* [RFC PATCH 15/21] ubi: use lib tagset init helper
  2022-10-05  3:22 [RFC PATCH 00/21] block: add and use init tagset helper Chaitanya Kulkarni
                   ` (13 preceding siblings ...)
  2022-10-05  3:22 ` [RFC PATCH 14/21] scm_blk: " Chaitanya Kulkarni
@ 2022-10-05  3:22 ` Chaitanya Kulkarni
  2022-10-05  3:22 ` [RFC PATCH 16/21] mmc: core: " Chaitanya Kulkarni
                   ` (6 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Chaitanya Kulkarni @ 2022-10-05  3:22 UTC (permalink / raw)
  To: linux-block, linux-kernel, linux-omap, linux-remoteproc,
	linux-mmc, linux-mtd, linux-arm-kernel, linux-nvme, linux-s390,
	linux-scsi
  Cc: axboe, efremov, josef, idryomov, dongsheng.yang, haris.iqbal,
	jinpu.wang, mst, jasowang, pbonzini, stefanha, ohad, andersson,
	baolin.wang, ulf.hansson, richard, miquel.raynal, vigneshr,
	marcan, sven, alyssa, kbusch, hch, sagi, sth, hoeppner, hca, gor,
	agordeev, borntraeger, svens, jejb, martin.petersen, hare, kch,
	bhelgaas, john.garry, mcgrof, christophe.jaillet, vaibhavgupta40,
	wsa+renesas, damien.lemoal, johannes.thumshirn, bvanassche,
	ming.lei, shinichiro.kawasaki, vincent.fu, christoph.boehmwalder,
	joel, vincent.whitchurch, nbd, ceph-devel, virtualization, asahi

Use the block layer helper to initialize the common fields of tag_set
such as blk_mq_ops, number of h/w queues, queue depth, command size,
numa_node, timeout, BLK_MQ_F_XXX flags, driver data. This initialization
is spread all over the block drivers. This avoids the code repetation of
the inialization code of the tag set in current block drivers and any
future ones.

Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
---
 drivers/mtd/ubi/block.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c
index 4cf67a2a0d04..809e946cfc93 100644
--- a/drivers/mtd/ubi/block.c
+++ b/drivers/mtd/ubi/block.c
@@ -398,14 +398,9 @@ int ubiblock_create(struct ubi_volume_info *vi)
 	dev->vol_id = vi->vol_id;
 	dev->leb_size = vi->usable_leb_size;
 
-	dev->tag_set.ops = &ubiblock_mq_ops;
-	dev->tag_set.queue_depth = 64;
-	dev->tag_set.numa_node = NUMA_NO_NODE;
-	dev->tag_set.flags = BLK_MQ_F_SHOULD_MERGE;
-	dev->tag_set.cmd_size = sizeof(struct ubiblock_pdu);
-	dev->tag_set.driver_data = dev;
-	dev->tag_set.nr_hw_queues = 1;
-
+	blk_mq_init_tag_set(&dev->tag_set, &ubiblock_mq_ops, 1, 64,
+			sizeof(struct ubiblock_pdu), NUMA_NO_NODE, 0,
+			BLK_MQ_F_SHOULD_MERGE, dev);
 	ret = blk_mq_alloc_tag_set(&dev->tag_set);
 	if (ret) {
 		dev_err(disk_to_dev(dev->gd), "blk_mq_alloc_tag_set failed");
-- 
2.29.0


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

* [RFC PATCH 16/21] mmc: core: use lib tagset init helper
  2022-10-05  3:22 [RFC PATCH 00/21] block: add and use init tagset helper Chaitanya Kulkarni
                   ` (14 preceding siblings ...)
  2022-10-05  3:22 ` [RFC PATCH 15/21] ubi: " Chaitanya Kulkarni
@ 2022-10-05  3:22 ` Chaitanya Kulkarni
  2022-10-05  3:22 ` [RFC PATCH 17/21] dasd: " Chaitanya Kulkarni
                   ` (5 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Chaitanya Kulkarni @ 2022-10-05  3:22 UTC (permalink / raw)
  To: linux-block, linux-kernel, linux-omap, linux-remoteproc,
	linux-mmc, linux-mtd, linux-arm-kernel, linux-nvme, linux-s390,
	linux-scsi
  Cc: axboe, efremov, josef, idryomov, dongsheng.yang, haris.iqbal,
	jinpu.wang, mst, jasowang, pbonzini, stefanha, ohad, andersson,
	baolin.wang, ulf.hansson, richard, miquel.raynal, vigneshr,
	marcan, sven, alyssa, kbusch, hch, sagi, sth, hoeppner, hca, gor,
	agordeev, borntraeger, svens, jejb, martin.petersen, hare, kch,
	bhelgaas, john.garry, mcgrof, christophe.jaillet, vaibhavgupta40,
	wsa+renesas, damien.lemoal, johannes.thumshirn, bvanassche,
	ming.lei, shinichiro.kawasaki, vincent.fu, christoph.boehmwalder,
	joel, vincent.whitchurch, nbd, ceph-devel, virtualization, asahi

Use the block layer helper to initialize the common fields of tag_set
such as blk_mq_ops, number of h/w queues, queue depth, command size,
numa_node, timeout, BLK_MQ_F_XXX flags, driver data. This initialization
is spread all over the block drivers. This avoids the code repetation of
the inialization code of the tag set in current block drivers and any
future ones.

Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
---
 drivers/mmc/core/queue.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/mmc/core/queue.c b/drivers/mmc/core/queue.c
index fefaa901b50f..599a34a5680a 100644
--- a/drivers/mmc/core/queue.c
+++ b/drivers/mmc/core/queue.c
@@ -417,7 +417,6 @@ struct gendisk *mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card)
 	spin_lock_init(&mq->lock);
 
 	memset(&mq->tag_set, 0, sizeof(mq->tag_set));
-	mq->tag_set.ops = &mmc_mq_ops;
 	/*
 	 * The queue depth for CQE must match the hardware because the request
 	 * tag is used to index the hardware queue.
@@ -427,11 +426,9 @@ struct gendisk *mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card)
 			min_t(int, card->ext_csd.cmdq_depth, host->cqe_qdepth);
 	else
 		mq->tag_set.queue_depth = MMC_QUEUE_DEPTH;
-	mq->tag_set.numa_node = NUMA_NO_NODE;
-	mq->tag_set.flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_BLOCKING;
-	mq->tag_set.nr_hw_queues = 1;
-	mq->tag_set.cmd_size = sizeof(struct mmc_queue_req);
-	mq->tag_set.driver_data = mq;
+	blk_mq_init_tag_set(&mq->tag_set, &mmc_mq_ops, 1, 0,
+			sizeof(struct mmc_queue_req), NUMA_NO_NODE, 0,
+			BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_BLOCKING, mq);
 
 	/*
 	 * Since blk_mq_alloc_tag_set() calls .init_request() of mmc_mq_ops,
-- 
2.29.0


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

* [RFC PATCH 17/21] dasd: use lib tagset init helper
  2022-10-05  3:22 [RFC PATCH 00/21] block: add and use init tagset helper Chaitanya Kulkarni
                   ` (15 preceding siblings ...)
  2022-10-05  3:22 ` [RFC PATCH 16/21] mmc: core: " Chaitanya Kulkarni
@ 2022-10-05  3:22 ` Chaitanya Kulkarni
  2022-10-05  3:22 ` [RFC PATCH 18/21] nvme-core: use lib tagset init helper for I/O q Chaitanya Kulkarni
                   ` (4 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Chaitanya Kulkarni @ 2022-10-05  3:22 UTC (permalink / raw)
  To: linux-block, linux-kernel, linux-omap, linux-remoteproc,
	linux-mmc, linux-mtd, linux-arm-kernel, linux-nvme, linux-s390,
	linux-scsi
  Cc: axboe, efremov, josef, idryomov, dongsheng.yang, haris.iqbal,
	jinpu.wang, mst, jasowang, pbonzini, stefanha, ohad, andersson,
	baolin.wang, ulf.hansson, richard, miquel.raynal, vigneshr,
	marcan, sven, alyssa, kbusch, hch, sagi, sth, hoeppner, hca, gor,
	agordeev, borntraeger, svens, jejb, martin.petersen, hare, kch,
	bhelgaas, john.garry, mcgrof, christophe.jaillet, vaibhavgupta40,
	wsa+renesas, damien.lemoal, johannes.thumshirn, bvanassche,
	ming.lei, shinichiro.kawasaki, vincent.fu, christoph.boehmwalder,
	joel, vincent.whitchurch, nbd, ceph-devel, virtualization, asahi

Use the block layer helper to initialize the common fields of tag_set
such as blk_mq_ops, number of h/w queues, queue depth, command size,
numa_node, timeout, BLK_MQ_F_XXX flags, driver data. This initialization
is spread all over the block drivers. This avoids the code repetation of
the inialization code of the tag set in current block drivers and any
future ones.

Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
---
 drivers/s390/block/dasd_genhd.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/s390/block/dasd_genhd.c b/drivers/s390/block/dasd_genhd.c
index 998a961e1704..a7c55b7e5f6d 100644
--- a/drivers/s390/block/dasd_genhd.c
+++ b/drivers/s390/block/dasd_genhd.c
@@ -48,12 +48,9 @@ int dasd_gendisk_alloc(struct dasd_block *block)
 	if (base->devindex >= DASD_PER_MAJOR)
 		return -EBUSY;
 
-	block->tag_set.ops = &dasd_mq_ops;
-	block->tag_set.cmd_size = sizeof(struct dasd_ccw_req);
-	block->tag_set.nr_hw_queues = nr_hw_queues;
-	block->tag_set.queue_depth = queue_depth;
-	block->tag_set.flags = BLK_MQ_F_SHOULD_MERGE;
-	block->tag_set.numa_node = NUMA_NO_NODE;
+	blk_mq_alloc_tag_set(&block->tag_set, &dasd_mq_ops, nr_hw_queues,
+			queue_depth, sizeof(struct dasd_ccw_req), NUMA_NO_NODE,
+			0, BLK_MQ_F_SHOULD_MERGE, NULL);
 	rc = blk_mq_alloc_tag_set(&block->tag_set);
 	if (rc)
 		return rc;
-- 
2.29.0


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

* [RFC PATCH 18/21] nvme-core: use lib tagset init helper for I/O q
  2022-10-05  3:22 [RFC PATCH 00/21] block: add and use init tagset helper Chaitanya Kulkarni
                   ` (16 preceding siblings ...)
  2022-10-05  3:22 ` [RFC PATCH 17/21] dasd: " Chaitanya Kulkarni
@ 2022-10-05  3:22 ` Chaitanya Kulkarni
  2022-10-05  3:22 ` [RFC PATCH 19/21] nvme-core: use lib tagset init helper for adminq Chaitanya Kulkarni
                   ` (3 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Chaitanya Kulkarni @ 2022-10-05  3:22 UTC (permalink / raw)
  To: linux-block, linux-kernel, linux-omap, linux-remoteproc,
	linux-mmc, linux-mtd, linux-arm-kernel, linux-nvme, linux-s390,
	linux-scsi
  Cc: axboe, efremov, josef, idryomov, dongsheng.yang, haris.iqbal,
	jinpu.wang, mst, jasowang, pbonzini, stefanha, ohad, andersson,
	baolin.wang, ulf.hansson, richard, miquel.raynal, vigneshr,
	marcan, sven, alyssa, kbusch, hch, sagi, sth, hoeppner, hca, gor,
	agordeev, borntraeger, svens, jejb, martin.petersen, hare, kch,
	bhelgaas, john.garry, mcgrof, christophe.jaillet, vaibhavgupta40,
	wsa+renesas, damien.lemoal, johannes.thumshirn, bvanassche,
	ming.lei, shinichiro.kawasaki, vincent.fu, christoph.boehmwalder,
	joel, vincent.whitchurch, nbd, ceph-devel, virtualization, asahi

Use the block layer helper to initialize the common fields of tag_set
such as blk_mq_ops, number of h/w queues, queue depth, command size,
numa_node, timeout, BLK_MQ_F_XXX flags, driver data. This initialization
is spread all over the block drivers. This avoids the code repetation of
the inialization code of the tag set in current block drivers and any
future ones.

Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
---
 drivers/nvme/host/core.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 965a4c3e9d44..639767759c41 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -4869,15 +4869,10 @@ int nvme_alloc_io_tag_set(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set,
 	int ret;
 
 	memset(set, 0, sizeof(*set));
-	set->ops = ops;
-	set->queue_depth = ctrl->sqsize + 1;
+	blk_mq_init_tag_set(set, ops, ctrl->queue_count - 1, ctrl->sqsize + 1,
+			cmd_size, ctrl->numa_node, NVME_IO_TIMEOUT, flags,
+			ctrl);
 	set->reserved_tags = NVMF_RESERVED_TAGS;
-	set->numa_node = ctrl->numa_node;
-	set->flags = flags;
-	set->cmd_size = cmd_size,
-	set->driver_data = ctrl;
-	set->nr_hw_queues = ctrl->queue_count - 1;
-	set->timeout = NVME_IO_TIMEOUT;
 	if (ops->map_queues)
 		set->nr_maps = ctrl->opts->nr_poll_queues ? HCTX_MAX_TYPES : 2;
 	ret = blk_mq_alloc_tag_set(set);
-- 
2.29.0


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

* [RFC PATCH 19/21] nvme-core: use lib tagset init helper for adminq
  2022-10-05  3:22 [RFC PATCH 00/21] block: add and use init tagset helper Chaitanya Kulkarni
                   ` (17 preceding siblings ...)
  2022-10-05  3:22 ` [RFC PATCH 18/21] nvme-core: use lib tagset init helper for I/O q Chaitanya Kulkarni
@ 2022-10-05  3:22 ` Chaitanya Kulkarni
  2022-10-05  3:22 ` [RFC PATCH 20/21] nvme-apple: use lib tagset init helper Chaitanya Kulkarni
                   ` (2 subsequent siblings)
  21 siblings, 0 replies; 27+ messages in thread
From: Chaitanya Kulkarni @ 2022-10-05  3:22 UTC (permalink / raw)
  To: linux-block, linux-kernel, linux-omap, linux-remoteproc,
	linux-mmc, linux-mtd, linux-arm-kernel, linux-nvme, linux-s390,
	linux-scsi
  Cc: axboe, efremov, josef, idryomov, dongsheng.yang, haris.iqbal,
	jinpu.wang, mst, jasowang, pbonzini, stefanha, ohad, andersson,
	baolin.wang, ulf.hansson, richard, miquel.raynal, vigneshr,
	marcan, sven, alyssa, kbusch, hch, sagi, sth, hoeppner, hca, gor,
	agordeev, borntraeger, svens, jejb, martin.petersen, hare, kch,
	bhelgaas, john.garry, mcgrof, christophe.jaillet, vaibhavgupta40,
	wsa+renesas, damien.lemoal, johannes.thumshirn, bvanassche,
	ming.lei, shinichiro.kawasaki, vincent.fu, christoph.boehmwalder,
	joel, vincent.whitchurch, nbd, ceph-devel, virtualization, asahi

Use the block layer helper to initialize the common fields of tag_set
such as blk_mq_ops, number of h/w queues, queue depth, command size,
numa_node, timeout, BLK_MQ_F_XXX flags, driver data. This initialization
is spread all over the block drivers. This avoids the code repetation of
the inialization code of the tag set in current block drivers and any
future ones.

Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
---
 drivers/nvme/host/core.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 639767759c41..69789c2c1ba1 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -4814,16 +4814,10 @@ int nvme_alloc_admin_tag_set(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set,
 	int ret;
 
 	memset(set, 0, sizeof(*set));
-	set->ops = ops;
-	set->queue_depth = NVME_AQ_MQ_TAG_DEPTH;
 	if (ctrl->ops->flags & NVME_F_FABRICS)
 		set->reserved_tags = NVMF_RESERVED_TAGS;
-	set->numa_node = ctrl->numa_node;
-	set->flags = flags;
-	set->cmd_size = cmd_size;
-	set->driver_data = ctrl;
-	set->nr_hw_queues = 1;
-	set->timeout = NVME_ADMIN_TIMEOUT;
+	blk_mq_init_tag_set(set, ops, 1, NVME_AQ_MQ_TAG_DEPTH, cmd_size,
+			ctrl->numa_node, NVME_ADMIN_TIMEOUT, flags, ctrl);
 	ret = blk_mq_alloc_tag_set(set);
 	if (ret)
 		return ret;
-- 
2.29.0


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

* [RFC PATCH 20/21] nvme-apple: use lib tagset init helper
  2022-10-05  3:22 [RFC PATCH 00/21] block: add and use init tagset helper Chaitanya Kulkarni
                   ` (18 preceding siblings ...)
  2022-10-05  3:22 ` [RFC PATCH 19/21] nvme-core: use lib tagset init helper for adminq Chaitanya Kulkarni
@ 2022-10-05  3:22 ` Chaitanya Kulkarni
  2022-10-05  3:22 ` [RFC PATCH 21/21] nvme-pci: " Chaitanya Kulkarni
  2022-10-07 18:26 ` [RFC PATCH 00/21] block: add and use init tagset helper Luis Chamberlain
  21 siblings, 0 replies; 27+ messages in thread
From: Chaitanya Kulkarni @ 2022-10-05  3:22 UTC (permalink / raw)
  To: linux-block, linux-kernel, linux-omap, linux-remoteproc,
	linux-mmc, linux-mtd, linux-arm-kernel, linux-nvme, linux-s390,
	linux-scsi
  Cc: axboe, efremov, josef, idryomov, dongsheng.yang, haris.iqbal,
	jinpu.wang, mst, jasowang, pbonzini, stefanha, ohad, andersson,
	baolin.wang, ulf.hansson, richard, miquel.raynal, vigneshr,
	marcan, sven, alyssa, kbusch, hch, sagi, sth, hoeppner, hca, gor,
	agordeev, borntraeger, svens, jejb, martin.petersen, hare, kch,
	bhelgaas, john.garry, mcgrof, christophe.jaillet, vaibhavgupta40,
	wsa+renesas, damien.lemoal, johannes.thumshirn, bvanassche,
	ming.lei, shinichiro.kawasaki, vincent.fu, christoph.boehmwalder,
	joel, vincent.whitchurch, nbd, ceph-devel, virtualization, asahi

Use the block layer helper to initialize the common fields of tag_set
such as blk_mq_ops, number of h/w queues, queue depth, command size,
numa_node, timeout, BLK_MQ_F_XXX flags, driver data. This initialization
is spread all over the block drivers. This avoids the code repetation of
the inialization code of the tag set in current block drivers and any
future ones.

Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
---
 drivers/nvme/host/apple.c | 25 ++++++++-----------------
 1 file changed, 8 insertions(+), 17 deletions(-)

diff --git a/drivers/nvme/host/apple.c b/drivers/nvme/host/apple.c
index 5fc5ea196b40..bc95c3d93c57 100644
--- a/drivers/nvme/host/apple.c
+++ b/drivers/nvme/host/apple.c
@@ -1228,15 +1228,10 @@ static int apple_nvme_alloc_tagsets(struct apple_nvme *anv)
 {
 	int ret;
 
-	anv->admin_tagset.ops = &apple_nvme_mq_admin_ops;
-	anv->admin_tagset.nr_hw_queues = 1;
-	anv->admin_tagset.queue_depth = APPLE_NVME_AQ_MQ_TAG_DEPTH;
-	anv->admin_tagset.timeout = NVME_ADMIN_TIMEOUT;
-	anv->admin_tagset.numa_node = NUMA_NO_NODE;
-	anv->admin_tagset.cmd_size = sizeof(struct apple_nvme_iod);
-	anv->admin_tagset.flags = BLK_MQ_F_NO_SCHED;
-	anv->admin_tagset.driver_data = &anv->adminq;
-
+	blk_mq_init_tag_set(&anv->admin_tagset, &apple_nvme_mq_admin_ops, 1,
+			APPLE_NVME_AQ_MQ_TAG_DEPTH, sizeof(struct apple_nvme_iod),
+			NUMA_NO_NODE, NVME_ADMIN_TIMEOUT, BLK_MQ_F_NO_SCHED,
+			&anv->adminq);
 	ret = blk_mq_alloc_tag_set(&anv->admin_tagset);
 	if (ret)
 		return ret;
@@ -1245,8 +1240,6 @@ static int apple_nvme_alloc_tagsets(struct apple_nvme *anv)
 	if (ret)
 		return ret;
 
-	anv->tagset.ops = &apple_nvme_mq_ops;
-	anv->tagset.nr_hw_queues = 1;
 	anv->tagset.nr_maps = 1;
 	/*
 	 * Tags are used as an index to the NVMMU and must be unique across
@@ -1254,13 +1247,11 @@ static int apple_nvme_alloc_tagsets(struct apple_nvme *anv)
 	 * must be marked as reserved in the IO queue.
 	 */
 	anv->tagset.reserved_tags = APPLE_NVME_AQ_DEPTH;
-	anv->tagset.queue_depth = APPLE_ANS_MAX_QUEUE_DEPTH - 1;
-	anv->tagset.timeout = NVME_IO_TIMEOUT;
-	anv->tagset.numa_node = NUMA_NO_NODE;
-	anv->tagset.cmd_size = sizeof(struct apple_nvme_iod);
-	anv->tagset.flags = BLK_MQ_F_SHOULD_MERGE;
-	anv->tagset.driver_data = &anv->ioq;
 
+	blk_mq_init_tag_set(&anv->admin_tagset, &apple_nvme_mq_admin_ops, 1,
+			APPLE_ANS_MAX_QUEUE_DEPTH - 1, sizeof(struct apple_nvme_iod),
+			NUMA_NO_NODE, NVME_IO_TIMEOUT, BLK_MQ_F_SHOULD_MERGE,
+			&anv->ioq);
 	ret = blk_mq_alloc_tag_set(&anv->tagset);
 	if (ret)
 		return ret;
-- 
2.29.0


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

* [RFC PATCH 21/21] nvme-pci: use lib tagset init helper
  2022-10-05  3:22 [RFC PATCH 00/21] block: add and use init tagset helper Chaitanya Kulkarni
                   ` (19 preceding siblings ...)
  2022-10-05  3:22 ` [RFC PATCH 20/21] nvme-apple: use lib tagset init helper Chaitanya Kulkarni
@ 2022-10-05  3:22 ` Chaitanya Kulkarni
  2022-10-07 18:26 ` [RFC PATCH 00/21] block: add and use init tagset helper Luis Chamberlain
  21 siblings, 0 replies; 27+ messages in thread
From: Chaitanya Kulkarni @ 2022-10-05  3:22 UTC (permalink / raw)
  To: linux-block, linux-kernel, linux-omap, linux-remoteproc,
	linux-mmc, linux-mtd, linux-arm-kernel, linux-nvme, linux-s390,
	linux-scsi
  Cc: axboe, efremov, josef, idryomov, dongsheng.yang, haris.iqbal,
	jinpu.wang, mst, jasowang, pbonzini, stefanha, ohad, andersson,
	baolin.wang, ulf.hansson, richard, miquel.raynal, vigneshr,
	marcan, sven, alyssa, kbusch, hch, sagi, sth, hoeppner, hca, gor,
	agordeev, borntraeger, svens, jejb, martin.petersen, hare, kch,
	bhelgaas, john.garry, mcgrof, christophe.jaillet, vaibhavgupta40,
	wsa+renesas, damien.lemoal, johannes.thumshirn, bvanassche,
	ming.lei, shinichiro.kawasaki, vincent.fu, christoph.boehmwalder,
	joel, vincent.whitchurch, nbd, ceph-devel, virtualization, asahi

Use the block layer helper to initialize the common fields of tag_set
such as blk_mq_ops, number of h/w queues, queue depth, command size,
numa_node, timeout, BLK_MQ_F_XXX flags, driver data. This initialization
is spread all over the block drivers. This avoids the code repetation of
the inialization code of the tag set in current block drivers and any
future ones.

Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
---
 drivers/nvme/host/pci.c | 25 +++++++------------------
 1 file changed, 7 insertions(+), 18 deletions(-)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 7bbffd2a9beb..52af4b2bb668 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -1757,15 +1757,9 @@ static int nvme_pci_alloc_admin_tag_set(struct nvme_dev *dev)
 {
 	struct blk_mq_tag_set *set = &dev->admin_tagset;
 
-	set->ops = &nvme_mq_admin_ops;
-	set->nr_hw_queues = 1;
-
-	set->queue_depth = NVME_AQ_MQ_TAG_DEPTH;
-	set->timeout = NVME_ADMIN_TIMEOUT;
-	set->numa_node = dev->ctrl.numa_node;
-	set->cmd_size = sizeof(struct nvme_iod);
-	set->flags = BLK_MQ_F_NO_SCHED;
-	set->driver_data = dev;
+	blk_mq_init_tag_set(set, &nvme_mq_admin_ops, 1, NVME_AQ_MQ_TAG_DEPTH,
+			sizeof(struct nvme_iod), dev->ctrl.numa_node,
+			NVME_ADMIN_TIMEOUT, BLK_MQ_F_NO_SCHED, dev);
 
 	if (blk_mq_alloc_tag_set(set))
 		return -ENOMEM;
@@ -2528,20 +2522,15 @@ static void nvme_pci_alloc_tag_set(struct nvme_dev *dev)
 	struct blk_mq_tag_set * set = &dev->tagset;
 	int ret;
 
-	set->ops = &nvme_mq_ops;
-	set->nr_hw_queues = dev->online_queues - 1;
 	set->nr_maps = 1;
 	if (dev->io_queues[HCTX_TYPE_READ])
 		set->nr_maps = 2;
 	if (dev->io_queues[HCTX_TYPE_POLL])
 		set->nr_maps = 3;
-	set->timeout = NVME_IO_TIMEOUT;
-	set->numa_node = dev->ctrl.numa_node;
-	set->queue_depth = min_t(unsigned, dev->q_depth, BLK_MQ_MAX_DEPTH) - 1;
-	set->cmd_size = sizeof(struct nvme_iod);
-	set->flags = BLK_MQ_F_SHOULD_MERGE;
-	set->driver_data = dev;
-
+	blk_mq_init_tag_set(set, &nvme_mq_ops, dev->online_queues - 1,
+			min_t(unsigned, dev->q_depth, BLK_MQ_MAX_DEPTH) - 1,
+			sizeof(struct nvme_iod), dev->ctrl.numa_node,
+			NVME_IO_TIMEOUT, BLK_MQ_F_SHOULD_MERGE, dev);
 	/*
 	 * Some Apple controllers requires tags to be unique
 	 * across admin and IO queue, so reserve the first 32
-- 
2.29.0


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

* Re: [RFC PATCH 01/21] block: add and use init tagset helper
  2022-10-05  3:22 ` [RFC PATCH 01/21] " Chaitanya Kulkarni
@ 2022-10-05  5:11   ` Damien Le Moal
  2022-10-05  9:47     ` Ulf Hansson
  0 siblings, 1 reply; 27+ messages in thread
From: Damien Le Moal @ 2022-10-05  5:11 UTC (permalink / raw)
  To: Chaitanya Kulkarni, linux-block, linux-kernel, linux-omap,
	linux-remoteproc, linux-mmc, linux-mtd, linux-arm-kernel,
	linux-nvme, linux-s390, linux-scsi
  Cc: axboe, efremov, josef, idryomov, dongsheng.yang, haris.iqbal,
	jinpu.wang, mst, jasowang, pbonzini, stefanha, ohad, andersson,
	baolin.wang, ulf.hansson, richard, miquel.raynal, vigneshr,
	marcan, sven, alyssa, kbusch, hch, sagi, sth, hoeppner, hca, gor,
	agordeev, borntraeger, svens, jejb, martin.petersen, hare,
	bhelgaas, john.garry, mcgrof, christophe.jaillet, vaibhavgupta40,
	wsa+renesas, johannes.thumshirn, bvanassche, ming.lei,
	shinichiro.kawasaki, vincent.fu, christoph.boehmwalder, joel,
	vincent.whitchurch, nbd, ceph-devel, virtualization, asahi

On 10/5/22 12:22, Chaitanya Kulkarni wrote:
> Add and use the helper to initialize the common fields of the tag_set
> such as blk_mq_ops, number of h/w queues, queue depth, command size,
> numa_node, timeout, BLK_MQ_F_XXX flags, driver data. This initialization
> is spread all over the block drivers. This avoids the code repetation of
> the inialization code of the tag set in current block drivers and any

s/inialization/initialization
s/repetation/repetition

> future ones.
> 
> Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
> ---
>  block/blk-mq.c                | 20 ++++++++++++++++++++
>  drivers/block/null_blk/main.c | 10 +++-------
>  include/linux/blk-mq.h        |  5 +++++
>  3 files changed, 28 insertions(+), 7 deletions(-)
> 
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index 8070b6c10e8d..e3a8dd81bbe2 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -4341,6 +4341,26 @@ static int blk_mq_alloc_tag_set_tags(struct blk_mq_tag_set *set,
>  	return blk_mq_realloc_tag_set_tags(set, 0, new_nr_hw_queues);
>  }
>  
> +void blk_mq_init_tag_set(struct blk_mq_tag_set *set,
> +		const struct blk_mq_ops *ops, unsigned int nr_hw_queues,
> +		unsigned int queue_depth, unsigned int cmd_size, int numa_node,
> +		unsigned int timeout, unsigned int flags, void *driver_data)

That is an awful lot of arguments... I would be tempted to say pack all
these into a struct but then that would kind of negate this patchset goal.
Using a function with that many arguments will be error prone, and hard to
review... Not a fan.

> +{
> +	if (!set)
> +		return;
> +
> +	set->ops = ops;
> +	set->nr_hw_queues = nr_hw_queues;
> +	set->queue_depth = queue_depth;
> +	set->cmd_size = cmd_size;
> +	set->numa_node = numa_node;
> +	set->timeout = timeout;
> +	set->flags = flags;
> +	set->driver_data = driver_data;
> +}
> +

No blank line here.

> +EXPORT_SYMBOL_GPL(blk_mq_init_tag_set);
> +
>  /*
>   * Alloc a tag set to be associated with one or more request queues.
>   * May fail with EINVAL for various error conditions. May adjust the
> diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
> index 1f154f92f4c2..0b07aab980c4 100644
> --- a/drivers/block/null_blk/main.c
> +++ b/drivers/block/null_blk/main.c
> @@ -1926,13 +1926,9 @@ static int null_init_tag_set(struct nullb *nullb, struct blk_mq_tag_set *set)
>  			flags |= BLK_MQ_F_BLOCKING;
>  	}
>  
> -	set->ops = &null_mq_ops;
> -	set->cmd_size	= sizeof(struct nullb_cmd);
> -	set->flags = flags;
> -	set->driver_data = nullb;
> -	set->nr_hw_queues = hw_queues;
> -	set->queue_depth = queue_depth;
> -	set->numa_node = numa_node;
> +	blk_mq_init_tag_set(set, &null_mq_ops, hw_queues, queue_depth,
> +			sizeof(struct nullb_cmd), numa_node, 0, flags, nullb);
> +
>  	if (poll_queues) {
>  		set->nr_hw_queues += poll_queues;
>  		set->nr_maps = 3;
> diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
> index ba18e9bdb799..06087a8e4398 100644
> --- a/include/linux/blk-mq.h
> +++ b/include/linux/blk-mq.h
> @@ -708,6 +708,11 @@ int blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
>  		struct request_queue *q);
>  void blk_mq_destroy_queue(struct request_queue *);
>  
> +

No need for the extra whiteline.

> +void blk_mq_init_tag_set(struct blk_mq_tag_set *set,
> +		const struct blk_mq_ops *ops, unsigned int nr_hw_queues,
> +		unsigned int queue_depth, unsigned int cmd_size, int numa_node,
> +		unsigned int timeout, unsigned int flags, void *driver_data);
>  int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set);
>  int blk_mq_alloc_sq_tag_set(struct blk_mq_tag_set *set,
>  		const struct blk_mq_ops *ops, unsigned int queue_depth,

-- 
Damien Le Moal
Western Digital Research


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

* Re: [RFC PATCH 01/21] block: add and use init tagset helper
  2022-10-05  5:11   ` Damien Le Moal
@ 2022-10-05  9:47     ` Ulf Hansson
  2022-10-05 16:54       ` Bart Van Assche
  0 siblings, 1 reply; 27+ messages in thread
From: Ulf Hansson @ 2022-10-05  9:47 UTC (permalink / raw)
  To: Chaitanya Kulkarni, Damien Le Moal
  Cc: linux-block, linux-kernel, linux-omap, linux-remoteproc,
	linux-mmc, linux-mtd, linux-arm-kernel, linux-nvme, linux-s390,
	linux-scsi, axboe, efremov, josef, idryomov, dongsheng.yang,
	haris.iqbal, jinpu.wang, mst, jasowang, pbonzini, stefanha, ohad,
	andersson, baolin.wang, richard, miquel.raynal, vigneshr, marcan,
	sven, alyssa, kbusch, hch, sagi, sth, hoeppner, hca, gor,
	agordeev, borntraeger, svens, jejb, martin.petersen, hare,
	bhelgaas, john.garry, mcgrof, christophe.jaillet, vaibhavgupta40,
	wsa+renesas, johannes.thumshirn, bvanassche, ming.lei,
	shinichiro.kawasaki, vincent.fu, christoph.boehmwalder, joel,
	vincent.whitchurch, nbd, ceph-devel, virtualization, asahi

On Wed, 5 Oct 2022 at 07:11, Damien Le Moal
<damien.lemoal@opensource.wdc.com> wrote:
>
> On 10/5/22 12:22, Chaitanya Kulkarni wrote:
> > Add and use the helper to initialize the common fields of the tag_set
> > such as blk_mq_ops, number of h/w queues, queue depth, command size,
> > numa_node, timeout, BLK_MQ_F_XXX flags, driver data. This initialization
> > is spread all over the block drivers. This avoids the code repetation of
> > the inialization code of the tag set in current block drivers and any
>
> s/inialization/initialization
> s/repetation/repetition
>
> > future ones.
> >
> > Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
> > ---
> >  block/blk-mq.c                | 20 ++++++++++++++++++++
> >  drivers/block/null_blk/main.c | 10 +++-------
> >  include/linux/blk-mq.h        |  5 +++++
> >  3 files changed, 28 insertions(+), 7 deletions(-)
> >
> > diff --git a/block/blk-mq.c b/block/blk-mq.c
> > index 8070b6c10e8d..e3a8dd81bbe2 100644
> > --- a/block/blk-mq.c
> > +++ b/block/blk-mq.c
> > @@ -4341,6 +4341,26 @@ static int blk_mq_alloc_tag_set_tags(struct blk_mq_tag_set *set,
> >       return blk_mq_realloc_tag_set_tags(set, 0, new_nr_hw_queues);
> >  }
> >
> > +void blk_mq_init_tag_set(struct blk_mq_tag_set *set,
> > +             const struct blk_mq_ops *ops, unsigned int nr_hw_queues,
> > +             unsigned int queue_depth, unsigned int cmd_size, int numa_node,
> > +             unsigned int timeout, unsigned int flags, void *driver_data)
>
> That is an awful lot of arguments... I would be tempted to say pack all
> these into a struct but then that would kind of negate this patchset goal.
> Using a function with that many arguments will be error prone, and hard to
> review... Not a fan.

I completely agree.

But there is also another problem going down this route. If/when we
realize that there is another parameter needed in the blk_mq_tag_set.
Today that's quite easy to add (assuming the parameter can be
optional), without changing the blk_mq_init_tag_set() interface.

>
> > +{
> > +     if (!set)
> > +             return;
> > +
> > +     set->ops = ops;
> > +     set->nr_hw_queues = nr_hw_queues;
> > +     set->queue_depth = queue_depth;
> > +     set->cmd_size = cmd_size;
> > +     set->numa_node = numa_node;
> > +     set->timeout = timeout;
> > +     set->flags = flags;
> > +     set->driver_data = driver_data;
> > +}
> > +
>

[...]

Kind regards
Uffe

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

* Re: [RFC PATCH 01/21] block: add and use init tagset helper
  2022-10-05  9:47     ` Ulf Hansson
@ 2022-10-05 16:54       ` Bart Van Assche
  0 siblings, 0 replies; 27+ messages in thread
From: Bart Van Assche @ 2022-10-05 16:54 UTC (permalink / raw)
  To: Chaitanya Kulkarni, Damien Le Moal, Ulf Hansson
  Cc: linux-block, linux-kernel, linux-omap, linux-remoteproc,
	linux-mmc, linux-mtd, linux-arm-kernel, linux-nvme, linux-s390,
	linux-scsi, axboe, efremov, josef, idryomov, dongsheng.yang,
	haris.iqbal, jinpu.wang, mst, jasowang, pbonzini, stefanha, ohad,
	andersson, baolin.wang, richard, miquel.raynal, vigneshr, marcan,
	sven, alyssa, kbusch, hch, sagi, sth, hoeppner, hca, gor,
	agordeev, borntraeger, svens, jejb, martin.petersen, hare,
	bhelgaas, john.garry, mcgrof, christophe.jaillet, vaibhavgupta40,
	wsa+renesas, johannes.thumshirn, ming.lei, shinichiro.kawasaki,
	vincent.fu, christoph.boehmwalder, joel, vincent.whitchurch, nbd,
	ceph-devel, virtualization, asahi

On 10/5/22 02:47, Ulf Hansson wrote:
> On Wed, 5 Oct 2022 at 07:11, Damien Le Moal <damien.lemoal@opensource.wdc.com> wrote:
>> On 10/5/22 12:22, Chaitanya Kulkarni wrote:
>>> +void blk_mq_init_tag_set(struct blk_mq_tag_set *set,
>>> +             const struct blk_mq_ops *ops, unsigned int nr_hw_queues,
>>> +             unsigned int queue_depth, unsigned int cmd_size, int numa_node,
>>> +             unsigned int timeout, unsigned int flags, void *driver_data)
>>
>> That is an awful lot of arguments... I would be tempted to say pack all
>> these into a struct but then that would kind of negate this patchset goal.
>> Using a function with that many arguments will be error prone, and hard to
>> review... Not a fan.
> 
> I completely agree.
> 
> But there is also another problem going down this route. If/when we
> realize that there is another parameter needed in the blk_mq_tag_set.
> Today that's quite easy to add (assuming the parameter can be
> optional), without changing the blk_mq_init_tag_set() interface.

Hi Chaitanya,

Please consider to drop the entire patch series. In addition to the 
disadvantages mentioned above I'd like to mention the following 
disadvantages:
* Replacing named member assignments with positional arguments in a
   function call makes code harder to read and harder to verify.
* This patch series makes tree-wide changes without improving the code
   in a substantial way.

Thanks,

Bart.


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

* Re: [RFC PATCH 00/21] block: add and use init tagset helper
  2022-10-05  3:22 [RFC PATCH 00/21] block: add and use init tagset helper Chaitanya Kulkarni
                   ` (20 preceding siblings ...)
  2022-10-05  3:22 ` [RFC PATCH 21/21] nvme-pci: " Chaitanya Kulkarni
@ 2022-10-07 18:26 ` Luis Chamberlain
  2022-10-10  7:55   ` Christoph Hellwig
  21 siblings, 1 reply; 27+ messages in thread
From: Luis Chamberlain @ 2022-10-07 18:26 UTC (permalink / raw)
  To: Chaitanya Kulkarni
  Cc: linux-block, linux-kernel, linux-omap, linux-remoteproc,
	linux-mmc, linux-mtd, linux-arm-kernel, linux-nvme, linux-s390,
	linux-scsi, axboe, efremov, josef, idryomov, dongsheng.yang,
	haris.iqbal, jinpu.wang, mst, jasowang, pbonzini, stefanha, ohad,
	andersson, baolin.wang, ulf.hansson, richard, miquel.raynal,
	vigneshr, marcan, sven, alyssa, kbusch, hch, sagi, sth, hoeppner,
	hca, gor, agordeev, borntraeger, svens, jejb, martin.petersen,
	hare, bhelgaas, john.garry, christophe.jaillet, vaibhavgupta40,
	wsa+renesas, damien.lemoal, johannes.thumshirn, bvanassche,
	ming.lei, shinichiro.kawasaki, vincent.fu, christoph.boehmwalder,
	joel, vincent.whitchurch, nbd, ceph-devel, virtualization, asahi

On Tue, Oct 04, 2022 at 08:22:36PM -0700, Chaitanya Kulkarni wrote:
> Hi,
> 
> Add and use the helper to initialize the common fields of the tag_set
> such as blk_mq_ops, number of h/w queues, queue depth, command size,
> numa_node, timeout, BLK_MQ_F_XXX flags, driver data. This initialization
> is spread all over the block drivers. This avoids repetation of
> inialization code of the tag set in current block drivers and any future
> ones.
> 
> P.S. I'm aware of the EXPORT_SYMBOL_GPL() checkpatch warn just to make
> get some feedback to so I can remove the RFC tag.
> 

*If* there were commonalities at init and these could be broken up into
common groups, each having their own set of calls, then we simplify and
can abstract these. I say this without doing a complete review of the
removals, but if there really isn't much of commonalities I tend to
agree with Bart that open coding this is better.

  Luis

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

* Re: [RFC PATCH 00/21] block: add and use init tagset helper
  2022-10-07 18:26 ` [RFC PATCH 00/21] block: add and use init tagset helper Luis Chamberlain
@ 2022-10-10  7:55   ` Christoph Hellwig
  0 siblings, 0 replies; 27+ messages in thread
From: Christoph Hellwig @ 2022-10-10  7:55 UTC (permalink / raw)
  To: Luis Chamberlain
  Cc: Chaitanya Kulkarni, linux-block, linux-kernel, linux-omap,
	linux-remoteproc, linux-mmc, linux-mtd, linux-arm-kernel,
	linux-nvme, linux-s390, linux-scsi, axboe, efremov, josef,
	idryomov, dongsheng.yang, haris.iqbal, jinpu.wang, mst, jasowang,
	pbonzini, stefanha, ohad, andersson, baolin.wang, ulf.hansson,
	richard, miquel.raynal, vigneshr, marcan, sven, alyssa, kbusch,
	hch, sagi, sth, hoeppner, hca, gor, agordeev, borntraeger, svens,
	jejb, martin.petersen, hare, bhelgaas, john.garry,
	christophe.jaillet, vaibhavgupta40, wsa+renesas, damien.lemoal,
	johannes.thumshirn, bvanassche, ming.lei, shinichiro.kawasaki,
	vincent.fu, christoph.boehmwalder, joel, vincent.whitchurch, nbd,
	ceph-devel, virtualization, asahi

On Fri, Oct 07, 2022 at 11:26:13AM -0700, Luis Chamberlain wrote:
> *If* there were commonalities at init and these could be broken up into
> common groups, each having their own set of calls, then we simplify and
> can abstract these. I say this without doing a complete review of the
> removals, but if there really isn't much of commonalities I tend to
> agree with Bart that open coding this is better.

The commonality is that there are various required or optional
fields to fill out.  I actually have a WIP series to make the tag_set
dynamically allocated and refcounted to fix some long standing life time
issues.  That creates a new alloc helper that will take a few mandatory
arguments and would heavily clash with this series.

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

end of thread, other threads:[~2022-10-10  7:55 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-05  3:22 [RFC PATCH 00/21] block: add and use init tagset helper Chaitanya Kulkarni
2022-10-05  3:22 ` [RFC PATCH 01/21] " Chaitanya Kulkarni
2022-10-05  5:11   ` Damien Le Moal
2022-10-05  9:47     ` Ulf Hansson
2022-10-05 16:54       ` Bart Van Assche
2022-10-05  3:22 ` [RFC PATCH 02/21] loop: use lib tagset init helper Chaitanya Kulkarni
2022-10-05  3:22 ` [RFC PATCH 03/21] nbd: " Chaitanya Kulkarni
2022-10-05  3:22 ` [RFC PATCH 04/21] rnbd: " Chaitanya Kulkarni
2022-10-05  3:22 ` [RFC PATCH 05/21] bsg-lib: " Chaitanya Kulkarni
2022-10-05  3:22 ` [RFC PATCH 06/21] rnbd-clt: " Chaitanya Kulkarni
2022-10-05  3:22 ` [RFC PATCH 07/21] virtio-blk: " Chaitanya Kulkarni
2022-10-05  3:22 ` [RFC PATCH 08/21] scsi: " Chaitanya Kulkarni
2022-10-05  3:22 ` [RFC PATCH 09/21] block: " Chaitanya Kulkarni
2022-10-05  3:22 ` [RFC PATCH 10/21] amiflop: " Chaitanya Kulkarni
2022-10-05  3:22 ` [RFC PATCH 11/21] floppy: " Chaitanya Kulkarni
2022-10-05  3:22 ` [RFC PATCH 12/21] mtip32xx: " Chaitanya Kulkarni
2022-10-05  3:22 ` [RFC PATCH 13/21] z3ram: " Chaitanya Kulkarni
2022-10-05  3:22 ` [RFC PATCH 14/21] scm_blk: " Chaitanya Kulkarni
2022-10-05  3:22 ` [RFC PATCH 15/21] ubi: " Chaitanya Kulkarni
2022-10-05  3:22 ` [RFC PATCH 16/21] mmc: core: " Chaitanya Kulkarni
2022-10-05  3:22 ` [RFC PATCH 17/21] dasd: " Chaitanya Kulkarni
2022-10-05  3:22 ` [RFC PATCH 18/21] nvme-core: use lib tagset init helper for I/O q Chaitanya Kulkarni
2022-10-05  3:22 ` [RFC PATCH 19/21] nvme-core: use lib tagset init helper for adminq Chaitanya Kulkarni
2022-10-05  3:22 ` [RFC PATCH 20/21] nvme-apple: use lib tagset init helper Chaitanya Kulkarni
2022-10-05  3:22 ` [RFC PATCH 21/21] nvme-pci: " Chaitanya Kulkarni
2022-10-07 18:26 ` [RFC PATCH 00/21] block: add and use init tagset helper Luis Chamberlain
2022-10-10  7:55   ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).