Linux SCSI subsystem development
 help / color / mirror / Atom feed
* [PATCH] tcm_loop: Fixup tag handling
@ 2014-10-02  7:30 Hannes Reinecke
  2014-10-02  9:08 ` Sagi Grimberg
  2014-10-03  5:16 ` Nicholas A. Bellinger
  0 siblings, 2 replies; 3+ messages in thread
From: Hannes Reinecke @ 2014-10-02  7:30 UTC (permalink / raw)
  To: Nic Bellinger
  Cc: Christoph Hellwig, linux-scsi, target-devel, Hannes Reinecke

The SCSI command tag is set to the tag assigned from the block
layer, not the SCSI-II tag message. So we need to convert
it into the correct SCSI-II tag message based on the
device flags, not the tag value itself.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/target/loopback/tcm_loop.c | 23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
index 340de9d..c2a9370 100644
--- a/drivers/target/loopback/tcm_loop.c
+++ b/drivers/target/loopback/tcm_loop.c
@@ -153,18 +153,11 @@ static int tcm_loop_change_queue_type(struct scsi_device *sdev, int tag)
 /*
  * Locate the SAM Task Attr from struct scsi_cmnd *
  */
-static int tcm_loop_sam_attr(struct scsi_cmnd *sc)
-{
-	if (sc->device->tagged_supported) {
-		switch (sc->tag) {
-		case HEAD_OF_QUEUE_TAG:
-			return MSG_HEAD_TAG;
-		case ORDERED_QUEUE_TAG:
-			return MSG_ORDERED_TAG;
-		default:
-			break;
-		}
-	}
+static int tcm_loop_sam_attr(struct scsi_cmnd *sc, int tag)
+{
+	if (sc->device->tagged_supported &&
+	    sc->device->ordered_tags && tag >= 0)
+		return MSG_ORDERED_TAG;
 
 	return MSG_SIMPLE_TAG;
 }
@@ -227,7 +220,7 @@ static void tcm_loop_submission_work(struct work_struct *work)
 
 	rc = target_submit_cmd_map_sgls(se_cmd, tl_nexus->se_sess, sc->cmnd,
 			&tl_cmd->tl_sense_buf[0], tl_cmd->sc->device->lun,
-			transfer_length, tcm_loop_sam_attr(sc),
+			transfer_length, tcm_loop_sam_attr(sc, tl_cmd->sc_cmd_tag),
 			sc->sc_data_direction, 0,
 			scsi_sglist(sc), scsi_sg_count(sc),
 			sgl_bidi, sgl_bidi_count,
@@ -266,7 +259,7 @@ static int tcm_loop_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *sc)
 	}
 
 	tl_cmd->sc = sc;
-	tl_cmd->sc_cmd_tag = sc->tag;
+	tl_cmd->sc_cmd_tag = sc->request->tag;
 	INIT_WORK(&tl_cmd->work, tcm_loop_submission_work);
 	queue_work(tcm_loop_workqueue, &tl_cmd->work);
 	return 0;
@@ -370,7 +363,7 @@ static int tcm_loop_abort_task(struct scsi_cmnd *sc)
 	 */
 	tl_tpg = &tl_hba->tl_hba_tpgs[sc->device->id];
 	ret = tcm_loop_issue_tmr(tl_tpg, tl_nexus, sc->device->lun,
-				 sc->tag, TMR_ABORT_TASK);
+				 sc->request->tag, TMR_ABORT_TASK);
 	return (ret == TMR_FUNCTION_COMPLETE) ? SUCCESS : FAILED;
 }
 
-- 
1.8.5.2


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

* Re: [PATCH] tcm_loop: Fixup tag handling
  2014-10-02  7:30 [PATCH] tcm_loop: Fixup tag handling Hannes Reinecke
@ 2014-10-02  9:08 ` Sagi Grimberg
  2014-10-03  5:16 ` Nicholas A. Bellinger
  1 sibling, 0 replies; 3+ messages in thread
