From: sashiko-bot@kernel.org
To: "Laurence Oberman" <loberman@redhat.com>
Cc: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org
Subject: Re: [PATCH v3 4/4] scsi: target: iscsi: Claim the completion on the DataOut submit path
Date: Mon, 26 Oct 2026 13:08:41 +0000 [thread overview]
Message-ID: <sashiko-outbox-185270@kernel.org> (raw)
In-Reply-To: <20261026124344.745124-5-loberman@redhat.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] scsi: target: iscsi: CMD_T_ABORTED race in iscsit_check_dataout_payload()
--
commit 106a0e34d325c477082712ef599ef2736992fc34
Author: Laurence Oberman <loberman@redhat.com>
scsi: target: iscsi: Claim the completion on the DataOut submit path
This commit checks for CMD_T_ABORTED in iscsit_check_dataout_payload() before
submitting the command to target_execute_cmd(), completing already-aborted
commands via iscsit_complete_aborted_cmd() so that completion_claimed is set
and connection teardown does not complete the command a second time.
> diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
> index 83184de284825..e6113a549e053 100644
> --- a/drivers/target/iscsi/iscsi_target.c
> +++ b/drivers/target/iscsi/iscsi_target.c
> @@ -1699,6 +1699,16 @@ iscsit_check_dataout_payload(struct iscsit_cmd *cmd, struct iscsi_data *hdr,
> iscsit_stop_dataout_timer(cmd);
> if (ooo_cmdsn)
> return 0;
> + /*
> + * target_execute_cmd() tests CMD_T_ABORTED before it touches
> + * t_state, so for an aborted command it would queue
> + * target_abort_work and return with the command still in
> + * TRANSPORT_WRITE_PENDING and the completion unclaimed.
> + */
> + if (cmd->se_cmd.transport_state & CMD_T_ABORTED) {
> + iscsit_complete_aborted_cmd(cmd);
> + return 0;
> + }
> target_execute_cmd(&cmd->se_cmd);
[Severity: High]
Can CMD_T_ABORTED still be set after the check in
iscsit_check_dataout_payload() but before target_execute_cmd() updates
t_state, leaving the completion unclaimed?
If CMD_T_ABORTED is not yet set at this check, iscsit_check_dataout_payload()
calls target_execute_cmd() with cmd->completion_claimed still false and
cmd->se_cmd.t_state still in TRANSPORT_WRITE_PENDING.
A concurrent task management request (such as ABORT_TASK via
core_tmr_abort_task() or LUN_RESET via core_tmr_drain_state_list()) calling
__target_check_io_state() can then set CMD_T_ABORTED before
target_execute_cmd() calls target_cmd_interrupted():
drivers/target/target_core_tmr.c:__target_check_io_state()
spin_lock_irqsave(&se_cmd->t_state_lock, flags);
...
se_cmd->transport_state |= CMD_T_ABORTED;
When target_execute_cmd() runs, it calls target_cmd_interrupted() before
taking t_state_lock to transition t_state to TRANSPORT_PROCESSING:
drivers/target/target_core_transport.c:target_execute_cmd()
if (target_cmd_interrupted(cmd))
return;
spin_lock_irq(&cmd->t_state_lock);
cmd->t_state = TRANSPORT_PROCESSING;
cmd->transport_state |= CMD_T_ACTIVE | CMD_T_SENT;
spin_unlock_irq(&cmd->t_state_lock);
Because target_cmd_interrupted() sees CMD_T_ABORTED, it queues
target_abort_work on target_completion_wq and returns true, so
target_execute_cmd() returns with t_state still in TRANSPORT_WRITE_PENDING
and completion_claimed still false.
If the connection then drops, iscsit_release_commands_from_conn() sees
TRANSPORT_WRITE_PENDING and claims the completion:
drivers/target/iscsi/iscsi_target.c:iscsit_release_commands_from_conn()
if (cmd->se_cmd.t_state == TRANSPORT_WRITE_PENDING) {
bool claimed = iscsit_claim_completion_locked(cmd);
spin_unlock_irq(&se_cmd->t_state_lock);
if (claimed)
target_complete_cmd(&cmd->se_cmd,
SAM_STAT_TASK_ABORTED);
continue;
}
Wouldn't that call target_complete_cmd() and re-queue cmd->se_cmd.work while
target_abort_work is already queued or running?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261026124344.745124-1-loberman@redhat.com?part=4
prev parent reply other threads:[~2026-10-26 13:08 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-26 12:43 [PATCH v3 0/4] scsi: target: iscsi: fix stalled and doubly completed aborted WRITEs Laurence Oberman
2026-10-26 12:43 ` [PATCH v3 1/4] scsi: target: iscsi: Complete an aborted WRITE stuck before the first R2T Laurence Oberman
2026-10-26 13:13 ` sashiko-bot
2026-10-26 12:43 ` [PATCH v3 2/4] scsi: target: iscsi: Complete an aborted WRITE when a new R2T would be sent Laurence Oberman
2026-10-26 13:13 ` sashiko-bot
2026-10-26 13:42 ` Laurence Oberman
2026-10-26 12:43 ` [PATCH v3 3/4] scsi: target: iscsi: Claim the completion in __iscsit_check_dataout_hdr() Laurence Oberman
2026-10-26 12:43 ` [PATCH v3 4/4] scsi: target: iscsi: Claim the completion on the DataOut submit path Laurence Oberman
2026-10-26 13:08 ` sashiko-bot [this message]
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=sashiko-outbox-185270@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=loberman@redhat.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=target-devel@vger.kernel.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.