From: John L. Hammond Date: Mon, 15 Oct 2018 18:58:10 +0000 (-0500) Subject: LU-11479 rsync: replicate attributes of file in .lustrerepl X-Git-Tag: 2.12.0-RC1~134 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=337f230565ea033d126653e8da01315211470665 LU-11479 rsync: replicate attributes of file in .lustrerepl When lustre_rsync receives a setattr or setxattr changelog record, the file to be replicated may still be in the .lustrerepl directory of the archive. When this is the case, apply the attributes to the file there. Signed-off-by: John L. Hammond Change-Id: I6e686d5c4dbeb3acf177a061eb70807c8dd7dfb3 Reviewed-on: https://review.whamcloud.com/33373 Tested-by: Jenkins Reviewed-by: Andreas Dilger Reviewed-by: Jian Yu Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lustre/utils/lustre_rsync.c b/lustre/utils/lustre_rsync.c index a54ac25..2c7add8 100644 --- a/lustre/utils/lustre_rsync.c +++ b/lustre/utils/lustre_rsync.c @@ -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);