All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Jens Axboe <axboe@kernel.dk>,
	James Bottomley <JBottomley@Parallels.com>,
	Nicholas Bellinger <nab@linux-iscsi.org>
Cc: linux-scsi@vger.kernel.org
Subject: [PATCH 07/17] virtio_scsi: use cmd_size
Date: Wed, 05 Feb 2014 04:39:37 -0800	[thread overview]
Message-ID: <20140205124020.142099443@bombadil.infradead.org> (raw)
In-Reply-To: 20140205123930.150608699@bombadil.infradead.org

[-- Attachment #1: 0007-virtio_scsi-use-cmd_size.patch --]
[-- Type: text/plain, Size: 2805 bytes --]

Taken almost entirely from Nicholas Bellinger's scsi-mq conversion.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/scsi/virtio_scsi.c |   25 +++++++------------------
 1 file changed, 7 insertions(+), 18 deletions(-)

diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index 16bfd50..d9a6074 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -204,7 +204,6 @@ static void virtscsi_complete_cmd(struct virtio_scsi *vscsi, void *buf)
 			set_driver_byte(sc, DRIVER_SENSE);
 	}
 
-	mempool_free(cmd, virtscsi_cmd_pool);
 	sc->scsi_done(sc);
 
 	atomic_dec(&tgt->reqs);
@@ -279,8 +278,6 @@ static void virtscsi_complete_free(struct virtio_scsi *vscsi, void *buf)
 
 	if (cmd->comp)
 		complete_all(cmd->comp);
-	else
-		mempool_free(cmd, virtscsi_cmd_pool);
 }
 
 static void virtscsi_ctrl_done(struct virtqueue *vq)
