From 007c39e79954a853f72de470d336cb9e52d5ac1f Mon Sep 17 00:00:00 2001 From: John Spray Date: Fri, 12 Jun 2015 14:24:04 +0100 Subject: [PATCH] mds/CInode: move hash_dentry_name up into InodeStore Because it only depends on the data in the store, not anything from a live MDS, and it's useful when we're dealing with fragmented directories from an offline tool. Signed-off-by: John Spray --- src/mds/CInode.cc | 4 ++-- src/mds/CInode.h | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc index 41bcb5c53794a..58ebf3f966430 100644 --- a/src/mds/CInode.cc +++ b/src/mds/CInode.cc @@ -468,7 +468,7 @@ void CInode::pop_projected_snaprealm(sr_t *next_snaprealm) // dirfrags -__u32 CInode::hash_dentry_name(const string &dn) +__u32 InodeStoreBase::hash_dentry_name(const string &dn) { int which = inode.dir_layout.dl_dir_hash; if (!which) @@ -476,7 +476,7 @@ __u32 CInode::hash_dentry_name(const string &dn) return ceph_str_hash(which, dn.data(), dn.length()); } -frag_t CInode::pick_dirfrag(const string& dn) +frag_t InodeStoreBase::pick_dirfrag(const string& dn) { if (dirfragtree.empty()) return frag_t(); // avoid the string hash if we can. diff --git a/src/mds/CInode.h b/src/mds/CInode.h index e63bce8208c05..8b7a38db83f81 100644 --- a/src/mds/CInode.h +++ b/src/mds/CInode.h @@ -97,6 +97,10 @@ public: /* For test/debug output */ void dump(Formatter *f) const; + + /* For use by offline tools */ + __u32 hash_dentry_name(const std::string &dn); + frag_t pick_dirfrag(const std::string &dn); }; class InodeStore : public InodeStoreBase { @@ -398,8 +402,6 @@ private: int stickydir_ref; public: - __u32 hash_dentry_name(const std::string &dn); - frag_t pick_dirfrag(const std::string &dn); bool has_dirfrags() { return !dirfrags.empty(); } CDir* get_dirfrag(frag_t fg) { if (dirfrags.count(fg)) { -- 2.39.5