X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Futils%2Flustre_rsync.c;h=550ffddbf33aa63b500b395258f1cdbb2733a712;hb=refs%2Fchanges%2F15%2F35815%2F2;hp=e4bc0e5dc538acb902737ac143da028917dc5498;hpb=75c0f9c701a7a5f1e9caeee1a6cd7164e6635dfb;p=fs%2Flustre-release.git diff --git a/lustre/utils/lustre_rsync.c b/lustre/utils/lustre_rsync.c index e4bc0e5..550ffdd 100644 --- a/lustre/utils/lustre_rsync.c +++ b/lustre/utils/lustre_rsync.c @@ -192,8 +192,8 @@ int quit; /* Flag to stop processing the changelog; set on the receipt of a signal */ int abort_on_err = 0; -char rsync[PATH_MAX]; -char rsync_ver[PATH_MAX]; +char rsync[PATH_MAX + 128]; +char rsync_ver[PATH_MAX * 2]; struct lr_parent_child_list *parents; FILE *debug_log; @@ -428,7 +428,7 @@ int lr_sync_data(struct lr_info *info) } /* Copy all attributes from file src to file dest */ -int lr_copy_attr(char *src, char *dest) +int lr_copy_attr(const char *src, const char *dest) { struct stat st; struct utimbuf time; @@ -498,9 +498,10 @@ int lr_copy_xattr(struct lr_info *info) rc, errno); if (rc == -1) { if (errno != ENOTSUP) { - fprintf(stderr, "Error replicating " - " xattr for %s: %d\n", - info->dest, errno); + fprintf(stderr, + "cannot replicate xattrs from '%s' to '%s': %s\n", + info->src, info->dest, + strerror(errno)); errors++; } rc = 0; @@ -1094,6 +1095,30 @@ int lr_link(struct lr_info *info) return rc; } +int lr_set_dest_for_attr(struct lr_info *info) +{ + int rc; + + snprintf(info->dest, sizeof(info->dest), "%s/%s", + status->ls_targets[info->target_no], info->path); + rc = access(info->dest, F_OK); + if (rc < 0) + rc = -errno; + + if (rc != -ENOENT) + return rc; + + snprintf(info->dest, sizeof(info->dest), "%s/%s/%s", + status->ls_targets[info->target_no], SPECIAL_DIR, + info->tfid); + + rc = access(info->dest, F_OK); + if (rc < 0) + return -errno; + + return 0; +} + /* Replicate file attributes */ int lr_setattr(struct lr_info *info) { @@ -1111,9 +1136,10 @@ int lr_setattr(struct lr_info *info) for (info->target_no = 0; info->target_no < status->ls_num_targets; info->target_no++) { + rc = lr_set_dest_for_attr(info); + if (rc < 0) + continue; - snprintf(info->dest, sizeof(info->dest), "%s/%s", - status->ls_targets[info->target_no], info->path); lr_debug(DINFO, "setattr: %s %s %s", info->src, info->dest, info->tfid); @@ -1142,9 +1168,10 @@ int lr_setxattr(struct lr_info *info) for (info->target_no = 0; info->target_no < status->ls_num_targets; info->target_no++) { + rc = lr_set_dest_for_attr(info); + if (rc < 0) + continue; - snprintf(info->dest, sizeof(info->dest), "%s/%s", - status->ls_targets[info->target_no], info->path); lr_debug(DINFO, "setxattr: %s %s %s\n", info->src, info->dest, info->tfid); @@ -1396,14 +1423,9 @@ int lr_read_log() int lr_clear_cl(struct lr_info *info, int force) { char mdt_device[LR_NAME_MAXLEN + 1]; - long long rec; int rc = 0; if (force || info->recno > status->ls_last_recno + CLEAR_INTERVAL) { - if (info->type == CL_RENAME) - rec = info->recno + 1; - else - rec = info->recno; if (!noclear && !dryrun) { /* llapi_changelog_clear modifies the mdt * device name so make a copy of it until this @@ -1413,20 +1435,21 @@ int lr_clear_cl(struct lr_info *info, int force) status->ls_mdt_device); rc = llapi_changelog_clear(mdt_device, status->ls_registration, - rec); + info->recno); if (rc) - printf("Changelog clear (%s, %s, %lld) " - "returned %d\n", status->ls_mdt_device, - status->ls_registration, rec, rc); - } - if (!rc && !dryrun) { - status->ls_last_recno = rec; - lr_write_log(); + printf("Changelog clear (%s, %s, %lld) " + "returned %d\n", status->ls_mdt_device, + status->ls_registration, info->recno, + rc); + } - } - } + if (!rc && !dryrun) { + status->ls_last_recno = info->recno; + lr_write_log(); + } + } - return rc; + return rc; } /* Locate a usable version of rsync. At this point we'll use any @@ -1611,6 +1634,7 @@ int lr_replicate() snprintf(info->name, sizeof(info->name), "%s", ext->name); info->is_extended = 1; + info->recno = ext->recno; /* For lr_clear_cl(). */ } if (dryrun)