From: Jes Sorensen <jes@trained-monkey.org>
To: Li Xiao Keng <lixiaokeng@huawei.com>,
Martin Wilck <mwilck@suse.com>, Coly Li <colyli@suse.de>,
linux-raid@vger.kernel.org
Cc: louhongxiang@huawei.com, miaoguanqin <miaoguanqin@huawei.com>
Subject: Re: [PATCH v3] Fix race of "mdadm --add" and "mdadm --incremental"
Date: Thu, 26 Oct 2023 17:42:39 -0400 [thread overview]
Message-ID: <cc19fa8a-55e8-9b34-5de9-1c78b0762ed9@trained-monkey.org> (raw)
In-Reply-To: <a25e4d75-ebc3-0841-832c-34b8e5f4cbb7@huawei.com>
On 9/7/23 07:37, Li Xiao Keng wrote:
> There is a raid1 with sda and sdb. And we add sdc to this raid,
> it may return -EBUSY.
>
> The main process of --add:
> 1. dev_open(sdc) in Manage_add
> 2. store_super1(st, di->fd) in write_init_super1
> 3. fsync(fd) in store_super1
> 4. close(di->fd) in write_init_super1
> 5. ioctl(ADD_NEW_DISK)
>
> Step 2 and 3 will add sdc to metadata of raid1. There will be
> udev(change of sdc) event after step4. Then "/usr/sbin/mdadm
> --incremental --export $devnode --offroot $env{DEVLINKS}"
> will be run, and the sdc will be added to the raid1. Then
> step 5 will return -EBUSY because it checks if device isn't
> claimed in md_import_device()->lock_rdev()->blkdev_get_by_dev()
> ->blkdev_get().
>
> It will be confusing for users because sdc is added first time.
> The "incremental" will get map_lock before add sdc to raid1.
> So we add map_lock before write_init_super in "mdadm --add"
> to fix the race of "add" and "incremental".
>
> Signed-off-by: Li Xiao Keng <lixiaokeng@huawei.com>
> Signed-off-by: Guanqin Miao <miaoguanqin@huawei.com>
Applied!
Thanks,
Jes
prev parent reply other threads:[~2023-10-26 21:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-07 11:37 [PATCH v3] Fix race of "mdadm --add" and "mdadm --incremental" Li Xiao Keng
2023-09-11 16:00 ` Mariusz Tkaczyk
2023-09-12 7:18 ` Li Xiao Keng
2023-09-12 7:58 ` Mariusz Tkaczyk
2023-10-07 9:26 ` Li Xiao Keng
2023-10-26 21:42 ` Jes Sorensen [this message]
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=cc19fa8a-55e8-9b34-5de9-1c78b0762ed9@trained-monkey.org \
--to=jes@trained-monkey.org \
--cc=colyli@suse.de \
--cc=linux-raid@vger.kernel.org \
--cc=lixiaokeng@huawei.com \
--cc=louhongxiang@huawei.com \
--cc=miaoguanqin@huawei.com \
--cc=mwilck@suse.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).