From: Patrick Donnelly Date: Wed, 3 May 2017 14:39:48 +0000 (-0400) Subject: mds: check export_pin on dirfrag load X-Git-Tag: v12.0.3~38^2~11 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4cd4782da89b9680ebbbaa589b8b69eef20d89a1;p=ceph.git mds: check export_pin on dirfrag load Zheng's suggestion: "[maybe_export_pin is called by MDCache::add_inode() and Migrator. For the first case, inode has no dirfrag (I think it's better to call this function in CInode::get_or_open_dirfrag)" Signed-off-by: Patrick Donnelly --- diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc index 46bc035237ac..4eade9fce5f7 100644 --- a/src/mds/CInode.cc +++ b/src/mds/CInode.cc @@ -655,6 +655,13 @@ CDir *CInode::add_dirfrag(CDir *dir) dir->get(CDir::PIN_STICKY); } + if (get_export_pin(false) != mdcache->mds->get_nodeid()) { + /* We don't need to look at parents export pins as that would be done when + * the parent's dirfrags are loaded. + */ + maybe_export_pin(); + } + return dir; } @@ -4486,7 +4493,7 @@ void CInode::set_export_pin(mds_rank_t rank) maybe_export_pin(); } -mds_rank_t CInode::get_export_pin(void) const +mds_rank_t CInode::get_export_pin(bool inherit) const { /* An inode that is export pinned may not necessarily be a subtree root, we * need to traverse the parents. A base or system inode cannot be pinned. @@ -4498,6 +4505,7 @@ mds_rank_t CInode::get_export_pin(void) const if (pin >= 0) { return pin; } + if (!inherit) break; } return MDS_RANK_NONE; } diff --git a/src/mds/CInode.h b/src/mds/CInode.h index 85324882bfa7..05659df80c2b 100644 --- a/src/mds/CInode.h +++ b/src/mds/CInode.h @@ -1092,7 +1092,7 @@ private: void maybe_export_pin(); public: void set_export_pin(mds_rank_t rank); - mds_rank_t get_export_pin(void) const; + mds_rank_t get_export_pin(bool inherit=true) const; bool is_exportable(mds_rank_t dest) const; void print(ostream& out) override; diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 5a58b7b85705..4954fdc22ead 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -271,9 +271,6 @@ void MDCache::add_inode(CInode *in) g_conf->mds_cache_size * g_conf->mds_health_cache_threshold) { exceeded_size_limit = true; } - - /* This is the place where inodes are thrown in the cache, so check if the inode should be somewhere else: */ - in->maybe_export_pin(); } void MDCache::remove_inode(CInode *o)