]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_file: advance_mtime() should consider namespace expiration 29410/head
authorMatt Benjamin <mbenjamin@redhat.com>
Tue, 18 Jun 2019 11:39:09 +0000 (07:39 -0400)
committerPrashant D <pdhange@redhat.com>
Tue, 30 Jul 2019 23:08:27 +0000 (19:08 -0400)
Predictably, slow NFS operations like READDIR will overlap mtime
advance, so don't advance faster than the nfs namespace
expiration timer.

Fixes: http://tracker.ceph.com/issues/40415
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
(cherry picked from commit fc14eeb6dbf7deaf11a70a3d3b48ce41998d4e39)

src/rgw/rgw_file.cc
src/rgw/rgw_file.h

index 07b36ce0a174bedf3e42a279f243d33928eed96f..297e4d84d2352dcad41164cbf6627b4eb54b5592 100644 (file)
@@ -1430,6 +1430,23 @@ namespace rgw {
     }
   }
 
+  void RGWFileHandle::advance_mtime() {
+    /* intended for use on directories, fast-forward mtime so as to
+     * ensure a new, higher value for the change attribute */
+    lock_guard guard(mtx);
+    /* advance mtime only if stored mtime is older than the
+     * configured namespace expiration */
+    auto now = real_clock::now();
+    auto cmptime = state.mtime;
+    cmptime.tv_sec +=
+      fs->get_context()->_conf->rgw_nfs_namespace_expire_secs;
+    if (cmptime < real_clock::to_timespec(now)) {
+      /* sets ctime as well as mtime, to avoid masking updates should
+       * ctime inexplicably hold a higher value */
+      set_times(now);
+    }
+  }
+
   void RGWFileHandle::invalidate() {
     RGWLibFS *fs = get_fs();
     if (fs->invalidate_cb) {
index 72787e3ba8f176cfb1c4d010fb13c0d9a54bee45..9dbc913523f49b24c4095d68434c1ff9fe0a2880 100644 (file)
@@ -238,15 +238,7 @@ namespace rgw {
     };
 
     void clear_state();
-
-    void advance_mtime() {
-      /* intended for use on directories, fast-forward mtime so as to
-       * ensure a new, higher value for the change attribute */
-      lock_guard guard(mtx);
-      /* sets ctime as well as mtime, to avoid masking updates should
-       * ctime inexplicably hold a higher value */
-      set_times(real_clock::now());
-    }
+    void advance_mtime();
 
     boost::variant<file, directory> variant_type;