linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* misc driver updates
@ 2014-05-01 14:51 Christoph Hellwig
  2014-05-01 14:51 ` [PATCH 1/2] virtio_scsi: use cmd_size Christoph Hellwig
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Christoph Hellwig @ 2014-05-01 14:51 UTC (permalink / raw)
  To: James Bottomley; +Cc: linux-scsi

Two small driver updates that were a fallout from the scsi multiqueue
work.  Both have been ACKed by the maintainers.


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

* [PATCH 1/2] virtio_scsi: use cmd_size
  2014-05-01 14:51 misc driver updates Christoph Hellwig
@ 2014-05-01 14:51 ` Christoph Hellwig
  2014-05-19 17:44   ` Nicholas A. Bellinger
  2014-05-01 14:51 ` [PATCH 2/2] scsi_debug: simple short transfer injection Christoph Hellwig
  2014-05-19 14:07 ` misc driver updates Christoph Hellwig
  2 siblings, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2014-05-01 14:51 UTC (permalink / raw)
  To: James Bottomley; +Cc: linux-scsi

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

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
---
 drivers/scsi/virtio_scsi.c |   25 +++++++------------------
 include/scsi/scsi_cmnd.h   |    9 +++++++++
 2 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index 16bfd50..5ec4a73 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 = scsi_cmd_priv(sc);
+
 	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,
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index dd7c998..e016e2a 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -133,6 +133,15 @@ struct scsi_cmnd {
 	unsigned char tag;	/* SCSI-II queued command tag */
 };
 
+/*
+ * Return the driver private allocation behind the command.
+ * Only works if cmd_size is set in the host template.
+ */
+static inline void *scsi_cmd_priv(struct scsi_cmnd *cmd)
+{
+	return cmd + 1;
+}
+
 /* make sure not to use it with REQ_TYPE_BLOCK_PC commands */
 static inline struct scsi_driver *scsi_cmd_to_driver(struct scsi_cmnd *cmd)
 {
-- 
1.7.10.4


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

* [PATCH 2/2] scsi_debug: simple short transfer injection
  2014-05-01 14:51 misc driver updates Christoph Hellwig
  2014-05-01 14:51 ` [PATCH 1/2] virtio_scsi: use cmd_size Christoph Hellwig
@ 2014-05-01 14:51 ` Christoph Hellwig
  2014-05-19 17:45   ` Nicholas A. Bellinger
  2014-05-19 14:07 ` misc driver updates Christoph Hellwig
  2 siblings, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2014-05-01 14:51 UTC (permalink / raw)
  To: James Bottomley; +Cc: linux-scsi

Add an option to only transfer half the data for every n-th command.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Douglas Gilbert <dgilbert@interlog.com>
---
 drivers/scsi/scsi_debug.c |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index f3e9cc0..1328a26 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -130,6 +130,7 @@ static const char * scsi_debug_version_date = "20100324";
 #define SCSI_DEBUG_OPT_DIF_ERR   32
 #define SCSI_DEBUG_OPT_DIX_ERR   64
 #define SCSI_DEBUG_OPT_MAC_TIMEOUT  128
+#define SCSI_DEBUG_OPT_SHORT_TRANSFER	256
 /* When "every_nth" > 0 then modulo "every_nth" commands:
  *   - a no response is simulated if SCSI_DEBUG_OPT_TIMEOUT is set
  *   - a RECOVERED_ERROR is simulated on successful read and write
@@ -3583,6 +3584,7 @@ int scsi_debug_queuecommand_lck(struct scsi_cmnd *SCpnt, done_funct_t done)
 	int inj_transport = 0;
 	int inj_dif = 0;
 	int inj_dix = 0;
+	int inj_short = 0;
 	int delay_override = 0;
 	int unmap = 0;
 
@@ -3628,6 +3630,8 @@ int scsi_debug_queuecommand_lck(struct scsi_cmnd *SCpnt, done_funct_t done)
 			inj_dif = 1; /* to reads and writes below */
 		else if (SCSI_DEBUG_OPT_DIX_ERR & scsi_debug_opts)
 			inj_dix = 1; /* to reads and writes below */
+		else if (SCSI_DEBUG_OPT_SHORT_TRANSFER & scsi_debug_opts)
+			inj_short = 1;
 	}
 
 	if (devip->wlun) {
@@ -3744,6 +3748,10 @@ read:
 		if (scsi_debug_fake_rw)
 			break;
 		get_data_transfer_info(cmd, &lba, &num, &ei_lba);
+
+		if (inj_short)
+			num /= 2;
+
 		errsts = resp_read(SCpnt, lba, num, devip, ei_lba);
 		if (inj_recovered && (0 == errsts)) {
 			mk_sense_buffer(devip, RECOVERED_ERROR,
-- 
1.7.10.4


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

* Re: misc driver updates
  2014-05-01 14:51 misc driver updates Christoph Hellwig
  2014-05-01 14:51 ` [PATCH 1/2] virtio_scsi: use cmd_size Christoph Hellwig
  2014-05-01 14:51 ` [PATCH 2/2] scsi_debug: simple short transfer injection Christoph Hellwig
@ 2014-05-19 14:07 ` Christoph Hellwig
  2 siblings, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2014-05-19 14:07 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-scsi

I'm still looking for one more review for each of the patches.


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

