Whamcloud - gitweb
LU-9183 llite: handle make the string hashes salt the hash 19/25819/14
authorDmitry Eremin <dmitry.eremin@intel.com>
Thu, 2 Mar 2017 19:57:15 +0000 (22:57 +0300)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 9 May 2017 03:44:45 +0000 (03:44 +0000)
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 <dmitry.eremin@intel.com>
Reviewed-on: https://review.whamcloud.com/25819
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/autoconf/lustre-core.m4
lustre/include/lustre_compat.h
lustre/lfsck/lfsck_lib.c
lustre/llite/dir.c
lustre/llite/file.c
lustre/llite/statahead.c
lustre/mdt/mdt_handler.c

index 16bf84b..b4dceea 100644 (file)
@@ -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 <linux/stringhash.h>
+],[
+       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], [
index fa0a256..6d039ea 100644 (file)
@@ -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 */
index 5144c9e..a6491a4 100644 (file)
@@ -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);
index ce4961e..e42b7f5 100644 (file)
@@ -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;
index 3183ced..8fe18a2 100644 (file)
@@ -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);
index a2002d3..1ecb86a 100644 (file)
@@ -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;
 
index d2e1367..633529b 100644 (file)
@@ -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