From: Yan, Zheng Date: Mon, 13 Jul 2020 01:55:29 +0000 (+0800) Subject: mds: use parent/d_name in cap_reconnect_t to speedup MDCache::open_ino() X-Git-Tag: v16.1.0~1258^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3e7c5b4077b68ec519f9e3e98fea8fd9dcf9cbc3;p=ceph.git mds: use parent/d_name in cap_reconnect_t to speedup MDCache::open_ino() Signed-off-by: "Yan, Zheng" --- diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 920e141f9a4..953dafb27b4 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -5454,19 +5454,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 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(); }