From 4d1bb7a76ebef4e69f9aaeb28175e62f73afa002 Mon Sep 17 00:00:00 2001 From: Dmitry Eremin Date: Thu, 2 Mar 2017 22:57:15 +0300 Subject: [PATCH] LU-9183 llite: handle make the string hashes salt the hash In commit 8387ff2577eb9ed245df9a39947f66976c6bcd02 Linus Torvalds make the string hashes salt the hash. Hash users that don't have any particular initial salt can just use the NULL pointer as a no-salt. Change-Id: Id262d459370aa46c2e3d0e8b1e09dad74c717f03 Signed-off-by: Dmitry Eremin Reviewed-on: https://review.whamcloud.com/25819 Reviewed-by: James Simmons Reviewed-by: Bob Glossman Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/autoconf/lustre-core.m4 | 20 ++++++++++++++++++++ lustre/include/lustre_compat.h | 6 ++++++ lustre/lfsck/lfsck_lib.c | 3 ++- lustre/llite/dir.c | 3 ++- lustre/llite/file.c | 2 +- lustre/llite/statahead.c | 8 ++++---- lustre/mdt/mdt_handler.c | 4 ++-- 7 files changed, 37 insertions(+), 9 deletions(-) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index 16bf84b..b4dceea 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -2388,6 +2388,25 @@ d_compare_4args, [ ]) # LC_D_COMPARE_4ARGS # +# LC_FULL_NAME_HASH_3ARGS +# +# Kernel version 4.8 commit 8387ff2577eb9ed245df9a39947f66976c6bcd02 +# vfs: make the string hashes salt the hash +# +AC_DEFUN([LC_FULL_NAME_HASH_3ARGS], [ +LB_CHECK_COMPILE([if 'full_name_hash' taken 3 arguments], +full_name_hash_3args, [ + #include +],[ + unsigned int hash; + hash = full_name_hash(NULL,NULL,0); +],[ + AC_DEFINE(HAVE_FULL_NAME_HASH_3ARGS, 1, + [full_name_hash need 3 arguments]) +]) +]) # LC_FULL_NAME_HASH_3ARGS + +# # LC_PROG_LINUX # # Lustre linux kernel checks @@ -2584,6 +2603,7 @@ AC_DEFUN([LC_PROG_LINUX], [ # 4.8 LC_HAVE_POSIX_ACL_VALID_USER_NS LC_D_COMPARE_4ARGS + LC_FULL_NAME_HASH_3ARGS # AS_IF([test "x$enable_server" != xno], [ diff --git a/lustre/include/lustre_compat.h b/lustre/include/lustre_compat.h index fa0a256..6d039ea 100644 --- a/lustre/include/lustre_compat.h +++ b/lustre/include/lustre_compat.h @@ -428,4 +428,10 @@ static inline void truncate_inode_pages_final(struct address_space *map) # define ll_task_pid_ns(task) ((task)->nsproxy->pid_ns) #endif +#ifdef HAVE_FULL_NAME_HASH_3ARGS +# define ll_full_name_hash(salt, name, len) full_name_hash(salt, name, len) +#else +# define ll_full_name_hash(salt, name, len) full_name_hash(name, len) +#endif + #endif /* _LUSTRE_COMPAT_H */ diff --git a/lustre/lfsck/lfsck_lib.c b/lustre/lfsck/lfsck_lib.c index 5144c9e..a6491a4 100644 --- a/lustre/lfsck/lfsck_lib.c +++ b/lustre/lfsck/lfsck_lib.c @@ -504,7 +504,8 @@ int lfsck_lock(const struct lu_env *env, struct lfsck_instance *lfsck, return rc; llh->llh_reg_mode = mode; - resid->name[LUSTRE_RES_ID_HSH_OFF] = full_name_hash(name, strlen(name)); + resid->name[LUSTRE_RES_ID_HSH_OFF] = ll_full_name_hash(NULL, name, + strlen(name)); LASSERT(resid->name[LUSTRE_RES_ID_HSH_OFF] != 0); rc = __lfsck_ibits_lock(env, lfsck, obj, resid, &llh->llh_reg_lh, bits, llh->llh_reg_mode); diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index ce4961e..e42b7f5 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -448,7 +448,8 @@ static int ll_dir_setdirstripe(struct dentry *dparent, struct lmv_user_md *lump, .d_name = { .name = dirname, .len = strlen(dirname), - .hash = full_name_hash(dirname, strlen(dirname)), + .hash = ll_full_name_hash(dparent, dirname, + strlen(dirname)), }, }; int err; diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 3183ced..8fe18a2 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -3275,7 +3275,7 @@ int ll_migrate(struct inode *parent, struct file *file, int mdtidx, RETURN(PTR_ERR(op_data)); /* Get child FID first */ - qstr.hash = full_name_hash(name, namelen); + qstr.hash = ll_full_name_hash(file_dentry(file), name, namelen); qstr.name = name; qstr.len = namelen; dchild = d_lookup(file_dentry(file), &qstr); diff --git a/lustre/llite/statahead.c b/lustre/llite/statahead.c index a2002d3..1ecb86a 100644 --- a/lustre/llite/statahead.c +++ b/lustre/llite/statahead.c @@ -179,8 +179,8 @@ static inline int is_omitted_entry(struct ll_statahead_info *sai, __u64 index) /* allocate sa_entry and hash it to allow scanner process to find it */ static struct sa_entry * -sa_alloc(struct ll_statahead_info *sai, __u64 index, const char *name, int len, - const struct lu_fid *fid) +sa_alloc(struct dentry *parent, struct ll_statahead_info *sai, __u64 index, + const char *name, int len, const struct lu_fid *fid) { struct ll_inode_info *lli; struct sa_entry *entry; @@ -203,7 +203,7 @@ sa_alloc(struct ll_statahead_info *sai, __u64 index, const char *name, int len, dname = (char *)entry + sizeof(struct sa_entry); memcpy(dname, name, len); dname[len] = 0; - entry->se_qstr.hash = full_name_hash(name, len); + entry->se_qstr.hash = ll_full_name_hash(parent, name, len); entry->se_qstr.len = len; entry->se_qstr.name = dname; entry->se_fid = *fid; @@ -846,7 +846,7 @@ static void sa_statahead(struct dentry *parent, const char *name, int len, int rc; ENTRY; - entry = sa_alloc(sai, sai->sai_index, name, len, fid); + entry = sa_alloc(parent, sai, sai->sai_index, name, len, fid); if (IS_ERR(entry)) RETURN_EXIT; diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index d2e1367..633529b 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -175,8 +175,8 @@ void mdt_lock_pdo_init(struct mdt_lock_handle *lh, enum ldlm_mode lock_mode, lh->mlh_type = MDT_PDO_LOCK; if (lu_name_is_valid(lname)) { - lh->mlh_pdo_hash = full_name_hash(lname->ln_name, - lname->ln_namelen); + lh->mlh_pdo_hash = ll_full_name_hash(NULL, lname->ln_name, + lname->ln_namelen); /* XXX Workaround for LU-2856 * * Zero is a valid return value of full_name_hash, but -- 1.8.3.1