From: Yan, Zheng Date: Tue, 3 Mar 2020 07:37:59 +0000 (+0800) Subject: mds: make MDCache::scan_stray_dir() handle dir fragmentation X-Git-Tag: v17.0.0~2578^2~2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=f558dff01771a82487927baf3e493ab4bfc59e19;p=ceph.git mds: make MDCache::scan_stray_dir() handle dir fragmentation Signed-off-by: "Yan, Zheng" --- diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 6a1e1525f22c7..e5e1da59e6a9d 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -9942,29 +9942,40 @@ void MDCache::scan_stray_dir(dirfrag_t next) { dout(10) << "scan_stray_dir " << next << dendl; - std::vector ls; + if (next.ino) + next.frag = strays[MDS_INO_STRAY_INDEX(next.ino)]->dirfragtree[next.frag.value()]; + for (int i = 0; i < NUM_STRAY; ++i) { if (strays[i]->ino() < next.ino) continue; + + std::vector ls; strays[i]->get_dirfrags(ls); - } - for (const auto& dir : ls) { - if (dir->dirfrag() < next) - continue; - if (!dir->is_complete()) { - dir->fetch(new C_MDC_RetryScanStray(this, dir->dirfrag())); - return; - } - for (auto &p : dir->items) { - CDentry *dn = p.second; - dn->state_set(CDentry::STATE_STRAY); - CDentry::linkage_t *dnl = dn->get_projected_linkage(); - if (dnl->is_primary()) { - CInode *in = dnl->get_inode(); - if (in->inode.nlink == 0) - in->state_set(CInode::STATE_ORPHAN); - maybe_eval_stray(in); + for (const auto& dir : ls) { + if (dir->get_frag() < next.frag) + continue; + + if (!dir->can_auth_pin()) { + dir->add_waiter(CDir::WAIT_UNFREEZE, new C_MDC_RetryScanStray(this, dir->dirfrag())); + return; + } + + if (!dir->is_complete()) { + dir->fetch(new C_MDC_RetryScanStray(this, dir->dirfrag())); + return; + } + + for (auto &p : dir->items) { + CDentry *dn = p.second; + dn->state_set(CDentry::STATE_STRAY); + CDentry::linkage_t *dnl = dn->get_projected_linkage(); + if (dnl->is_primary()) { + CInode *in = dnl->get_inode(); + if (in->inode.nlink == 0) + in->state_set(CInode::STATE_ORPHAN); + maybe_eval_stray(in); + } } } }