From: Ming Lei <ming.lei@redhat.com>
To: Bart Van Assche <bvanassche@acm.org>
Cc: linux-scsi@vger.kernel.org,
"Martin K . Petersen" <martin.petersen@oracle.com>,
Christoph Hellwig <hch@lst.de>,
"Ewan D . Milne" <emilne@redhat.com>,
Hannes Reinecke <hare@suse.de>
Subject: Re: [PATCH] scsi: core: don't start concurrent async scan on same host
Date: Mon, 19 Oct 2020 22:38:18 +0800 [thread overview]
Message-ID: <20201019143818.GA1427336@T590> (raw)
In-Reply-To: <ff55dd89-f48c-2900-d967-8eb6b1e33289@acm.org>
On Mon, Oct 19, 2020 at 07:17:52AM -0700, Bart Van Assche wrote:
> On 10/9/20 8:25 PM, Ming Lei wrote:
> > Current scsi host scan mechanism supposes to fallback into sync host
> > scan if async scan is in-progress. However, this rule isn't strictly
> > respected, because scsi_prep_async_scan() doesn't hold scan_mutex when
> > checking shost->async_scan. When scsi_scan_host() is called
> > concurrently, two async scan on same host may be started, and hang in
> > do_scan_async() is observed.
> >
> > Fixes this issue by checking & setting shost->async_scan atomically
> > with shost->scan_mutex.
>
> Did you perhaps mean "by serializing shost->async_scan accesses with
> shost->scan_mutex"?
Specifically, the following checking & setting has to be done atomically,
so shost->scan_mutex is required, just as what scsi_finish_async_scan()
does for clearing shost->async_scan:
scsi_prep_async_scan():
if (!shost->async_scan)
return NULL;
...
shost->async_scan = 1
>
> It is not clear to me why the shost->async_scan assignment is protected
> with the host lock. Can spin_lock_irqsave(shost->host_lock, flags) and
> spin_unlock_irqrestore(shost->host_lock, flags) be left out from this
> function?
I think it is doable to remove the ->host_lock from both scsi_prep_async_scan()
and scsi_finish_async_scan(), which can be done as one follow-up cleanup.
With this patch, all reading/writing shost->async_scan are protected by
shost->scan_mutex.
>
> Anyway:
>
> Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Thanks!
--
Ming
next prev parent reply other threads:[~2020-10-19 14:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-10 3:25 [PATCH] scsi: core: don't start concurrent async scan on same host Ming Lei
2020-10-10 17:31 ` Lee Duncan
2020-10-17 6:23 ` Ming Lei
2020-10-19 14:17 ` Bart Van Assche
2020-10-19 14:38 ` Ming Lei [this message]
2020-10-26 20:08 ` Martin K. Petersen
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=20201019143818.GA1427336@T590 \
--to=ming.lei@redhat.com \
--cc=bvanassche@acm.org \
--cc=emilne@redhat.com \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/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