[lustre-devel] [PATCH 22/27] lustre: lmv: change default hash type to crush
James Simmons
jsimmons at infradead.org
Sun Jun 13 16:11:32 PDT 2021
From: Andreas Dilger <adilger at whamcloud.com>
Change the default hash type to CRUSH to minimize the number
of directory entries that need to be migrated.
WC-bug-id: https://jira.whamcloud.com/browse/LU-14459
Lustre-commit: bb60caa1c6e7c14c ("LU-14459 lmv: change default hash type to crush")
Signed-off-by: Andreas Dilger <adilger at whamcloud.com>
Reviewed-on: https://review.whamcloud.com/43684
Reviewed-by: Lai Siyao <lai.siyao at whamcloud.com>
Reviewed-by: Hongchao Zhang <hongchao at whamcloud.com>
Reviewed-by: Oleg Drokin <green at whamcloud.com>
Signed-off-by: James Simmons <jsimmons at infradead.org>
---
fs/lustre/llite/dir.c | 26 ++++++++++----------------
include/uapi/linux/lustre/lustre_user.h | 2 +-
2 files changed, 11 insertions(+), 17 deletions(-)
diff --git a/fs/lustre/llite/dir.c b/fs/lustre/llite/dir.c
index d7466f3..bd15fee 100644
--- a/fs/lustre/llite/dir.c
+++ b/fs/lustre/llite/dir.c
@@ -417,23 +417,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))))
diff --git a/include/uapi/linux/lustre/lustre_user.h b/include/uapi/linux/lustre/lustre_user.h
index aae6642..49b013c 100644
--- a/include/uapi/linux/lustre/lustre_user.h
+++ b/include/uapi/linux/lustre/lustre_user.h
@@ -701,7 +701,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,
--
1.8.3.1
More information about the lustre-devel
mailing list