From: Chaohai Chen <wdhh6@aliyun.com>
To: John Garry <john.g.garry@oracle.com>
Cc: James.Bottomley@hansenpartnership.com,
martin.petersen@oracle.com, dlemoal@kernel.org,
bvanassche@acm.org, hch@infradead.org,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] scsi: core: Fix async_scan race condition with READ_ONCE/WRITE_ONCE
Date: Wed, 4 Mar 2026 17:43:33 +0800 [thread overview]
Message-ID: <aaf+ucySU/sSN8WZ@VM-209-93-tencentos> (raw)
In-Reply-To: <2885ac50-2326-4548-b92c-c5ae566a8013@oracle.com>
On Wed, Mar 04, 2026 at 09:20:25AM +0000, John Garry wrote:
> On 04/03/2026 07:57, Chaohai Chen wrote:
> > Previously, host_lock was used to prevent bit-set conflicts in async_scan,
> > but this approach introduced naked reads in some code paths.
> >
> > Convert async_scan from a bitfield to a bool type to eliminate bit-level
> > conflicts entirely. Use READ_ONCE() and WRITE_ONCE() to ensure proper
> > memory ordering on Alpha and satisfy KCSAN requirements.
>
> Is the shost->scan_mutex always held when shost->async_scan is read/written?
>
Yes. In theory, there is no need for READ-ONCE/WRITE-ONCE. Plus, this belongs
to defensive programming. And it indicates that this is a shared variable,
which means that this variable will be accessed by multiple threads and
concurrency issues need to be handled carefully.
next prev parent reply other threads:[~2026-03-04 9:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-04 7:57 Chaohai Chen
2026-03-04 8:32 ` Damien Le Moal
2026-03-04 9:20 ` John Garry
2026-03-04 9:43 ` Chaohai Chen [this message]
2026-03-04 9:52 ` Damien Le Moal
2026-03-04 9:55 ` John Garry
2026-03-04 12:21 ` Bart Van Assche
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=aaf+ucySU/sSN8WZ@VM-209-93-tencentos \
--to=wdhh6@aliyun.com \
--cc=James.Bottomley@hansenpartnership.com \
--cc=bvanassche@acm.org \
--cc=dlemoal@kernel.org \
--cc=hch@infradead.org \
--cc=john.g.garry@oracle.com \
--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
all inboxes | Powered by JetHome®