[PATCH v3 0/3] scsi: libiscsi: tighten task completion
From: Yehyeong Lee
Date: Sun Nov 15 2026 - 07:21:40 EST
1/3 stops the receive path from completing a management task that is still
queued or still being filled in, so a slot cannot be returned to the task
pool while the transmit path still owns it. 2/3 stops it from completing a
NOP-Out sent with RESERVED_ITT, whose single reference belongs to the
transport, so that reference cannot be dropped twice. 3/3 is new: it makes
the transmit path hold a reference before it publishes the state the other
two test, and makes the SCSI command lookup honour that state at all.
v2 -> v3:
- 1/3 and 2/3 are unchanged.
- 3/3 is new.
The review of v2 1/2 raised three issues. All three are older than this
series, which narrows two of them and leaves the third as it was, and 3/3
addresses each one:
- the window between the ISCSI_TASK_RUNNING store in
iscsi_prep_mgmt_task() / iscsi_prep_scsi_cmd_pdu() and iscsi_get_task()
in iscsi_xmit_task(): the store moves into iscsi_xmit_task(), after the
reference has been taken. For a SCSI command that alone is not enough,
because iscsi_itt_to_ctask() never read task->state, so a command still
queued on conn->cmdqueue in ISCSI_TASK_PENDING could be completed by the
receive path; that lookup now skips a task that has not been sent, the
way 1/3 does for the management lookup.
- iscsi_xmit_task() requeueing in conn->task a task that the receive path
completed while frwd_lock was dropped: the requeue becomes conditional
on the task still being ISCSI_TASK_RUNNING, read under back_lock, which
is the test commit 533ac412fdb4 ("scsi: iscsi: Remove unneeded task
state check") removed. The other half of the same window - a task that
was parked in conn->task and finished before it could be sent again - is
dropped now instead of sent.
- transports without ihost->workq, which call session->tt->xmit_task()
from iscsi_send_mgmt_task() and iscsi_queuecommand() with no reference
beyond the allocation one: both now take a transmit reference of their
own, and both finish with a failed send inside the same back_lock
section that tests for it, so the receive path can no longer complete
a task whose reference the caller is about to put.
iscsi_queuecommand() gives the command back to scsi-ml right there;
iscsi_send_mgmt_task(), whose caller frees the task, parks it in
ISCSI_TASK_COMPLETED, which is a state no ->cleanup_task() reads
differently from ISCSI_TASK_RUNNING.
3/3 needs 1/3 underneath, and is marked for stable for the same reason.
v1 of 1/3:
https://lore.kernel.org/all/20261113145140.282504-1-yhlee@xxxxxxxxxxxxxxxxxx/
v1 of 2/3:
https://lore.kernel.org/all/20261113232322.395246-1-yhlee@xxxxxxxxxxxxxxxxxx/
v2:
https://lore.kernel.org/all/20261113233938.397415-1-yhlee@xxxxxxxxxxxxxxxxxx/
Best regards,
Yehyeong Lee
Yehyeong Lee (3):
scsi: libiscsi: only complete a task that has been sent
scsi: libiscsi: do not complete a task sent with a reserved ITT
scsi: libiscsi: take a transmit reference before a task is published
drivers/scsi/libiscsi.c | 67 +++++++++++++++++++++++++++++++++++------
1 file changed, 58 insertions(+), 9 deletions(-)
base-commit: 7e1392a42ea288d70a266f6553fe06f57f8647ea
--
2.43.0