From: Chaohai Chen <wdhh6@aliyun.com>
To: Damien Le Moal <dlemoal@kernel.org>
Cc: James.Bottomley@hansenpartnership.com,
martin.petersen@oracle.com, linux-scsi@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] scsi: core: Fix missing lock when read async_scan in Scsi_Host
Date: Tue, 3 Mar 2026 17:20:49 +0800 [thread overview]
Message-ID: <aaan8Vlw7HQMZdA7@VM-209-93-tencentos> (raw)
In-Reply-To: <8dbc772a-e0dd-44d2-8e1f-1e54df42d72b@kernel.org>
On Tue, Mar 03, 2026 at 05:45:13PM +0900, Damien Le Moal wrote:
> On 3/2/26 21:13, Chaohai Chen wrote:
> > When setting the async_scan flag in host, the host lock was locked,
> > but it is not locked during reading. Encapsulate the corresponding
> > API to fix this issue.
> >
> > Signed-off-by: Chaohai Chen <wdhh6@aliyun.com>
> > ---
> > drivers/scsi/scsi_scan.c | 60 +++++++++++++++++++++++++++++-----------
> > 1 file changed, 44 insertions(+), 16 deletions(-)
> >
> > diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
> > index 60c06fa4ec32..8b63130ef2e5 100644
> > --- a/drivers/scsi/scsi_scan.c
> > +++ b/drivers/scsi/scsi_scan.c
> > @@ -122,6 +122,42 @@ struct async_scan_data {
> > struct completion prev_finished;
> > };
> >
> > +static bool scsi_test_async_scan(struct Scsi_Host *shost)
> > +{
> > + bool async;
> > + unsigned long flags;
> > +
> > + lockdep_assert_not_held(shost->host_lock);
> > +
> > + spin_lock_irqsave(shost->host_lock, flags);
> > + async = shost->async_scan;
> > + spin_unlock_irqrestore(shost->host_lock, flags);
> > +
> > + return async;
> > +}
>
> Use an atomic ?
>
The structure member async_stcan is defined in a bit field manner,
and using atomic may change the structure definition, making it too complex
next prev parent reply other threads:[~2026-03-03 9:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-02 12:13 [PATCH] scsi: core: Fix missing lock when read async_scan in Scsi_Host Chaohai Chen
2026-03-02 14:37 ` Bart Van Assche
2026-03-03 8:45 ` Damien Le Moal
2026-03-03 9:20 ` Chaohai Chen [this message]
2026-03-03 9:28 ` Damien Le Moal
2026-03-03 15:12 ` Christoph Hellwig
2026-03-03 16:25 ` James Bottomley
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=aaan8Vlw7HQMZdA7@VM-209-93-tencentos \
--to=wdhh6@aliyun.com \
--cc=James.Bottomley@hansenpartnership.com \
--cc=dlemoal@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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