[PATCH V2 1/2] md/raid10: annotate lockless access to array_freeze_pending

From: Zizhi Wo

Date: Sun Aug 16 2026 - 23:40:14 EST


conf->array_freeze_pending is updated under conf->resync_lock in
freeze_array(), but read locklessly in allow_barrier(). Annotate these
accesses with READ_ONCE()/WRITE_ONCE() to document the intentional lockless
access and to prevent load/store tearing or fusing by the compiler. No
functional change.

Signed-off-by: Zizhi Wo <wozizhi@xxxxxxxxxx>
---
drivers/md/raid10.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 0a3cfdd3f5df..dc40110a6736 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1031,11 +1031,11 @@ static bool wait_barrier(struct r10conf *conf, bool nowait)
}

static void allow_barrier(struct r10conf *conf)
{
if ((atomic_dec_and_test(&conf->nr_pending)) ||
- (conf->array_freeze_pending))
+ READ_ONCE(conf->array_freeze_pending))
wake_up_barrier(conf);
}

static void freeze_array(struct r10conf *conf, int extra)
{
@@ -1050,16 +1050,16 @@ static void freeze_array(struct r10conf *conf, int extra)
* Thus the number queued (nr_queued) plus this request (extra)
* must match the number of pending IOs (nr_pending) before
* we continue.
*/
write_seqlock_irq(&conf->resync_lock);
- conf->array_freeze_pending++;
+ WRITE_ONCE(conf->array_freeze_pending, conf->array_freeze_pending + 1);
WRITE_ONCE(conf->barrier, conf->barrier + 1);
conf->nr_waiting++;
wait_event_barrier_cmd(conf, atomic_read(&conf->nr_pending) ==
conf->nr_queued + extra, flush_pending_writes(conf));
- conf->array_freeze_pending--;
+ WRITE_ONCE(conf->array_freeze_pending, conf->array_freeze_pending - 1);
write_sequnlock_irq(&conf->resync_lock);
}

static void unfreeze_array(struct r10conf *conf)
{
--
2.52.0