50dc83
From 7f5658a299081cec4c77d3cca4e70099cd59b1fc Mon Sep 17 00:00:00 2001
50dc83
From: Kinglong Mee <kinglongmee@gmail.com>
50dc83
Date: Mon, 5 Aug 2019 11:08:02 +0800
50dc83
Subject: [PATCH 276/276] features/utime: always update ctime at setattr
50dc83
50dc83
For the nfs EXCLUSIVE mode create may sets a later time
50dc83
to mtime (at verifier), it should not set to ctime for
50dc83
storage.ctime does not allowed set ctime to a earlier time.
50dc83
50dc83
 /* Earlier, mdata was updated only if the existing time is less
50dc83
  * than the time to be updated. This would fail the scenarios
50dc83
  * where mtime can be set to any time using the syscall. Hence
50dc83
  * just updating without comparison. But the ctime is not
50dc83
  * allowed to changed to older date.
50dc83
  */
50dc83
50dc83
According to kernel's setattr, always set ctime at setattr,
50dc83
and doesnot set ctime from mtime at storage.ctime.
50dc83
50dc83
>Change-Id: I5cfde6cb7f8939da9617506e3dc80bd840e0d749
50dc83
>fixes: bz#1737288
50dc83
>Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
50dc83
Upstream Patch: https://review.gluster.org/#/c/glusterfs/+/23154/
50dc83
50dc83
BUG: 1737705
50dc83
Change-Id: I5cfde6cb7f8939da9617506e3dc80bd840e0d749
50dc83
Signed-off-by: Sunil Kumar Acharya <sheggodu@redhat.com>
50dc83
Reviewed-on: https://code.engineering.redhat.com/gerrit/178225
50dc83
Tested-by: RHGS Build Bot <nigelb@redhat.com>
50dc83
---
50dc83
 xlators/features/utime/src/utime-gen-fops-c.py | 13 +------------
50dc83
 xlators/storage/posix/src/posix-metadata.c     |  2 +-
50dc83
 2 files changed, 2 insertions(+), 13 deletions(-)
50dc83
50dc83
diff --git a/xlators/features/utime/src/utime-gen-fops-c.py b/xlators/features/utime/src/utime-gen-fops-c.py
50dc83
index 8730a51..a8637ff 100755
50dc83
--- a/xlators/features/utime/src/utime-gen-fops-c.py
50dc83
+++ b/xlators/features/utime/src/utime-gen-fops-c.py
50dc83
@@ -82,18 +82,7 @@ gf_utime_@NAME@ (call_frame_t *frame, xlator_t *this,
50dc83
              @LONG_ARGS@)
50dc83
 {
50dc83
         gl_timespec_get(&frame->root->ctime);
50dc83
-
50dc83
-        if (!valid) {
50dc83
-                frame->root->flags |= MDATA_CTIME;
50dc83
-        }
50dc83
-
50dc83
-        if (valid & (GF_SET_ATTR_UID | GF_SET_ATTR_GID)) {
50dc83
-                frame->root->flags |= MDATA_CTIME;
50dc83
-        }
50dc83
-
50dc83
-        if (valid & GF_SET_ATTR_MODE) {
50dc83
-                frame->root->flags |= MDATA_CTIME;
50dc83
-        }
50dc83
+        frame->root->flags |= MDATA_CTIME;
50dc83
 
50dc83
         STACK_WIND (frame, gf_utime_@NAME@_cbk, FIRST_CHILD(this),
50dc83
                     FIRST_CHILD(this)->fops->@NAME@, @SHORT_ARGS@);
50dc83
diff --git a/xlators/storage/posix/src/posix-metadata.c b/xlators/storage/posix/src/posix-metadata.c
50dc83
index 57791fa..5cbdc98 100644
50dc83
--- a/xlators/storage/posix/src/posix-metadata.c
50dc83
+++ b/xlators/storage/posix/src/posix-metadata.c
50dc83
@@ -631,7 +631,7 @@ posix_update_utime_in_mdata(xlator_t *this, const char *real_path, int fd,
50dc83
             tv.tv_sec = stbuf->ia_mtime;
50dc83
             SET_TIMESPEC_NSEC_OR_TIMEVAL_USEC(tv, stbuf->ia_mtime_nsec);
50dc83
 
50dc83
-            flag.ctime = 1;
50dc83
+            flag.ctime = 0;
50dc83
             flag.mtime = 1;
50dc83
             flag.atime = 0;
50dc83
 
50dc83
-- 
50dc83
1.8.3.1
50dc83