diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-10 16:14:12 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-10 22:54:35 -0400 |
commit | 26fe575028703948880fce4355a210c76bb0536e (patch) | |
tree | 0a7d04289e1eb1f1739659ebc9498d40f2add5da /include/linux | |
parent | ee983e89670704b2a05e897b161f2674a42d1508 (diff) |
vfs: make it possible to access the dentry hash/len as one 64-bit entry
This allows comparing hash and len in one operation on 64-bit
architectures. Right now only __d_lookup_rcu() takes advantage of this,
since that is the case we care most about.
The use of anonymous struct/unions hides the alternate 64-bit approach
from most users, the exception being a few cases where we initialize a
'struct qstr' with a static initializer. This makes the problematic
cases use a new QSTR_INIT() helper function for that (but initializing
just the name pointer with a "{ .name = xyzzy }" initializer remains
valid, as does just copying another qstr structure).
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/dcache.h | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/include/linux/dcache.h b/include/linux/dcache.h index 8239f64d1c2e..094789ff3e9f 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h | |||
@@ -25,6 +25,13 @@ struct vfsmount; | |||
25 | 25 | ||
26 | #define IS_ROOT(x) ((x) == (x)->d_parent) | 26 | #define IS_ROOT(x) ((x) == (x)->d_parent) |
27 | 27 | ||
28 | /* The hash is always the low bits of hash_len */ | ||
29 | #ifdef __LITTLE_ENDIAN | ||
30 | #define HASH_LEN_DECLARE u32 hash; u32 len; | ||
31 | #else | ||
32 | #define HASH_LEN_DECLARE u32 len; u32 hash; | ||
33 | #endif | ||
34 | |||
28 | /* | 35 | /* |
29 | * "quick string" -- eases parameter passing, but more importantly | 36 | * "quick string" -- eases parameter passing, but more importantly |
30 | * saves "metadata" about the string (ie length and the hash). | 37 | * saves "metadata" about the string (ie length and the hash). |
@@ -33,11 +40,19 @@ struct vfsmount; | |||
33 | * dentry. | 40 | * dentry. |
34 | */ | 41 | */ |
35 | struct qstr { | 42 | struct qstr { |
36 | unsigned int hash; | 43 | union { |
37 | unsigned int len; | 44 | struct { |
45 | HASH_LEN_DECLARE; | ||
46 | }; | ||
47 | u64 hash_len; | ||
48 | }; | ||
38 | const unsigned char *name; | 49 | const unsigned char *name; |
39 | }; | 50 | }; |
40 | 51 | ||
52 | #define QSTR_INIT(n,l) { { { .len = l } }, .name = n } | ||
53 | #define hashlen_hash(hashlen) ((u32) (hashlen)) | ||
54 | #define hashlen_len(hashlen) ((u32)((hashlen) >> 32)) | ||
55 | |||
41 | struct dentry_stat_t { | 56 | struct dentry_stat_t { |
42 | int nr_dentry; | 57 | int nr_dentry; |
43 | int nr_unused; | 58 | int nr_unused; |