diff options
author | Jeff Layton <jlayton@poochiereds.net> | 2014-05-02 13:50:02 -0400 |
---|---|---|
committer | Steve French <smfrench@gmail.com> | 2014-05-21 13:18:04 -0400 |
commit | 02323db17e3a73dd335690b7b1a2392912b05513 (patch) | |
tree | 24a6b832587ad960bd0da9af7a3f22e7826135e9 /fs/cifs | |
parent | 4b660a7f5c8099d88d1a43d8ae138965112592c7 (diff) |
cifs: fix cifs_uniqueid_to_ino_t not to ever return 0
Currently, when the top and bottom 32-bit words are equivalent and the
host is a 32-bit arch, cifs_uniqueid_to_ino_t returns 0 as the ino_t
value. All we're doing to hash the value down to 32 bits is xor'ing the
top and bottom 32-bit words and that obviously results in 0 if they are
equivalent.
The kernel doesn't really care if it returns this value, but some
userland apps (like "ls") will ignore dirents that have a zero d_ino
value.
Change this function to use hash_64 to convert this value to a 31 bit
value and then add 1 to ensure that it doesn't ever return 0. Also,
there's no need to check the sizeof(ino_t) at runtime so create two
different cifs_uniqueid_to_ino_t functions based on whether
BITS_PER_LONG is 64 for not.
This should fix:
https://bugzilla.kernel.org/show_bug.cgi?id=19282
Reported-by: Eric <copet_eric@emc.com>
Reported-by: <per-ola@sadata.se>
Signed-off-by: Jeff Layton <jlayton@poochiereds.net>
Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs/cifs')
-rw-r--r-- | fs/cifs/cifsfs.h | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h index 26a754f49ba1..89eab9a55f18 100644 --- a/fs/cifs/cifsfs.h +++ b/fs/cifs/cifsfs.h | |||
@@ -22,20 +22,28 @@ | |||
22 | #ifndef _CIFSFS_H | 22 | #ifndef _CIFSFS_H |
23 | #define _CIFSFS_H | 23 | #define _CIFSFS_H |
24 | 24 | ||
25 | #include <linux/hash.h> | ||
26 | |||
25 | #define ROOT_I 2 | 27 | #define ROOT_I 2 |
26 | 28 | ||
27 | /* | 29 | /* |
28 | * ino_t is 32-bits on 32-bit arch. We have to squash the 64-bit value down | 30 | * ino_t is 32-bits on 32-bit arch. We have to squash the 64-bit value down |
29 | * so that it will fit. | 31 | * so that it will fit. We use hash_64 to convert the value to 31 bits, and |
32 | * then add 1, to ensure that we don't end up with a 0 as the value. | ||
30 | */ | 33 | */ |
34 | #if BITS_PER_LONG == 64 | ||
31 | static inline ino_t | 35 | static inline ino_t |
32 | cifs_uniqueid_to_ino_t(u64 fileid) | 36 | cifs_uniqueid_to_ino_t(u64 fileid) |
33 | { | 37 | { |
34 | ino_t ino = (ino_t) fileid; | 38 | return (ino_t)fileid; |
35 | if (sizeof(ino_t) < sizeof(u64)) | ||
36 | ino ^= fileid >> (sizeof(u64)-sizeof(ino_t)) * 8; | ||
37 | return ino; | ||
38 | } | 39 | } |
40 | #else | ||
41 | static inline ino_t | ||
42 | cifs_uniqueid_to_ino_t(u64 fileid) | ||
43 | { | ||
44 | return (ino_t)hash_64(fileid, (sizeof(ino_t) * 8) - 1) + 1; | ||
45 | } | ||
46 | #endif | ||
39 | 47 | ||
40 | extern struct file_system_type cifs_fs_type; | 48 | extern struct file_system_type cifs_fs_type; |
41 | extern const struct address_space_operations cifs_addr_ops; | 49 | extern const struct address_space_operations cifs_addr_ops; |