-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 '-A', and '-R' are mutually exclusive with each other, and any
+specific layout (e.g. any specific parameters like '-c', '-S', '-E', '-p').
Options '-C', '-M', and '-X' are ignored if '-A' is not set.
If a directory is an argument, all files in the directory are migrated.
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'
+ lctl set_param osp.<fsname>-OSTxxxx*.max_create_count=0
Examples:
lfs_migrate /mnt/lustre/dir
-n) OPT_DRYRUN=true; OPT_YES=true
echo "$PROG: -n deprecated, use --dry-run or --non-block" 1>&2;;
--dry-run) OPT_DRYRUN=true; OPT_YES=true;;
- -p|--pool) OPT_POOL="$arg $2"; OPT_LAYOUT+="$OPT_POOL "; shift;;
+ -p|--pool) # if within a component, pass through pool
+ $OPT_COMP && OPT_LAYOUT+="$arg $2 " || OPT_POOL="-p $2";
+ shift;;
-q|--quiet) ECHO=:;;
-R|--restripe) OPT_RESTRIPE=true;;
-s|--skip) OPT_CHECK=false;;
OPT_PASSTHROUGH+=("$arg");;
--rsync) OPT_RSYNC=true; OPT_NO_RSYNC=false;;
--no-rsync) OPT_NO_RSYNC=true; OPT_RSYNC=false;;
- --copy|--yaml|--file) OPT_COMP=true;
+ --copy|--yaml|--file) OPT_COPY=true;
# these options have files as arguments, pass both through
OPT_LAYOUT+="$arg $2 "; shift;;
--auto-stripe|-A) OPT_AUTOSTRIPE=true;;
-C) OPT_CAP="$2"; shift;;
+ -D) LFS_OPT_DIRECTIO="-D";;
+ -E|--comp-end|--component-end) OPT_COMP=true; OPT_LAYOUT+="$arg ";;
-M|--min-free) OPT_MINFREE="$2"; shift;;
-X|--max-free) OPT_MAXFREE="$2"; shift;;
- -c|--stripe-count) OPT_STRIPE_COUNT="$2"; shift;;
- -S|--stripe-size) OPT_STRIPE_SIZE="$2"; shift;;
+ -c|--stripe-count) # if within a component, pass through stripe_count
+ $OPT_COMP && OPT_LAYOUT+="$arg $2 " || OPT_STRIPE_COUNT="$2"
+ shift;;
+ -S|--stripe-size) # if within a component, pass through stripe_size
+ $OPT_COMP && OPT_LAYOUT+="$arg $2 " || OPT_STRIPE_SIZE="$2"
+ shift;;
*) # Pass other non-file layout options to 'lfs migrate'
- [ -e "$arg" ] && OPT_FILE+="$arg " && break || OPT_LAYOUT+="$arg "
+ [[ -e "$arg" ]] && OPT_FILE+="$arg " && break || OPT_LAYOUT+="$arg "
esac
shift
done
-if $OPT_RESTRIPE || $OPT_AUTOSTRIPE && [ -n "$OPT_LAYOUT" ]; then
- echo "$PROG error: Options '$OPT_LAYOUT' can't be used with -R or -A" \
- 1>&2
+if ( $OPT_RESTRIPE || $OPT_AUTOSTRIPE ) &&
+ [[ -n "$OPT_STRIPE_COUNT" || -n "$OPT_STRIPE_SIZE" || -n "$OPT_POOL" ]]; then
+ echo "$PROG error: option -R or -A cannot be used with -c, -S, or -p" 1>&2
exit 1
-elif $OPT_RESTRIPE && [[ "$OPT_STRIPE_COUNT" || "$OPT_STRIPE_SIZE" ]]; then
- echo "$PROG error: Option -R can't be used with -c or -S" 1>&2
+elif ( $OPT_RESTRIPE || $OPT_AUTOSTRIPE ) && [[ -n "$OPT_LAYOUT" ]]; then
+ echo "$PROG error: option -R or -A cannot be used with $OPT_LAYOUT" 1>&2
exit 1
-elif $OPT_AUTOSTRIPE && [ -n "$OPT_STRIPE_COUNT" ]; then
- echo "$PROG error: Option -A can't be used with -c" 1>&2
- exit 1
-elif $OPT_AUTOSTRIPE && $OPT_RESTRIPE; then
- echo "$PROG error: Option -A can't be used with -R" 1>&2
+elif $OPT_RESTRIPE && $OPT_AUTOSTRIPE; then
+ echo "$PROG error: option -R cannot be used with -A" 1>&2
exit 1
fi
local olddir=$(dirname "$OLDNAME")
local stripe_size="$OPT_STRIPE_SIZE"
local stripe_count="$OPT_STRIPE_COUNT"
- local stripe_opts="-N --comp-count -c -S -p -y"
+ local getstripe_opts="-N --comp-count -c -S -p -y"
local parent_count=""
local parent_size=""
local stripe_pool="${OPT_POOL#-p }"
local mirror_count=1
local comp_count=0
- # avoid multiple getstripe calls
- # lcm_mirror_count: 1
- # lcm_entry_count: 0
- # lmm_stripe_count: 1
- # lmm_stripe_size: 1048576
- # lmm_pool: pool_abc
- local l_mirror_count=0
- local l_comp_count=1
- local l_stripe_count=2
- local l_stripe_size=3
- local l_stripe_pool=4
- local layout_info=($($LFS getstripe $stripe_opts "$OLDNAME" \
- 2>/dev/null | awk '{ print $2 }'))
layout="${OPT_PASSTHROUGH[@]} "
if $OPT_RESTRIPE; then
UNLINK=""
layout+="--copy $olddir"
- OPT_COMP=true
- else
+ OPT_COPY=true
+ elif ! $OPT_COMP; then
+ # avoid multiple getstripe calls
+ # lcm_mirror_count: 1
+ # lcm_entry_count: 0
+ # lmm_stripe_count: 1
+ # lmm_stripe_size: 1048576
+ # lmm_pool: pool_abc
+ local l_mirror_count=0
+ local l_comp_count=1
+ local l_stripe_count=2
+ local l_stripe_size=3
+ local l_stripe_pool=4
+ local layout_info
+
+ layout_info=($($LFS getstripe $getstripe_opts $OLDNAME \
+ 2>/dev/null | awk '{ print $2 }'))
# If rsync copies Lustre xattrs properly in the future
# (i.e. before the file data, so that it preserves
# striping) then we don't need this getstripe stuff.
local parent_layout
if $OPT_RESTRIPE; then
- parent_layout=($($LFS getstripe $stripe_opts \
+ parent_layout=($($LFS getstripe $getstripe_opts\
-d "$olddir" 2>/dev/null |
awk '{print $2 }'))
parent_count=${parent_layout[$l_stripe_count]}
continue
fi
- if ! $OPT_COMP && [ ${layout_info[$l_comp_count]} -gt 0 ]; then
+ if ! $OPT_COPY && ! $OPT_COMP &&
+ [[ ${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" ] &&
}
run_test 56v "check 'lfs find -m match with lfs getstripe -m'"
-test_56w() {
- [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
+test_56wa() {
+ (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
[ $PARALLEL == "yes" ] && skip "skip parallel run"
local dir=$DIR/$tdir
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)) ]] &&
+ (( free_space >= required_space / 1024 )) ||
skip_env "need $required_space, have $free_space kbytes"
local dd_bs=65536
local j
local file
- for i in $(seq $NUMFILES); do
+ for ((i = 1; i <= NUMFILES; i++ )); do
file=$dir/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 $NUMDIRS); do
- for j in $(seq $NUMFILES); do
+ for ((i = 1; i <= NUMDIRS; i++ )); do
+ for ((j = 1; j <= NUMFILES; j++ )); do
file=$dir/dir$i/file$j
yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
error "write data into $file failed"
done
# $LFS_MIGRATE will fail if hard link migration is unsupported
- if [[ $MDS1_VERSION -gt $(version_code 2.5.55) ]]; then
+ if (( MDS1_VERSION > $(version_code 2.5.55) )); then
createmany -l$dir/dir1/file1 $dir/dir1/link 200 ||
error "creating links to $dir/dir1/file1 failed"
fi
local expected=-1
- [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
+ (( OSTCOUNT <= 1 )) || expected=$((OSTCOUNT - 1))
# lfs_migrate file
local cmd="$LFS_MIGRATE -y -c $expected $dir/file1"
check_stripe_count $dir/file1 $expected
- if [ $MDS1_VERSION -ge $(version_code 2.6.90) ];
- then
+ if (( $MDS1_VERSION >= $(version_code 2.6.90) )); then
# lfs_migrate file onto OST 0 if it is on OST 1, or onto
# OST 1 if it is on OST 0. This file is small enough to
# be on only one stripe.
local oldmd5=$(md5sum $file)
local newobdidx=0
- [[ $obdidx -eq 0 ]] && newobdidx=1
+ (( obdidx != 0 )) || newobdidx=1
cmd="$LFS migrate -i $newobdidx $file"
echo $cmd
eval $cmd || error "$cmd failed"
local realobdix=$($LFS getstripe -i $file)
local newmd5=$(md5sum $file)
- [[ $newobdidx -ne $realobdix ]] &&
- error "new OST is different (was=$obdidx, "\
- "wanted=$newobdidx, got=$realobdix)"
- [[ "$oldmd5" != "$newmd5" ]] &&
+ (( $newobdidx == $realobdix )) ||
+ error "new OST is different (was=$obdidx, wanted=$newobdidx, got=$realobdix)"
+ [[ "$oldmd5" == "$newmd5" ]] ||
error "md5sum differ: $oldmd5, $newmd5"
fi
echo "$cmd"
eval $cmd || error "$cmd failed"
- for j in $(seq $NUMFILES); do
+ for (( j = 1; j <= NUMFILES; j++ )); do
check_stripe_count $dir/dir1/file$j $expected
done
echo "$cmd"
eval $cmd || error "$cmd failed"
- for i in $(seq 2 $NUMFILES); do
+ for (( i = 2; i <= NUMFILES; i++ )); do
check_stripe_count $dir/file$i $expected
done
- for i in $(seq 2 $NUMDIRS); do
- for j in $(seq $NUMFILES); do
- check_stripe_count $dir/dir$i/file$j $expected
+ for (( i = 2; i <= NUMDIRS; i++ )); do
+ for (( j = 1; j <= NUMFILES; j++ )); do
+ check_stripe_count $dir/dir$i/file$j $expected
done
done
}
-run_test 56w "check lfs_migrate -c stripe_count works"
+run_test 56wa "check lfs_migrate -c stripe_count works"
test_56wb() {
local file1=$DIR/$tdir/file1
run_test 56wb "check lfs_migrate pool support"
test_56wc() {
- local file1="$DIR/$tdir/file1"
+ local file1="$DIR/$tdir/$tfile"
+ local md5
local parent_ssize
local parent_scount
local cur_ssize
local cur_scount
local orig_ssize
+ local new_scount
+ local cur_comp
echo -n "Creating test dir..."
test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
$LFS setstripe -S 512K -c 1 "$file1" &> /dev/null ||
error "cannot set stripe"
cur_ssize=$($LFS getstripe -S "$file1")
- [ $cur_ssize -eq 524288 ] || error "setstripe -S $cur_ssize != 524288"
+ (( cur_ssize == 524288 )) || error "setstripe -S $cur_ssize != 524288"
echo "done."
+ dd if=/dev/urandom of=$file1 bs=1M count=12 || error "dd $file1 failed"
+ stack_trap "rm -f $file1"
+ md5="$(md5sum $file1)"
+
# File currently set to -S 512K -c 1
# Ensure -c and -S options are rejected when -R is set
echo -n "Verifying incompatible options are detected..."
- $LFS_MIGRATE -y -R -c 1 "$file1" &> /dev/null &&
- error "incompatible -c and -R options not detected"
- $LFS_MIGRATE -y -R -S 1M "$file1" &> /dev/null &&
- error "incompatible -S and -R options not detected"
+ $LFS_MIGRATE -R -c 1 "$file1" &&
+ error "incompatible -R and -c options not detected"
+ $LFS_MIGRATE -R -S 1M "$file1" &&
+ error "incompatible -R and -S options not detected"
+ $LFS_MIGRATE -R -p pool "$file1" &&
+ error "incompatible -R and -p options not detected"
+ $LFS_MIGRATE -R -E eof -c 1 "$file1" &&
+ error "incompatible -R and -E options not detected"
+ $LFS_MIGRATE -R -A "$file1" &&
+ error "incompatible -R and -A options not detected"
+ $LFS_MIGRATE -A -c 1 "$file1" &&
+ error "incompatible -A and -c options not detected"
+ $LFS_MIGRATE -A -S 1M "$file1" &&
+ error "incompatible -A and -S options not detected"
+ $LFS_MIGRATE -A -p pool "$file1" &&
+ error "incompatible -A and -p options not detected"
+ $LFS_MIGRATE -A -E eof -c 1 "$file1" &&
+ error "incompatible -A and -E options not detected"
echo "done."
# Ensure unrecognized options are passed through to 'lfs migrate'
echo -n "Verifying -S option is passed through to lfs migrate..."
- $LFS_MIGRATE -y -S 1M "$file1" &> /dev/null ||
- error "migration failed"
+ $LFS_MIGRATE -y -S 1M "$file1" || error "migration failed"
cur_ssize=$($LFS getstripe -S "$file1")
- [ $cur_ssize -eq 1048576 ] || error "migrate -S $cur_ssize != 1048576"
+ (( cur_ssize == 1048576 )) || error "migrate -S $cur_ssize != 1048576"
+ [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (1)"
echo "done."
# File currently set to -S 1M -c 1
# Ensure long options are supported
echo -n "Verifying long options supported..."
- $LFS_MIGRATE -y --non-block "$file1" &> /dev/null ||
+ $LFS_MIGRATE --non-block "$file1" ||
error "long option without argument not supported"
- $LFS_MIGRATE -y --stripe-size 512K "$file1" &> /dev/null ||
+ $LFS_MIGRATE --stripe-size 512K "$file1" ||
error "long option with argument not supported"
cur_ssize=$($LFS getstripe -S "$file1")
- [ $cur_ssize -eq 524288 ] ||
+ (( cur_ssize == 524288 )) ||
error "migrate --stripe-size $cur_ssize != 524288"
+ [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (2)"
echo "done."
# File currently set to -S 512K -c 1
- if [ "$OSTCOUNT" -gt 1 ]; then
+ if (( OSTCOUNT > 1 )); then
echo -n "Verifying explicit stripe count can be set..."
- $LFS_MIGRATE -y -c 2 "$file1" &> /dev/null ||
- error "migrate failed"
+ $LFS_MIGRATE -c 2 "$file1" || error "migrate failed"
cur_scount=$($LFS getstripe -c "$file1")
- [ $cur_scount -eq 2 ] || error "migrate -c $cur_scount != 2"
+ (( cur_scount == 2 )) || error "migrate -c $cur_scount != 2"
+ [[ "$(md5sum $file1)" == "$md5" ]] ||
+ error "file data has changed (3)"
echo "done."
fi
echo -n "Setting stripe for parent directory..."
$LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
error "cannot set stripe '-S 2M -c 1'"
+ [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (4)"
echo "done."
echo -n "Verifying restripe option uses parent stripe settings..."
parent_ssize=$($LFS getstripe -S $DIR/$tdir 2>/dev/null)
parent_scount=$($LFS getstripe -c $DIR/$tdir 2>/dev/null)
- $LFS_MIGRATE -y -R "$file1" &> /dev/null ||
- error "migrate failed"
+ $LFS_MIGRATE -R "$file1" || error "migrate failed"
cur_ssize=$($LFS getstripe -S "$file1")
- [ $cur_ssize -eq $parent_ssize ] ||
+ (( cur_ssize == parent_ssize )) ||
error "migrate -R stripe_size $cur_ssize != $parent_ssize"
cur_scount=$($LFS getstripe -c "$file1")
- [ $cur_scount -eq $parent_scount ] ||
+ (( cur_scount == parent_scount )) ||
error "migrate -R stripe_count $cur_scount != $parent_scount"
+ [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (5)"
echo "done."
# File currently set to -S 1M -c 1
orig_ssize=$($LFS getstripe -S "$file1" 2>/dev/null)
$LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
error "cannot set stripe on parent directory"
- $LFS_MIGRATE -y "$file1" &> /dev/null ||
- error "migrate failed"
+ $LFS_MIGRATE "$file1" || error "migrate failed"
cur_ssize=$($LFS getstripe -S "$file1")
- [ $cur_ssize -eq $orig_ssize ] ||
+ (( cur_ssize == orig_ssize )) ||
error "migrate by default $cur_ssize != $orig_ssize"
+ [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (6)"
echo "done."
# Ensure file name properly detected when final option has no argument
echo -n "Verifying file name properly detected..."
- $LFS_MIGRATE -y "$file1" &> /dev/null ||
+ $LFS_MIGRATE "$file1" ||
error "file name interpreted as option argument"
+ [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (7)"
echo "done."
- # Clean up
- rm -f "$file1"
+ # Ensure PFL arguments are passed through properly
+ echo -n "Verifying PFL options passed through..."
+ new_scount=$(((OSTCOUNT + 1) / 2))
+ $LFS_MIGRATE -E 1M -c 1 -E 16M -c $new_scount -E eof -c -1 "$file1" ||
+ error "migrate PFL arguments failed"
+ cur_comp=$($LFS getstripe --comp-count $file1)
+ (( cur_comp == 3 )) || error "component count '$cur_comp' != 3"
+ cur_scount=$($LFS getstripe --stripe-count $file1)
+ (( cur_scount == new_scount)) ||
+ error "PFL stripe count $cur_scount != $new_scount"
+ [[ "$(md5sum $file1)" == "$md5" ]] || error "file data has changed (8)"
+ echo "done."
}
run_test 56wc "check unrecognized options for lfs_migrate are passed through"