[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a5d9a13b-6b95-b2ba-203a-f8bb8dfb4936@huaweicloud.com>
Date: Tue, 2 Jan 2024 14:16:32 +0800
From: Yu Kuai <yukuai1@...weicloud.com>
To: Li Lingfeng <lilingfeng@...weicloud.com>, song@...nel.org
Cc: linux-raid@...r.kernel.org, linux-kernel@...r.kernel.org,
linan122@...wei.com, yi.zhang@...wei.com, yangerkun@...wei.com,
lilingfeng3@...wei.com, "yukuai (C)" <yukuai3@...wei.com>
Subject: Re: [PATCH] md: get rdev->mddev with READ_ONCE()
在 2023/12/29 15:05, Li Lingfeng 写道:
> From: Li Lingfeng <lilingfeng3@...wei.com>
>
> Users may get rdev->mddev by sysfs while rdev is releasing.
> So use both READ_ONCE() and WRITE_ONCE() to prevent load/store tearing
> and to read/write mddev atomically.
LGTM
Reviewed-by: Yu Kuai <yukuai3@...wei.com>
>
> Signed-off-by: Li Lingfeng <lilingfeng3@...wei.com>
> ---
> drivers/md/md.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index 9bdd57324c37..3b38a565bffa 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -2562,7 +2562,7 @@ static void md_kick_rdev_from_array(struct md_rdev *rdev)
> list_del_rcu(&rdev->same_set);
> pr_debug("md: unbind<%pg>\n", rdev->bdev);
> mddev_destroy_serial_pool(rdev->mddev, rdev);
> - rdev->mddev = NULL;
> + WRITE_ONCE(rdev->mddev, NULL);
> sysfs_remove_link(&rdev->kobj, "block");
> sysfs_put(rdev->sysfs_state);
> sysfs_put(rdev->sysfs_unack_badblocks);
> @@ -3646,7 +3646,7 @@ rdev_attr_store(struct kobject *kobj, struct attribute *attr,
> struct kernfs_node *kn = NULL;
> bool suspend = false;
> ssize_t rv;
> - struct mddev *mddev = rdev->mddev;
> + struct mddev *mddev = READ_ONCE(rdev->mddev);
>
> if (!entry->store)
> return -EIO;
>
Powered by blists - more mailing lists