From ed1e6b0698c1902ece59dd7d082a1ba0e4feb0d2 Mon Sep 17 00:00:00 2001 From: Daniel Kobras Date: Wed, 10 Apr 2013 14:25:12 +0200 Subject: [PATCH] LU-2856 mdt: Workaround for filenames w/zero hash 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 Change-Id: I8b2622cb9b04d9f005f8e414ad35102155820c7d Reviewed-on: http://review.whamcloud.com/6166 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Fan Yong --- lustre/mdt/mdt_handler.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 53545e0..82cfdef 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -154,6 +154,13 @@ void mdt_lock_pdo_init(struct mdt_lock_handle *lh, ldlm_mode_t lm, 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; -- 1.8.3.1