[PATCH 04/23] scsi: initialize scsi midlayer limits before allocating the queue

2024-03-24 Thread Christoph Hellwig
Turn __scsi_init_queue into scsi_init_limits which initializes
queue_limits structure that can be passed to blk_mq_alloc_queue.

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/scsi_lib.c | 32 ++---
 drivers/scsi/scsi_scan.c|  5 +++--
 drivers/scsi/scsi_transport_fc.c| 11 +-
 drivers/scsi/scsi_transport_iscsi.c |  5 +++--
 include/scsi/scsi_transport.h   |  2 +-
 5 files changed, 28 insertions(+), 27 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 2e28e2360c8574..1deca84914e87a 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -32,7 +32,7 @@
 #include 
 #include 
 #include 
-#include  /* __scsi_init_queue() */
+#include  /* scsi_init_limits() */
 #include 
 
 #include 
@@ -1965,31 +1965,26 @@ static void scsi_map_queues(struct blk_mq_tag_set *set)
blk_mq_map_queues(&set->map[HCTX_TYPE_DEFAULT]);
 }
 
-void __scsi_init_queue(struct Scsi_Host *shost, struct request_queue *q)
+void scsi_init_limits(struct Scsi_Host *shost, struct queue_limits *lim)
 {
struct device *dev = shost->dma_dev;
 
-   /*
-* this limit is imposed by hardware restrictions
-*/
-   blk_queue_max_segments(q, min_t(unsigned short, shost->sg_tablesize,
-   SG_MAX_SEGMENTS));
+   memset(lim, 0, sizeof(*lim));
+   lim->max_segments =
+   min_t(unsigned short, shost->sg_tablesize, SG_MAX_SEGMENTS);
 
if (scsi_host_prot_dma(shost)) {
shost->sg_prot_tablesize =
min_not_zero(shost->sg_prot_tablesize,
 (unsigned short)SCSI_MAX_PROT_SG_SEGMENTS);
BUG_ON(shost->sg_prot_tablesize < shost->sg_tablesize);
-   blk_queue_max_integrity_segments(q, shost->sg_prot_tablesize);
+   lim->max_integrity_segments = shost->sg_prot_tablesize;
}
 
-   blk_queue_max_hw_sectors(q, shost->max_sectors);
-   blk_queue_segment_boundary(q, shost->dma_boundary);
-   dma_set_seg_boundary(dev, shost->dma_boundary);
-
-   blk_queue_max_segment_size(q, shost->max_segment_size);
-   blk_queue_virt_boundary(q, shost->virt_boundary_mask);
-   dma_set_max_seg_size(dev, queue_max_segment_size(q));
+   lim->max_hw_sectors = shost->max_sectors;
+   lim->seg_boundary_mask = shost->dma_boundary;
+   lim->max_segment_size = shost->max_segment_size;
+   lim->virt_boundary_mask = shost->virt_boundary_mask;
 
/*
 * Set a reasonable default alignment:  The larger of 32-byte (dword),
@@ -1998,9 +1993,12 @@ void __scsi_init_queue(struct Scsi_Host *shost, struct 
request_queue *q)
 *
 * Devices that require a bigger alignment can increase it later.
 */
-   blk_queue_dma_alignment(q, max(4, dma_get_cache_alignment()) - 1);
+   lim->dma_alignment = max(4, dma_get_cache_alignment()) - 1;
+
+   dma_set_seg_boundary(dev, shost->dma_boundary);
+   dma_set_max_seg_size(dev, shost->max_segment_size);
 }
-EXPORT_SYMBOL_GPL(__scsi_init_queue);
+EXPORT_SYMBOL_GPL(scsi_init_limits);
 
 static const struct blk_mq_ops scsi_mq_ops_no_commit = {
.get_budget = scsi_mq_get_budget,
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 8d06475de17a33..205ab3b3ea89be 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -283,6 +283,7 @@ static struct scsi_device *scsi_alloc_sdev(struct 
scsi_target *starget,
struct request_queue *q;
int display_failure_msg = 1, ret;
struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
+   struct queue_limits lim;
 
sdev = kzalloc(sizeof(*sdev) + shost->transportt->device_size,
   GFP_KERNEL);
@@ -332,7 +333,8 @@ static struct scsi_device *scsi_alloc_sdev(struct 
scsi_target *starget,
 
sdev->sg_reserved_size = INT_MAX;
 
-   q = blk_mq_alloc_queue(&sdev->host->tag_set, NULL, NULL);
+   scsi_init_limits(shost, &lim);
+   q = blk_mq_alloc_queue(&sdev->host->tag_set, &lim, NULL);
if (IS_ERR(q)) {
/* release fn is set up in scsi_sysfs_device_initialise, so
 * have to free and put manually here */
@@ -343,7 +345,6 @@ static struct scsi_device *scsi_alloc_sdev(struct 
scsi_target *starget,
kref_get(&sdev->host->tagset_refcnt);
sdev->request_queue = q;
q->queuedata = sdev;
-   __scsi_init_queue(sdev->host, q);
 
depth = sdev->host->cmd_per_lun ?: 1;
 
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index 87b2235b8ece45..0799700b0fca77 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -4276,6 +4276,7 @@ fc_bsg_hostadd(struct Scsi_Host *shost, struct 
fc_host_attrs *fc_host)
 {
struct device *dev = &shost->shost_gendev;
struct fc_internal *i = to_fc_internal(shost

Re: [PATCH 04/23] scsi: initialize scsi midlayer limits before allocating the queue

2024-03-25 Thread Damien Le Moal
On 3/25/24 08:54, Christoph Hellwig wrote:
> Turn __scsi_init_queue into scsi_init_limits which initializes
> queue_limits structure that can be passed to blk_mq_alloc_queue.
> 
> Signed-off-by: Christoph Hellwig 

Looks OK to me.

Reviewed-by: Damien Le Moal 

-- 
Damien Le Moal
Western Digital Research

-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to open-iscsi+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/open-iscsi/be1655f7-3ae0-4a5a-ac35-95e9c7d2da02%40kernel.org.


Re: [PATCH 04/23] scsi: initialize scsi midlayer limits before allocating the queue

2024-03-25 Thread Bart Van Assche

On 3/24/24 16:54, Christoph Hellwig wrote:

Turn __scsi_init_queue into scsi_init_limits which initializes
queue_limits structure that can be passed to blk_mq_alloc_queue.


Reviewed-by: Bart Van Assche 

--
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to open-iscsi+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/open-iscsi/26f51e14-0625-4225-aaf0-f4f7bff5c2ba%40acm.org.