diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-02 18:57:47 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-02 18:57:47 -0500 |
commit | 8e3bda0863c1578ddf47a015eac7dc6efb1ef48b (patch) | |
tree | b3257fc9b005352a7c3536097123de97f43748a2 /fs/ubifs/key.h | |
parent | 574c3fdae3890e60f8bc59e8107686944ba1e446 (diff) | |
parent | 8e5033adc78ff4fbeab7052134e7af1f6ff04187 (diff) |
Merge branch 'linux-next' of git://git.infradead.org/ubifs-2.6
* 'linux-next' of git://git.infradead.org/ubifs-2.6: (33 commits)
UBIFS: add more useful debugging prints
UBIFS: print debugging messages properly
UBIFS: fix numerous spelling mistakes
UBIFS: allow mounting when short of space
UBIFS: fix writing uncompressed files
UBIFS: fix checkpatch.pl warnings
UBIFS: fix sparse warnings
UBIFS: simplify make_free_space
UBIFS: do not lie about used blocks
UBIFS: restore budg_uncommitted_idx
UBIFS: always commit on unmount
UBIFS: use ubi_sync
UBIFS: always commit in sync_fs
UBIFS: fix file-system synchronization
UBIFS: fix constants initialization
UBIFS: avoid unnecessary calculations
UBIFS: re-calculate min_idx_size after the commit
UBIFS: use nicer 64-bit math
UBIFS: fix available blocks count
UBIFS: various comment improvements and fixes
...
Diffstat (limited to 'fs/ubifs/key.h')
-rw-r--r-- | fs/ubifs/key.h | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/fs/ubifs/key.h b/fs/ubifs/key.h index 3f1f16bc25c9..efb3430a2581 100644 --- a/fs/ubifs/key.h +++ b/fs/ubifs/key.h | |||
@@ -38,6 +38,22 @@ | |||
38 | #define __UBIFS_KEY_H__ | 38 | #define __UBIFS_KEY_H__ |
39 | 39 | ||
40 | /** | 40 | /** |
41 | * key_mask_hash - mask a valid hash value. | ||
42 | * @val: value to be masked | ||
43 | * | ||
44 | * We use hash values as offset in directories, so values %0 and %1 are | ||
45 | * reserved for "." and "..". %2 is reserved for "end of readdir" marker. This | ||
46 | * function makes sure the reserved values are not used. | ||
47 | */ | ||
48 | static inline uint32_t key_mask_hash(uint32_t hash) | ||
49 | { | ||
50 | hash &= UBIFS_S_KEY_HASH_MASK; | ||
51 | if (unlikely(hash <= 2)) | ||
52 | hash += 3; | ||
53 | return hash; | ||
54 | } | ||
55 | |||
56 | /** | ||
41 | * key_r5_hash - R5 hash function (borrowed from reiserfs). | 57 | * key_r5_hash - R5 hash function (borrowed from reiserfs). |
42 | * @s: direntry name | 58 | * @s: direntry name |
43 | * @len: name length | 59 | * @len: name length |
@@ -54,16 +70,7 @@ static inline uint32_t key_r5_hash(const char *s, int len) | |||
54 | str++; | 70 | str++; |
55 | } | 71 | } |
56 | 72 | ||
57 | a &= UBIFS_S_KEY_HASH_MASK; | 73 | return key_mask_hash(a); |
58 | |||
59 | /* | ||
60 | * We use hash values as offset in directories, so values %0 and %1 are | ||
61 | * reserved for "." and "..". %2 is reserved for "end of readdir" | ||
62 | * marker. | ||
63 | */ | ||
64 | if (unlikely(a >= 0 && a <= 2)) | ||
65 | a += 3; | ||
66 | return a; | ||
67 | } | 74 | } |
68 | 75 | ||
69 | /** | 76 | /** |
@@ -77,10 +84,7 @@ static inline uint32_t key_test_hash(const char *str, int len) | |||
77 | 84 | ||
78 | len = min_t(uint32_t, len, 4); | 85 | len = min_t(uint32_t, len, 4); |
79 | memcpy(&a, str, len); | 86 | memcpy(&a, str, len); |
80 | a &= UBIFS_S_KEY_HASH_MASK; | 87 | return key_mask_hash(a); |
81 | if (unlikely(a >= 0 && a <= 2)) | ||
82 | a += 3; | ||
83 | return a; | ||
84 | } | 88 | } |
85 | 89 | ||
86 | /** | 90 | /** |