public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: target: tcm_loop: fix wrong abort tag
@ 2025-03-13  1:47 Guixin Liu
  2025-03-14  3:06 ` Guixin Liu
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Guixin Liu @ 2025-03-13  1:47 UTC (permalink / raw)
  To: Martin K . Petersen; +Cc: linux-scsi, target-devel

When the tcm_loop_nr_hw_queues is set to a value greater than 1, the
tags of requests in the block layer are no longer unique. This may lead
to erroneous aborting of commands with the same tag. The issue can be
resolved by using blk_mq_unique_tag to generate globally unique
identifiers by combining the hardware queue index and per-queue tags.

Fixes: 6375f8908255 ("tcm_loop: Fixup tag handling")
Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
---
 drivers/target/loopback/tcm_loop.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
index 761c511aea07..c7b7da629741 100644
--- a/drivers/target/loopback/tcm_loop.c
+++ b/drivers/target/loopback/tcm_loop.c
@@ -176,7 +176,7 @@ static int tcm_loop_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *sc)
 
 	memset(tl_cmd, 0, sizeof(*tl_cmd));
 	tl_cmd->sc = sc;
-	tl_cmd->sc_cmd_tag = scsi_cmd_to_rq(sc)->tag;
+	tl_cmd->sc_cmd_tag = blk_mq_unique_tag(scsi_cmd_to_rq(sc));
 
 	tcm_loop_target_queue_cmd(tl_cmd);
 	return 0;
@@ -242,7 +242,8 @@ static int tcm_loop_abort_task(struct scsi_cmnd *sc)
 	tl_hba = *(struct tcm_loop_hba **)shost_priv(sc->device->host);
 	tl_tpg = &tl_hba->tl_hba_tpgs[sc->device->id];
 	ret = tcm_loop_issue_tmr(tl_tpg, sc->device->lun,
-				 scsi_cmd_to_rq(sc)->tag, TMR_ABORT_TASK);
+				 blk_mq_unique_tag(scsi_cmd_to_rq(sc)),
+				 TMR_ABORT_TASK);
 	return (ret == TMR_FUNCTION_COMPLETE) ? SUCCESS : FAILED;
 }
 
-- 
2.43.0


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

* Re: [PATCH] scsi: target: tcm_loop: fix wrong abort tag
  2025-03-13  1:47 [PATCH] scsi: target: tcm_loop: fix wrong abort tag Guixin Liu
@ 2025-03-14  3:06 ` Guixin Liu
  2025-03-18  1:53 ` Martin K. Petersen
  2025-03-21  0:36 ` Martin K. Petersen
  2 siblings, 0 replies; 4+ messages in thread
From: Guixin Liu @ 2025-03-14  3:06 UTC (permalink / raw)
  To: Martin K . Petersen; +Cc: linux-scsi, target-devel

Gently ping...

Hi Martin, this is a serious issue I think, cloud you plz take a look?

Best Regards,

Guixin Liu

在 2025/3/13 09:47, Guixin Liu 写道:
> When the tcm_loop_nr_hw_queues is set to a value greater than 1, the
> tags of requests in the block layer are no longer unique. This may lead
> to erroneous aborting of commands with the same tag. The issue can be
> resolved by using blk_mq_unique_tag to generate globally unique
> identifiers by combining the hardware queue index and per-queue tags.
>
> Fixes: 6375f8908255 ("tcm_loop: Fixup tag handling")
> Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
> ---
>   drivers/target/loopback/tcm_loop.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
> index 761c511aea07..c7b7da629741 100644
> --- a/drivers/target/loopback/tcm_loop.c
> +++ b/drivers/target/loopback/tcm_loop.c
> @@ -176,7 +176,7 @@ static int tcm_loop_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *sc)
>   
>   	memset(tl_cmd, 0, sizeof(*tl_cmd));
>   	tl_cmd->sc = sc;
> -	tl_cmd->sc_cmd_tag = scsi_cmd_to_rq(sc)->tag;
> +	tl_cmd->sc_cmd_tag = blk_mq_unique_tag(scsi_cmd_to_rq(sc));
>   
>   	tcm_loop_target_queue_cmd(tl_cmd);
>   	return 0;
> @@ -242,7 +242,8 @@ static int tcm_loop_abort_task(struct scsi_cmnd *sc)
>   	tl_hba = *(struct tcm_loop_hba **)shost_priv(sc->device->host);
>   	tl_tpg = &tl_hba->tl_hba_tpgs[sc->device->id];
>   	ret = tcm_loop_issue_tmr(tl_tpg, sc->device->lun,
> -				 scsi_cmd_to_rq(sc)->tag, TMR_ABORT_TASK);
> +				 blk_mq_unique_tag(scsi_cmd_to_rq(sc)),
> +				 TMR_ABORT_TASK);
>   	return (ret == TMR_FUNCTION_COMPLETE) ? SUCCESS : FAILED;
>   }
>   

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

* Re: [PATCH] scsi: target: tcm_loop: fix wrong abort tag
  2025-03-13  1:47 [PATCH] scsi: target: tcm_loop: fix wrong abort tag Guixin Liu
  2025-03-14  3:06 ` Guixin Liu
@ 2025-03-18  1:53 ` Martin K. Petersen
  2025-03-21  0:36 ` Martin K. Petersen
  2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2025-03-18  1:53 UTC (permalink / raw)
  To: Guixin Liu; +Cc: Martin K . Petersen, linux-scsi, target-devel


Guixin,

> When the tcm_loop_nr_hw_queues is set to a value greater than 1, the
> tags of requests in the block layer are no longer unique. This may
> lead to erroneous aborting of commands with the same tag. The issue
> can be resolved by using blk_mq_unique_tag to generate globally unique
> identifiers by combining the hardware queue index and per-queue tags.

Applied to 6.15/scsi-staging, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH] scsi: target: tcm_loop: fix wrong abort tag
  2025-03-13  1:47 [PATCH] scsi: target: tcm_loop: fix wrong abort tag Guixin Liu
  2025-03-14  3:06 ` Guixin Liu
  2025-03-18  1:53 ` Martin K. Petersen
@ 2025-03-21  0:36 ` Martin K. Petersen
  2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2025-03-21  0:36 UTC (permalink / raw)
  To: Guixin Liu; +Cc: Martin K . Petersen, linux-scsi, target-devel

On Thu, 13 Mar 2025 09:47:27 +0800, Guixin Liu wrote:

> When the tcm_loop_nr_hw_queues is set to a value greater than 1, the
> tags of requests in the block layer are no longer unique. This may lead
> to erroneous aborting of commands with the same tag. The issue can be
> resolved by using blk_mq_unique_tag to generate globally unique
> identifiers by combining the hardware queue index and per-queue tags.
> 
> 
> [...]

Applied to 6.15/scsi-queue, thanks!

[1/1] scsi: target: tcm_loop: fix wrong abort tag
      https://git.kernel.org/mkp/scsi/c/1909b643034e

-- 
Martin K. Petersen	Oracle Linux Engineering

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

end of thread, other threads:[~2025-03-21  0:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-13  1:47 [PATCH] scsi: target: tcm_loop: fix wrong abort tag Guixin Liu
2025-03-14  3:06 ` Guixin Liu
2025-03-18  1:53 ` Martin K. Petersen
2025-03-21  0:36 ` Martin K. Petersen

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