From 55766865bd51a3983514e163d67a5a81ce1120cf Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Mon, 18 May 2015 14:48:10 +0800 Subject: [PATCH] mds: unlink any stale remote snap dentry when evaluating stray inode Remote snap dentry may hold reference to the stray directory inode, the reference prevent the stray inode from being purged. After making sure the stray directory inode is not referenced by any snapshot, we know that all remote snap dentries should be stale, so we can unlink them safely. Signed-off-by: Yan, Zheng --- src/mds/StrayManager.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/mds/StrayManager.cc b/src/mds/StrayManager.cc index 4ca33e8427e34..d0334f5a3ba19 100644 --- a/src/mds/StrayManager.cc +++ b/src/mds/StrayManager.cc @@ -573,6 +573,17 @@ bool StrayManager::eval_stray(CDentry *dn, bool delay) (*p)->try_remove_dentries_for_stray(); } } + + if (!in->remote_parents.empty()) { + // unlink any stale remote snap dentry. + for (compact_set::iterator p = in->remote_parents.begin(); + p != in->remote_parents.end(); ) { + CDentry *remote_dn = *p; + ++p; + assert(remote_dn->last != CEPH_NOSNAP); + remote_dn->unlink_remote(remote_dn->get_linkage()); + } + } } if (dn->is_replicated()) { dout(20) << " replicated" << dendl; -- 2.39.5