From: Yan, Zheng Date: Thu, 8 Jun 2017 04:59:34 +0000 (+0800) Subject: mds: move MDCache::eval_remote into StrayManager X-Git-Tag: v12.1.0~5^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d2ab40feeb5c512b727724cc1c2778f8ab3dd1a2;p=ceph.git mds: move MDCache::eval_remote into StrayManager Signed-off-by: "Yan, Zheng" --- diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 837439a7eeb..5d2cc0b8529 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -9467,41 +9467,6 @@ void MDCache::scan_stray_dir(dirfrag_t next) } } -/** - * If a remote dentry refers to an inode whose primary - * dentry is a stray, then evaluate the inode for purging if - * we have the auth copy, or migrate the stray to use if we - * do not. - */ -void MDCache::eval_remote(CDentry *remote_dn) -{ - assert(remote_dn); - dout(10) << __func__ << " " << *remote_dn << dendl; - - CDentry::linkage_t *dnl = remote_dn->get_projected_linkage(); - assert(dnl->is_remote()); - CInode *in = dnl->get_inode(); - - if (!in) { - dout(20) << __func__ << ": no inode, cannot evaluate" << dendl; - return; - } - - if (remote_dn->last != CEPH_NOSNAP) { - dout(20) << __func__ << ": snap dentry, cannot evaluate" << dendl; - return; - } - - // refers to stray? - CDentry *primary_dn = in->get_projected_parent_dn(); - assert(primary_dn != NULL); - if (primary_dn->get_dir()->get_inode()->is_stray()) { - stray_manager.eval_remote_stray(primary_dn, remote_dn); - } else { - dout(20) << __func__ << ": inode's primary dn not stray" << dendl; - } -} - void MDCache::fetch_backtrace(inodeno_t ino, int64_t pool, bufferlist& bl, Context *fin) { object_t oid = CInode::get_object_name(ino, frag_t(), ""); diff --git a/src/mds/MDCache.h b/src/mds/MDCache.h index ca3cdff76d9..179d17c962e 100644 --- a/src/mds/MDCache.h +++ b/src/mds/MDCache.h @@ -196,6 +196,11 @@ public: stray_manager.notify_stray_created(); } + void eval_remote(CDentry *dn) + { + stray_manager.eval_remote(dn); + } + // -- client caps -- uint64_t last_cap_id; @@ -970,7 +975,6 @@ public: // -- stray -- public: - void eval_remote(CDentry *dn); void fetch_backtrace(inodeno_t ino, int64_t pool, bufferlist& bl, Context *fin); uint64_t get_num_strays() const { return stray_manager.get_num_strays(); } diff --git a/src/mds/StrayManager.cc b/src/mds/StrayManager.cc index 34ba18679ec..ea4b2025a84 100644 --- a/src/mds/StrayManager.cc +++ b/src/mds/StrayManager.cc @@ -535,7 +535,7 @@ bool StrayManager::_eval_stray(CDentry *dn, bool delay) * if we can do anything with them if we happen to have them in * cache. */ - eval_remote_stray(dn, NULL); + _eval_stray_remote(dn, NULL); return false; } } @@ -558,8 +558,37 @@ bool StrayManager::eval_stray(CDentry *dn, bool delay) return ret; } -void StrayManager::eval_remote_stray(CDentry *stray_dn, CDentry *remote_dn) +void StrayManager::eval_remote(CDentry *remote_dn) { + dout(10) << __func__ << " " << *remote_dn << dendl; + + CDentry::linkage_t *dnl = remote_dn->get_projected_linkage(); + assert(dnl->is_remote()); + CInode *in = dnl->get_inode(); + + if (!in) { + dout(20) << __func__ << ": no inode, cannot evaluate" << dendl; + return; + } + + if (remote_dn->last != CEPH_NOSNAP) { + dout(20) << __func__ << ": snap dentry, cannot evaluate" << dendl; + return; + } + + // refers to stray? + CDentry *primary_dn = in->get_projected_parent_dn(); + assert(primary_dn != NULL); + if (primary_dn->get_dir()->get_inode()->is_stray()) { + _eval_stray_remote(primary_dn, remote_dn); + } else { + dout(20) << __func__ << ": inode's primary dn not stray" << dendl; + } +} + +void StrayManager::_eval_stray_remote(CDentry *stray_dn, CDentry *remote_dn) +{ + dout(20) << __func__ << " " << *stray_dn << dendl; assert(stray_dn != NULL); assert(stray_dn->get_dir()->get_inode()->is_stray()); CDentry::linkage_t *stray_dnl = stray_dn->get_projected_linkage(); diff --git a/src/mds/StrayManager.h b/src/mds/StrayManager.h index a9bf3aa7840..54629ee046b 100644 --- a/src/mds/StrayManager.h +++ b/src/mds/StrayManager.h @@ -119,6 +119,8 @@ class StrayManager */ bool _eval_stray(CDentry *dn, bool delay=false); + void _eval_stray_remote(CDentry *stray_dn, CDentry *remote_dn); + // My public interface is for consumption by MDCache public: explicit StrayManager(MDSRank *mds, PurgeQueue &purge_queue_); @@ -144,11 +146,10 @@ class StrayManager void advance_delayed(); /** - * When a metadata op touches a remote dentry that points to - * a stray, call in here to evaluate it for migration (move - * a stray residing on another MDS to this MDS) or reintegration - * (move a stray dentry's inode into a non-stray hardlink dentry and - * clean up the stray). + * Remote dentry potentially points to a stray. When it is touched, + * call in here to evaluate it for migration (move a stray residing + * on another MDS to this MDS) or reintegration (move a stray dentry's + * inode into a non-stray hardlink dentry and clean up the stray). * * @param stray_dn a stray dentry whose inode has been referenced * by a remote dentry @@ -157,7 +158,7 @@ class StrayManager * as a hint for which remote to reintegrate into * if there are multiple remotes. */ - void eval_remote_stray(CDentry *stray_dn, CDentry *remote_dn=NULL); + void eval_remote(CDentry *remote_dn); /** * Given a dentry within one of my stray directories,