From 22b128497ac26e6f722270ad9047fd55a40ffa9f Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Wed, 18 Dec 2013 01:50:56 -0700 Subject: [PATCH 1/1] LU-4293 utils: handle lfs migrate failure in lfs_migrate If "lfs migrate" returns an error, possibly because it is refusing to migrate an IGIF FID, fall back to using rsync to copy the file and rename it. Print a message in this case so the user knows it is not a fatal error yet. Signed-off-by: Andreas Dilger Change-Id: I114006afb93d8c8d78923a874f3b914200500c1e Reviewed-on: http://review.whamcloud.com/8616 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Faccini Bruno Reviewed-by: Bob Glossman Reviewed-by: Oleg Drokin --- lustre/scripts/lfs_migrate | 8 ++++---- lustre/utils/lfs.c | 8 +++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/lustre/scripts/lfs_migrate b/lustre/scripts/lfs_migrate index bf595b3..e9c8aae 100755 --- a/lustre/scripts/lfs_migrate +++ b/lustre/scripts/lfs_migrate @@ -147,16 +147,17 @@ lfs_migrate() { 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 - $LFS migrate -c${COUNT} ${LFS_SIZE_OPT}${SIZE} $OLDNAME - if [[ $? == 0 ]]; 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 @@ -167,8 +168,7 @@ lfs_migrate() { continue fi - [ "$UNLINK" ] && $LFS setstripe -c${COUNT} \ - ${LFS_SIZE_OPT}${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 diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 5f4c849..614fbc3 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -533,14 +533,12 @@ static int lfs_migrate(char *name, unsigned long long stripe_size, SWAP_LAYOUTS_KEEP_MTIME | SWAP_LAYOUTS_KEEP_ATIME); if (rc == -EAGAIN) { - fprintf(stderr, "file dataversion for %s has changed" - " during copy, migration is aborted\n", - name); + fprintf(stderr, "%s: dataversion changed during copy, " + "migration aborted\n", name); goto error; } if (rc != 0) - fprintf(stderr, "cannot swap layouts between %s and " - "a volatile file (%s)\n", + fprintf(stderr, "%s: swap layout to new file failed: %s\n", name, strerror(-rc)); error: -- 1.8.3.1