From 29d30ecd4667567a58a7f92641a8a7618e88fd44 Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Thu, 12 Nov 2015 21:57:27 +0800 Subject: [PATCH] mds: properly set STATE_STRAY/STATE_ORPHAN for stray dentry/inode Fixes: #13777 Signed-off-by: Yan, Zheng (cherry picked from commit 460c74a0b872336a7279f0b40b17ed672b6e15a1) --- src/mds/MDCache.cc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 3ec852a97d136..65b4ff8c4d596 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -6622,12 +6622,6 @@ void MDCache::trim_non_auth() if (dnl->is_remote() && dnl->get_inode() && !dnl->get_inode()->is_auth()) dn->unlink_remote(dnl); - if (dn->get_dir()->get_inode()->is_stray()) { - dn->state_set(CDentry::STATE_STRAY); - if (dnl->is_primary() && dnl->get_inode()->inode.nlink == 0) - dnl->get_inode()->state_set(CInode::STATE_ORPHAN); - } - if (!first_auth) { first_auth = dn; } else { @@ -9185,10 +9179,14 @@ void MDCache::scan_stray_dir(dirfrag_t next) } for (CDir::map_t::iterator q = dir->items.begin(); q != dir->items.end(); ++q) { CDentry *dn = q->second; + dn->state_set(CDentry::STATE_STRAY); CDentry::linkage_t *dnl = dn->get_projected_linkage(); stray_manager.notify_stray_created(); if (dnl->is_primary()) { - maybe_eval_stray(dnl->get_inode()); + CInode *in = dnl->get_inode(); + if (in->inode.nlink == 0) + in->state_set(CInode::STATE_ORPHAN); + maybe_eval_stray(in); } } } -- 2.39.5