]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: pin base object of discover 12974/head
authorYan, Zheng <zyan@redhat.com>
Thu, 26 Jan 2017 02:50:23 +0000 (10:50 +0800)
committerYan, Zheng <zyan@redhat.com>
Thu, 26 Jan 2017 02:52:25 +0000 (10:52 +0800)
make sure the base object is in the cache when handing MDiscoverReply

Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
src/mds/MDCache.cc
src/mds/MDCache.h
src/mds/MDSCacheObject.h

index 97a2787129ba95605b275f31003e743228e069be..1e86b8cfd65321d960be4c026a23b2ea3f3a47fe 100644 (file)
@@ -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;
index 4bd7e77cdfcf7dafd214af7b00a5ba6328cf7b0b..ec710df84c9275d9204862e2ed9a0d7f4ba6dcc2 100644 (file)
@@ -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<ceph_tid_t, discover_info_t> discovers;
index 97e1d9a6098fab5e0bea46b4df07e588a5e6e979..ec40359dd762b15c80fbe083c34d313f01be0769 100644 (file)
@@ -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;
     }
   }