diff options
-rw-r--r-- | src/client/Inode.h | 1 | ||||
-rw-r--r-- | src/common/ceph_hash.cc | 11 | ||||
-rw-r--r-- | src/include/ceph_hash.h | 1 | ||||
-rw-r--r-- | src/mds/CInode.cc | 1 |
4 files changed, 14 insertions, 0 deletions
diff --git a/src/client/Inode.h b/src/client/Inode.h index dc9b91de65e..aa96afd3e97 100644 --- a/src/client/Inode.h +++ b/src/client/Inode.h @@ -139,6 +139,7 @@ struct Inode { int which = dir_layout.dl_dir_hash; if (!which) which = CEPH_STR_HASH_LINUX; + assert(ceph_str_hash_valid(which)); return ceph_str_hash(which, dn.data(), dn.length()); } diff --git a/src/common/ceph_hash.cc b/src/common/ceph_hash.cc index c738e316155..061926d27b7 100644 --- a/src/common/ceph_hash.cc +++ b/src/common/ceph_hash.cc @@ -115,3 +115,14 @@ const char *ceph_str_hash_name(int type) return "unknown"; } } + +bool ceph_str_hash_valid(int type) +{ + switch (type) { + case CEPH_STR_HASH_LINUX: + case CEPH_STR_HASH_RJENKINS: + return true; + default: + return false; + } +} diff --git a/src/include/ceph_hash.h b/src/include/ceph_hash.h index d099c3f9023..f9d80ac36ad 100644 --- a/src/include/ceph_hash.h +++ b/src/include/ceph_hash.h @@ -9,5 +9,6 @@ extern unsigned ceph_str_hash_rjenkins(const char *s, unsigned len); extern unsigned ceph_str_hash(int type, const char *s, unsigned len); extern const char *ceph_str_hash_name(int type); +extern bool ceph_str_hash_valid(int type); #endif diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc index ed75d587abc..326fe35995b 100644 --- a/src/mds/CInode.cc +++ b/src/mds/CInode.cc @@ -493,6 +493,7 @@ __u32 InodeStoreBase::hash_dentry_name(const string &dn) int which = inode.dir_layout.dl_dir_hash; if (!which) which = CEPH_STR_HASH_LINUX; + assert(ceph_str_hash_valid(which)); return ceph_str_hash(which, dn.data(), dn.length()); } |