]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common: unknown hash type of judgment modification 9510/head
authorhuanwen ren <ren.huanwen@zte.com.cn>
Tue, 21 Jun 2016 11:51:30 +0000 (19:51 +0800)
committerhuanwen ren <ren.huanwen@zte.com.cn>
Tue, 21 Jun 2016 11:51:30 +0000 (19:51 +0800)
ceph_str_hash() return -1 if set unknown hash type
but (unsiged)-1 = unsiged 4294967295
So we can't judge whether the 4294967295 is the normal value of hash, or the return value of the unknown hash type
use ceph_str_hash_valid() verify the hash type before generating the hash value

Signed-off-by: huanwen ren <ren.huanwen@zte.com.cn>
src/client/Inode.h
src/mds/CInode.cc

index 67128c5afa5d67975964dd7ca10601441f1161b1..ec4333ca8bcc28a9ac7d933d4d9e6a26ad2cb7d5 100644 (file)
@@ -212,6 +212,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());
   }
 
index 718c0bc2f8d982c43ff6a722f4f94eb9eaf4f91c..7133df77f63231eb6435ed9c730228149300e3b4 100644 (file)
@@ -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());
 }