diff options
author | Yan, Zheng <zheng.z.yan@intel.com> | 2013-09-04 10:05:10 +0800 |
---|---|---|
committer | Yan, Zheng <zheng.z.yan@intel.com> | 2013-09-19 14:01:02 +0800 |
commit | 298c39f2f596bf94e0b287b543e3aa6286ae453f (patch) | |
tree | 0d205230f8ea92c055bbb5798537bd58d3e9e598 | |
parent | e303b964f7c0129c2b0b83e2e719613271e822d8 (diff) | |
download | ceph-298c39f2f596bf94e0b287b543e3aa6286ae453f.tar.gz |
mds: touch dentry bottom recursively
Deleted directory inode's dirfrags may contain some null dentries.
When touch_dentry_bottom() is called, also move these null dentries
to the tail of LRU.
Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
-rw-r--r-- | src/mds/CDir.cc | 8 | ||||
-rw-r--r-- | src/mds/CDir.h | 1 | ||||
-rw-r--r-- | src/mds/MDCache.cc | 4 | ||||
-rw-r--r-- | src/mds/MDCache.h | 9 |
4 files changed, 20 insertions, 2 deletions
diff --git a/src/mds/CDir.cc b/src/mds/CDir.cc index 2b991d78fde..c7527419e47 100644 --- a/src/mds/CDir.cc +++ b/src/mds/CDir.cc @@ -655,6 +655,14 @@ void CDir::remove_null_dentries() { assert(get_num_any() == items.size()); } +void CDir::touch_dentries_bottom() { + dout(12) << "touch_dentries_bottom " << *this << dendl; + + for (CDir::map_t::iterator p = items.begin(); + p != items.end(); + ++p) + inode->mdcache->touch_dentry_bottom(p->second); +} bool CDir::try_trim_snap_dentry(CDentry *dn, const set<snapid_t>& snaps) { diff --git a/src/mds/CDir.h b/src/mds/CDir.h index 7cf2b6a43d7..86da4e5dfd3 100644 --- a/src/mds/CDir.h +++ b/src/mds/CDir.h @@ -357,6 +357,7 @@ private: void remove_null_dentries(); void purge_stale_snap_data(const set<snapid_t>& snaps); public: + void touch_dentries_bottom(); bool try_trim_snap_dentry(CDentry *dn, const set<snapid_t>& snaps); diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 9d59b70249a..7bbbacee234 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -10640,7 +10640,7 @@ void MDCache::handle_dentry_unlink(MDentryUnlink *m) !in->state_test(CInode::STATE_EXPORTINGCAPS)) migrator->export_caps(in); - lru.lru_bottouch(straydn); // move stray to end of lru + touch_dentry_bottom(straydn); // move stray to end of lru straydn = NULL; } else { assert(!straydn); @@ -10650,7 +10650,7 @@ void MDCache::handle_dentry_unlink(MDentryUnlink *m) assert(dnl->is_null()); // move to bottom of lru - lru.lru_bottouch(dn); + touch_dentry_bottom(dn); } } diff --git a/src/mds/MDCache.h b/src/mds/MDCache.h index b4b57da84b2..1673ad8076a 100644 --- a/src/mds/MDCache.h +++ b/src/mds/MDCache.h @@ -646,6 +646,15 @@ public: } void touch_dentry_bottom(CDentry *dn) { lru.lru_bottouch(dn); + if (dn->get_projected_linkage()->is_primary()) { + CInode *in = dn->get_projected_linkage()->get_inode(); + if (in->has_dirfrags()) { + list<CDir*> ls; + in->get_dirfrags(ls); + for (list<CDir*>::iterator p = ls.begin(); p != ls.end(); ++p) + (*p)->touch_dentries_bottom(); + } + } } protected: |