All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Christie <michael.christie@oracle.com>
To: lduncan@suse.com, cleech@redhat.com, martin.petersen@oracle.com,
	linux-scsi@vger.kernel.org,
	james.bottomley@hansenpartnership.com
Cc: lutianxiong@huawei.com, linfeilong@huawei.com,
	liuzhiqiang26@huawei.com, haowenchao@huawei.com
Subject: [PATCH 6/7] iscsi_tcp: fix shost can_queue initialization
Date: Mon, 18 Jan 2021 14:34:29 -0600	[thread overview]
Message-ID: <20210118203430.4921-7-michael.christie@oracle.com> (raw)
In-Reply-To: <20210118203430.4921-1-michael.christie@oracle.com>

We are setting the shost's can_queue after we add the host which is
too late, because scsi-ml will have allocated the tag set based on
the can_queue value at that time. This patch has us use the
iscsi_host_get_max_scsi_cmds helper to figure out the number of
scsi cmds.

It also fixes up the template can_queue so it reflects the max scsi
cmds we can support like how other drivers work.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
 drivers/scsi/iscsi_tcp.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index a9ce6298b935..f0070e3c7ffa 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -847,6 +847,7 @@ iscsi_sw_tcp_session_create(struct iscsi_endpoint *ep, uint16_t cmds_max,
 	struct iscsi_session *session;
 	struct iscsi_sw_tcp_host *tcp_sw_host;
 	struct Scsi_Host *shost;
+	int rc;
 
 	if (ep) {
 		printk(KERN_ERR "iscsi_tcp: invalid ep %p.\n", ep);
@@ -864,6 +865,11 @@ iscsi_sw_tcp_session_create(struct iscsi_endpoint *ep, uint16_t cmds_max,
 	shost->max_channel = 0;
 	shost->max_cmd_len = SCSI_MAX_VARLEN_CDB_SIZE;
 
+	rc = iscsi_host_get_max_scsi_cmds(shost, cmds_max);
+	if (rc < 0)
+		goto free_host;
+	shost->can_queue = rc;
+
 	if (iscsi_host_add(shost, NULL))
 		goto free_host;
 
@@ -878,7 +884,6 @@ iscsi_sw_tcp_session_create(struct iscsi_endpoint *ep, uint16_t cmds_max,
 	tcp_sw_host = iscsi_host_priv(shost);
 	tcp_sw_host->session = session;
 
-	shost->can_queue = session->scsi_cmds_max;
 	if (iscsi_tcp_r2tpool_alloc(session))
 		goto remove_session;
 	return cls_session;
@@ -981,7 +986,7 @@ static struct scsi_host_template iscsi_sw_tcp_sht = {
 	.name			= "iSCSI Initiator over TCP/IP",
 	.queuecommand           = iscsi_queuecommand,
 	.change_queue_depth	= scsi_change_queue_depth,
-	.can_queue		= ISCSI_DEF_XMIT_CMDS_MAX - 1,
+	.can_queue		= ISCSI_TOTAL_CMDS_MAX - ISCSI_MGMT_CMDS_MAX,
 	.sg_tablesize		= 4096,
 	.max_sectors		= 0xFFFF,
 	.cmd_per_lun		= ISCSI_DEF_CMD_PER_LUN,
-- 
2.25.1


  parent reply	other threads:[~2021-01-18 20:36 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-18 20:34 [PATCH 0/7] iscsi fixes/cleanups Mike Christie
2021-01-18 20:34 ` [PATCH 1/7] libiscsi: fix iscsi_prep_scsi_cmd_pdu error handling Mike Christie
2021-01-18 20:34 ` [PATCH 2/7] libiscsi: drop taskqueuelock Mike Christie
2021-01-27 22:30   ` Lee Duncan
2021-01-18 20:34 ` [PATCH 3/7] libiscsi: fix iscsi_task use after free Mike Christie
2021-01-18 20:34 ` [PATCH 4/7] libiscsi: fix iscsi host workq destruction Mike Christie
2021-01-27 18:09   ` Lee Duncan
2021-01-18 20:34 ` [PATCH 5/7] libiscsi: add helper to calc max scsi cmds per session Mike Christie
2021-01-27 19:45   ` Lee Duncan
2021-01-28  0:55     ` michael.christie
2021-01-18 20:34 ` Mike Christie [this message]
2021-01-27 19:47   ` [PATCH 6/7] iscsi_tcp: fix shost can_queue initialization Lee Duncan
2021-01-18 20:34 ` [PATCH 7/7] libiscsi: reset max/exp cmdsn during recovery Mike Christie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210118203430.4921-7-michael.christie@oracle.com \
    --to=michael.christie@oracle.com \
    --cc=cleech@redhat.com \
    --cc=haowenchao@huawei.com \
    --cc=james.bottomley@hansenpartnership.com \
    --cc=lduncan@suse.com \
    --cc=linfeilong@huawei.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=liuzhiqiang26@huawei.com \
    --cc=lutianxiong@huawei.com \
    --cc=martin.petersen@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.