From ad478b6ccb66b20f2e97d50f9ec79cfcdc4368ba Mon Sep 17 00:00:00 2001 From: Csaba Henk Date: Tue, 8 May 2018 21:19:56 +0200 Subject: posix: use the ctime framework to handle setattr ctime payload Work on #208 having been been merged, we have obtained means to associate arbitrary ctimes with files, so we can handle setattr ctime payload with proper semantics. Updates: #435 Change-Id: I7302a3ee2574ca9bba605c7a8586c16c452f82c1 Signed-off-by: Csaba Henk --- xlators/storage/posix/src/posix-inode-fd-ops.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'xlators/storage') diff --git a/xlators/storage/posix/src/posix-inode-fd-ops.c b/xlators/storage/posix/src/posix-inode-fd-ops.c index 2e5b7c5772a..011dc193d90 100644 --- a/xlators/storage/posix/src/posix-inode-fd-ops.c +++ b/xlators/storage/posix/src/posix-inode-fd-ops.c @@ -307,6 +307,9 @@ posix_setattr (call_frame_t *frame, xlator_t *this, struct iatt statpre = {0,}; struct iatt statpost = {0,}; dict_t *xattr_rsp = NULL; + struct posix_private *priv = NULL; + + priv = this->private; DECLARE_OLD_FS_ID_VAR; @@ -360,12 +363,12 @@ posix_setattr (call_frame_t *frame, xlator_t *this, stbuf, valid); } - if (valid & GF_SET_ATTR_CTIME) { + if (valid & GF_SET_ATTR_CTIME && !priv->ctime) { /* - * At the moment we have no means to associate an arbitrary - * ctime with the file, so we ignore the ctime payload - * and update the file ctime to current time (which POSIX - * lets us to do). + * If ctime is not enabled, we have no means to associate an + * arbitrary ctime with the file, so as a fallback, we ignore + * the ctime payload and update the file ctime to current time + * (which is possible directly with the POSIX API). */ op_ret = PATH_SET_TIMESPEC_OR_TIMEVAL (real_path, NULL); if (op_ret == -1) { @@ -398,6 +401,14 @@ posix_setattr (call_frame_t *frame, xlator_t *this, goto out; } + if (valid & GF_SET_ATTR_CTIME && priv->ctime) { + /* + * If we got ctime payload, we override + * the ctime of statpost with that. + */ + statpost.ia_ctime = stbuf->ia_ctime; + statpost.ia_ctime_nsec = stbuf->ia_ctime_nsec; + } posix_set_ctime (frame, this, real_path, -1, loc->inode, &statpost); if (xdata) -- cgit