[PATCH v3 4/4] scsi: target: iscsi: Claim the completion on the DataOut submit path
From: Laurence Oberman
Date: Mon Oct 26 2026 - 08:48:59 EST
When the final DataOut PDU for a WRITE has been received,
iscsit_check_dataout_payload() submits the command with
target_execute_cmd(). For a command that has already been aborted,
target_execute_cmd() calls target_cmd_interrupted() before it touches
t_state, so it queues target_abort_work and returns with the command still
in TRANSPORT_WRITE_PENDING and still on conn_cmd_list, recording nothing to
say that a completion has been started.
A connection drop before target_abort_work reaches iscsit_aborted_task()
then lets iscsit_release_commands_from_conn() complete the command a second
time.
Complete aborted commands through iscsit_complete_aborted_cmd() rather than
handing them to target_execute_cmd(). Both reach target_cmd_interrupted()
and queue target_abort_work; the work target_execute_cmd() does after that
test is not reached for an aborted command either way. The dataout timer
has already been stopped a few lines above, so the helper's call to
iscsit_stop_dataout_timer() is a no-op here.
Fixes: ea87981a0ee8 ("scsi: target: iscsi: Handle abort for WRITE_PENDING cmds")
Signed-off-by: Laurence Oberman <loberman@xxxxxxxxxx>
---
Notes:
Not observed in the field; closed by inspection after the review of v2
pointed out that this site has the same shape as the one in
__iscsit_check_dataout_hdr(). I have deliberately left Cc: stable off,
since the window predates d5869dae5080 and has never been seen -- I would
rather it sat in mainline for a cycle first. Happy to drop this patch if
you would prefer the series to stop at patch 3.
drivers/target/iscsi/iscsi_target.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index 83184de..e6113a5 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);
return 0;
} else /* DATAOUT_CANNOT_RECOVER */
--
2.43.0