From e30b2577d94fec4e74feeecd940569880bc883a5 Mon Sep 17 00:00:00 2001 From: Matt Benjamin Date: Thu, 6 Jun 2019 16:54:43 -0400 Subject: [PATCH] rgw_file: permit lookup_handle to lookup root_fh Originally, root_fh was reachable from RGWLibFS::fh_cache, but this was problematic as it has infinite lifetime and so is not present in RGWLibFS::fs_lru. To fix the above, RGWLibFS::root_fh came to live unhooked from the handle caches which works because nfs-ganesha/the application always has an instance handle. However, this silently breaks READDIR event invalidation. Fixes: https://tracker.ceph.com/issues/40196 Signed-off-by: Matt Benjamin (cherry picked from commit 547cb9f87b72440cb8a1d496ac5cfb37b2d83cc7) --- src/rgw/rgw_file.cc | 22 +++++++++++++++------- src/rgw/rgw_file.h | 9 ++++++--- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/rgw/rgw_file.cc b/src/rgw/rgw_file.cc index 5c0a4d3beffbd..301322223dbc4 100644 --- a/src/rgw/rgw_file.cc +++ b/src/rgw/rgw_file.cc @@ -993,7 +993,12 @@ namespace rgw { << dendl; { lock_guard guard(state.mtx); /* LOCKED */ - /* just return if no events */ + lsubdout(get_context(), rgw, 15) + << "GC: processing" + << " count=" << events.size() + << " events" + << dendl; + /* just return if no events */ if (events.empty()) { return; } @@ -1189,6 +1194,11 @@ namespace rgw { struct timespec now; CephContext* cct = fs->get_context(); + lsubdout(cct, rgw, 10) + << __func__ << " readdir called on " + << object_name() + << dendl; + directory* d = get(&variant_type); if (d) { (void) clock_gettime(CLOCK_MONOTONIC_COARSE, &now); /* !LOCKED */ @@ -1215,9 +1225,6 @@ namespace rgw { set_nlink(2); inc_nlink(req.d_count); *eof = req.eof(); - event ev(event::type::READDIR, get_key(), state.atime); - lock_guard sguard(fs->state.mtx); - fs->state.push_event(ev); } } else { RGWReaddirRequest req(cct, fs->get_user(), this, rcb, cb_arg, offset); @@ -1230,12 +1237,13 @@ namespace rgw { set_nlink(2); inc_nlink(req.d_count); *eof = req.eof(); - event ev(event::type::READDIR, get_key(), state.atime); - lock_guard sguard(fs->state.mtx); - fs->state.push_event(ev); } } + event ev(event::type::READDIR, get_key(), state.atime); + lock_guard sguard(fs->state.mtx); + fs->state.push_event(ev); + lsubdout(fs->get_context(), rgw, 15) << __func__ << " final link count=" << state.nlink diff --git a/src/rgw/rgw_file.h b/src/rgw/rgw_file.h index 1bd9433240370..e45aa58cb61ad 100644 --- a/src/rgw/rgw_file.h +++ b/src/rgw/rgw_file.h @@ -1205,10 +1205,13 @@ namespace rgw { RGWFileHandle::FHCache::FLAG_LOCK); /* LATCHED */ if (! fh) { + if (unlikely(fhk == root_fh.fh.fh_hk)) { + /* lookup for root of this fs */ + fh = &root_fh; + goto out; + } lsubdout(get_context(), rgw, 0) - << __func__ << " handle lookup failed <" - << fhk.fh_hk.bucket << "," << fhk.fh_hk.object << ">" - << "(need persistent handles)" + << __func__ << " handle lookup failed " << fhk << dendl; goto out; } -- 2.39.5