|
|
9ae3f9 |
From c140d30382306d08eaf2bc5c53e5be26d3e381e1 Mon Sep 17 00:00:00 2001
|
|
|
9ae3f9 |
From: Kotresh HR <khiremat@redhat.com>
|
|
|
9ae3f9 |
Date: Mon, 18 Nov 2019 05:24:33 -0500
|
|
|
9ae3f9 |
Subject: [PATCH 423/449] ctime: Fix ctime inconsisteny with utimensat
|
|
|
9ae3f9 |
|
|
|
9ae3f9 |
Problem:
|
|
|
9ae3f9 |
When touch is used to create a file, the ctime is not matching
|
|
|
9ae3f9 |
atime and mtime which ideally should match. There is a difference
|
|
|
9ae3f9 |
in nano seconds.
|
|
|
9ae3f9 |
|
|
|
9ae3f9 |
Cause:
|
|
|
9ae3f9 |
When touch is used modify atime or mtime to current time (UTIME_NOW),
|
|
|
9ae3f9 |
the current time is taken from kernel. The ctime gets updated to current
|
|
|
9ae3f9 |
time when atime or mtime is updated. But the current time to update
|
|
|
9ae3f9 |
ctime is taken from utime xlator. Hence the difference in nano seconds.
|
|
|
9ae3f9 |
|
|
|
9ae3f9 |
Fix:
|
|
|
9ae3f9 |
When utimesat uses UTIME_NOW, use the current time from kernel.
|
|
|
9ae3f9 |
|
|
|
9ae3f9 |
>fixes: bz#1773530
|
|
|
9ae3f9 |
>Change-Id: I9ccfa47dcd39df23396852b4216f1773c49250ce
|
|
|
9ae3f9 |
>Signed-off-by: Kotresh HR <khiremat@redhat.com>
|
|
|
9ae3f9 |
|
|
|
9ae3f9 |
backport of: https://review.gluster.org/#/c/glusterfs/+/23719/
|
|
|
9ae3f9 |
BUG: 1761932
|
|
|
9ae3f9 |
Change-Id: I9ccfa47dcd39df23396852b4216f1773c49250ce
|
|
|
9ae3f9 |
Signed-off-by: Kotresh HR <khiremat@redhat.com>
|
|
|
9ae3f9 |
Reviewed-on: https://code.engineering.redhat.com/gerrit/202541
|
|
|
9ae3f9 |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
9ae3f9 |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
9ae3f9 |
---
|
|
|
9ae3f9 |
libglusterfs/src/glusterfs/xlator.h | 2 ++
|
|
|
9ae3f9 |
tests/basic/ctime/ctime-utimesat.t | 28 ++++++++++++++++++++++++++
|
|
|
9ae3f9 |
xlators/features/utime/src/utime-gen-fops-c.py | 10 +++++++++
|
|
|
9ae3f9 |
xlators/mount/fuse/src/fuse-bridge.c | 8 ++++++++
|
|
|
9ae3f9 |
4 files changed, 48 insertions(+)
|
|
|
9ae3f9 |
create mode 100644 tests/basic/ctime/ctime-utimesat.t
|
|
|
9ae3f9 |
|
|
|
9ae3f9 |
diff --git a/libglusterfs/src/glusterfs/xlator.h b/libglusterfs/src/glusterfs/xlator.h
|
|
|
9ae3f9 |
index da551e9..db04c4d 100644
|
|
|
9ae3f9 |
--- a/libglusterfs/src/glusterfs/xlator.h
|
|
|
9ae3f9 |
+++ b/libglusterfs/src/glusterfs/xlator.h
|
|
|
9ae3f9 |
@@ -35,6 +35,8 @@
|
|
|
9ae3f9 |
#define GF_SET_ATTR_ATIME 0x10
|
|
|
9ae3f9 |
#define GF_SET_ATTR_MTIME 0x20
|
|
|
9ae3f9 |
#define GF_SET_ATTR_CTIME 0x40
|
|
|
9ae3f9 |
+#define GF_ATTR_ATIME_NOW 0x80
|
|
|
9ae3f9 |
+#define GF_ATTR_MTIME_NOW 0x100
|
|
|
9ae3f9 |
|
|
|
9ae3f9 |
#define gf_attr_mode_set(mode) ((mode)&GF_SET_ATTR_MODE)
|
|
|
9ae3f9 |
#define gf_attr_uid_set(mode) ((mode)&GF_SET_ATTR_UID)
|
|
|
9ae3f9 |
diff --git a/tests/basic/ctime/ctime-utimesat.t b/tests/basic/ctime/ctime-utimesat.t
|
|
|
9ae3f9 |
new file mode 100644
|
|
|
9ae3f9 |
index 0000000..540e57a
|
|
|
9ae3f9 |
--- /dev/null
|
|
|
9ae3f9 |
+++ b/tests/basic/ctime/ctime-utimesat.t
|
|
|
9ae3f9 |
@@ -0,0 +1,28 @@
|
|
|
9ae3f9 |
+#!/bin/bash
|
|
|
9ae3f9 |
+. $(dirname $0)/../../include.rc
|
|
|
9ae3f9 |
+. $(dirname $0)/../../volume.rc
|
|
|
9ae3f9 |
+. $(dirname $0)/../../afr.rc
|
|
|
9ae3f9 |
+cleanup;
|
|
|
9ae3f9 |
+
|
|
|
9ae3f9 |
+TEST glusterd
|
|
|
9ae3f9 |
+TEST pidof glusterd
|
|
|
9ae3f9 |
+TEST $CLI volume create $V0 replica 3 $H0:$B0/${V0}{0,1,2}
|
|
|
9ae3f9 |
+TEST $CLI volume set $V0 performance.stat-prefetch off
|
|
|
9ae3f9 |
+TEST $CLI volume set $V0 performance.read-ahead off
|
|
|
9ae3f9 |
+TEST $CLI volume set $V0 performance.quick-read off
|
|
|
9ae3f9 |
+TEST $CLI volume set $V0 performance.read-after-open off
|
|
|
9ae3f9 |
+TEST $CLI volume set $V0 performance.open-behind off
|
|
|
9ae3f9 |
+TEST $CLI volume set $V0 performance.write-behind off
|
|
|
9ae3f9 |
+TEST $CLI volume set $V0 performance.io-cache off
|
|
|
9ae3f9 |
+
|
|
|
9ae3f9 |
+TEST $CLI volume start $V0
|
|
|
9ae3f9 |
+
|
|
|
9ae3f9 |
+TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 --entry-timeout=0 $M0;
|
|
|
9ae3f9 |
+
|
|
|
9ae3f9 |
+touch $M0/FILE
|
|
|
9ae3f9 |
+
|
|
|
9ae3f9 |
+atime=$(stat -c "%.X" $M0/FILE)
|
|
|
9ae3f9 |
+EXPECT $atime stat -c "%.Y" $M0/FILE
|
|
|
9ae3f9 |
+EXPECT $atime stat -c "%.Z" $M0/FILE
|
|
|
9ae3f9 |
+
|
|
|
9ae3f9 |
+cleanup
|
|
|
9ae3f9 |
diff --git a/xlators/features/utime/src/utime-gen-fops-c.py b/xlators/features/utime/src/utime-gen-fops-c.py
|
|
|
9ae3f9 |
index 8730a51..9fb3e1b 100755
|
|
|
9ae3f9 |
--- a/xlators/features/utime/src/utime-gen-fops-c.py
|
|
|
9ae3f9 |
+++ b/xlators/features/utime/src/utime-gen-fops-c.py
|
|
|
9ae3f9 |
@@ -95,6 +95,16 @@ gf_utime_@NAME@ (call_frame_t *frame, xlator_t *this,
|
|
|
9ae3f9 |
frame->root->flags |= MDATA_CTIME;
|
|
|
9ae3f9 |
}
|
|
|
9ae3f9 |
|
|
|
9ae3f9 |
+ if (valid & (GF_SET_ATTR_ATIME | GF_SET_ATTR_MTIME)) {
|
|
|
9ae3f9 |
+ if (valid & GF_ATTR_ATIME_NOW) {
|
|
|
9ae3f9 |
+ frame->root->ctime.tv_sec = stbuf->ia_atime;
|
|
|
9ae3f9 |
+ frame->root->ctime.tv_nsec = stbuf->ia_atime_nsec;
|
|
|
9ae3f9 |
+ } else if (valid & GF_ATTR_MTIME_NOW) {
|
|
|
9ae3f9 |
+ frame->root->ctime.tv_sec = stbuf->ia_mtime;
|
|
|
9ae3f9 |
+ frame->root->ctime.tv_nsec = stbuf->ia_mtime_nsec;
|
|
|
9ae3f9 |
+ }
|
|
|
9ae3f9 |
+ }
|
|
|
9ae3f9 |
+
|
|
|
9ae3f9 |
STACK_WIND (frame, gf_utime_@NAME@_cbk, FIRST_CHILD(this),
|
|
|
9ae3f9 |
FIRST_CHILD(this)->fops->@NAME@, @SHORT_ARGS@);
|
|
|
9ae3f9 |
return 0;
|
|
|
9ae3f9 |
diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c
|
|
|
9ae3f9 |
index 6e99053..fdeec49 100644
|
|
|
9ae3f9 |
--- a/xlators/mount/fuse/src/fuse-bridge.c
|
|
|
9ae3f9 |
+++ b/xlators/mount/fuse/src/fuse-bridge.c
|
|
|
9ae3f9 |
@@ -1706,6 +1706,14 @@ fattr_to_gf_set_attr(int32_t valid)
|
|
|
9ae3f9 |
gf_valid |= GF_SET_ATTR_CTIME;
|
|
|
9ae3f9 |
#endif
|
|
|
9ae3f9 |
|
|
|
9ae3f9 |
+#if FUSE_KERNEL_MINOR_VERSION >= 9
|
|
|
9ae3f9 |
+ if (valid & FATTR_ATIME_NOW)
|
|
|
9ae3f9 |
+ gf_valid |= GF_ATTR_ATIME_NOW;
|
|
|
9ae3f9 |
+
|
|
|
9ae3f9 |
+ if (valid & FATTR_MTIME_NOW)
|
|
|
9ae3f9 |
+ gf_valid |= GF_ATTR_MTIME_NOW;
|
|
|
9ae3f9 |
+#endif
|
|
|
9ae3f9 |
+
|
|
|
9ae3f9 |
if (valid & FATTR_SIZE)
|
|
|
9ae3f9 |
gf_valid |= GF_SET_ATTR_SIZE;
|
|
|
9ae3f9 |
|
|
|
9ae3f9 |
--
|
|
|
9ae3f9 |
1.8.3.1
|
|
|
9ae3f9 |
|