mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Laurence Oberman <loberman@redhat.com>
To: Bart Van Assche <bvanassche@acm.org>, mkp@kernel.org
Cc: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org,
	 mlombard@redhat.com, michael.christie@oracle.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 0/3] scsi: target: iscsi: fix stalled and doubly completed aborted WRITEs
Date: Mon, 26 Oct 2026 14:57:03 -0400	[thread overview]
Message-ID: <698f6e4ff260d9480316c68ea30a63af05c936f5.camel@redhat.com> (raw)
In-Reply-To: <ea77fa74-3290-4685-b1d7-24c45ca1286c@acm.org>

On Mon, 2026-10-26 at 09:47 -0700, Bart Van Assche wrote:
> On 10/26/26 9:12 AM, Laurence Oberman wrote:
>  > If the guard is one-shot across both, a second call that would
> have
>  > taken the CMD_T_STOP branch is suppressed too, and I am not sure
> that
>  > is safe -- a suppressed complete_all() could leave a waiter in
>  > transport_wait_for_tasks() stuck. Should the guard cover only the
>  > CMD_T_ABORTED branch, or do you see a reason it is safe across
> both?
> 
> Please limit the guard to the CMD_T_ABORTED branch. The only things
> in
> target_cmd_interrupted() that must not run twice are in that branch:
> INIT_WORK() + queue_work() on cmd->work, and the
> transport_complete_callback() call. For COMPARE AND WRITE the latter
> releases dev->caw_sem in compare_and_write_callback(), so calling it
> twice would release that semaphore twice.
> 
> The CMD_T_STOP branch doesn't need a guard. complete_all() is
> idempotent and t_transport_stop_comp is initialized only once, in
> __target_init_cmd(). Suppressing a repeated complete_all() wouldn't
> strand a waiter either, since the completion stays done. However, a
> guard shared by both branches would be wrong for another reason: if
> the first call takes the CMD_T_STOP branch and CMD_T_ABORTED is set
> afterwards, a shared guard would suppress queueing target_abort_work
> and we would be back to the target_put_cmd_and_wait() hang.
> 
> Something like this (untested):
> 
> 	static bool target_cmd_interrupted(struct se_cmd *cmd)
> 	{
> 		bool queue_abort = false, stop = false;
> 		unsigned long flags;
> 		int post_ret;
> 
> 		spin_lock_irqsave(&cmd->t_state_lock, flags);
> 		if (cmd->transport_state & CMD_T_ABORTED) {
> 			if (cmd->transport_state &
> CMD_T_ABORT_QUEUED) {
> 				spin_unlock_irqrestore(&cmd-
> >t_state_lock,
> 						       flags);
> 				return true;
> 			}
> 			cmd->transport_state |= CMD_T_ABORT_QUEUED;
> 			queue_abort = true;
> 		} else if (cmd->transport_state & CMD_T_STOP) {
> 			stop = true;
> 		}
> 		spin_unlock_irqrestore(&cmd->t_state_lock, flags);
> 
> 		if (!queue_abort && !stop)
> 			return false;
> 		if (cmd->transport_complete_callback)
> 			cmd->transport_complete_callback(cmd, false,
> 							 &post_ret);
> 		if (queue_abort) {
> 			INIT_WORK(&cmd->work, target_abort_work);
> 			queue_work(target_completion_wq, &cmd-
> >work);
> 		} else {
> 			complete_all(&cmd->t_transport_stop_comp);
> 		}
> 		return true;
> 	}
> 
> Notes:
> - Please use spin_lock_irqsave(): target_complete_cmd() may be called
> by
>    backend drivers from interrupt context.
> - Call the callback and queue_work() after unlocking t_state_lock,
>    like the current code does.
> - A repeated call in the aborted case must still return true so that
>    callers don't proceed with normal completion.
> - Please describe in the patch description that the second call is a
>    no-op by design and that fabrics that complete once are
> unaffected.
> 
> Thanks,
> 
> Bart.

Hello Bart, 
You always take the time to help me and I appreciate it very much.
I am following up shortly with a V5 that I think addresses your
concerns and also limits this to only two patches. 
I am back-porting to RHEL9 and will get it tested the same way there
too but I expect it will be fine.

Thank you
Laurence


      reply	other threads:[~2026-10-26 18:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-26 15:07 Laurence Oberman
2026-10-26 15:07 ` [PATCH v4 1/3] scsi: target: iscsi: Complete an aborted WRITE stuck before the first R2T Laurence Oberman
2026-10-26 15:07 ` [PATCH v4 2/3] scsi: target: iscsi: Claim the completion in __iscsit_check_dataout_hdr() Laurence Oberman
2026-10-26 15:07 ` [PATCH v4 3/3] scsi: target: iscsi: Claim the completion on the DataOut submit path Laurence Oberman
2026-10-26 15:24 ` [PATCH v4 0/3] scsi: target: iscsi: fix stalled and doubly completed aborted WRITEs Bart Van Assche
2026-10-26 16:12   ` Laurence Oberman
2026-10-26 16:47     ` Bart Van Assche
2026-10-26 18:57       ` Laurence Oberman [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=698f6e4ff260d9480316c68ea30a63af05c936f5.camel@redhat.com \
    --to=loberman@redhat.com \
    --cc=bvanassche@acm.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=michael.christie@oracle.com \
    --cc=mkp@kernel.org \
    --cc=mlombard@redhat.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®