summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix/src
diff options
context:
space:
mode:
authorCsaba Henk <csaba@redhat.com>2018-05-08 21:19:56 +0200
committerAmar Tumballi <amarts@redhat.com>2018-05-18 09:27:36 +0000
commitad478b6ccb66b20f2e97d50f9ec79cfcdc4368ba (patch)
treefc6a173d09fa96bc39440c165d722661ffd6cd89 /xlators/storage/posix/src
parent89e1a4e5720509c096ff6860c1a8c483e0019278 (diff)
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 <csaba@redhat.com>
Diffstat (limited to 'xlators/storage/posix/src')
-rw-r--r--xlators/storage/posix/src/posix-inode-fd-ops.c21
1 files changed, 16 insertions, 5 deletions
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)