From: Sagi Grimberg @ 2014-10-02  9:08 UTC (permalink / raw)
  To: Hannes Reinecke, Nic Bellinger
  Cc: Christoph Hellwig, linux-scsi, target-devel

On 10/2/2014 10:30 AM, Hannes Reinecke wrote:
> The SCSI command tag is set to the tag assigned from the block
> layer, not the SCSI-II tag message. So we need to convert
> it into the correct SCSI-II tag message based on the
> device flags, not the tag value itself.
>

Looks Good

Reviewed-by: Sagi Grimberg <sagig@mellanox.com>

> Signed-off-by: Hannes Reinecke <hare@suse.de>
> ---
>   drivers/target/loopback/tcm_loop.c | 23 ++++++++---------------
>   1 file changed, 8 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
> index 340de9d..c2a9370 100644
> --- a/drivers/target/loopback/tcm_loop.c
> +++ b/drivers/target/loopback/tcm_loop.c
> @@ -153,18 +153,11 @@ static int tcm_loop_change_queue_type(struct scsi_device *sdev, int tag)
>   /*
>    * Locate the SAM Task Attr from struct scsi_cmnd *
>    */
> -static int tcm_loop_sam_attr(struct scsi_cmnd *sc)
> -{
> -	if (sc->device->tagged_supported) {
> -		switch (sc->tag) {
> -		case HEAD_OF_QUEUE_TAG:
> -			return MSG_HEAD_TAG;
> -		case ORDERED_QUEUE_TAG:
> -			return MSG_ORDERED_TAG;
> -		default:
> -			break;
> -		}
> -	}
> +static int tcm_loop_sam_attr(struct scsi_cmnd *sc, int tag)
> +{
> +	if (sc->device->tagged_supported &&
> +	    sc->device->ordered_tags && tag >= 0)
> +		return MSG_ORDERED_TAG;
>
>   	return MSG_SIMPLE_TAG;
>   }
> @@ -227,7 +220,7 @@ static void tcm_loop_submission_work(struct work_struct *work)
>
>   	rc = target_submit_cmd_map_sgls(se_cmd, tl_nexus->se_sess, sc->cmnd,
>   			&tl_cmd->tl_sense_buf[0], tl_cmd->sc->device->lun,
> -			transfer_length, tcm_loop_sam_attr(sc),
> +			transfer_length, tcm_loop_sam_attr(sc, tl_cmd->sc_cmd_tag),
>   			sc->sc_data_direction, 0,
>   			scsi_sglist(sc), scsi_sg_count(sc),
>   			sgl_bidi, sgl_bidi_count,
> @@ -266,7 +259,7 @@ static int tcm_loop_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *sc)
>   	}
>
>   	tl_cmd->sc = sc;
> -	tl_cmd->sc_cmd_tag = sc->tag;
> +	tl_cmd->sc_cmd_tag = sc->request->tag;
>   	INIT_WORK(&tl_cmd->work, tcm_loop_submission_work);
>   	queue_work(tcm_loop_workqueue, &tl_cmd->work);
>   	return 0;
> @@ -370,7 +363,7 @@ static int tcm_loop_abort_task(struct scsi_cmnd *sc)
>   	 */
>   	tl_tpg = &tl_hba->tl_hba_tpgs[sc->device->id];
>   	ret = tcm_loop_issue_tmr(tl_tpg, tl_nexus, sc->device->lun,
> -				 sc->tag, TMR_ABORT_TASK);
> +				 sc->request->tag, TMR_ABORT_TASK);
>   	return (ret == TMR_FUNCTION_COMPLETE) ? SUCCESS : FAILED;
>   }
>
>


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

* Re: [PATCH] tcm_loop: Fixup tag handling
  2014-10-02  7:30 [PATCH] tcm_loop: Fixup tag handling Hannes Reinecke
  2014-10-02  9:08 ` Sagi Grimberg
@ 2014-10-03  5:16 ` Nicholas A. Bellinger
  1 sibling, 0 replies; 3+ messages in thread
