linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: majianpeng <majianpeng@gmail.com>
To: nab <nab@linux-iscsi.org>
Cc: linux-scsi <linux-scsi@vger.kernel.org>
Subject: [PATCH 6/6] scsi-mq: Pre-allocation of sg tables base on min(host->hostt->sg_tablesize,SCSI_MQ_MAX_SG_SEGMENTS).
Date: Fri, 29 Nov 2013 16:42:24 +0800	[thread overview]
Message-ID: <201311291642208390779@gmail.com> (raw)

Signed-off-by: Jianpeng Ma <majianpeng@gmail.com>
---
 drivers/scsi/scsi-mq.c |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/scsi-mq.c b/drivers/scsi/scsi-mq.c
index 78b05c1..7b8137b 100644
--- a/drivers/scsi/scsi-mq.c
+++ b/drivers/scsi/scsi-mq.c
@@ -154,6 +154,7 @@ int scsi_mq_alloc_queue(struct Scsi_Host *sh, struct scsi_device *sdev)
 	struct request *rq;
 	struct scsi_cmnd *sc;
 	int i, j;
+	int sgl_size;
 
 	sdev->sdev_mq_reg.ops = &scsi_mq_ops;
 	sdev->sdev_mq_reg.queue_depth = min((short)sh->hostt->can_queue,
@@ -186,13 +187,20 @@ int scsi_mq_alloc_queue(struct Scsi_Host *sh, struct scsi_device *sdev)
 	 * Set existing Scsi_Host based hardware limits from scsi_lib.c
 	 */
 	scsi_init_request_queue(q, sh);
+
+	if (sh->hostt->sg_tablesize > SCSI_MQ_MAX_SG_SEGMENTS) {
+		printk(KERN_ERR"Host%d sg_tablesize too larger than %d\n",
+			sh->host_no, SCSI_MQ_MAX_SG_SEGMENTS);
+		sh->hostt->sg_tablesize = SCSI_MQ_MAX_SG_SEGMENTS;
+	}
+	sgl_size = sh->hostt->sg_tablesize * sizeof(struct scatterlist);
+
 	/*
 	 * Do remaining setup of pre-allocated scsi_cmnd descriptor map for
 	 * each scsi-mq hctx
 	 */
 //FIXME: Do cmd->prot_sdb setup for DIF from scsi_host_alloc_command
 	queue_for_each_hw_ctx(q, hctx, i) {
-
 		printk("Performing sc map setup on q: %p hctx: %p i: %d\n", q, hctx, i);
 
 		for (j = 0; j < hctx->queue_depth; j++) {
@@ -201,8 +209,7 @@ int scsi_mq_alloc_queue(struct Scsi_Host *sh, struct scsi_device *sdev)
 			sc->device = sdev;
 			sc->ll_list.next = NULL;
 
-//FIXME: Pre-allocation of sg tables based upon max_sectors
-			sc->mq_sgl = kzalloc_node(SCSI_MQ_SGL_SIZE,
+			sc->mq_sgl = kzalloc_node(sgl_size,
 					GFP_KERNEL, sdev->sdev_mq_reg.numa_node);
 			if (!sc->mq_sgl) {
 				pr_err("Unable to pre-allocate sc->sdb\n");
-- 
1.7.10.4

             reply	other threads:[~2013-11-29  8:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-29  8:42 majianpeng [this message]
2013-12-23  6:33 ` [PATCH 6/6] scsi-mq: Pre-allocation of sg tables base on min(host->hostt->sg_tablesize,SCSI_MQ_MAX_SG_SEGMENTS) Nicholas A. Bellinger

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=201311291642208390779@gmail.com \
    --to=majianpeng@gmail.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=nab@linux-iscsi.org \
    /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 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).