Whamcloud - gitweb
LU-6051 utils: allow lfs_migrate to migrate links 99/30799/2
authorAndreas Dilger <andreas.dilger@intel.com>
Sat, 10 Jun 2017 02:39:11 +0000 (20:39 -0600)
committerJohn L. Hammond <john.hammond@intel.com>
Fri, 9 Feb 2018 16:58:14 +0000 (16:58 +0000)
When running on a server that supports "lfs migrate", it is possible
to migrate hard links transparently.  This is still not possible for
servers that do not support "lfs migrate" (layout swap) so we still
need to keep the hard-link check if "lfs migrate" fails.

Add test for migrating many hardlinks on supported kernels.

Test-Parameters: trivial
Lustre-change: https://review.whamcloud.com/27553
Lustre-commit: 6086d0d69c84ce57c4daff18595fa7b620ed2b04

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Change-Id: I7fa1c70611aa7dd61f822844d5fe339f730640e5
Reviewed-by: Steve Guminski <stephenx.guminski@intel.com>
Reviewed-by: Nathaniel Clark <nathaniel.l.clark@intel.com>
Signed-off-by: Minh Diep <minh.diep@intel.com>
Reviewed-on: https://review.whamcloud.com/30799
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
lustre/scripts/lfs_migrate
lustre/tests/sanity.sh

index 6bc0797..37e8ee0 100755 (executable)
@@ -15,6 +15,7 @@ set -e
 # to be 100% safe the administrator needs to ensure this is safe.
 
 RSYNC=${RSYNC:-rsync}
+LFS_MIGRATE_RSYNC_MODE=${LFS_MIGRATE_RSYNC_MODE:-false}
 ECHO=echo
 LFS=${LFS:-lfs}
 LFS_SIZE_OPT="-s"
@@ -26,7 +27,7 @@ usage: lfs_migrate [-c <stripe_count>] [-h] [-l] [-n] [-q] [-R] [-s] [-y] [-0]
     -c <stripe_count>
        restripe file using the specified stripe count
     -h show this usage message
-    -l migrate files with hard links (skip by default)
+    -l migrate files with hard links (skip by default for rsync)
     -n only print the names of files to be migrated
     -q run quietly (don't print filenames or status)
     -R restripe file using default directory striping
@@ -101,8 +102,6 @@ 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: "
 
@@ -116,11 +115,6 @@ lfs_migrate() {
                        continue
                fi
 
-               if [ -z "$OPT_NLINK" -a ${TYPE_LINK[0]} -gt 1 ]; then
-                       echo -e "multiple hard links, skipped"
-                       continue
-               fi
-
                # working out write perms is hard, let the shell do it
                if [ ! -w "$OLDNAME" ]; then
                        echo -e "no write permission, skipped"
@@ -152,16 +146,21 @@ lfs_migrate() {
 
                # first try to migrate inside lustre
                # if failed go back to old rsync mode
-               if [[ $RSYNC_MODE == false ]]; then
+               if [[ $LFS_MIGRATE_RSYNC_MODE == false ]]; then
                        if $LFS migrate -c${COUNT} ${SIZE} "$OLDNAME"; then
                                $ECHO "done"
                                continue
                        else
                                echo "falling back to rsync-based migration"
-                               RSYNC_MODE=true
+                               LFS_MIGRATE_RSYNC_MODE=true
                        fi
                fi
 
+               if [ -z "$OPT_NLINK" -a ${TYPE_LINK[0]} -gt 1 ]; then
+                       echo -e "multiple hard links, skipped"
+                       continue
+               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
index b870c4f..ec664fc 100755 (executable)
@@ -5055,54 +5055,59 @@ test_56w() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
        TDIR=$DIR/${tdir}w
 
-    rm -rf $TDIR || error "remove $TDIR failed"
-    setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
-
-    local stripe_size
-    stripe_size=$($GETSTRIPE -S -d $TDIR) ||
-        error "$GETSTRIPE -S -d $TDIR failed"
-    stripe_size=${stripe_size%% *}
-
-    local file_size=$((stripe_size * OSTCOUNT))
-    local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
-    local required_space=$((file_num * file_size))
-
-    local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
-                       head -n1)
-    [[ $free_space -le $((required_space / 1024)) ]] &&
-        skip_env "need at least $required_space bytes free space," \
-                 "have $free_space kbytes" && return
-
-    local dd_bs=65536
-    local dd_count=$((file_size / dd_bs))
-
-    # write data into the files
-    local i
-    local j
-    local file
-    for i in $(seq 1 $NUMFILES); do
-        file=$TDIR/file$i
-        yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
-            error "write data into $file failed"
-    done
-    for i in $(seq 1 $NUMDIRS); do
-        for j in $(seq 1 $NUMFILES); do
-            file=$TDIR/dir$i/file$j
-            yes | dd bs=$dd_bs count=$dd_count of=$file \
-                >/dev/null 2>&1 ||
-                error "write data into $file failed"
-        done
-    done
+       rm -rf $TDIR || error "remove $TDIR failed"
+       setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
+
+       local stripe_size
+       stripe_size=$($GETSTRIPE -S -d $TDIR) ||
+               error "$GETSTRIPE -S -d $TDIR failed"
+       stripe_size=${stripe_size%% *}
+
+       local file_size=$((stripe_size * OSTCOUNT))
+       local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
+       local required_space=$((file_num * file_size))
+
+       local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
+                          head -n1)
+       [[ $free_space -le $((required_space / 1024)) ]] &&
+               skip_env "need $required_space bytes, have $free_space KB" &&
+               return
 
-    local expected=-1
-    [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
+       local dd_bs=65536
+       local dd_count=$((file_size / dd_bs))
 
-    # lfs_migrate file
-    local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
-    echo "$cmd"
-    eval $cmd || error "$cmd failed"
+       # write data into the files
+       local i
+       local j
+       local file
+       for i in $(seq 1 $NUMFILES); do
+               file=$TDIR/file$i
+               yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
+                       error "write data into $file failed"
+       done
+       for i in $(seq 1 $NUMDIRS); do
+               for j in $(seq 1 $NUMFILES); do
+                       file=$TDIR/dir$i/file$j
+                       yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
+                               error "write data into $file failed"
+               done
+       done
+
+       # $LFS_MIGRATE will fail if hard link migration is unsupported
+       if [[ $(lustre_version_code mds1) -gt $(version_code 2.5.55) ]]; then
+               createmany -l$TDIR/dir1/file1 $TDIR/dir1/link 200 ||
+                       error "creating links to $TDIR/dir1/file1 failed"
+       fi
+
+       local expected=-1
+       [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
+
+       # lfs_migrate file
+       local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
+       echo "$cmd"
+       eval $cmd || error "$cmd failed"
 
-    check_stripe_count $TDIR/file1 $expected
+       check_stripe_count $TDIR/file1 $expected
 
        if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.90) ];
        then