# process, but it would catch the worst cases of in-use files, but
# to be 100% safe the administrator needs to ensure this is safe.
-RSYNC=${RSYNC:-rsync}
+RSYNC=${RSYNC:-"rsync"}
+RSYNC_OPTS=${RSYNC_OPTS:-"-a --inplace"}
OPT_RSYNC=${LFS_MIGRATE_RSYNC_MODE:-false}
ECHO=echo
LFS=${LFS:-lfs}
usage() {
cat -- <<USAGE 1>&2
-usage: lfs_migrate [--dry-run|-n] [--help|-h] [--no-rsync|--rsync] [--quiet|-q]
+usage: lfs_migrate [--dry-run|-n] [--help|-h] [--no-rsync|--rsync|--cp]
[--auto-stripe|-A [-C <cap>]
[--min-free|-M <min_free>] [--max-free|-X <max_free>]]
[--pool|-p <pool>] [--stripe-count|-c <stripe_count>]
- [--stripe-size|-S <stripe_size>]
+ [--stripe-size|-S <stripe_size>] [--quiet|-q]
[-D] [-h] [-n] [-S]
[--restripe|-R] [--skip|-s] [--verbose|-v] [--yes|-y] [-0]
[FILE|DIR...]
restripe file using the specified <stripe_count>
-C <cap> when -A is set, limit the migrated file to use on each OST
at most 1/<cap> of the available space of the smallest OST
+ --cp force the use of 'cp' instead of migrate or rsync
-D do not use direct I/O to copy file contents
-h show this usage message
-M <min_free>
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.
+Options --rsync, --cp, --no-rsync 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.
while [ -n "$*" ]; do
arg="$1"
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");;
+ --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;;
+ --dry-run) OPT_DRYRUN=true; OPT_YES=true;;
+ -c|--stripe-count) OPT_STRIPE_COUNT="$2"; shift;;
+ -C) OPT_CAP="$2"; shift;;
-h|--help) usage;;
-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;;
- --dry-run) OPT_DRYRUN=true; OPT_YES=true;;
-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 ;;
-s|--skip) OPT_CHECK=false;;
+ -S|--stripe-size) OPT_STRIPE_SIZE="$2"; shift;;
-v|--verbose) OPT_DEBUG=true; ECHO=echo;;
+ -X|--max-free) OPT_MAXFREE="$2"; shift;;
-y|--yes) OPT_YES=true;;
-0) OPT_NULL=true;;
- -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;;
- --copy|--yaml|--file) OPT_COMP=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;;
- -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;;
*) # Pass other non-file layout options to 'lfs migrate'
[ -e "$arg" ] && OPT_FILE+="$arg " && break || OPT_LAYOUT+="$arg "
esac
fi
if $OPT_RSYNC && $OPT_NO_RSYNC; then
- echo "$PROG: Options --rsync and --no-rsync may not be" \
+ echo "$PROG: Options --cp, --rsync, and --no-rsync may not be" \
"specified at the same time." 1>&2
exit 1
fi
fi
# if rsync has --xattr support, then try to copy the xattrs.
-$RSYNC --help 2>&1 | grep -q xattr && RSYNC_OPTS="$RSYNC_OPTS -X"
-$RSYNC --help 2>&1 | grep -q acls && RSYNC_OPTS="$RSYNC_OPTS -A"
+$RSYNC --help 2>&1 | grep -q -- --xattrs && RSYNC_OPTS="$RSYNC_OPTS --xattrs"
+$RSYNC --help 2>&1 | grep -q -- --acls && RSYNC_OPTS="$RSYNC_OPTS --acls"
# If rsync copies lustre xattrs in the future, then we can skip lfs (bug 22189)
strings $(which $RSYNC) 2>&1 | grep -q lustre && LFS=:
continue
fi
- if ! $OPT_COMP && [ ${layout_info[$l_comp_count]} -gt 0 ]; then
+ if ! $OPT_COMP && ! $OPT_RSYNC &&
+ (( ${layout_info[$l_comp_count]} > 0 )); then
layout+="--copy $OLDNAME"
OPT_COMP=true
fi
echo -e "\n$LFS migrate $layout \"$OLDNAME\""
fi
if $LFS migrate $layout "$OLDNAME"; then
+ (( $mirror_count > 1 )) &&
+ $LFS mirror resync "$OLDNAME"
$ECHO "done"
# no-op if hlinks empty for 1-link files
for link in ${hlinks[*]}; do
fi
# we use --inplace, since we created our own temp file already
- if ! $RSYNC -a --inplace $RSYNC_OPTS "$OLDNAME" "$NEWNAME";then
+ if ! $RSYNC $RSYNC_OPTS "$OLDNAME" "$NEWNAME";then
echo -e "\r$OLDNAME: copy error, exiting" 1>&2
exit 4
fi
exit 12
fi
- $ECHO "done rsync"
+ (( $mirror_count > 1 )) && $LFS mirror resync "$OLDNAME"
+ $ECHO "done $RSYNC"
# no-op if hlinks empty for 1-link files
for link in ${hlinks[*]}; do
if [ "$link" != "$OLDNAME" ]; then