]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: use parent/d_name in cap_reconnect_t to speedup MDCache::open_ino()
authorYan, Zheng <zyan@redhat.com>
Mon, 13 Jul 2020 01:55:29 +0000 (09:55 +0800)
committerYan, Zheng <zyan@redhat.com>
Fri, 9 Oct 2020 16:02:44 +0000 (00:02 +0800)
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
(cherry picked from commit 3e7c5b4077b68ec519f9e3e98fea8fd9dcf9cbc3)

src/mds/MDCache.cc

index 788d7e8c02c1644d015522eca83e8a4281e8be78..f1e956f2d16687cf05a1554a7318cb9a0e7d65bf 100644 (file)
@@ -5432,19 +5432,43 @@ bool MDCache::process_imported_caps()
     return true;
   }
 
-  for (auto p = cap_imports.begin(); p != cap_imports.end(); ++p) {
-    CInode *in = get_inode(p->first);
+  for (auto& p : cap_imports) {
+    CInode *in = get_inode(p.first);
     if (in) {
       ceph_assert(in->is_auth());
-      cap_imports_missing.erase(p->first);
+      cap_imports_missing.erase(p.first);
       continue;
     }
-    if (cap_imports_missing.count(p->first) > 0)
+    if (cap_imports_missing.count(p.first) > 0)
       continue;
 
+    uint64_t parent_ino = 0;
+    std::string_view d_name;
+    for (auto& q : p.second) {
+      for (auto& r : q.second) {
+       auto &icr = r.second;
+       if (icr.capinfo.pathbase &&
+           icr.path.length() > 0 &&
+           icr.path.find('/') == string::npos) {
+         parent_ino = icr.capinfo.pathbase;
+         d_name = icr.path;
+         break;
+       }
+      }
+      if (parent_ino)
+       break;
+    }
+
+    dout(10) << "  opening missing ino " << p.first << dendl;
     cap_imports_num_opening++;
-    dout(10) << "  opening missing ino " << p->first << dendl;
-    open_ino(p->first, (int64_t)-1, new C_MDC_RejoinOpenInoFinish(this, p->first), false);
+    auto fin = new C_MDC_RejoinOpenInoFinish(this, p.first);
+    if (parent_ino) {
+      vector<inode_backpointer_t> ancestors;
+      ancestors.push_back(inode_backpointer_t(parent_ino, string{d_name}, 0));
+      open_ino(p.first, (int64_t)-1, fin, false, false, &ancestors);
+    } else {
+      open_ino(p.first, (int64_t)-1, fin, false);
+    }
     if (!(cap_imports_num_opening % 1000))
       mds->heartbeat_reset();
   }