From 669343f513cec593872807edf5fa5ab4cc6578fa Mon Sep 17 00:00:00 2001 From: Matt Benjamin Date: Tue, 18 Jun 2019 07:39:09 -0400 Subject: [PATCH] rgw_file: advance_mtime() should consider namespace expiration 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 (cherry picked from commit fc14eeb6dbf7deaf11a70a3d3b48ce41998d4e39) --- src/rgw/rgw_file.cc | 17 +++++++++++++++++ src/rgw/rgw_file.h | 10 +--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/rgw/rgw_file.cc b/src/rgw/rgw_file.cc index 3ab675682f0cd..4bd17a8e8774e 100644 --- a/src/rgw/rgw_file.cc +++ b/src/rgw/rgw_file.cc @@ -1304,6 +1304,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) { diff --git a/src/rgw/rgw_file.h b/src/rgw/rgw_file.h index eade60cff8f60..882d88f8561d1 100644 --- a/src/rgw/rgw_file.h +++ b/src/rgw/rgw_file.h @@ -236,15 +236,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 variant_type; -- 2.39.5