4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.gnu.org/licenses/gpl-2.0.html
23 #define DEBUG_SUBSYSTEM S_LNET
25 #include <linux/module.h>
26 #ifdef HAVE_STRINGHASH
27 #include <linux/stringhash.h>
29 #include <linux/dcache.h>
31 #include <linux/hash.h>
33 #include <libcfs/linux/linux-hash.h>
35 /* Return the "hash_len" (hash and length) of a null-terminated string */
36 /* The kernel equivalent is in fs/namei.c but for some strange reason
37 * RHEL7.5 stuck it in dax/super.c instead. This placement never existed
38 * upstream so to make life easier we just have the equavilent
40 u64 cfs_hashlen_string(const void *salt, const char *name)
42 #ifdef HAVE_FULL_NAME_HASH_3ARGS
43 unsigned long hash = init_name_hash(salt);
45 unsigned long hash = init_name_hash();
47 unsigned long len = 0, c;
49 c = (unsigned char)*name;
52 hash = partial_name_hash(c, hash);
53 c = (unsigned char)name[len];
55 return hashlen_create(end_name_hash(hash), len);
57 EXPORT_SYMBOL(cfs_hashlen_string);