[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c47a4ff6-43a0-a536-29ff-db2d1a931181@huaweicloud.com>
Date: Mon, 29 Jan 2024 21:55:39 +0800
From: Li Lingfeng <lilingfeng@...weicloud.com>
To: song@...nel.org
Cc: linux-raid@...r.kernel.org, linux-kernel@...r.kernel.org,
yukuai3@...wei.com, linan122@...wei.com, yi.zhang@...wei.com,
yangerkun@...wei.com, lilingfeng3@...wei.com
Subject: Re: [PATCH] md: get rdev->mddev with READ_ONCE()
Friendly ping ...
Thanks
在 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.
>
> 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