Whamcloud - gitweb
LU-2337 scripts: init script to not use -d with zpool import
authorNed Bass <bass6@llnl.gov>
Tue, 27 Nov 2012 19:06:43 +0000 (11:06 -0800)
committerOleg Drokin <green@whamcloud.com>
Tue, 8 Jan 2013 06:19:14 +0000 (01:19 -0500)
The zpool import command shipped with ZFS on Linux now searches the
following directories for devices (in order), eliminating the need for
the zpool import -d option in the lustre init script.

  /dev/disk/by-vdev   - Custom rules, use first if they exist
  /dev/disk/zpool     - Custom rules, use first if they exist
  /dev/mapper         - Use multipath devices before components
  /dev/disk/by-uuid   - Single unique entry and persistent
  /dev/disk/by-id     - May be multiple entries and persistent
  /dev/disk/by-path   - Encodes physical location and persistent
  /dev/disk/by-label  - Custom persistent labels
  /dev                - UNSAFE device names will change

The command formerly only searched /dev by default, so the init script
used the -d option to give precedence to preferred locations such as
/dev/mapper.  However this approach is error-prone on systems where
/dev/mapper exists but doesn't contain the zpool member devices.  With
this change the default script behavior should work on systems using
any of the above directories.

Also print an error message if zpool import fails, and remove an
unused variable from an unrelated function.

Signed-off-by: Ned Bass <bass6@llnl.gov>
Change-Id: I257da17328bec84aa568a61a40cdb374535aa935
Reviewed-on: http://review.whamcloud.com/4686
Tested-by: Hudson
Reviewed-by: Prakash Surya <surya1@llnl.gov>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/scripts/lustre

index 55c6601..b97951f 100644 (file)
@@ -75,7 +75,6 @@ start_zfs_services ()
 stop_devices ()
 {
        local labels=$*
-       local result=0
        local label devtype
        for label in $labels; do
                devtype=`$LDEV -t $label`
@@ -102,10 +101,6 @@ import_zpool ()
                args="$args -c $cache"
        elif [ -n "$ZPOOL_IMPORT_DIR" ] ; then
                args="$args -d $ZPOOL_IMPORT_DIR"
-       elif [ -d "/dev/disk/by-vdev" ] ; then
-               args="$args -d /dev/disk/by-vdev"
-       elif [ -d "/dev/mapper" ] ; then
-               args="$args -d /dev/mapper"
        fi
 
        if zpool status $pool >/dev/null 2>&1 ; then
@@ -114,6 +109,9 @@ import_zpool ()
                zpool import $pool $args 2>/dev/null
                result=$?
        fi
+       if [ $result -ne 0 ] ; then
+               echo "Unexpected return code from import of pool $pool: $result"
+       fi
        return $result
 }