diff mbox series

[-next] md/raid5: fix spares errors about rcu usage

Message ID 20240615085143.1648223-1-yukuai1@huaweicloud.com (mailing list archive)
State Accepted
Headers show
Series [-next] md/raid5: fix spares errors about rcu usage | expand

Checks

Context Check Description
mdraidci/vmtest-md-6_11-PR success PR summary
mdraidci/vmtest-md-6_11-VM_Test-0 success Logs for build-kernel

Commit Message

Yu Kuai June 15, 2024, 8:51 a.m. UTC
From: Yu Kuai <yukuai3@huawei.com>

As commit ad8606702f26 ("md/raid5: remove rcu protection to access rdev
from conf") explains, rcu protection can be removed, however, there are
three places left, there won't be any real problems.

drivers/md/raid5.c:8071:24: error: incompatible types in comparison expression (different address spaces):
drivers/md/raid5.c:8071:24:    struct md_rdev [noderef] __rcu *
drivers/md/raid5.c:8071:24:    struct md_rdev *
drivers/md/raid5.c:7569:25: error: incompatible types in comparison expression (different address spaces):
drivers/md/raid5.c:7569:25:    struct md_rdev [noderef] __rcu *
drivers/md/raid5.c:7569:25:    struct md_rdev *
drivers/md/raid5.c:7573:25: error: incompatible types in comparison expression (different address spaces):
drivers/md/raid5.c:7573:25:    struct md_rdev [noderef] __rcu *
drivers/md/raid5.c:7573:25:    struct md_rdev *

Fixes: ad8606702f26 ("md/raid5: remove rcu protection to access rdev from conf")
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 drivers/md/raid5.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

Comments

Song Liu July 4, 2024, 7:06 a.m. UTC | #1
On Sat, Jun 15, 2024 at 4:52 PM Yu Kuai <yukuai1@huaweicloud.com> wrote:
>
> From: Yu Kuai <yukuai3@huawei.com>
>
> As commit ad8606702f26 ("md/raid5: remove rcu protection to access rdev
> from conf") explains, rcu protection can be removed, however, there are
> three places left, there won't be any real problems.
>
> drivers/md/raid5.c:8071:24: error: incompatible types in comparison expression (different address spaces):
> drivers/md/raid5.c:8071:24:    struct md_rdev [noderef] __rcu *
> drivers/md/raid5.c:8071:24:    struct md_rdev *
> drivers/md/raid5.c:7569:25: error: incompatible types in comparison expression (different address spaces):
> drivers/md/raid5.c:7569:25:    struct md_rdev [noderef] __rcu *
> drivers/md/raid5.c:7569:25:    struct md_rdev *
> drivers/md/raid5.c:7573:25: error: incompatible types in comparison expression (different address spaces):
> drivers/md/raid5.c:7573:25:    struct md_rdev [noderef] __rcu *
> drivers/md/raid5.c:7573:25:    struct md_rdev *
>
> Fixes: ad8606702f26 ("md/raid5: remove rcu protection to access rdev from conf")
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>

Applied to md-6.11. Thanks!

Song
diff mbox series

Patch

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 547fd15115cd..3827f7df6b9a 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -155,7 +155,7 @@  static int raid6_idx_to_slot(int idx, struct stripe_head *sh,
 	return slot;
 }
 
-static void print_raid5_conf (struct r5conf *conf);
+static void print_raid5_conf(struct r5conf *conf);
 
 static int stripe_operations_active(struct stripe_head *sh)
 {
@@ -7566,11 +7566,11 @@  static struct r5conf *setup_conf(struct mddev *mddev)
 		if (test_bit(Replacement, &rdev->flags)) {
 			if (disk->replacement)
 				goto abort;
-			RCU_INIT_POINTER(disk->replacement, rdev);
+			disk->replacement = rdev;
 		} else {
 			if (disk->rdev)
 				goto abort;
-			RCU_INIT_POINTER(disk->rdev, rdev);
+			disk->rdev = rdev;
 		}
 
 		if (test_bit(In_sync, &rdev->flags)) {
@@ -8052,7 +8052,7 @@  static void raid5_status(struct seq_file *seq, struct mddev *mddev)
 	seq_printf (seq, "]");
 }
 
-static void print_raid5_conf (struct r5conf *conf)
+static void print_raid5_conf(struct r5conf *conf)
 {
 	struct md_rdev *rdev;
 	int i;
@@ -8066,15 +8066,13 @@  static void print_raid5_conf (struct r5conf *conf)
 	       conf->raid_disks,
 	       conf->raid_disks - conf->mddev->degraded);
 
-	rcu_read_lock();
 	for (i = 0; i < conf->raid_disks; i++) {
-		rdev = rcu_dereference(conf->disks[i].rdev);
+		rdev = conf->disks[i].rdev;
 		if (rdev)
 			pr_debug(" disk %d, o:%d, dev:%pg\n",
 			       i, !test_bit(Faulty, &rdev->flags),
 			       rdev->bdev);
 	}
-	rcu_read_unlock();
 }
 
 static int raid5_spare_active(struct mddev *mddev)