linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: mdadm named array (metadata 1.2) and udev when assembling an array in initramfs
@ 2014-11-03  1:50 NeilBrown
  2014-11-03  4:16 ` Stephen Kent
  0 siblings, 1 reply; 6+ messages in thread
From: NeilBrown @ 2014-11-03  1:50 UTC (permalink / raw)
  To: Stephen Kent; +Cc: linux RAID

[-- Attachment #1: Type: text/plain, Size: 1343 bytes --]


Hi Stephen,
 thanks for the bug report.
This patch should fix it.

NeilBrown

From 628cdf19ea35daad22e409e51c0abc7ffb19d6aa Mon Sep 17 00:00:00 2001
From: NeilBrown <neilb@suse.de>
Date: Mon, 3 Nov 2014 12:49:05 +1100
Subject: [PATCH] Rebuildmap: strip local host name from device name.

When /run/mdadm/map is being rebuilt, e.g. by "mdadm -Ir",
if the device doesn't exist in /dev, we have to choose
a name.
Currently we don't strip the hostname which is wrong if
it is the local host.

Reported-by: Stephen Kent <smkent@smkent.net>
Signed-off-by: NeilBrown <neilb@suse.de>

diff --git a/mapfile.c b/mapfile.c
index 4e7f24214b8a..41599df05f97 100644
--- a/mapfile.c
+++ b/mapfile.c
@@ -455,12 +455,19 @@ void RebuildMap(void)
 							sep = "";
 						}
 					}
-					if (strchr(name, ':'))
-						/* probably a uniquifying
+					if (strchr(name, ':')) {
+						/* Probably a uniquifying
 						 * hostname prefix.  Allow
-						 * without a suffix
+						 * without a suffix, and strip
+						 * hostname if it is us.
 						 */
+						if (homehost && unum == -1 &&
+						    strncmp(name, homehost,
+							    strlen(homehost)) == 0 &&
+						    name[strlen(homehost)] == ':')
+							name += strlen(homehost)+1;
 						unum = -1;
+					}
 
 					while (conflict) {
 						if (unum >= 0)

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

^ permalink raw reply related	[flat|nested] 6+ messages in thread
* mdadm named array (metadata 1.2) and udev when assembling an array in initramfs
@ 2014-11-01 18:53 Stephen Kent
  2014-11-04  9:06 ` Michael Tokarev
  0 siblings, 1 reply; 6+ messages in thread
From: Stephen Kent @ 2014-11-01 18:53 UTC (permalink / raw)
  To: linux-raid

I have set up a machine to use an md array as the root device. I have
created the array with metadata type 1.2, name "root," on host
"optimus" (so the full metadata name is "optimus:root").

I'm using Gentoo Linux (kernel 3.16.5-gentoo), and previously I had no
initramfs so I wrote a short one to assemble the array. My initramfs
sets the hostname and runs "mdadm -As," which correctly auto-assembles
the root device array on /dev/md/root (even without an
/etc/mdadm.conf).

Once the initramfs script is finished, init starts which then starts
udev. Now, at this point the array is already assembled, but the
/dev/md/* name is lost (and so is /run/mdadm/map) since those files
were on the initramfs' tempfs root. udev creates a /dev/mdXXX node
(ex. /dev/md127) and then runs a rule to try to figure out the
/dev/md/* name, which should be /dev/md/root. The default udev rule
calls mdadm --detail --export /dev/md127, which should print
MD_DEVNAME=root for udev, but instead it prints
MD_DEVNAME=optimus:root, and the symlink in /dev/md gets created as
/dev/md/optimus:root.

I think this is a bug in mdadm, but I'm not sure how to dig into it. I
have made sure that my main OS init sets the hostname before starting
udev, and I have tried with and without "HOMEHOST optimus" in
/etc/mdadm.conf.

The workaround I am using right now is to define the array name
manually in /etc/mdadm.conf like this:

ARRAY /dev/md/root UUID=782a671c:e646f2d5:848baad0:5668ee84

This works by avoiding automatic name detection and using the defined
name (/dev/md/root), but it really seems that mdadm should know how to
determine MD_DEVNAME correctly for an already-started array if the
hostname (or homehost) is correctly set. Is this a bug in mdadm? If
so, is this the correct place to report it or is there a bug tracking
system I should use? I am using mdadm v3.3.1.

(Please cc me on replies as I am not currently subscribed to the
linux-raid list.)

Thanks,

Stephen

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-11-04 18:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-03  1:50 mdadm named array (metadata 1.2) and udev when assembling an array in initramfs NeilBrown
2014-11-03  4:16 ` Stephen Kent
2014-11-03  5:43   ` NeilBrown
  -- strict thread matches above, loose matches on Subject: below --
2014-11-01 18:53 Stephen Kent
2014-11-04  9:06 ` Michael Tokarev
2014-11-04 18:17   ` Stephen Kent

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).