]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw_file: advance_mtime() should consider namespace expiration
authorMatt Benjamin <mbenjamin@redhat.com>
Tue, 18 Jun 2019 11:39:09 +0000 (07:39 -0400)
committerMatt Benjamin <mbenjamin@redhat.com>
Tue, 18 Jun 2019 13:15:49 +0000 (09:15 -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>
src/rgw/rgw_file.cc
src/rgw/rgw_file.h

index 4c4926db6ba428330d1f20a84648e2646bb1f0cf..21ac5641dfbb9f0ed56398f72b3dd4da3ced0fd7 100644 (file)
@@ -1438,6 +1438,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 5ab2a1b378375d41628869580ec3744fef04bd7b..d3ab2441f0a41d0007ae5de9a782d25527eca442 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;