Whamcloud - gitweb
LU-14459 lmv: change default hash type to crush 84/43684/5
authorAndreas Dilger <adilger@whamcloud.com>
Thu, 13 May 2021 01:20:04 +0000 (19:20 -0600)
committerOleg Drokin <green@whamcloud.com>
Tue, 8 Jun 2021 21:57:55 +0000 (21:57 +0000)
Change the default hash type to CRUSH to minimize the number
of directory entries that need to be migrated.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I75aff45898044be9d12ae1bfad31b4693b3ebbe5
Reviewed-on: https://review.whamcloud.com/43684
Reviewed-by: Lai Siyao <lai.siyao@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Hongchao Zhang <hongchao@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/uapi/linux/lustre/lustre_user.h
lustre/llite/dir.c

index 723e47f..5bd1693 100644 (file)
@@ -1004,7 +1004,7 @@ static __attribute__((unused)) const char *mdt_hash_name[] = {
        "crush",
 };
 
-#define LMV_HASH_TYPE_DEFAULT LMV_HASH_TYPE_FNV_1A_64
+#define LMV_HASH_TYPE_DEFAULT LMV_HASH_TYPE_CRUSH
 
 /* Right now only the lower part(0-16bits) of lmv_hash_type is being used,
  * and the higher part will be the flag to indicate the status of object,
index b77a8af..5db622e 100644 (file)
@@ -444,23 +444,17 @@ static int ll_dir_setdirstripe(struct dentry *dparent, struct lmv_user_md *lump,
            !OBD_FAIL_CHECK(OBD_FAIL_LLITE_NO_CHECK_DEAD))
                RETURN(-ENOENT);
 
+       /* MDS < 2.14 doesn't support 'crush' hash type, and cannot handle
+        * unknown hash if client doesn't set a valid one. switch to fnv_1a_64.
+        */
        if (!(exp_connect_flags2(sbi->ll_md_exp) & OBD_CONNECT2_CRUSH)) {
-               if ((lump->lum_hash_type & LMV_HASH_TYPE_MASK) ==
-                    LMV_HASH_TYPE_CRUSH) {
-                       /* if server doesn't support 'crush' hash type,
-                        * switch to fnv_1a_64.
-                        */
-                       lump->lum_hash_type &= ~LMV_HASH_TYPE_MASK;
-                       lump->lum_hash_type |= LMV_HASH_TYPE_FNV_1A_64;
-               } else if ((lump->lum_hash_type & LMV_HASH_TYPE_MASK) ==
-                    LMV_HASH_TYPE_UNKNOWN) {
-                       /* from 2.14 MDT will choose default hash type if client
-                        * doesn't set a valid one, while old server doesn't
-                        * handle it.
-                        */
-                       lump->lum_hash_type &= ~LMV_HASH_TYPE_MASK;
-                       lump->lum_hash_type |= LMV_HASH_TYPE_DEFAULT;
-               }
+               enum lmv_hash_type type = lump->lum_hash_type &
+                                         LMV_HASH_TYPE_MASK;
+
+               if (type == LMV_HASH_TYPE_CRUSH ||
+                   type == LMV_HASH_TYPE_UNKNOWN)
+                       lump->lum_hash_type = (lump->lum_hash_type ^ type) |
+                                             LMV_HASH_TYPE_FNV_1A_64;
        }
 
        if (unlikely(!lmv_user_magic_supported(cpu_to_le32(lump->lum_magic))))