From: Nicholas A. Bellinger @ 2014-10-03  5:16 UTC (permalink / raw)
  To: Hannes Reinecke; +Cc: Christoph Hellwig, linux-scsi, target-devel

On Thu, 2014-10-02 at 09:30 +0200, Hannes Reinecke wrote:
> The SCSI command tag is set to the tag assigned from the block
> layer, not the SCSI-II tag message. So we need to convert
> it into the correct SCSI-II tag message based on the
> device flags, not the tag value itself.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> ---
>  drivers/target/loopback/tcm_loop.c | 23 ++++++++---------------
>  1 file changed, 8 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
> index 340de9d..c2a9370 100644
> --- a/drivers/target/loopback/tcm_loop.c
> +++ b/drivers/target/loopback/tcm_loop.c
> @@ -153,18 +153,11 @@ static int tcm_loop_change_queue_type(struct scsi_device *sdev, int tag)
>  /*
>   * Locate the SAM Task Attr from struct scsi_cmnd *
>   */
> -static int tcm_loop_sam_attr(struct scsi_cmnd *sc)
> -{
> -	if (sc->device->tagged_supported) {
> -		switch (sc->tag) {
> -		case HEAD_OF_QUEUE_TAG:
> -			return MSG_HEAD_TAG;
> -		case ORDERED_QUEUE_TAG:
> -			return MSG_ORDERED_TAG;
> -		default:
> -			break;
> -		}
> -	}
> +static int tcm_loop_sam_attr(struct scsi_cmnd *sc, int tag)
> +{
> +	if (sc->device->tagged_supported &&
> +	    sc->device->ordered_tags && tag >= 0)
> +		return MSG_ORDERED_TAG;
>  
>  	return MSG_SIMPLE_TAG;
>  }
> @@ -227,7 +220,7 @@ static void tcm_loop_submission_work(struct work_struct *work)
>  
>  	rc = target_submit_cmd_map_sgls(se_cmd, tl_nexus->se_sess, sc->cmnd,
>  			&tl_cmd->tl_sense_buf[0], tl_cmd->sc->device->lun,
> -			transfer_length, tcm_loop_sam_attr(sc),
> +			transfer_length, tcm_loop_sam_attr(sc, tl_cmd->sc_cmd_tag),
>  			sc->sc_data_direction, 0,
>  			scsi_sglist(sc), scsi_sg_count(sc),
>  			sgl_bidi, sgl_bidi_count,
> @@ -266,7 +259,7 @@ static int tcm_loop_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *sc)
>  	}
>  
>  	tl_cmd->sc = sc;
> -	tl_cmd->sc_cmd_tag = sc->tag;
> +	tl_cmd->sc_cmd_tag = sc->request->tag;
>  	INIT_WORK(&tl_cmd->work, tcm_loop_submission_work);
>  	queue_work(tcm_loop_workqueue, &tl_cmd->work);
>  	return 0;
> @@ -370,7 +363,7 @@ static int tcm_loop_abort_task(struct scsi_cmnd *sc)
>  	 */
>  	tl_tpg = &tl_hba->tl_hba_tpgs[sc->device->id];
>  	ret = tcm_loop_issue_tmr(tl_tpg, tl_nexus, sc->device->lun,
> -				 sc->tag, TMR_ABORT_TASK);
> +				 sc->request->tag, TMR_ABORT_TASK);
>  	return (ret == TMR_FUNCTION_COMPLETE) ? SUCCESS : FAILED;
>  }
>  

Applied.  Thanks Hannes!


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

end of thread, other threads:[~2014-10-03  5:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-02  7:30 [PATCH] tcm_loop: Fixup tag handling Hannes Reinecke
2014-10-02  9:08 ` Sagi Grimberg
2014-10-03  5:16 ` Nicholas A. Bellinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox