[Fai-commit] r6104 - branches/stable/3.4/lib/setup-storage

Michael Prokop mika at alioth.debian.org
Tue Oct 5 15:15:14 UTC 2010


Author: mika
Date: 2010-10-05 15:15:11 +0000 (Tue, 05 Oct 2010)
New Revision: 6104

Modified:
   branches/stable/3.4/lib/setup-storage/Commands.pm
   branches/stable/3.4/lib/setup-storage/Parser.pm
   branches/stable/3.4/lib/setup-storage/Volumes.pm
Log:
Fix preserve for RAID

Preserving a RAID volume did not work:
 - mdadm --detail --scan doesn't give information on non-assembled
   arrays, leading setup-storage to think there aren't any;
 - preserved arrays must be assembled before setup-storage calls
   fai-vol-id;
 - (minor) always_format was not initialized for RAID arrays.

Modified: branches/stable/3.4/lib/setup-storage/Commands.pm
===================================================================
--- branches/stable/3.4/lib/setup-storage/Commands.pm	2010-10-05 15:15:01 UTC (rev 6103)
+++ branches/stable/3.4/lib/setup-storage/Commands.pm	2010-10-05 15:15:11 UTC (rev 6104)
@@ -284,28 +284,11 @@
       # keep a reference to the current volume
       my $vol = (\%FAI::configs)->{$config}->{volumes}->{$id};
 
-      # if it is a volume that has to be preserved, there is not much to be
-      # done; its existance has been checked in propagate_and_check_preserve
-      if ($vol->{preserve}) {
-        &FAI::push_command("true", "", "exist_/dev/md$id");
-        # create the filesystem on the volume, if requested
-        &FAI::build_mkfs_commands("/dev/md$id",
-          \%{ $FAI::configs{$config}{volumes}{$id} })
-          if (1 == $vol->{always_format});
-        next;
-      }
-
-      # the desired RAID level
-      my $level = $vol->{mode};
-
-      # prepend "raid", if the mode is numeric-only
-      $level = "raid$level" if ($level =~ /^\d+$/);
-
       # the list of RAID devices
       my @devs = keys %{ $vol->{devices} };
       my @eff_devs = ();
       my @spares = ();
-      my $pre_req;
+      my $pre_req = "";
 
       # set proper partition types for RAID
       foreach my $d (@devs) {
@@ -324,14 +307,41 @@
             push @eff_devs, &FAI::enc_name($d);
           }
         }
+
         $d = &FAI::enc_name($d);
-        if (&FAI::set_partition_type_on_phys_dev($d, "raid")) {
+	if ($vol->{preserve}) {
+	  $pre_req .= (&FAI::phys_dev($d))[0] ?
+	      ",pt_complete_" . (&FAI::phys_dev($d))[1] :
+	      ",exist_$d";
+        } elsif (&FAI::set_partition_type_on_phys_dev($d, "raid")) {
           $pre_req .= ",pt_complete_" . (&FAI::phys_dev($d))[1];
         } else {
           $pre_req .= ",exist_$d";
         }
       }
 
+      # if it is a volume that has to be preserved, there is not much to be
+      # done; its existance has been checked in propagate_and_check_preserve
+      if ($vol->{preserve}) {
+	$pre_req =~ s/^,//;
+        # Assemble the array
+        &FAI::push_command(
+	    "mdadm --assemble /dev/md$id " . join(" ", @eff_devs),
+	    "$pre_req", "exist_/dev/md$id");
+
+        # create the filesystem on the volume, if requested
+        &FAI::build_mkfs_commands("/dev/md$id",
+          \%{ $FAI::configs{$config}{volumes}{$id} })
+          if (1 == $vol->{always_format});
+        next;
+      }
+
+      # the desired RAID level
+      my $level = $vol->{mode};
+
+      # prepend "raid", if the mode is numeric-only
+      $level = "raid$level" if ($level =~ /^\d+$/);
+
       my ($create_options) = $FAI::configs{$config}{volumes}{$id}{mdcreateopts};
       # prevent warnings of uninitialized variables
       $create_options = '' unless $create_options;

Modified: branches/stable/3.4/lib/setup-storage/Parser.pm
===================================================================
--- branches/stable/3.4/lib/setup-storage/Parser.pm	2010-10-05 15:15:01 UTC (rev 6103)
+++ branches/stable/3.4/lib/setup-storage/Parser.pm	2010-10-05 15:15:11 UTC (rev 6104)
@@ -602,6 +602,9 @@
           # initialise the preserve flag
           defined($FAI::configs{RAID}{volumes}{$vol_id}{preserve}) or
             $FAI::configs{RAID}{volumes}{$vol_id}{preserve} = 0;
+          # initialise the always_format flag
+          defined($FAI::configs{RAID}{volumes}{$vol_id}{always_format}) or
+            $FAI::configs{RAID}{volumes}{$vol_id}{always_format} = 0;
           # set the reference to the current volume
           # the reference is used by all further processing of this config line
           $FAI::partition_pointer = (\%FAI::configs)->{RAID}->{volumes}->{$vol_id};

Modified: branches/stable/3.4/lib/setup-storage/Volumes.pm
===================================================================
--- branches/stable/3.4/lib/setup-storage/Volumes.pm	2010-10-05 15:15:01 UTC (rev 6103)
+++ branches/stable/3.4/lib/setup-storage/Volumes.pm	2010-10-05 15:15:11 UTC (rev 6104)
@@ -419,17 +419,17 @@
 
   # try to obtain the list of existing RAID arrays
   my $error =
-    &FAI::execute_ro_command("mdadm --detail --scan --verbose -c partitions",
+    &FAI::execute_ro_command("mdadm --examine --scan --verbose -c partitions",
     \@mdadm_print, 0);
 
 # the expected output is as follows
-# $ mdadm --detail --scan --verbose -c partitions
+# $ mdadm --examine --scan --verbose -c partitions
 # ARRAY /dev/md0 level=linear num-devices=2 UUID=7e11efd6:93e977fd:b110d941:ce79a4f6
 #    devices=/dev/hda1,/dev/hda2
 # ARRAY /dev/md1 level=raid0 num-devices=2 UUID=50d7a6ec:4207f0db:b110d941:ce79a4f6
 #    devices=/dev/md0,/dev/hda3
 # or (newer version of mdadm?)
-# kueppers[~]# mdadm --detail --scan --verbose -c partitions
+# kueppers[~]# mdadm --examine --scan --verbose -c partitions
 # ARRAY /dev/md0 level=raid0 num-devices=3 metadata=00.90
 # UUID=a4553444:0baf31ae:135399f0:a895f15f
 #    devices=/dev/sdf2,/dev/sdd2,/dev/sde2




More information about the Fai-commit mailing list