Whamcloud - gitweb
LU-2856 mdt: Workaround for filenames w/zero hash
authorDaniel Kobras <d.kobras@science-computing.de>
Wed, 10 Apr 2013 12:25:12 +0000 (14:25 +0200)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 30 Apr 2013 21:57:09 +0000 (17:57 -0400)
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>
lustre/mdt/mdt_handler.c

index 53545e0..82cfdef 100644 (file)
@@ -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);
         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;