[Rear-users] SF.net SVN: rear:[385] trunk/usr/share/rear

jhoekx at users.sourceforge.net jhoekx at users.sourceforge.net
Wed Apr 27 11:14:07 CEST 2011


Revision: 385
          http://rear.svn.sourceforge.net/rear/?rev=385&view=rev
Author:   jhoekx
Date:     2011-04-27 09:14:07 +0000 (Wed, 27 Apr 2011)

Log Message:
-----------
Layout: automatically exclude multipath disks.

This does not handle the case of AUTOEXCLUDE_MULTIPATH unset.

Implemented by Dag Wieers and Jeroen Hoekx for the Belgian Federal Police.

Modified Paths:
--------------
    trunk/usr/share/rear/conf/default.conf
    trunk/usr/share/rear/layout/prepare/default/51_list_dependencies.sh
    trunk/usr/share/rear/layout/save/default/32_autoexclude.sh

Added Paths:
-----------
    trunk/usr/share/rear/layout/save/GNU/Linux/28_multipath_layout.sh

Modified: trunk/usr/share/rear/conf/default.conf
===================================================================
--- trunk/usr/share/rear/conf/default.conf	2011-04-27 09:02:45 UTC (rev 384)
+++ trunk/usr/share/rear/conf/default.conf	2011-04-27 09:14:07 UTC (rev 385)
@@ -468,6 +468,9 @@
 # (layout code)
 AUTOEXCLUDE_DISKS=y
 
+# Automatically exclude multipath disks and their dependent components
+AUTOEXCLUDE_MULTIPATH=y
+
 ################ ---- various warnings
 #
 # Warnings can be also disabled by unsetting these variables

Modified: trunk/usr/share/rear/layout/prepare/default/51_list_dependencies.sh
===================================================================
--- trunk/usr/share/rear/layout/prepare/default/51_list_dependencies.sh	2011-04-27 09:02:45 UTC (rev 384)
+++ trunk/usr/share/rear/layout/prepare/default/51_list_dependencies.sh	2011-04-27 09:14:07 UTC (rev 385)
@@ -88,5 +88,14 @@
             add_dependency "$name" "$device"
             add_component "$name" "crypt"
             ;;
+        multipath)
+            name=$(echo "$remainder" | cut -d " " -f "1")
+            disks=$(echo "$remainder" | cut -d " " -f "2" | tr "," " ")
+            
+            for disk in $disks ; do
+                add_dependency "$name" "$disk"
+                add_component "$name" "multipath"
+            done
+            ;;
     esac
 done < <(cat $LAYOUT_FILE)

Added: trunk/usr/share/rear/layout/save/GNU/Linux/28_multipath_layout.sh
===================================================================
--- trunk/usr/share/rear/layout/save/GNU/Linux/28_multipath_layout.sh	                        (rev 0)
+++ trunk/usr/share/rear/layout/save/GNU/Linux/28_multipath_layout.sh	2011-04-27 09:14:07 UTC (rev 385)
@@ -0,0 +1,24 @@
+# Describe multipath devices
+
+while read dm_name junk ; do
+    if [ ! -e /dev/mpath/$dm_name ] ; then
+        Log "Did not find multipath device $dm_name in the expected location."
+        continue
+    fi
+
+    # follow symlinks to find the real device
+    dev_name=$(readlink -f /dev/mpath/$dm_name)
+    # we try to find the sysfs name
+    name=$(get_sysfs_name $dev_name)
+    
+    if [ ! -e /sys/block/$name ] ; then
+        Log "Did not find sysfs name for device $dm_name (/sys/block/$name)"
+    fi
+    
+    slaves=""
+    for slave in /sys/block/$name/slaves/* ; do
+        slaves="$slaves$(get_device_name ${slave##*/}),"
+    done
+    
+    echo "multipath /dev/mpath/$dm_name ${slaves%,}" >> $DISKLAYOUT_FILE
+done < <( dmsetup ls --target multipath )

Modified: trunk/usr/share/rear/layout/save/default/32_autoexclude.sh
===================================================================
--- trunk/usr/share/rear/layout/save/default/32_autoexclude.sh	2011-04-27 09:02:45 UTC (rev 384)
+++ trunk/usr/share/rear/layout/save/default/32_autoexclude.sh	2011-04-27 09:14:07 UTC (rev 385)
@@ -1,3 +1,12 @@
+# Automatically exclude multipath devices
+if [ -n "$AUTOEXCLUDE_MULTIPATH" ] ; then
+    while read multipath device devices junk ; do
+        Log "Automatically excluding multipath device $device."
+        mark_as_done "$device"
+        mark_tree_as_done "$device"
+    done < <(grep ^multipath $LAYOUT_FILE)
+fi
+
 # Automatically exclude disks that do not have filesystems mounted.
 if [ -n "$AUTOEXCLUDE_DISKS" ] ; then
     used_disks=()


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rear-users mailing list