@@ -496,10 +493,9 @@ static int virtscsi_queuecommand(struct virtio_scsi *vscsi,
 				 struct virtio_scsi_vq *req_vq,
 				 struct scsi_cmnd *sc)
 {
-	struct virtio_scsi_cmd *cmd;
-	int ret;
-
 	struct Scsi_Host *shost = virtio_scsi_host(vscsi->vdev);
+	struct virtio_scsi_cmd *cmd = (struct virtio_scsi_cmd *)(sc + 1);
+
 	BUG_ON(scsi_sg_count(sc) > shost->sg_tablesize);
 
 	/* TODO: check feature bit and fail if unsupported?  */
@@ -508,11 +504,6 @@ static int virtscsi_queuecommand(struct virtio_scsi *vscsi,
 	dev_dbg(&sc->device->sdev_gendev,
 		"cmd %p CDB: %#02x\n", sc, sc->cmnd[0]);
 
-	ret = SCSI_MLQUEUE_HOST_BUSY;
-	cmd = mempool_alloc(virtscsi_cmd_pool, GFP_ATOMIC);
-	if (!cmd)
-		goto out;
-
 	memset(cmd, 0, sizeof(*cmd));
 	cmd->sc = sc;
 	cmd->req.cmd = (struct virtio_scsi_cmd_req){
@@ -531,13 +522,9 @@ static int virtscsi_queuecommand(struct virtio_scsi *vscsi,
 
 	if (virtscsi_kick_cmd(req_vq, cmd,
 			      sizeof cmd->req.cmd, sizeof cmd->resp.cmd,
-			      GFP_ATOMIC) == 0)
-		ret = 0;
-	else
-		mempool_free(cmd, virtscsi_cmd_pool);
-
-out:
-	return ret;
+			      GFP_ATOMIC) != 0)
+		return SCSI_MLQUEUE_HOST_BUSY;
+	return 0;
 }
 
 static int virtscsi_queuecommand_single(struct Scsi_Host *sh,
@@ -683,6 +670,7 @@ static struct scsi_host_template virtscsi_host_template_single = {
 	.name = "Virtio SCSI HBA",
 	.proc_name = "virtio_scsi",
 	.this_id = -1,
+	.cmd_size = sizeof(struct virtio_scsi_cmd),
 	.queuecommand = virtscsi_queuecommand_single,
 	.eh_abort_handler = virtscsi_abort,
 	.eh_device_reset_handler = virtscsi_device_reset,
@@ -699,6 +687,7 @@ static struct scsi_host_template virtscsi_host_template_multi = {
 	.name = "Virtio SCSI HBA",
 	.proc_name = "virtio_scsi",
 	.this_id = -1,
+	.cmd_size = sizeof(struct virtio_scsi_cmd),
 	.queuecommand = virtscsi_queuecommand_multi,
 	.eh_abort_handler = virtscsi_abort,
 	.eh_device_reset_handler = virtscsi_device_reset,
-- 
1.7.10.4



  parent reply	other threads:[~2014-02-05 12:40 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-05 12:39 [PATCH 00/17] SCSI data path micro-optimizations Christoph Hellwig
2014-02-05 12:39 ` [PATCH 01/17] scsi: handle command allocation failure in scsi_reset_provider Christoph Hellwig
2014-02-05 12:39 ` [PATCH 02/17] megaraid: simplify internal command handling Christoph Hellwig
2014-02-06 16:40   ` Christoph Hellwig
2014-02-05 12:39 ` [PATCH 03/17] scsi: remove scsi_allocate_command/scsi_free_command Christoph Hellwig
2014-02-05 12:39 ` [PATCH 04/17] scsi: avoid useless free_list lock roundtrips Christoph Hellwig
2014-02-05 23:44   ` James Bottomley
2014-02-06 16:22     ` Christoph Hellwig
2014-02-07  9:05   ` Paolo Bonzini
2014-02-05 12:39 ` [PATCH 05/17] scsi: simplify command allocation and freeing a bit Christoph Hellwig
2014-02-05 23:51   ` James Bottomley
2014-02-06 16:21     ` Christoph Hellwig
2014-02-05 12:39 ` [PATCH 06/17] scsi: add support for per-host cmd pools Christoph Hellwig
2014-02-07  9:13   ` Paolo Bonzini
2014-02-07 12:44     ` Christoph Hellwig
2014-02-07  9:35   ` Mike Christie
2014-02-07 12:46     ` Christoph Hellwig
2014-02-07 21:43       ` Mike Christie
2014-02-10 12:20         ` Christoph Hellwig
2014-02-05 12:39 ` Christoph Hellwig [this message]
2014-02-07  9:13   ` [PATCH 07/17] virtio_scsi: use cmd_size Paolo Bonzini
2014-02-05 12:39 ` [PATCH 08/17] scsi: do not manipulate device reference counts in scsi_get/put_command Christoph Hellwig
2014-02-05 12:39 ` [PATCH 09/17] scsi: micro-optimize scsi_request_fn() Christoph Hellwig
2014-02-05 12:39 ` [PATCH 10/17] scsi: micro-optimize scsi_next_command() Christoph Hellwig
2014-02-05 12:39 ` [PATCH 11/17] scsi: micro-optimize scsi_requeue_command() Christoph Hellwig
2014-02-05 12:39 ` [PATCH 12/17] scsi: avoid taking host_lock in scsi_run_queue unless nessecary Christoph Hellwig
2014-02-05 23:54   ` James Bottomley
2014-02-06 16:19     ` Christoph Hellwig
2014-02-05 12:39 ` [PATCH 13/17] scsi: push host_lock down into scsi_{host,target}_queue_ready Christoph Hellwig
2014-02-06 16:56   ` James Bottomley
2014-02-06 17:10     ` Bart Van Assche
2014-02-06 18:41       ` James Bottomley
2014-02-07 10:42         ` Bart Van Assche
2014-02-06 21:58       ` Nicholas A. Bellinger
2014-02-07 10:32         ` Bart Van Assche
2014-02-07 19:30           ` Nicholas A. Bellinger
2014-02-08 11:00             ` Bart Van Assche
2014-02-09  8:26               ` Nicholas A. Bellinger
2014-02-10 12:09                 ` Christoph Hellwig
2014-02-10 19:53                   ` Nicholas A. Bellinger
2014-02-10 11:39     ` Christoph Hellwig
2014-02-10 20:09       ` Jens Axboe
2014-02-17  9:36         ` Bart Van Assche
2014-02-17 22:00           ` Christoph Hellwig
2014-02-26 15:39             ` Bart Van Assche
2014-02-10 21:10       ` James Bottomley
2014-02-05 12:39 ` [PATCH 14/17] scsi: convert target_busy to an atomic_t Christoph Hellwig
2014-02-05 12:39 ` [PATCH 15/17] scsi: convert host_busy to atomic_t Christoph Hellwig
2014-02-05 12:39 ` [PATCH 16/17] scsi: convert device_busy " Christoph Hellwig
2014-02-05 12:39 ` [PATCH 17/17] scsi: fix the {host,target,device}_blocked counter mess Christoph Hellwig
2014-02-05 23:41 ` [PATCH 00/17] SCSI data path micro-optimizations James Bottomley
2014-02-06 16:29   ` Christoph Hellwig

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=20140205124020.142099443@bombadil.infradead.org \
    --to=hch@infradead.org \
    --cc=JBottomley@Parallels.com \
    --cc=axboe@kernel.dk \
    --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 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.