From: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
To: Martin Wilck <mwilck@suse.com>
Cc: Li Xiao Keng <lixiaokeng@huawei.com>, Song Liu <song@kernel.org>,
Jes Sorensen <jes@trained-monkey.org>,
Paul Menzel <pmenzel@molgen.mpg.de>, Coly Li <colyli@suse.de>,
linux-raid@vger.kernel.org, linfeilong <linfeilong@huawei.com>,
louhongxiang@huawei.com,
"liuzhiqiang (I)" <liuzhiqiang26@huawei.com>,
miaoguanqin <miaoguanqin@huawei.com>
Subject: Re: [QUESTION] How to fix the race of "mdadm --add" and "mdadm mdadm --incremental --export"
Date: Mon, 20 Mar 2023 16:51:17 +0100 [thread overview]
Message-ID: <20230320165117.000011d5@linux.intel.com> (raw)
In-Reply-To: <b3b124db659115dd2523dab828ad463d88afbe54.camel@suse.com>
On Mon, 20 Mar 2023 16:36:44 +0100
Martin Wilck <mwilck@suse.com> wrote:
> On Thu, 2023-03-16 at 11:44 +0100, Mariusz Tkaczyk wrote:
> > On Wed, 15 Mar 2023 16:01:26 +0100
> > Martin Wilck <mwilck@suse.com> wrote:
> > >
> > > Normally this is what you want to happen if a change uevent for a
> > > MD
> > > member device is processed.
> > >
> > > The case you're looking at is the exception, as another instance of
> > > mdamn is handling the device right at this point in time.
> > >
> > > Martin
> > >
> > Hi,
> > Code snipped from Incremental, devname seems to be our disk:
> >
> > /* 4/ Check if array exists.
> > */
> > if (map_lock(&map))
> > pr_err("failed to get exclusive lock on mapfile\n");
> > /* Now check we can get O_EXCL. If not, probably "mdadm -A"
> > has
> > * taken over
> > */
> > dfd = dev_open(devname, O_RDONLY|O_EXCL);
> >
> > The map_lock in --add should resolve your issue. It seems to be
> > simplest
> > option. I we cannot lock udev effectively then it seems to be the
> > best one.
> > We need to control adding the device because external metadata is
> > quite
> > different and for example in IMSM the initial metadata doesn't point
> > to
> > container wanted by user. Hope it clarifies all objections here.
> >
> > I don't see any blocker from using locking mechanism for --add.
>
>
> AFAICS it would only help if the code snipped above did not only
> pr_err() but exit if it can't get an exclusive lock.
>
> Martin
>
Indeed. I missed that... Thanks for catching. My idea is no longer valid.
Mariusz
next prev parent reply other threads:[~2023-03-20 16:03 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-14 14:58 [QUESTION] How to fix the race of "mdadm --add" and "mdadm mdadm --incremental --export" Li Xiao Keng
2023-03-14 15:04 ` Martin Wilck
2023-03-14 15:59 ` Mariusz Tkaczyk
2023-03-14 16:11 ` Martin Wilck
2023-03-15 10:10 ` Mariusz Tkaczyk
2023-03-15 13:10 ` Li Xiao Keng
2023-03-15 14:14 ` Martin Wilck
2023-03-15 14:57 ` Li Xiao Keng
2023-03-15 15:01 ` Martin Wilck
2023-03-16 10:44 ` Mariusz Tkaczyk
2023-03-20 15:36 ` Martin Wilck
2023-03-20 15:51 ` Mariusz Tkaczyk [this message]
2023-03-14 16:40 ` Coly Li
2023-03-15 2:25 ` Li Xiao Keng
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=20230320165117.000011d5@linux.intel.com \
--to=mariusz.tkaczyk@linux.intel.com \
--cc=colyli@suse.de \
--cc=jes@trained-monkey.org \
--cc=linfeilong@huawei.com \
--cc=linux-raid@vger.kernel.org \
--cc=liuzhiqiang26@huawei.com \
--cc=lixiaokeng@huawei.com \
--cc=louhongxiang@huawei.com \
--cc=miaoguanqin@huawei.com \
--cc=mwilck@suse.com \
--cc=pmenzel@molgen.mpg.de \
--cc=song@kernel.org \
/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).