From: Yan, Zheng Date: Wed, 15 Feb 2017 07:51:00 +0000 (+0800) Subject: mds: avoid race between cache expire and MDentryLink X-Git-Tag: v12.0.1~266^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5d91ca3385f81667ebf5bbe6ad1f55825a9ea37a;p=ceph.git mds: avoid race between cache expire and MDentryLink commit 22535340 tried to fix race between cache expire and MDentryLink. It avoids trimming null dentry whose lock is not readable. The fix does not handle the case that MDS first recevies a MDentryUnlink message, then receives a MDentryLink message. Signed-off-by: "Yan, Zheng" --- diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 38177c60296..6aa92064e1e 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -6565,11 +6565,20 @@ bool MDCache::trim_dentry(CDentry *dn, map& expiremap assert(dn->is_auth()); } + // If replica dentry is not readable, it's likely we will receive + // MDentryLink/MDentryUnlink message soon (It's possible we first + // receive a MDentryUnlink message, then MDentryLink message) + // MDentryLink message only replicates an inode, so we should + // avoid trimming the inode's parent dentry. This is because that + // unconnected replicas are problematic for subtree migration. + if (!dn->is_auth() && !dn->lock.can_read(-1) && + !dn->get_dir()->get_inode()->is_stray()) + return true; + // adjust the dir state // NOTE: we can safely remove a clean, null dentry without effecting // directory completeness. // (check this _before_ we unlink the inode, below!) - bool null_dentry = false; bool clear_complete = false; if (!(dnl->is_null() && dn->is_clean())) clear_complete = true; @@ -6586,7 +6595,6 @@ bool MDCache::trim_dentry(CDentry *dn, map& expiremap return true; // purging stray instead of trimming } else { assert(dnl->is_null()); - null_dentry = true; } if (dn->is_auth()) { @@ -6595,16 +6603,6 @@ bool MDCache::trim_dentry(CDentry *dn, map& expiremap } } else { // notify dentry authority. - - // If null replica dentry is not readable, it's likely we will - // receive a MDentryLink message soon. MDentryLink message only - // replicates an inode, so we should avoid trimming the inode's - // parent dentry. This is because that unconnected replicas are - // problematic for subtree migration. - if (null_dentry && !dn->lock.can_read(-1) && - !dn->get_dir()->get_inode()->is_stray()) - return true; - mds_authority_t auth = dn->authority(); for (int p=0; p<2; p++) {