* Re: [PATCH 1/2] virtio_scsi: use cmd_size
  2014-05-01 14:51 ` [PATCH 1/2] virtio_scsi: use cmd_size Christoph Hellwig
@ 2014-05-19 17:44   ` Nicholas A. Bellinger
  0 siblings, 0 replies; 6+ messages in thread
From: Nicholas A. Bellinger @ 2014-05-19 17:44 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: James Bottomley, linux-scsi

On Thu, 2014-05-01 at 16:51 +0200, Christoph Hellwig wrote:
> Taken almost entirely from Nicholas Bellinger's scsi-mq conversion.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Acked-by: Paolo Bonzini <pbonzini@redhat.com>
> ---

Reviewed-by: Nicholas Bellinger <nab@linux-iscsi.org>

>  drivers/scsi/virtio_scsi.c |   25 +++++++------------------
>  include/scsi/scsi_cmnd.h   |    9 +++++++++
>  2 files changed, 16 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
> index 16bfd50..5ec4a73 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 = scsi_cmd_priv(sc);
> +
>  	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,
> diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
> index dd7c998..e016e2a 100644
> --- a/include/scsi/scsi_cmnd.h
> +++ b/include/scsi/scsi_cmnd.h
> @@ -133,6 +133,15 @@ struct scsi_cmnd {
>  	unsigned char tag;	/* SCSI-II queued command tag */
>  };
>  
> +/*
> + * Return the driver private allocation behind the command.
> + * Only works if cmd_size is set in the host template.
> + */
> +static inline void *scsi_cmd_priv(struct scsi_cmnd *cmd)
> +{
> +	return cmd + 1;
> +}
> +
>  /* make sure not to use it with REQ_TYPE_BLOCK_PC commands */
>  static inline struct scsi_driver *scsi_cmd_to_driver(struct scsi_cmnd *cmd)
>  {



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

* Re: [PATCH 2/2] scsi_debug: simple short transfer injection
  2014-05-01 14:51 ` [PATCH 2/2] scsi_debug: simple short transfer injection Christoph Hellwig
@ 2014-05-19 17:45   ` Nicholas A. Bellinger
  0 siblings, 0 replies; 6+ messages in thread
From: Nicholas A. Bellinger @ 2014-05-19 17:45 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: James Bottomley, linux-scsi

On Thu, 2014-05-01 at 16:51 +0200, Christoph Hellwig wrote:
> Add an option to only transfer half the data for every n-th command.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Acked-by: Douglas Gilbert <dgilbert@interlog.com>

Reviewed-by: Nicholas Bellinger <nab@linux-iscsi.org>

> ---
>  drivers/scsi/scsi_debug.c |    8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
> index f3e9cc0..1328a26 100644
> --- a/drivers/scsi/scsi_debug.c
> +++ b/drivers/scsi/scsi_debug.c
> @@ -130,6 +130,7 @@ static const char * scsi_debug_version_date = "20100324";
>  #define SCSI_DEBUG_OPT_DIF_ERR   32
>  #define SCSI_DEBUG_OPT_DIX_ERR   64
>  #define SCSI_DEBUG_OPT_MAC_TIMEOUT  128
> +#define SCSI_DEBUG_OPT_SHORT_TRANSFER	256
>  /* When "every_nth" > 0 then modulo "every_nth" commands:
>   *   - a no response is simulated if SCSI_DEBUG_OPT_TIMEOUT is set
>   *   - a RECOVERED_ERROR is simulated on successful read and write
> @@ -3583,6 +3584,7 @@ int scsi_debug_queuecommand_lck(struct scsi_cmnd *SCpnt, done_funct_t done)
>  	int inj_transport = 0;
>  	int inj_dif = 0;
>  	int inj_dix = 0;
> +	int inj_short = 0;
>  	int delay_override = 0;
>  	int unmap = 0;
>  
> @@ -3628,6 +3630,8 @@ int scsi_debug_queuecommand_lck(struct scsi_cmnd *SCpnt, done_funct_t done)
>  			inj_dif = 1; /* to reads and writes below */
>  		else if (SCSI_DEBUG_OPT_DIX_ERR & scsi_debug_opts)
>  			inj_dix = 1; /* to reads and writes below */
> +		else if (SCSI_DEBUG_OPT_SHORT_TRANSFER & scsi_debug_opts)
> +			inj_short = 1;
>  	}
>  
>  	if (devip->wlun) {
> @@ -3744,6 +3748,10 @@ read:
>  		if (scsi_debug_fake_rw)
>  			break;
>  		get_data_transfer_info(cmd, &lba, &num, &ei_lba);
> +
> +		if (inj_short)
> +			num /= 2;
> +
>  		errsts = resp_read(SCpnt, lba, num, devip, ei_lba);
>  		if (inj_recovered && (0 == errsts)) {
>  			mk_sense_buffer(devip, RECOVERED_ERROR,



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

end of thread, other threads:[~2014-05-19 17:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-01 14:51 misc driver updates Christoph Hellwig
2014-05-01 14:51 ` [PATCH 1/2] virtio_scsi: use cmd_size Christoph Hellwig
2014-05-19 17:44   ` Nicholas A. Bellinger
2014-05-01 14:51 ` [PATCH 2/2] scsi_debug: simple short transfer injection Christoph Hellwig
2014-05-19 17:45   ` Nicholas A. Bellinger
2014-05-19 14:07 ` misc driver updates 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).