Whamcloud - gitweb
LU-13475 utils: disable lfs_migrate rsync and warning
authorAndreas Dilger <adilger@whamcloud.com>
Wed, 11 Nov 2020 21:53:22 +0000 (14:53 -0700)
committerAndreas Dilger <adilger@whamcloud.com>
Tue, 14 Feb 2023 19:08:09 +0000 (19:08 +0000)
The --rsync option is no longer enabled by default for fallback if
'lfs migrate' fails for some reason, and is mandatory for rsync usage.
The warning message and "-y" option of lfs_migrate is no longer needed
if rsync is not used, and is only shown if --rsync is used.

Remove the LFS_MIGRATE_RSYNC_MODE variable that was used for tests
and instead pass the "--rsync" option directly when needed.

Lustre-change: https://review.whamcloud.com/40614
Lustre-commit: 1be889a5bc713ab8db6c3d2cbf83aef8df813293

Test-Parameters: trivial
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I70b70d969f2dc8b4836c6c7692e6a73a0e2540e5
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/49867
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/doc/lfs_migrate.1
lustre/scripts/lfs_migrate
lustre/tests/sanity.sh

index 21b09f5..96d9f3f 100644 (file)
@@ -148,7 +148,7 @@ value is specified in KB.  This option is useful for testing, by simulating
 OSTs that are nearly full.
 .TP
 .B \\--yes|-y
-Answer 'y' to usage warning without prompting (for scripts, use with caution).
+Answer 'y' to usage warning without prompt (--rsync only, use with caution).
 .TP
 .B \\-0
 Input file names on stdin are separated by a null character.
@@ -169,7 +169,7 @@ disabling file creation on testfs-OST0004 (this is needed on all MDS nodes):
 .IP
 .nf
 mds# lctl set_param osp.testfs-OST0004*.max_create_count=0
-client# lfs find /testfs -obd testfs-OST0004 -size +4G -mtime +2d | lfs_migrate -y
+client# lfs find /testfs -obd testfs-OST0004 -size +4G -mtime +2d | lfs_migrate
 mds# lctl set_param osp.testfs-OST0004*.max_create_count=20000
 .fi
 .PP
index a480257..d04dccb 100755 (executable)
@@ -14,7 +14,6 @@
 
 RSYNC=${RSYNC:-"rsync"}
 RSYNC_OPTS=${RSYNC_OPTS:-"-a --inplace"}
-OPT_RSYNC=${LFS_MIGRATE_RSYNC_MODE:-false}
 ECHO=echo
 LFS=${LFS:-lfs}
 RSYNC_WITH_HLINKS=false
@@ -67,7 +66,7 @@ usage: lfs_migrate [--dry-run|-n] [--help|-h] [--no-rsync|--rsync|--cp]
                   when -A is set, an OST must contain more available space than
                   <min_free> KB in order for it to be considered available for
                   use in the migration
-       --no-rsync do not fall back to rsync mode even if lfs migrate fails
+       --no-rsync do not fall back to rsync even if lfs migrate fails (default)
        -n         only print the names of files to be migrated
        -p <pool>  use the specified OST pool for the destination file
        -q         run quietly (don't print filenames or status)
@@ -81,12 +80,12 @@ usage: lfs_migrate [--dry-run|-n] [--help|-h] [--no-rsync|--rsync|--cp]
                   when -A is set, limit the amount of space on each OST that
                   can be considered available for the migration to
                   <max_free> KB
-       -y         answer 'y' to usage question
+       -y         answer 'y' to usage question (only when --rsync/--cp used)
        -0         input file names on stdin are separated by a null character
 
 Options '-A', '-c', and '-R' are mutually exclusive.
 Options '-C', '-M', and '-X' are ignored if '-A' is not set.
-Options --rsync, --cp, --no-rsync may not be specified at the same time.
+Options --rsync, --cp, --no-rsync may not be used at the same time.
 
 If a directory is an argument, all files in the directory are migrated.
 If no file/directory is given, the file list is read from standard input.
@@ -94,10 +93,15 @@ If no file/directory is given, the file list is read from standard input.
 Any arguments that are not explicitly recognized by the script are passed
 through to the 'lfs migrate' utility.
 
+If emptying an active OST, new files may continue to be allocated there.
+To prevent this, on each MDS run the following for each OST being emptied:
+
+    lctl set_param osp.<fsname>-OSTNNNN*.max_create_count=0'
+
 Examples:
       lfs_migrate /mnt/lustre/dir
       lfs_migrate -p newpool /mnt/lustre/dir
-      lfs find /test -O test-OST0004 -size +4G | lfs_migrate -y
+      lfs find /test -O test-OST0004 -size +4G | lfs_migrate
 USAGE
     exit 1
 }
