summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorKotresh H R <khiremat@redhat.com>2014-08-01 16:12:38 +0530
committerVijay Bellur <vbellur@redhat.com>2014-08-04 07:51:07 -0700
commit0e8c537d6f48857b0f3c0ef10ce1c4458e303be8 (patch)
tree5a41d0e21b186d2c8d8589a5542930fcbb2fb0fe /libglusterfs
parent51394183e94ac0be70fcf22793b2040ba3f0b918 (diff)
feature/geo-rep: Keep marker.tstamp's mtime unchangeable during snapshot.
Problem: Geo-replicatoin does a full xsync crawl after snapshot restoration of slave and master. It does not do history crawl. Analysis: Marker creates 'marker.tstamp' file when geo-rep is started for the first time. The virtual extended attribute 'trusted.glusterfs.volume-mark' is maintained and whenever it is queried on gluster mount point, marker fills it on the fly and returns the combination of uuid, ctime of marker.tstamp and others. So ctime of marker.tstamp, in other sense 'volume-mark' marks the geo-rep start time when the session is freshly created. From the above, after the first filesystem crawl(xsync) is done during first geo-rep start, stime should always be less than 'volume-mark'. So whenever stime is less than volume-mark, it does full filesystem crawl (xsync). Root Cause: When snapshot is restored, marker.tstamp file is freshly created losing the timestamps, it was originally created with. Solution: 1. Change is made to depend on mtime instead of ctime. 2. mtime and atime of marker.tstamp is restored back when snapshot is created and restored. Change-Id: I4891b112f4aedc50cfae402832c50c5145807d7a BUG: 1125918 Signed-off-by: Kotresh H R <khiremat@redhat.com> Reviewed-on: http://review.gluster.org/8401 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/common-utils.c43
-rw-r--r--libglusterfs/src/common-utils.h1
2 files changed, 44 insertions, 0 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
index 54ee3e53818..be8bd6298ac 100644
--- a/libglusterfs/src/common-utils.c
+++ b/libglusterfs/src/common-utils.c
@@ -3232,3 +3232,46 @@ gf_compare_sockaddr (const struct sockaddr *addr1,
}
return _gf_false;
}
+
+/*
+ * gf_set_timestamp:
+ * It sets the mtime and atime of 'dest' file as of 'src'.
+ */
+
+int
+gf_set_timestamp (const char *src, const char* dest)
+{
+ struct stat sb = {0, };
+ struct timeval new_time[2] = {{0, },{0,}};
+ int ret = 0;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
+ GF_ASSERT (src);
+ GF_ASSERT (dest);
+
+ ret = stat (src, &sb);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "stat on %s failed: %s",
+ src, strerror(errno));
+ goto out;
+ }
+ new_time[0].tv_sec = sb.st_atime;
+ new_time[0].tv_usec = ST_ATIM_NSEC (&sb)/1000;
+
+ new_time[1].tv_sec = sb.st_mtime;
+ new_time[1].tv_usec = ST_MTIM_NSEC (&sb)/1000;
+
+ /* The granularity is micro seconds as per the current
+ * requiremnt. Hence using 'utimes'. This can be updated
+ * to 'utimensat' if we need timestamp in nanoseconds.
+ */
+ ret = utimes (dest, new_time);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "utimes on %s failed: %s",
+ dest, strerror(errno));
+ }
+out:
+ return ret;
+}
diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h
index 98f30fc47b0..4eec5170c60 100644
--- a/libglusterfs/src/common-utils.h
+++ b/libglusterfs/src/common-utils.h
@@ -620,6 +620,7 @@ int gf_get_hostname_from_ip (char *client_ip, char **hostname);
gf_boolean_t gf_is_local_addr (char *hostname);
gf_boolean_t gf_is_same_address (char *host1, char *host2);
void md5_wrapper(const unsigned char *data, size_t len, char *md5);
+int gf_set_timestamp (const char *src, const char* dest);
int gf_thread_create (pthread_t *thread, const pthread_attr_t *attr,
void *(*start_routine)(void *), void *arg);