From: Yan, Zheng Date: Thu, 26 Jan 2017 02:50:23 +0000 (+0800) Subject: mds: pin base object of discover X-Git-Tag: v12.0.0~43^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c9ecea101fa8f56c334431ff92a6e748f2a82276;p=ceph.git mds: pin base object of discover make sure the base object is in the cache when handing MDiscoverReply Signed-off-by: "Yan, Zheng" --- diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 97a2787129ba..1e86b8cfd653 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -9553,6 +9553,7 @@ void MDCache::discover_dir_frag(CInode *base, if (!base->is_waiting_for_dir(approx_fg) || !onfinish) { discover_info_t& d = _create_discover(from); + d.pin_base(base); d.ino = base->ino(); d.frag = approx_fg; d.want_base_dir = true; @@ -9607,6 +9608,7 @@ void MDCache::discover_path(CInode *base, !base->is_waiting_for_dir(fg) || !onfinish) { discover_info_t& d = _create_discover(from); d.ino = base->ino(); + d.pin_base(base); d.frag = fg; d.snap = snap; d.want_path = want_path; @@ -9660,6 +9662,7 @@ void MDCache::discover_path(CDir *base, !base->is_waiting_for_dentry(want_path[0].c_str(), snap) || !onfinish) { discover_info_t& d = _create_discover(from); d.ino = base->ino(); + d.pin_base(base); d.frag = base->get_frag(); d.snap = snap; d.want_path = want_path; diff --git a/src/mds/MDCache.h b/src/mds/MDCache.h index 4bd7e77cdfcf..ec710df84c92 100644 --- a/src/mds/MDCache.h +++ b/src/mds/MDCache.h @@ -216,10 +216,21 @@ public: frag_t frag; snapid_t snap; filepath want_path; + MDSCacheObject *base; bool want_base_dir; bool want_xlocked; - discover_info_t() : tid(0), mds(-1), snap(CEPH_NOSNAP), want_base_dir(false), want_xlocked(false) {} + discover_info_t() : + tid(0), mds(-1), snap(CEPH_NOSNAP), base(NULL), + want_base_dir(false), want_xlocked(false) {} + ~discover_info_t() { + if (base) + base->put(MDSCacheObject::PIN_DISCOVERBASE); + } + void pin_base(MDSCacheObject *b) { + base = b; + base->get(MDSCacheObject::PIN_DISCOVERBASE); + } }; map discovers; diff --git a/src/mds/MDSCacheObject.h b/src/mds/MDSCacheObject.h index 97e1d9a6098f..ec40359dd762 100644 --- a/src/mds/MDSCacheObject.h +++ b/src/mds/MDSCacheObject.h @@ -66,6 +66,7 @@ class MDSCacheObject { static const int PIN_PTRWAITER = -1007; const static int PIN_TEMPEXPORTING = 1008; // temp pin between encode_ and finish_export static const int PIN_CLIENTLEASE = 1009; + static const int PIN_DISCOVERBASE = 1010; const char *generic_pin_name(int p) const { switch (p) { @@ -79,6 +80,7 @@ class MDSCacheObject { case PIN_PTRWAITER: return "ptrwaiter"; case PIN_TEMPEXPORTING: return "tempexporting"; case PIN_CLIENTLEASE: return "clientlease"; + case PIN_DISCOVERBASE: return "discoverbase"; default: ceph_abort(); return 0; } }