Skip to contentSkip to conversation

mdadm named array (metadata 1.2) and udev when assembling an array in initramfs

DISCUSSION NeilBrown 2 participants 3 messages Nov 3, 2014 MD RAID

lore
Share & tools
lore

NeilBrown

author
#0 lore raw

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

NeilBrown

From 628cdf19ea35daad22e409e51c0abc7ffb19d6aa Mon Sep 17 00:00:00 2001
From: NeilBrown <[email protected]>
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.

mapfile.c +10 -3
index 4e7f24214b8a..41599df05f97 100644
@@ -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)
#1 lore raw
Quoted 38 lines · NeilBrown

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

NeilBrown

From 628cdf19ea35daad22e409e51c0abc7ffb19d6aa Mon Sep 17 00:00:00 2001
From: NeilBrown <[email protected]>
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.

mapfile.c +4 -3
index 4e7f24214b8a..41599df05f97 100644
@@ -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.
                                                 */

mapfile.c void RebuildMap(void) · line 473

Quoted 10 lines
mapfile.c +6 -0
+                                               if (homehost && unum == -1 &&
+                                                   strncmp(name, homehost,
+                                                           strlen(homehost)) == 0 &&
+                                                   name[strlen(homehost)] == ':')
+                                                       name += strlen(homehost)+1;
                                                unum = -1;
+                                       }
 
                                        while (conflict) {
                                                if (unum >= 0)

Your patch works for me! Thanks so much for taking a look.

Stephen

author
#2 lore raw
Quoted 47 lines · On Sun, 2 Nov 2014 20:16:34 -0800 Stephen Kent <[email protected]> wrote:
Quoted 46 lines · NeilBrown

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

NeilBrown

From 628cdf19ea35daad22e409e51c0abc7ffb19d6aa Mon Sep 17 00:00:00 2001
From: NeilBrown <[email protected]>
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.

mapfile.c +10 -3
index 4e7f24214b8a..41599df05f97 100644
@@ -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;
+                                       }
 
Quoted 6 lines

mapfile.c void RebuildMap(void) · line 473

Quoted 2 lines
mapfile.c +0 -0
                                        while (conflict) {
                                                if (unum >= 0)

Your patch works for me! Thanks so much for taking a look.

Great - thanks for the confirmation. It will be in the next release.

NeilBrown