[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAPhsuW5SPiy5bsSfagYrSLa3JTn2Gw0VJKUToS2PS9h4w2=zSA@mail.gmail.com>
Date: Thu, 21 Dec 2023 10:58:38 -0800
From: Song Liu <song@...nel.org>
To: linan666@...weicloud.com
Cc: yukuai3@...wei.com, linux-raid@...r.kernel.org,
linux-kernel@...r.kernel.org, yi.zhang@...wei.com, houtao1@...wei.com,
yangerkun@...wei.com
Subject: Re: [PATCH 1/2] md: fix WARN_ON if create symlink fail in bind_rdev_to_array()
Hi,
On Wed, Dec 20, 2023 at 11:13 PM <linan666@...weicloud.com> wrote:
>
> From: Li Nan <linan122@...wei.com>
>
> Removing a device can trigger WARN_ON in bd_unlink_disk_holder() if creating
> symlink failed while adding device.
>
> WARNING: CPU: 0 PID: 742 at block/holder.c:145 bd_unlink_disk_holder+0x17b/0x1a0
>
> Fix it by adding the flag 'SymlinkCreated', which only be set after
> creating symlink success.
>
> Signed-off-by: Li Nan <linan122@...wei.com>
> ---
> drivers/md/md.h | 3 +++
> drivers/md/md.c | 8 ++++++--
> 2 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/md/md.h b/drivers/md/md.h
> index 8d881cc59799..427d17713a8c 100644
> --- a/drivers/md/md.h
> +++ b/drivers/md/md.h
> @@ -207,6 +207,9 @@ enum flag_bits {
> * check if there is collision between raid1
> * serial bios.
> */
> + SymlinkCreated, /* This device has created the symlink
> + * with gendisk.
> + */
In general, I would like to avoid adding flags if possible.
> };
>
> static inline int is_badblock(struct md_rdev *rdev, sector_t s, int sectors,
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index e05858653a41..d6612b922c76 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -2526,7 +2526,8 @@ static int bind_rdev_to_array(struct md_rdev *rdev, struct mddev *mddev)
> sysfs_get_dirent_safe(rdev->kobj.sd, "bad_blocks");
>
> list_add_rcu(&rdev->same_set, &mddev->disks);
> - bd_link_disk_holder(rdev->bdev, mddev->gendisk);
> + if (!bd_link_disk_holder(rdev->bdev, mddev->gendisk))
> + set_bit(SymlinkCreated, &rdev->flags);
Shall we just fail bind_rdev_to_array() if bd_link_disk_holder()
returns non-zero?
Thanks,
Song
Powered by blists - more mailing lists