From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xiao Ni Subject: Re: The dev node can't be released at once after stopping raid Date: Thu, 31 Aug 2017 03:16:50 -0400 (EDT) Message-ID: <716638049.3884368.1504163810231.JavaMail.zimbra@redhat.com> References: <1159964415.16461871.1496288839399.JavaMail.zimbra@redhat.com> <43bca632-9d77-2063-603c-6dcf47f3d250@suse.com> <1471667815.16472496.1496296238179.JavaMail.zimbra@redhat.com> <1941784023.3852671.1504151717389.JavaMail.zimbra@redhat.com> <87bmmwfj5z.fsf@notabene.neil.brown.name> <1889255088.3872827.1504160273377.JavaMail.zimbra@redhat.com> <8760d4fd25.fsf@notabene.neil.brown.name> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Return-path: In-Reply-To: <8760d4fd25.fsf@notabene.neil.brown.name> Sender: linux-raid-owner@vger.kernel.org To: NeilBrown Cc: linux-raid@vger.kernel.org List-Id: linux-raid.ids ----- Original Message ----- > From: "NeilBrown" > To: "Xiao Ni" > Cc: linux-raid@vger.kernel.org > Sent: Thursday, August 31, 2017 2:48:02 PM > Subject: Re: The dev node can't be released at once after stopping raid > > On Thu, Aug 31 2017, Xiao Ni wrote: > > > > There is a bug https://bugzilla.redhat.com/show_bug.cgi?id=1444434. > > Another tool(blivet) stops raid device and the device node still exists. > > Then it calls mdadm -S xxx again and it fails. > > I would suggest that the tool is broken. It should trust mdadm and not > double check that it actually worked. > > > So I ask myself why > > /dev/mdxxx can't be removed immediately after command mdadm -S. > > Because udev is asynchronous. You cannot rely on things happening > instantly. udev doesn't work that way. > > mdadm has a function 'wait_for()' which waits for the device name to > appear when the array is started. Possibly we could add something to > wait for udev to remove the device when the array is stopped, but I > really think it shouldn't be necessary. Nothing should look at the name > after the device is stopped. Hmm I want to try it. There are many topics about /dev/mdxx exists after stop array before. I want to stop this topic forever. Can we remove /dev/mdxx directly? Something like this: diff --git a/Manage.c b/Manage.c index b82a729..04994b3 100644 --- a/Manage.c +++ b/Manage.c @@ -482,6 +482,7 @@ done: map_lock(&map); map_remove(&map, devnm); map_unlock(&map); + unlink(devname); out: sysfs_free(mdi); Best Regards Xiao > > > > > In topic "MD Remnants After –stop", you said the REMOVE events are > > generated by "md_free() -> del_gendisk() -> blk_unregister_queue()". > > When mdadm -S return, the REMOVE events should be generated already, > > right? > > Not necessarily. md_free is called from mddev_delayed_delete, which is > run on a work-queue, so might be delayed briefly. > > > > > I always have a question. Who is responsible for removing the device > > node under /dev/ directory? The function unlink()? > > udev is responsible for removing the device. Obviously udev uses unlink() > to do this. > > NeilBrown > >