@@ -109,22 +113,24 @@ cleanup() {
 
 trap cleanup EXIT
 
+OPT_AUTOSTRIPE=false
 OPT_CHECK=true
 OPT_DEBUG=false
 OPT_DRYRUN=false
 OPT_FILE=()
 OPT_LAYOUT=()
 OPT_COMP=false
-OPT_NO_RSYNC=false
+OPT_COPY=false
 OPT_NO_DIRECT=false
+OPT_NO_RSYNC=true
 OPT_NULL=false
 OPT_PASSTHROUGH=()
 OPT_POOL=""
 OPT_RESTRIPE=false
-OPT_YES=false
-OPT_AUTOSTRIPE=false
+OPT_RSYNC=false
 OPT_STRIPE_COUNT=""
 OPT_STRIPE_SIZE=""
+OPT_YES=false
 OPT_MINFREE=262144
 OPT_MAXFREE=""
 OPT_CAP=100
@@ -137,13 +143,13 @@ while [ -n "$*" ]; do
        case "$arg" in
        --auto-stripe|-A) OPT_AUTOSTRIPE=true;;
        -b|--block|--non-block|--non-direct|-D|--no-verify)
-          # Always pass non-layout options to 'lfs migrate'
-          OPT_PASSTHROUGH+=("$arg");;
+               # Always pass non-layout options to 'lfs migrate'
+               OPT_PASSTHROUGH+=("$arg");;
        --cp) $OPT_RSYNC && [[ "$RSYNC" != "cp" ]] && OPT_NO_RSYNC=true
-          OPT_RSYNC=true; RSYNC="cp"; RSYNC_OPTS="-p";;
-       --copy|--yaml|--file) OPT_COMP=true;
-          # these options have files as arguments, pass both through
-          OPT_LAYOUT+="$arg $2 "; shift;;
+               OPT_RSYNC=true; RSYNC="cp"; RSYNC_OPTS="-p";;
+       --copy|--yaml|--file) OPT_COPY=true;
+               # these options have files as arguments, pass both through
+               OPT_LAYOUT+="$arg $2 "; shift;;
        --dry-run) OPT_DRYRUN=true; OPT_YES=true;;
        -c|--stripe-count) OPT_STRIPE_COUNT="$2"; shift;;
        -C) OPT_CAP="$2"; shift;;
@@ -151,13 +157,13 @@ while [ -n "$*" ]; do
        -l|--link) ;; # maintained backward compatibility for now
        -M|--min-free) OPT_MINFREE="$2"; shift;;
        -n) OPT_DRYRUN=true; OPT_YES=true
-          echo "$PROG: -n deprecated, use --dry-run or --non-block" 1>&2;;
+               echo "$PROG: -n deprecated, use --dry-run or --non-block" 1>&2;;
        -p|--pool) OPT_POOL="$arg $2"; OPT_LAYOUT+="$OPT_POOL "; shift;;
        -q|--quiet) ECHO=:;;
        -R|--restripe) OPT_RESTRIPE=true;;
-       --no-rsync) OPT_NO_RSYNC=true;;
-       --rsync) $OPT_RSYNC && [[ "$RSYNC" != "rsync" ]] && OPT_NO_RSYNC=true
-          OPT_RSYNC=true ;;
+       --no-rsync) OPT_NO_RSYNC=true; OPT_RSYNC=false;;
+       --rsync) [[ "$RSYNC" != "rsync" ]] && OPT_NO_RSYNC=true || OPT_NO_RSYNC=false
+               OPT_RSYNC=true;;
        -s|--skip) OPT_CHECK=false;;
        -S|--stripe-size) OPT_STRIPE_SIZE="$2"; shift;;
        -v|--verbose) OPT_DEBUG=true; ECHO=echo;;
@@ -186,20 +192,15 @@ elif $OPT_AUTOSTRIPE && $OPT_RESTRIPE; then
 fi
 
 if $OPT_RSYNC && $OPT_NO_RSYNC; then
-       echo "$PROG: Options --cp, --rsync, and --no-rsync may not be" \
-               "specified at the same time." 1>&2
+       echo "$PROG: Options --cp, --rsync, --no-rsync may not be used together." 1>&2
        exit 1
 fi
 
-if ! $OPT_YES; then
+if $OPT_RSYNC && ! $OPT_YES; then
        echo ""
