+
+ if $OPT_DEBUG; then
+ local parent_count
+ local parent_size
+ local parent_layout
+
+ if $OPT_RESTRIPE; then
+ parent_layout=($($LFS getstripe $stripe_opts \
+ -d $(dirname $OLDNAME) 2>/dev/null |
+ awk '{print $2 }'))
+ parent_count=${parent_layout[$l_stripe_count]}
+ parent_size=${parent_layout[$l_stripe_size]}
+ stripe_pool=${parent_layout[$l_stripe_pool]}
+ mirror_count=${parent_layout[$l_mirror_count]}
+ fi
+
+ $ECHO -n "stripe_count=${stripe_count:-$parent_count},stripe_size=${stripe_size:-$parent_size}"
+ [ -n "$stripe_pool" ] &&
+ $ECHO -n ",pool=${stripe_pool}"
+ [[ $mirror_count -gt 1 ]] &&
+ $ECHO -n ",mirror_count=${mirror_count}"
+ $ECHO -n " "
+ fi
+
+ if $OPT_DRYRUN; then
+ $ECHO " dry run, skipped"
+ continue
+ fi
+
+ if ! $OPT_COMP && [ ${layout_info[$l_comp_count]} -gt 0 ]; then
+ layout+="--copy $OLDNAME"
+ OPT_COMP=true
+ fi
+ if ! $OPT_COMP; then
+ [ -n "$stripe_count" ] && layout+="-c $stripe_count "
+ [ -n "$stripe_size" ] && layout+="-S $stripe_size "
+ [ -n "$OPT_POOL" -a -n "$stripe_pool" ] &&
+ layout+="-p $stripe_pool "
+ [[ $mirror_count -gt 1 ]] && layout+="-N $mirror_count "
+ fi
+ layout+="$OPT_LAYOUT"
+
+ # detect other hard links and store them on a global
+ # list so we don't re-migrate them
+ if [[ ${nlink_type[$nlink_idx_link]} -gt 1 ]]; then
+ [ "${nlink_type[$nlink_idx_dev]}" == "$last_dev" ] ||
+ mntpoint=$(df -P "$OLDNAME" |
+ awk 'NR==2 { print $NF }')
+ if [ -z "$mntpoint" ]; then
+ echo -e "\r$OLDNAME: cannot determine mount point; skipped" 1>&2
+ continue
+ fi
+ hlinks=$($LFS fid2path "$mntpoint" "$fid" 2> /dev/null)
+ if $OPT_RSYNC && [ $? -ne 0 ]; then
+ echo -e "\r$OLDNAME: cannot determine hard link paths, skipped" 1>&2
+ continue
+ fi
+ hlinks+=("$OLDNAME")
+ else
+ hlinks=
+ fi
+
+ # first try to migrate via Lustre tools, then fall back to rsync
+ if ! $OPT_RSYNC; then
+ $OPT_DEBUG && echo -e "\n$LFS migrate $layout $OLDNAME"
+ if $LFS migrate $layout "$OLDNAME"; then
+ $ECHO "done"
+ # no-op if hlinks empty for 1-link files
+ for link in ${hlinks[*]}; do
+ add_to_set "$fid" "$link"
+ done
+ continue
+ elif $OPT_NO_RSYNC; then
+ echo -e "\r$OLDNAME: refusing to fall back to rsync, skipped" 1>&2
+ continue
+ else
+ $ECHO -n "falling back to rsync: "
+ OPT_RSYNC=true
+ fi
+ fi
+
+ local olddir=$(dirname $OLDNAME)
+ local oldfile=$(basename $OLDNAME)
+ NEWNAME=$(mktemp $UNLINK "$olddir/.$oldfile.XXXXXX")