From: Xiao Ni <xni@redhat.com>
To: linan666@huaweicloud.com
Cc: corbet@lwn.net, song@kernel.org, yukuai@fnnas.com,
linan122@huawei.com, hare@suse.de, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org,
yangerkun@huawei.com, yi.zhang@huawei.com
Subject: Re: [PATCH v8 1/4] md: delete md_redundancy_group when array is becoming inactive
Date: Mon, 3 Nov 2025 08:27:08 +0800 [thread overview]
Message-ID: <CALTww28FMQFKHOJ3jnbC-FyxusfF3bvRZEgBz_TCvJM4e-OoEQ@mail.gmail.com> (raw)
In-Reply-To: <20251030062807.1515356-2-linan666@huaweicloud.com>
On Thu, Oct 30, 2025 at 2:36 PM <linan666@huaweicloud.com> wrote:
>
> From: Li Nan <linan122@huawei.com>
>
> 'md_redundancy_group' are created in md_run() and deleted in del_gendisk(),
> but these are not paired. Writing inactive/active to sysfs array_state can
> trigger md_run() multiple times without del_gendisk(), leading to
> duplicate creation as below:
>
> sysfs: cannot create duplicate filename '/devices/virtual/block/md0/md/sync_action'
> Call Trace:
> dump_stack_lvl+0x9f/0x120
> dump_stack+0x14/0x20
> sysfs_warn_dup+0x96/0xc0
> sysfs_add_file_mode_ns+0x19c/0x1b0
> internal_create_group+0x213/0x830
> sysfs_create_group+0x17/0x20
> md_run+0x856/0xe60
> ? __x64_sys_openat+0x23/0x30
> do_md_run+0x26/0x1d0
> array_state_store+0x559/0x760
> md_attr_store+0xc9/0x1e0
> sysfs_kf_write+0x6f/0xa0
> kernfs_fop_write_iter+0x141/0x2a0
> vfs_write+0x1fc/0x5a0
> ksys_write+0x79/0x180
> __x64_sys_write+0x1d/0x30
> x64_sys_call+0x2818/0x2880
> do_syscall_64+0xa9/0x580
> entry_SYSCALL_64_after_hwframe+0x4b/0x53
> md: cannot register extra attributes for md0
>
> Creation of it depends on 'pers', its lifecycle cannot be aligned with
> gendisk. So fix this issue by triggering 'md_redundancy_group' deletion
> when the array is becoming inactive.
>
> Fixes: 790abe4d77af ("md: remove/add redundancy group only in level change")
> Signed-off-by: Li Nan <linan122@huawei.com>
> ---
> drivers/md/md.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index fa13eb02874e..f6fd55a1637b 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -6878,6 +6878,10 @@ static int do_md_stop(struct mddev *mddev, int mode)
> if (!md_is_rdwr(mddev))
> set_disk_ro(disk, 0);
>
> + if (mode == 2 && mddev->pers->sync_request &&
> + mddev->to_remove == NULL)
> + mddev->to_remove = &md_redundancy_group;
> +
> __md_stop_writes(mddev);
> __md_stop(mddev);
>
> --
> 2.39.2
>
Looks good to me.
Reviewed-by: Xiao Ni <xni@redhat.com>
next prev parent reply other threads:[~2025-11-03 0:27 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-30 6:28 [PATCH v8 0/4] make logical block size configurable linan666
2025-10-30 6:28 ` [PATCH v8 1/4] md: delete md_redundancy_group when array is becoming inactive linan666
2025-11-03 0:27 ` Xiao Ni [this message]
2025-10-30 6:28 ` [PATCH v8 2/4] md: init bioset in mddev_init linan666
2025-11-03 1:23 ` Xiao Ni
2025-11-03 12:32 ` Li Nan
2025-11-04 1:20 ` Xiao Ni
2025-10-30 6:28 ` [PATCH v8 3/4] md/raid0: Move queue limit setup before r0conf initialization linan666
2025-11-03 1:47 ` Xiao Ni
2025-10-30 6:28 ` [PATCH v8 4/4] md: allow configuring logical block size linan666
2025-11-03 3:11 ` Xiao Ni
2025-11-03 13:09 ` Li Nan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CALTww28FMQFKHOJ3jnbC-FyxusfF3bvRZEgBz_TCvJM4e-OoEQ@mail.gmail.com \
--to=xni@redhat.com \
--cc=corbet@lwn.net \
--cc=hare@suse.de \
--cc=linan122@huawei.com \
--cc=linan666@huaweicloud.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=song@kernel.org \
--cc=yangerkun@huawei.com \
--cc=yi.zhang@huawei.com \
--cc=yukuai@fnnas.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).