On Wed, 7 Jun 2006, Jonas Smedegaard wrote:

> Then I'll just lean back and wait for you to do the hard work :-D

ok i've got a partial solution... see below.

i say "partial" because the following scenario is not quite ideal:

- md initially on /dev/sda1 /dev/sdb1 ... build initrd
- another disk without a partition table is inserted so that sdb is 
  renamed sdc -- sdb exists, but there's no sdb1
- on reboot the mkbdev /dev/sdb1 will fail... and we'll be dropped to dash
- ^D will finish the reboot anyhow but it required operator intervention

since mdadm (>= 2.2) is capable of creating the device node it needs 
anyhow we don't even need to "mkbdev /dev/sdb1".  i tried removing that 
but there's several ways to do it and i'm not sure what you'd prefer...

if i suppress the addDevicePlan for the component device then the parent 
isn't added either and the modprobes never occur and the devices aren't 
loaded for md to find them.

there are probably some configurations where the components might take a 
while to show up (i.e. nbd component)... so in many ways testing for the 
component is a good thing...

the patch below is an improvement regardless -- it enables the system to 
handle many sorts of renames without trouble.  i deliberately chose 2.2 as 
the version cutoff because i was anticipating some solution which wouldn't 
require the ^D (which requires 2.2 ... whereas 1.10 is good enough to just 
get -Ac partitions working -- you might have to manually construct a 
device node for versions earlier than 2.2).

-dean

--- usr/lib/yaird/perl/Plan.pm.orig     2006-06-06 22:19:18.000000000 +0000
+++ usr/lib/yaird/perl/Plan.pm  2006-06-17 21:19:52.000000000 +0000
@@ -355,6 +355,35 @@
        return 1;
 }
 
+my $mdadm_version_check_complete;
+my $mdadm_supports_device_renaming;
+
+sub checkMdadmSupport() {
+       return 0 if defined($mdadm_version_check_complete);
+
+       my $ver = `mdadm --version 2>&1`;
+
+       # mdadm -Ac partitions is broken prior to 1.10 (and sarge has 1.9)
+       # also mdadm 2.2 and later will create devices as appropriate based
+       # on information in /proc/partitions.
+       #
+       # we require 2.2 or later in order to use "-Ac partitions".  technically
+       # we could survive with 1.10 -- but we'd need to create the renamed 
devices
+       # appropriately.
+       my ($major, $minor);
+       if ((($major, $minor) = $ver =~ /^mdadm - v(\d+)\.(\d+)/)
+               and ($major > 2 or ($major == 2 and $minor >= 2))) {
+               $mdadm_supports_device_renaming = 1;
+       }
+       else {
+               Base::warning ("consider upgrading to mdadm 2.2 or newer to 
support changes in device boot ordering");
+               $mdadm_supports_device_renaming = 0;
+       }
+
+       $mdadm_version_check_complete = 1;
+       0;
+}
+
 
 #
 # tryRaid -- To start an md raid device, start the underlying hardware,
@@ -369,6 +398,8 @@
                return 0;
        }
 
+       checkMdadmSupport();
+
        my $rd = RaidTab::findByDevno ($devno);
        if (! defined ($rd)) {
                Base::fatal ("Can't find Raid info for $name");
@@ -391,6 +422,7 @@
                minor => $minor,
                uuid => $uuid,
                components => $components,
+               supports_device_renaming => $mdadm_supports_device_renaming,
                );
        return 1;
 }
--- etc/yaird/Templates.cfg.orig        2006-06-06 22:19:18.000000000 +0000
+++ etc/yaird/Templates.cfg     2006-06-17 20:26:40.000000000 +0000
@@ -315,8 +315,12 @@
                SCRIPT "/init"
                BEGIN
                        !mknod <TMPL_VAR NAME=target> b <TMPL_VAR NAME=major> 
<TMPL_VAR NAME=minor>
-                       !mdadm --assemble <TMPL_VAR NAME=target> --run --uuid 
<TMPL_VAR NAME=uuid> \
-                       !       <TMPL_LOOP NAME=components> <TMPL_VAR 
NAME=dev></TMPL_LOOP>
+                       !<TMPL_IF NAME=supports_device_renaming>
+                       !       mdadm -Ac partitions <TMPL_VAR NAME=target> 
--run --uuid <TMPL_VAR NAME=uuid>
+                       !<TMPL_ELSE>
+                       !       mdadm --assemble <TMPL_VAR NAME=target> --run 
--uuid <TMPL_VAR NAME=uuid> \
+                       !               <TMPL_LOOP NAME=components> <TMPL_VAR 
NAME=dev></TMPL_LOOP>
+                       !</TMPL_IF>
                END SCRIPT
        END TEMPLATE
 


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to