From: Damien Le Moal <dlemoal@kernel.org>
To: Chaohai Chen <wdhh6@aliyun.com>, John Garry <john.g.garry@oracle.com>
Cc: James.Bottomley@hansenpartnership.com,
martin.petersen@oracle.com, 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 18:52:16 +0900 [thread overview]
Message-ID: <391b74b8-eb4b-4510-9cc8-3483f6605748@kernel.org> (raw)
In-Reply-To: <aaf+ucySU/sSN8WZ@VM-209-93-tencentos>
On 3/4/26 18:43, Chaohai Chen wrote:
> 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.
If the scan_mutex is always held when scan_mutex is used, there will not be
multiple threads, unless there are accessed also from IRQ context, which would
be odd. So I am not sure what concurrency issue you are referring to here.
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2026-03-04 9:52 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
2026-03-04 9:52 ` Damien Le Moal [this message]
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=391b74b8-eb4b-4510-9cc8-3483f6605748@kernel.org \
--to=dlemoal@kernel.org \
--cc=James.Bottomley@hansenpartnership.com \
--cc=bvanassche@acm.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 \
--cc=wdhh6@aliyun.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®