md/raid10: fix improper BUG_ON() in raise_barrier()
authorYu Kuai <yukuai3@huawei.com>
Fri, 16 Sep 2022 11:34:27 +0000 (19:34 +0800)
committerSong Liu <song@kernel.org>
Thu, 22 Sep 2022 07:05:05 +0000 (00:05 -0700)
'conf->barrier' is protected by 'conf->resync_lock', reading
'conf->barrier' without holding the lock is wrong.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
Acked-by: Guoqing Jiang <guoqing.jiang@linux.dev>
Signed-off-by: Song Liu <song@kernel.org>
drivers/md/raid10.c

index 461c8a7..2970a73 100644 (file)
@@ -936,8 +936,8 @@ static void flush_pending_writes(struct r10conf *conf)
 
 static void raise_barrier(struct r10conf *conf, int force)
 {
-       BUG_ON(force && !conf->barrier);
        spin_lock_irq(&conf->resync_lock);
+       BUG_ON(force && !conf->barrier);
 
        /* Wait until no block IO is waiting (unless 'force') */
        wait_event_lock_irq(conf->wait_barrier, force || !conf->nr_waiting,