diff options
author | Will Deacon <will.deacon@arm.com> | 2013-12-12 12:40:21 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-12-12 13:39:01 -0500 |
commit | a5c21dcefa1c3d759457a604b3cfc4af29c8713f (patch) | |
tree | 6832dfcb836f8d5043ba70f17a0ea9c2c428bc4d /fs/dcache.c | |
parent | 319720f534d88039615bceb88d4bc094a7cd4ce9 (diff) |
dcache: allow word-at-a-time name hashing with big-endian CPUs
When explicitly hashing the end of a string with the word-at-a-time
interface, we have to be careful which end of the word we pick up.
On big-endian CPUs, the upper-bits will contain the data we're after, so
ensure we generate our masks accordingly (and avoid hashing whatever
random junk may have been sitting after the string).
This patch adds a new dcache helper, bytemask_from_count, which creates
a mask appropriate for the CPU endianness.
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/dcache.c')
-rw-r--r-- | fs/dcache.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/dcache.c b/fs/dcache.c index 4bdb300b16e2..6055d61811d3 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
@@ -192,7 +192,7 @@ static inline int dentry_string_cmp(const unsigned char *cs, const unsigned char | |||
192 | if (!tcount) | 192 | if (!tcount) |
193 | return 0; | 193 | return 0; |
194 | } | 194 | } |
195 | mask = ~(~0ul << tcount*8); | 195 | mask = bytemask_from_count(tcount); |
196 | return unlikely(!!((a ^ b) & mask)); | 196 | return unlikely(!!((a ^ b) & mask)); |
197 | } | 197 | } |
198 | 198 | ||