From 1be889a5bc713ab8db6c3d2cbf83aef8df813293 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Wed, 11 Nov 2020 14:53:22 -0700 Subject: [PATCH] LU-13475 utils: disable lfs_migrate rsync and warning 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. Test-Parameters: trivial Signed-off-by: Andreas Dilger Change-Id: I70b70d969f2dc8b4836c6c7692e6a73a0e2540e5 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/40614 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Jian Yu Reviewed-by: Vitaliy Kuznetsov Reviewed-by: Oleg Drokin --- lustre/doc/lfs_migrate.1 | 4 ++-- lustre/scripts/lfs_migrate | 40 +++++++++++++++++----------------------- lustre/tests/sanity.sh | 28 ++++++++++------------------ 3 files changed, 29 insertions(+), 43 deletions(-) diff --git a/lustre/doc/lfs_migrate.1 b/lustre/doc/lfs_migrate.1 index 35358b1..fc9ffaba 100644 --- a/lustre/doc/lfs_migrate.1 +++ b/lustre/doc/lfs_migrate.1 @@ -142,7 +142,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. @@ -162,7 +162,7 @@ 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 -A +client# lfs find /testfs -obd testfs-OST0004 -size +4G -mtime +2d | lfs_migrate -A mds# lctl set_param osp.testfs-OST0004*.max_create_count=20000 .fi .PP diff --git a/lustre/scripts/lfs_migrate b/lustre/scripts/lfs_migrate index 9ed0f35..bba2ada 100755 --- a/lustre/scripts/lfs_migrate +++ b/lustre/scripts/lfs_migrate @@ -13,7 +13,6 @@ # to be 100% safe the administrator needs to ensure this is safe. RSYNC=${RSYNC:-rsync} -OPT_RSYNC=${LFS_MIGRATE_RSYNC_MODE:-false} ECHO=echo LFS=${LFS:-lfs} RSYNC_WITH_HLINKS=false @@ -65,7 +64,7 @@ usage: lfs_migrate [--dry-run|-n] [--help|-h] [--no-rsync|--rsync] [--quiet|-q] when -A is set, an OST must contain more available space than 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 use the specified OST pool for the destination file -q run quietly (don't print filenames or status) @@ -79,24 +78,27 @@ usage: lfs_migrate [--dry-run|-n] [--help|-h] [--no-rsync|--rsync] [--quiet|-q] when -A is set, limit the amount of space on each OST that can be considered available for the migration to KB - -y answer 'y' to usage question + -y answer 'y' to usage question (only when --rsync 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. -The --rsync and --no-rsync options may not be specified 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. 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.-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 } @@ -108,22 +110,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 @@ -149,8 +153,8 @@ while [ -n "$*" ]; do -b|--block|--non-block|--non-direct|-D|--no-verify) # Always pass non-layout options to 'lfs migrate' OPT_PASSTHROUGH+=("$arg");; - --rsync) OPT_RSYNC=true;; - --no-rsync) OPT_NO_RSYNC=true;; + --rsync) OPT_RSYNC=true; OPT_NO_RSYNC=false;; + --no-rsync) OPT_NO_RSYNC=true; OPT_RSYNC=false;; --copy|--yaml|--file) OPT_COMP=true; # these options have files as arguments, pass both through OPT_LAYOUT+="$arg $2 "; shift;; @@ -181,21 +185,11 @@ elif $OPT_AUTOSTRIPE && $OPT_RESTRIPE; then exit 1 fi -if $OPT_RSYNC && $OPT_NO_RSYNC; then - echo "$PROG: Options --rsync and --no-rsync may not be" \ - "specified at the same time." 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.-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 diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 405b2cf..e3333a4 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -7543,16 +7543,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, @@ -7569,15 +7569,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" @@ -7646,6 +7637,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" @@ -7695,7 +7687,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" @@ -7739,20 +7731,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 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 -- 1.8.3.1