From 92cc5d4f64d55675b45b85f612f513500d4e4fc7 Mon Sep 17 00:00:00 2001 From: Aravinda VK Date: Tue, 23 Dec 2014 21:13:32 +0530 Subject: geo-rep: Sync atime, mtime to slave when SETATTR Existing geo-rep only syncs chown and chmod, with this patch geo-rep also syncs atime and mtime. Change-Id: Iea52d86682873bb4a47eeb0d325f5b9ddf2de2cf Signed-off-by: Aravinda VK BUG: 1176934 Reviewed-on: http://review.gluster.org/9331 Tested-by: Gluster Build System Reviewed-by: Venky Shankar --- geo-replication/syncdaemon/master.py | 14 +++++++++++--- geo-replication/syncdaemon/resource.py | 4 ++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/geo-replication/syncdaemon/master.py b/geo-replication/syncdaemon/master.py index 51c1e571e53..48da768c935 100644 --- a/geo-replication/syncdaemon/master.py +++ b/geo-replication/syncdaemon/master.py @@ -742,10 +742,12 @@ class GMasterCommon(object): class XCrawlMetadata(object): - def __init__(self, st_uid, st_gid, st_mode): + def __init__(self, st_uid, st_gid, st_mode, st_atime, st_mtime): self.st_uid = int(st_uid) self.st_gid = int(st_gid) self.st_mode = int(st_mode) + self.st_atime = float(st_atime) + self.st_mtime = float(st_mtime) class GMasterChangelogMixin(GMasterCommon): @@ -816,6 +818,8 @@ class GMasterChangelogMixin(GMasterCommon): dst['uid'] = st.st_uid dst['gid'] = st.st_gid dst['mode'] = st.st_mode + dst['atime'] = st.st_atime + dst['mtime'] = st.st_mtime else: dct[k] = ed[k] return dct @@ -907,7 +911,9 @@ class GMasterChangelogMixin(GMasterCommon): meta_gfid.add((os.path.join(pfx, ec[0]), XCrawlMetadata(st_uid=ec[2], st_gid=ec[3], - st_mode=ec[4]))) + st_mode=ec[4], + st_atime=ec[5], + st_mtime=ec[6]))) else: meta_gfid.add((os.path.join(pfx, ec[0]), )) else: @@ -1482,7 +1488,9 @@ class GMasterXsyncMixin(GMasterChangelogMixin): st.st_uid), str(st.st_gid), escape(os.path.join(pargfid, bname))]) self.write_entry_change("M", [gfid, "SETATTR", str(st.st_uid), - str(st.st_gid), str(st.st_mode)]) + str(st.st_gid), str(st.st_mode), + str(st.st_atime), + str(st.st_mtime)]) self.Xcrawl(e, xtr_root) stime_to_update = xte if self.xsync_upper_limit: diff --git a/geo-replication/syncdaemon/resource.py b/geo-replication/syncdaemon/resource.py index 1e11b980ad3..c20a243352b 100644 --- a/geo-replication/syncdaemon/resource.py +++ b/geo-replication/syncdaemon/resource.py @@ -669,9 +669,13 @@ class Server(object): mode = e['stat']['mode'] uid = e['stat']['uid'] gid = e['stat']['gid'] + atime = e['stat']['atime'] + mtime = e['stat']['mtime'] go = e['go'] errno_wrap(os.chmod, [go, mode], [ENOENT], [ESTALE, EINVAL]) errno_wrap(os.chown, [go, uid, gid], [ENOENT], [ESTALE, EINVAL]) + errno_wrap(os.utime, [go, (atime, mtime)], + [ENOENT], [ESTALE, EINVAL]) @classmethod @_pathguard -- cgit