From: huanwen ren Date: Tue, 21 Jun 2016 11:51:30 +0000 (+0800) Subject: common: unknown hash type of judgment modification X-Git-Tag: ses5-milestone5~392^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5d282a39eec3083d9d7d74597f16b32b82c4d6ee;p=ceph.git common: unknown hash type of judgment modification 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 --- diff --git a/src/client/Inode.h b/src/client/Inode.h index 67128c5afa5d..ec4333ca8bcc 100644 --- a/src/client/Inode.h +++ b/src/client/Inode.h @@ -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()); } diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc index 718c0bc2f8d9..7133df77f632 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()); }