aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/xattr.c
diff options
context:
space:
mode:
authorTao Ma <tao.ma@oracle.com>2008-10-09 11:06:13 -0400
committerMark Fasheh <mfasheh@suse.com>2008-10-13 20:02:44 -0400
commit2057e5c6780d86939a199031cdbafb81e6f88aac (patch)
treef36039ea7d491f44215a880b03f37c1644bb4f41 /fs/ocfs2/xattr.c
parent99219aea68b5bff4f182858372b43181ad3bdb34 (diff)
ocfs2: Calculate EA hash only by its suffix.
According to Christoph Hellwig's advice, the hash value of EA is only calculated by its suffix. Signed-off-by: Tao Ma <tao.ma@oracle.com> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs/ocfs2/xattr.c')
-rw-r--r--fs/ocfs2/xattr.c35
1 files changed, 5 insertions, 30 deletions
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 0f556b00235e..092a12318986 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -148,21 +148,13 @@ static inline struct xattr_handler *ocfs2_xattr_handler(int name_index)
148} 148}
149 149
150static u32 ocfs2_xattr_name_hash(struct inode *inode, 150static u32 ocfs2_xattr_name_hash(struct inode *inode,
151 char *prefix, 151 const char *name,
152 int prefix_len,
153 char *name,
154 int name_len) 152 int name_len)
155{ 153{
156 /* Get hash value of uuid from super block */ 154 /* Get hash value of uuid from super block */
157 u32 hash = OCFS2_SB(inode->i_sb)->uuid_hash; 155 u32 hash = OCFS2_SB(inode->i_sb)->uuid_hash;
158 int i; 156 int i;
159 157
160 /* hash extended attribute prefix */
161 for (i = 0; i < prefix_len; i++) {
162 hash = (hash << OCFS2_HASH_SHIFT) ^
163 (hash >> (8*sizeof(hash) - OCFS2_HASH_SHIFT)) ^
164 *prefix++;
165 }
166 /* hash extended attribute name */ 158 /* hash extended attribute name */
167 for (i = 0; i < name_len; i++) { 159 for (i = 0; i < name_len; i++) {
168 hash = (hash << OCFS2_HASH_SHIFT) ^ 160 hash = (hash << OCFS2_HASH_SHIFT) ^
@@ -183,14 +175,9 @@ static void ocfs2_xattr_hash_entry(struct inode *inode,
183 struct ocfs2_xattr_entry *entry) 175 struct ocfs2_xattr_entry *entry)
184{ 176{
185 u32 hash = 0; 177 u32 hash = 0;
186 struct xattr_handler *handler =
187 ocfs2_xattr_handler(ocfs2_xattr_get_type(entry));
188 char *prefix = handler->prefix;
189 char *name = (char *)header + le16_to_cpu(entry->xe_name_offset); 178 char *name = (char *)header + le16_to_cpu(entry->xe_name_offset);
190 int prefix_len = strlen(handler->prefix);
191 179
192 hash = ocfs2_xattr_name_hash(inode, prefix, prefix_len, name, 180 hash = ocfs2_xattr_name_hash(inode, name, entry->xe_name_len);
193 entry->xe_name_len);
194 entry->xe_name_hash = cpu_to_le32(hash); 181 entry->xe_name_hash = cpu_to_le32(hash);
195 182
196 return; 183 return;
@@ -2093,18 +2080,6 @@ cleanup:
2093 return ret; 2080 return ret;
2094} 2081}
2095 2082
2096static inline u32 ocfs2_xattr_hash_by_name(struct inode *inode,
2097 int name_index,
2098 const char *suffix_name)
2099{
2100 struct xattr_handler *handler = ocfs2_xattr_handler(name_index);
2101 char *prefix = handler->prefix;
2102 int prefix_len = strlen(handler->prefix);
2103
2104 return ocfs2_xattr_name_hash(inode, prefix, prefix_len,
2105 (char *)suffix_name, strlen(suffix_name));
2106}
2107
2108/* 2083/*
2109 * Find the xattr extent rec which may contains name_hash. 2084 * Find the xattr extent rec which may contains name_hash.
2110 * e_cpos will be the first name hash of the xattr rec. 2085 * e_cpos will be the first name hash of the xattr rec.
@@ -2395,7 +2370,7 @@ static int ocfs2_xattr_index_block_find(struct inode *inode,
2395 struct ocfs2_extent_list *el = &xb_root->xt_list; 2370 struct ocfs2_extent_list *el = &xb_root->xt_list;
2396 u64 p_blkno = 0; 2371 u64 p_blkno = 0;
2397 u32 first_hash, num_clusters = 0; 2372 u32 first_hash, num_clusters = 0;
2398 u32 name_hash = ocfs2_xattr_hash_by_name(inode, name_index, name); 2373 u32 name_hash = ocfs2_xattr_name_hash(inode, name, strlen(name));
2399 2374
2400 if (le16_to_cpu(el->l_next_free_rec) == 0) 2375 if (le16_to_cpu(el->l_next_free_rec) == 0)
2401 return -ENODATA; 2376 return -ENODATA;
@@ -4435,8 +4410,8 @@ static int ocfs2_xattr_set_in_bucket(struct inode *inode,
4435 size_t value_len; 4410 size_t value_len;
4436 char *val = (char *)xi->value; 4411 char *val = (char *)xi->value;
4437 struct ocfs2_xattr_entry *xe = xs->here; 4412 struct ocfs2_xattr_entry *xe = xs->here;
4438 u32 name_hash = ocfs2_xattr_hash_by_name(inode, 4413 u32 name_hash = ocfs2_xattr_name_hash(inode, xi->name,
4439 xi->name_index, xi->name); 4414 strlen(xi->name));
4440 4415
4441 if (!xs->not_found && !ocfs2_xattr_is_local(xe)) { 4416 if (!xs->not_found && !ocfs2_xattr_is_local(xe)) {
4442 /* 4417 /*