From: Xiao Ni <xni@redhat.com>
To: NeilBrown <neilb@suse.com>
Cc: linux-raid@vger.kernel.org, jes sorensen <jes.sorensen@gmail.com>
Subject: Re: [MDADM PATCH 2/2] Give enough time to udev to handle events
Date: Sat, 30 Sep 2017 04:14:42 -0400 (EDT) [thread overview]
Message-ID: <417094054.15847718.1506759282166.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <87r2v3qj2o.fsf@notabene.neil.brown.name>
----- Original Message -----
> From: "NeilBrown" <neilb@suse.com>
> To: "Xiao Ni" <xni@redhat.com>, linux-raid@vger.kernel.org
> Cc: "jes sorensen" <jes.sorensen@gmail.com>
> Sent: Tuesday, September 19, 2017 2:49:19 PM
> Subject: Re: [MDADM PATCH 2/2] Give enough time to udev to handle events
>
> On Tue, Sep 19 2017, Xiao Ni wrote:
>
> > After mdadm -S /dev/md0, the device node /dev/md0 still exists. The Remove
> > events are generated by md_free() -> del_gendisk() ->
> > blk_unregister_queue().
> > After calling close(mdfd) the Remove events is generated. We should give
> > udev
> > a little time to handle the event.
> >
> > I tried usleep(100*1000), but the problem still can be reproduced sometime.
> > So I choose to sleep(1). Because after close(mdfd) it can be generated
> > CHANGE
> > events too. So it's ok to choose to sleep(1) to wait udev to handle CHANGE
> > events.
>
> I really don't like this approach. The fact that 1 second works for you
> is no guarantee that it will work for everybody.
> We have a few sleeps in the code already, but I don't like them either.
> Let's try not to add more.
Hi Neil
Yes, there are already some sleeps during STOP_ARRAY
count = 25; err = 0;
while (count && fd >= 0 &&
(err = ioctl(fd, STOP_ARRAY, NULL)) < 0 && errno == EBUSY) {
usleep(200000);
count --;
}
But it doesn't give time to wait for handling udev event which is generated
by close(mdfd). Because they are asynchronous, so there is a possibility that
the device node still exist after mdadm command exist.
>
> If there is some event that you want to wait for, wait for that event.
> e.g. if you want to wait for /dev/md0 to disappear then write a loop:
>
> while /dev/md0 exists
> usleep(1000)
Ok, I'll try this.
>
> But I'm still not convinced that this is really needed. If it is, then
> maybe some sort of kernel fix would be better.
>
Hmm the reason I focus on this is that there are some bugs about this.
After some investigation I know it's that we don't wait for udev remove
event. Because the event is generated by mdadm, so we should guarantee
the udev event finishes, right?
Do you have a better solution for this? The REMOVE event is created by
close(mdfd). I don't know how to wait for remove event in kernel space.
Best Regards
Xiao
next prev parent reply other threads:[~2017-09-30 8:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-19 6:06 [MDADM PATCH 0/2] /dev/md0 can't be released immediatly Xiao Ni
2017-09-19 6:06 ` [MDADM PATCH 1/2] Close mdfd before returning main function Xiao Ni
2017-10-02 17:27 ` Jes Sorensen
2017-09-19 6:06 ` [MDADM PATCH 2/2] Give enough time to udev to handle events Xiao Ni
2017-09-19 6:49 ` NeilBrown
2017-09-30 8:14 ` Xiao Ni [this message]
2017-10-02 17:28 ` Jes Sorensen
2017-10-02 23:00 ` NeilBrown
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=417094054.15847718.1506759282166.JavaMail.zimbra@redhat.com \
--to=xni@redhat.com \
--cc=jes.sorensen@gmail.com \
--cc=linux-raid@vger.kernel.org \
--cc=neilb@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).