All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitriy Bogdanov <d.bogdanov@yadro.com>
To: Mike Christie <michael.christie@oracle.com>,
	Martin Petersen <martin.petersen@oracle.com>,
	"target-devel@vger.kernel.org" <target-devel@vger.kernel.org>
Cc: "linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	"linux@yadro.com" <linux@yadro.com>,
	Konstantin Shelekhin <k.shelekhin@yadro.com>,
	Roman Bolshakov <r.bolshakov@yadro.com>
Subject: RE: [PATCH v3] target: core: remove from tmr_list at lun unlink
Date: Mon, 20 Sep 2021 16:40:23 +0000	[thread overview]
Message-ID: <8f81906545014a768a7f775d1dcf51cf@yadro.com> (raw)
In-Reply-To: <40b321b4-76bd-8eb4-84bd-c7378ad2bbc7@oracle.com>

Hi Mike,

> > @@ -234,6 +225,7 @@ static void core_tmr_drain_tmr_list(
> >  		}
> >  
> >  		list_move_tail(&tmr_p->tmr_list, &drain_tmr_list);
> > +		tmr_p->tmr_dev = NULL;
>
> Is this patch now adding a way to hit:
>
> if (!tmr->tmr_dev)
>	WARN_ON_ONCE(transport_lookup_tmr_lun(tmr->task_cmd) < 0);                      
>
> in core_tmr_abort_task?
>
> You have the abort and lun reset works running on different CPUs.
> The lun reset hits the above code first and clears tmr_dev.
> The abort then hits the tmr->tmr_dev check and tries to do
> transport_lookup_tmr_lun.
>
> For the case where the lun is not removed, it looks like
> transport_lookup_tmr_lun will add the tmr to the dev_tmr_list
> but it would also be on the drain_tmr_list above so we would
> hit list corruption.

Yes, there is a such race. I think,  I can solve it by changing the order of
draining the tmr_list and state_list at LUN Reset to make the raced lines 
be under the same lock.

Especially SAM-5 describes(but does not require) aborting commands
before tmfs:
| When responding to a logical unit reset condition, the logical unit shall:
|	a) abort all commands as described in 5.6;
|	b) abort all copy operations (see SPC-4);
|	c) terminate all task management functions;


> For the case where the lun is getting removed, percpu_ref_tryget_live
> would fail in transport_lookup_tmr_lun and we hit the WARN_ON_ONCE.
> I think though with your patch, we would be ok and don't want
> the WARN_ON_ONCE, right? The lun reset would just wait for the
> abort. When it completes the abort and reset complete as expected.

I don’t understand the meaning of that transport_lookup_tmr_lun there.
Every TMF Abort has already executed transport_lookup_tmr_lun at the very
beginning of its handling. 
Eliminating the race will eliminate the impact of my patch on this case too. 

BR,
 Dmitry

  reply	other threads:[~2021-09-20 16:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-15 14:17 [PATCH v3] target: core: remove from tmr_list at lun unlink Dmitry Bogdanov
2021-09-17 16:57 ` Mike Christie
2021-09-20 16:40   ` Dmitriy Bogdanov [this message]
2021-09-22 16:00     ` Mike Christie
2021-09-22 16:43       ` Dmitriy Bogdanov

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=8f81906545014a768a7f775d1dcf51cf@yadro.com \
    --to=d.bogdanov@yadro.com \
    --cc=k.shelekhin@yadro.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux@yadro.com \
    --cc=martin.petersen@oracle.com \
    --cc=michael.christie@oracle.com \
    --cc=r.bolshakov@yadro.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 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.