Skip to content

Commit cf0149c

Browse files
scsi: target: tcm_loop: Fix wrong abort tag
JIRA: https://issues.redhat.com/browse/RHEL-111938 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: 6375f89 ("tcm_loop: Fixup tag handling") Signed-off-by: Guixin Liu <kanie@linux.alibaba.com> Link: https://lore.kernel.org/r/20250313014728.105849-1-kanie@linux.alibaba.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> (cherry picked from commit 1909b64) Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
1 parent 978a271 commit cf0149c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/target/loopback/tcm_loop.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ static int tcm_loop_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *sc)
176176

177177
memset(tl_cmd, 0, sizeof(*tl_cmd));
178178
tl_cmd->sc = sc;
179-
tl_cmd->sc_cmd_tag = scsi_cmd_to_rq(sc)->tag;
179+
tl_cmd->sc_cmd_tag = blk_mq_unique_tag(scsi_cmd_to_rq(sc));
180180

181181
tcm_loop_target_queue_cmd(tl_cmd);
182182
return 0;
@@ -242,7 +242,8 @@ static int tcm_loop_abort_task(struct scsi_cmnd *sc)
242242
tl_hba = *(struct tcm_loop_hba **)shost_priv(sc->device->host);
243243
tl_tpg = &tl_hba->tl_hba_tpgs[sc->device->id];
244244
ret = tcm_loop_issue_tmr(tl_tpg, sc->device->lun,
245-
scsi_cmd_to_rq(sc)->tag, TMR_ABORT_TASK);
245+
blk_mq_unique_tag(scsi_cmd_to_rq(sc)),
246+
TMR_ABORT_TASK);
246247
return (ret == TMR_FUNCTION_COMPLETE) ? SUCCESS : FAILED;
247248
}
248249

0 commit comments

Comments
 (0)