-       echo "lfs_migrate is currently NOT SAFE for moving in-use files." 1>&2
+       echo "'lfs_migrate --$RSYNC' is NOT SAFE for moving in-use files." 1>&2
        echo "Use it only when you are sure migrated files are unused." 1>&2
        echo "" 1>&2
-       echo "If emptying an OST that is active on the MDS, new files may" 1>&2
-       echo "use it.  To stop allocating any new objects on OSTNNNN run:" 1>&2
-       echo "  lctl set_param osp.<fsname>-OSTNNNN*.max_create_count=0'" 1>&2
-       echo "on each MDS using the OST(s) being emptied." 1>&2
        echo -n "Continue? (y/n) "
        read CHECK
        [ "$CHECK" != "y" -a "$CHECK" != "yes" ] && exit 1
@@ -451,12 +452,12 @@ lfs_migrate() {
                        continue
                fi
 
-               if ! $OPT_COMP && ! $OPT_RSYNC &&
+               if ! $OPT_COPY && ! $OPT_COMP && ! $OPT_RSYNC &&
                   (( ${layout_info[$l_comp_count]} > 0 )); then
                        layout+="--copy $OLDNAME"
-                       OPT_COMP=true
+                       OPT_COPY=true
                fi
-               if ! $OPT_COMP; then
+               if ! $OPT_COPY && ! $OPT_COMP; then
                        [ -n "$stripe_count" ] && layout+="-c $stripe_count "
                        [ -n "$stripe_size" ] && layout+="-S $stripe_size "
                        [ -n "$OPT_POOL" -a -n "$stripe_pool" ] &&
index 3affe7c..ba1803a 100755 (executable)
@@ -7138,16 +7138,16 @@ test_56wc() {
 run_test 56wc "check unrecognized options for lfs_migrate are passed through"
 
 test_56wd() {
-       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
+       (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
 
-       local file1=$DIR/$tdir/file1
+       local file1=$DIR/$tdir/$tfile
 
        echo -n "Creating test dir..."
        test_mkdir $DIR/$tdir || error "cannot create dir"
        echo "done."
 
        echo -n "Creating test file..."
-       touch $file1
+       echo "$tfile" > $file1
        echo "done."
 
        # Ensure 'lfs migrate' will fail by using a non-existent option,
@@ -7164,15 +7164,6 @@ test_56wd() {
                grep -q 'falling back to rsync' &&
                error "lfs migrate was called with --rsync set"
        echo "done."
-
-       echo -n "Make sure --rsync and --no-rsync options are exclusive..."
-       $LFS_MIGRATE -y --rsync --no-rsync $file1 2>&1 |
-               grep -q 'at the same time' ||
-               error "--rsync and --no-rsync accepted concurrently"
-       echo "done."
-
-       # Clean up
-       rm -f $file1
 }
 run_test 56wd "check lfs_migrate --rsync and --no-rsync work"
 
@@ -7241,6 +7232,7 @@ test_56xa() {
 run_test 56xa "lfs migration --block support"
 
 check_migrate_links() {
+       [[ "$1" == "--rsync" ]] && local opts="--rsync -y" && shift
        local dir="$1"
        local file1="$dir/file1"
        local begin="$2"
@@ -7290,7 +7282,7 @@ check_migrate_links() {
        fi
 
        echo -n "migrating files..."
-       local migrate_out=$($runas $LFS_MIGRATE -y -S '1m' $dir)
+       local migrate_out=$($runas $LFS_MIGRATE $opts -S '1m' $dir)
        local rc=$?
        [ $rc -eq 0 ] || error "migrate failed rc = $rc"
        echo "done"
@@ -7334,20 +7326,20 @@ test_56xb() {
        test_mkdir "$dir" || error "cannot create dir $dir"
 
        echo "testing lfs migrate mode when all links fit within xattrs"
-       LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 2 99
+       check_migrate_links "$dir" 2 99
 
        echo "testing rsync mode when all links fit within xattrs"
-       LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 2 99
+       check_migrate_links --rsync "$dir" 2 99
 
        echo "testing lfs migrate mode when all links do not fit within xattrs"
-       LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100
+       check_migrate_links "$dir" 101 100
 
        echo "testing rsync mode when all links do not fit within xattrs"
-       LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 101 100
+       check_migrate_links --rsync "$dir" 101 100
 
-       chown -R $RUNAS_ID $dir
+       chown -R $RUNAS_ID:$RUNAS_GID $dir
        echo "testing non-root lfs migrate mode when not all links are in xattr"
-       LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100 "$RUNAS"
+       check_migrate_links "$dir" 101 100 "$RUNAS"
 
        # clean up
        rm -rf $dir