Whamcloud - gitweb
LU-2302 scripts: make lfs_migrate compatible with 1.8
authorKeith Mannthey <keith.mannthey@intel.com>
Thu, 17 Jan 2013 17:33:28 +0000 (09:33 -0800)
committerOleg Drokin <oleg.drokin@intel.com>
Sat, 9 Feb 2013 03:13:03 +0000 (22:13 -0500)
Earlier versions of lfs setstripe/getstripe use option -s instead
of -S. Make sure lfs_migrate can be used with any version.

Signed-off-by: Daniel Kobras <d.kobras@science-computing.de>
Signed-off-by: Keith Mannthey <keith.mannthey@intel.com>
Change-Id: Ic3caaeaf3d6c764afbd75cd7a8a7279462d21d47
Reviewed-on: http://review.whamcloud.com/4702
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/scripts/lfs_migrate

index c285510..a09c368 100755 (executable)
@@ -17,6 +17,7 @@ set -e
 RSYNC=${RSYNC:-rsync}
 ECHO=echo
 LFS=${LFS:-lfs}
 RSYNC=${RSYNC:-rsync}
 ECHO=echo
 LFS=${LFS:-lfs}
+LFS_SIZE_OPT="-s"
 
 usage() {
     cat -- <<USAGE 1>&2
 
 usage() {
     cat -- <<USAGE 1>&2
@@ -96,6 +97,9 @@ strings $(which $RSYNC) 2>&1 | grep -q lustre && LFS=:
 # access the temporary file.
 umask 0077
 
 # access the temporary file.
 umask 0077
 
+# This is needed for 1.8 Interoperability and can be removed in the future
+$LFS getstripe --help 2>&1 | grep -q stripe-size && LFS_SIZE_OPT="-S"
+
 lfs_migrate() {
        while IFS='' read -d '' OLDNAME; do
                $ECHO -n "$OLDNAME: "
 lfs_migrate() {
        while IFS='' read -d '' OLDNAME; do
                $ECHO -n "$OLDNAME: "
@@ -138,7 +142,8 @@ lfs_migrate() {
                        [ "$OPT_STRIPE_COUNT" ] && COUNT=$OPT_STRIPE_COUNT ||
                                COUNT=$($LFS getstripe -c "$OLDNAME" \
                                        2> /dev/null)
                        [ "$OPT_STRIPE_COUNT" ] && COUNT=$OPT_STRIPE_COUNT ||
                                COUNT=$($LFS getstripe -c "$OLDNAME" \
                                        2> /dev/null)
-                       SIZE=$($LFS getstripe -S "$OLDNAME" 2> /dev/null)
+                       SIZE=$($LFS getstripe $LFS_SIZE_OPT "$OLDNAME" \
+                              2> /dev/null)
 
                        [ -z "$COUNT" -o -z "$SIZE" ] && UNLINK=""
                fi
 
                        [ -z "$COUNT" -o -z "$SIZE" ] && UNLINK=""
                fi
@@ -148,7 +153,8 @@ lfs_migrate() {
                        continue
                fi
 
                        continue
                fi
 
-               [ "$UNLINK" ] && $LFS setstripe -c${COUNT} -S${SIZE} "$NEWNAME"
+               [ "$UNLINK" ] && $LFS setstripe -c${COUNT} \
+                                     ${LFS_SIZE_OPT}${SIZE} "$NEWNAME"
 
                # we use --inplace, since we created our own temp file already
                if ! $RSYNC -a --inplace $RSYNC_OPTS "$OLDNAME" "$NEWNAME";then
 
                # we use --inplace, since we created our own temp file already
                if ! $RSYNC -a --inplace $RSYNC_OPTS "$OLDNAME" "$NEWNAME";then