From: Matt Benjamin Date: Tue, 18 Jun 2019 11:39:09 +0000 (-0400) Subject: rgw_file: advance_mtime() should consider namespace expiration X-Git-Tag: v15.1.0~2334^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fc14eeb6dbf7deaf11a70a3d3b48ce41998d4e39;p=ceph-ci.git 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 --- diff --git a/src/rgw/rgw_file.cc b/src/rgw/rgw_file.cc index 4c4926db6ba..21ac5641dfb 100644 --- a/src/rgw/rgw_file.cc +++ b/src/rgw/rgw_file.cc @@ -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) { diff --git a/src/rgw/rgw_file.h b/src/rgw/rgw_file.h index 5ab2a1b3783..d3ab2441f0a 100644 --- a/src/rgw/rgw_file.h +++ b/src/rgw/rgw_file.h @@ -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 variant_type;