X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fscripts%2Flfs_migrate;h=f9cf91cddfe6caa0a4a6ea39a39b076b8a9cabdf;hb=25ee73e7733214f7a46f81b2540b7fca67b0eef1;hp=7d9386f6f87fc7c0f1220bad6d7ab275307554cc;hpb=91707ff6ba5130811a9350c8ce8c102d29a5930e;p=fs%2Flustre-release.git diff --git a/lustre/scripts/lfs_migrate b/lustre/scripts/lfs_migrate index 7d9386f..f9cf91c 100755 --- a/lustre/scripts/lfs_migrate +++ b/lustre/scripts/lfs_migrate @@ -17,6 +17,7 @@ set -e RSYNC=${RSYNC:-rsync} ECHO=echo LFS=${LFS:-lfs} +LFS_SIZE_OPT="-s" usage() { cat -- <&2 @@ -90,7 +91,18 @@ $RSYNC --help 2>&1 | grep -q acls && RSYNC_OPTS="$RSYNC_OPTS -A" # If rsync copies lustre xattrs in the future, then we can skip lfs (bug 22189) strings $(which $RSYNC) 2>&1 | grep -q lustre && LFS=: +# rsync creates its temporary files with lenient permissions, even if +# permissions on the original files are more strict. Tighten umask here +# to avoid the brief window where unprivileged users might be able to +# access the temporary file. +umask 0077 + +# This is needed for 1.8 Interoperability and can be removed in the future +$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: " @@ -120,7 +132,6 @@ lfs_migrate() { continue fi - if [ "$OPT_RESTRIPE" ]; then UNLINK="" else @@ -132,17 +143,32 @@ lfs_migrate() { [ "$OPT_STRIPE_COUNT" ] && COUNT=$OPT_STRIPE_COUNT || COUNT=$($LFS getstripe -c "$OLDNAME" \ 2> /dev/null) - SIZE=$($LFS getstripe -S "$OLDNAME" 2> /dev/null) + SIZE=$($LFS getstripe $LFS_SIZE_OPT "$OLDNAME" \ + 2> /dev/null) [ -z "$COUNT" -o -z "$SIZE" ] && UNLINK="" + SIZE=${LFS_SIZE_OPT}${SIZE} fi + + # first try to migrate inside lustre + # if failed go back to old rsync mode + if [[ $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 + fi + 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 continue fi - [ "$UNLINK" ] && $LFS setstripe -c${COUNT} -S${SIZE} "$NEWNAME" + [ "$UNLINK" ] && $LFS setstripe -c${COUNT} ${SIZE} "$NEWNAME" # we use --inplace, since we created our own temp file already if ! $RSYNC -a --inplace $RSYNC_OPTS "$OLDNAME" "$NEWNAME";then @@ -151,7 +177,7 @@ lfs_migrate() { exit 4 fi - if [ "$OPT_CHECK" ] && ! cmp "$OLDNAME" "$NEWNAME"; then + if [ "$OPT_CHECK" ] && ! cmp -s "$OLDNAME" "$NEWNAME"; then echo -e "\r$NEWNAME: compare failed, exiting" 1>&2 exit 8 fi