Whamcloud - gitweb
LU-2445 utils: lfs migrate support
[fs/lustre-release.git] / lustre / scripts / lfs_migrate
index a09c368..bf595b3 100755 (executable)
@@ -101,6 +101,8 @@ umask 0077
 $LFS getstripe --help 2>&1 | grep -q stripe-size && LFS_SIZE_OPT="-S"
 
 lfs_migrate() {
+       local RSYNC_MODE=false
+
        while IFS='' read -d '' OLDNAME; do
                $ECHO -n "$OLDNAME: "
 
@@ -130,7 +132,6 @@ lfs_migrate() {
                        continue
                fi
 
-
                if [ "$OPT_RESTRIPE" ]; then
                        UNLINK=""
                else
@@ -147,6 +148,19 @@ lfs_migrate() {
 
                        [ -z "$COUNT" -o -z "$SIZE" ] && UNLINK=""
                fi
+
+               # first try to migrate inside lustre
+               # if failed go back to old rsync mode
+               if [[ $RSYNC_MODE == false ]]; then
+                       $LFS migrate -c${COUNT} ${LFS_SIZE_OPT}${SIZE} $OLDNAME
+                       if [[ $? == 0 ]]; then
+                               $ECHO "done"
+                               continue
+                       else
+                               RSYNC_MODE=true
+                       fi
+               fi
+
                NEWNAME=$(mktemp $UNLINK "$OLDNAME.tmp.XXXXXX")
                if [ $? -ne 0 -o -z "$NEWNAME" ]; then
                        echo -e "\r$OLDNAME: can't make temp file, skipped" 1>&2