Zero is a valid return value of full_name_hash(), but
consumers of mlh_pdo_hash don't handle this case correctly.
Work around problems by consistently mapping zero hashes to
a different value.
Signed-off-by: Daniel Kobras <d.kobras@science-computing.de>
Change-Id: I8b2622cb9b04d9f005f8e414ad35102155820c7d
Reviewed-on: http://review.whamcloud.com/6166
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
if (name != NULL && (name[0] != '\0')) {
LASSERT(namelen > 0);
lh->mlh_pdo_hash = full_name_hash(name, namelen);
if (name != NULL && (name[0] != '\0')) {
LASSERT(namelen > 0);
lh->mlh_pdo_hash = full_name_hash(name, namelen);
+ /* XXX Workaround for LU-2856
+ * Zero is a valid return value of full_name_hash, but several
+ * users of mlh_pdo_hash assume a non-zero hash value. We
+ * therefore map zero onto an arbitrary, but consistent
+ * value (1) to avoid problems further down the road. */
+ if (unlikely(!lh->mlh_pdo_hash))
+ lh->mlh_pdo_hash = 1;
} else {
LASSERT(namelen == 0);
lh->mlh_pdo_hash = 0ull;
} else {
LASSERT(namelen == 0);
lh->mlh_pdo_hash = 0ull;