From: NeilBrown <neilb@suse.de>
To: Francis Moreau <francis.moro@gmail.com>
Cc: linux-raid <linux-raid@vger.kernel.org>,
sebastian.riemer@profitbricks.com
Subject: Re: /sys/block/md126 still exists even after stopping the array
Date: Tue, 30 Sep 2014 07:56:43 +1000 [thread overview]
Message-ID: <20140930075643.34e864fa@notabene.brown> (raw)
In-Reply-To: <54291C1D.7010005@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3512 bytes --]
On Mon, 29 Sep 2014 10:45:17 +0200 Francis Moreau <francis.moro@gmail.com>
wrote:
> > So what were pids 930 and 459?
> > One was presumably the "mdadm -Ss" - probably 930.
> > Is 459 the "mdadm --monitor" ?? That might be useful hint.
> >
>
> yes.
>
> [456] is: /sbin/mdadm --monitor --scan --daemonise --syslog
> --pid-file=/run/mdadm/mdadm.pid
>
> and [930] is 'mdamd -Ss'.
Good. Please try the patch below.
> >
> >>
> >>
> >>> Probably there is a 'change' event happening just before the 'remove' event,
> >>> and udev runs "mdadm" on the 'change' event, and that ends up happening after
> >>> the device has been removed.
> >>>
> >>> Is this really a problem? Can't you just ignore it and pretend it isn't
> >>> there?
> >>
> >> Well, if you list the block devices that the kernel detected in order to
> >> operate on them, it could. I don't know exactly what would be the result
> >> to use it but it could confuse some tools.
> >>
> >> Is there a way to check that the 'ghost' device has been removed by
> >> poking sysfs ?
> >
> > If you look at /sys/block/md*/md/array_state, those that contain 'inactive'
> > or 'clear' might be 'ghosts', or might be in the process of being assembled.
> > If you write 'clear' to the same file they should disappear.... unless udev
> > does something to re-create them.
> >
>
> It's in 'clear' state, and writing 'clear' doesn't make the device disapear.
>
> [root@localhost ~]# dmesg -c >/dev/null
> [root@localhost ~]# echo clear >/sys/block/md125/md/array_state
> [root@localhost ~]# dmesg
> [ 254.106252] md: md125 stopped.
> [ 254.108182] md_open(): mdX opened by mdadm [968]
>
> [ 254.109103] md_open(): md125 opened by mdadm [459]
> [ 254.109127] md_open(): md125 opened by mdadm [459]
> [ 254.109281] md_release(): md125 released by mdadm [459]
>
> [ 254.109337] md_open(): md125 opened by mdadm [968]
> [ 254.109572] md_release(): md125 released by mdadm [968]
>
> [ 254.109847] md_open(): md125 opened by systemd-udevd [967]
> [ 254.109986] md_release(): md125 released by systemd-udevd [967]
>
> In that sequence, it seems that mdadm [459] is missing a md_release()
> here. Is this expected ?
Presumably the first md_open returned an error. You could add another printk
at each 'return' to check.
Thanks,
NeilBrown
diff --git a/Monitor.c b/Monitor.c
index 5cb24fab8f2a..971d2ecbea72 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -460,7 +460,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
mdu_array_info_t array;
struct mdstat_ent *mse = NULL, *mse2;
char *dev = st->devname;
- int fd;
+ int fd = -1;
int i;
int remaining_disks;
int last_disk;
@@ -468,6 +468,27 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
if (test)
alert("TestMessage", dev, NULL, ainfo);
+ if (st->devnm[0])
+ fd = open("/sys/block", O_RDONLY|O_DIRECTORY);
+ if (fd >= 0) {
+ /* Don't open the device unless it is present and
+ * active in sysfs.
+ */
+ char buf[10];
+ close(fd);
+ fd = sysfs_open(st->devnm, NULL, "array_state");
+ if (fd < 0 ||
+ read(fd, buf, 10) < 5 ||
+ strncmp(buf,"clear",5) == 0 ||
+ strncmp(buf,"inact",5) == 0) {
+ if (fd >= 0)
+ close(fd);
+ if (!st->err)
+ alert("DeviceDisappeared", dev, NULL, ainfo);
+ st->err++;
+ return 0;
+ }
+ }
fd = open(dev, O_RDONLY);
if (fd < 0) {
if (!st->err)
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
next prev parent reply other threads:[~2014-09-29 21:56 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-24 15:38 /sys/block/md126 still exists even after stopping the array Francis Moreau
2014-06-25 1:03 ` NeilBrown
2014-06-25 6:59 ` Francis Moreau
2014-07-24 13:40 ` Sebastian Parschauer
2014-07-24 13:51 ` Artur Paszkiewicz
2014-09-25 16:12 ` Francis Moreau
2014-09-26 0:33 ` NeilBrown
2014-09-26 10:23 ` Francis Moreau
2014-09-26 10:44 ` NeilBrown
2014-09-26 11:23 ` Artur Paszkiewicz
2014-09-29 4:19 ` NeilBrown
2014-09-26 12:21 ` Francis Moreau
2014-09-26 12:50 ` Francis Moreau
2014-09-29 4:47 ` NeilBrown
2014-09-29 4:37 ` NeilBrown
2014-09-29 8:45 ` Francis Moreau
2014-09-29 21:56 ` NeilBrown [this message]
2014-09-30 7:43 ` Francis Moreau
2014-10-07 7:05 ` Francis Moreau
2014-10-07 23:54 ` NeilBrown
2014-10-09 9:40 ` Francis Moreau
2014-10-09 9:55 ` NeilBrown
2014-10-10 19:34 ` Francis Moreau
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=20140930075643.34e864fa@notabene.brown \
--to=neilb@suse.de \
--cc=francis.moro@gmail.com \
--cc=linux-raid@vger.kernel.org \
--cc=sebastian.riemer@profitbricks.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).