]> git.ipfire.org Git - ipfire-2.x.git/blame - src/patches/suse-2.6.27.39/patches.suse/ocfs2-Calculate-EA-hash-only-by-its-suffix.patch
Imported linux-2.6.27.39 suse/xen patches.
[ipfire-2.x.git] / src / patches / suse-2.6.27.39 / patches.suse / ocfs2-Calculate-EA-hash-only-by-its-suffix.patch
CommitLineData
2cb7cef9
BS
1From: Tao Ma <tao.ma@oracle.com>
2Subject: ocfs2: Calculate EA hash only by its suffix.
3Patch-mainline: 2.6.28
4
5According to Christoph Hellwig's advice, the hash value of EA
6is only calculated by its suffix.
7
8Signed-off-by: Tao Ma <tao.ma@oracle.com>
9Signed-off-by: Mark Fasheh <mfasheh@suse.com>
10---
11 fs/ocfs2/xattr.c | 35 +++++------------------------------
12 1 files changed, 5 insertions(+), 30 deletions(-)
13
14Index: linux-2.6.27/fs/ocfs2/xattr.c
15===================================================================
16--- linux-2.6.27.orig/fs/ocfs2/xattr.c
17+++ linux-2.6.27/fs/ocfs2/xattr.c
18@@ -164,21 +164,13 @@ static inline struct xattr_handler *ocfs
19 }
20
21 static u32 ocfs2_xattr_name_hash(struct inode *inode,
22- char *prefix,
23- int prefix_len,
24- char *name,
25+ const char *name,
26 int name_len)
27 {
28 /* Get hash value of uuid from super block */
29 u32 hash = OCFS2_SB(inode->i_sb)->uuid_hash;
30 int i;
31
32- /* hash extended attribute prefix */
33- for (i = 0; i < prefix_len; i++) {
34- hash = (hash << OCFS2_HASH_SHIFT) ^
35- (hash >> (8*sizeof(hash) - OCFS2_HASH_SHIFT)) ^
36- *prefix++;
37- }
38 /* hash extended attribute name */
39 for (i = 0; i < name_len; i++) {
40 hash = (hash << OCFS2_HASH_SHIFT) ^
41@@ -199,14 +191,9 @@ static void ocfs2_xattr_hash_entry(struc
42 struct ocfs2_xattr_entry *entry)
43 {
44 u32 hash = 0;
45- struct xattr_handler *handler =
46- ocfs2_xattr_handler(ocfs2_xattr_get_type(entry));
47- char *prefix = handler->prefix;
48 char *name = (char *)header + le16_to_cpu(entry->xe_name_offset);
49- int prefix_len = strlen(handler->prefix);
50
51- hash = ocfs2_xattr_name_hash(inode, prefix, prefix_len, name,
52- entry->xe_name_len);
53+ hash = ocfs2_xattr_name_hash(inode, name, entry->xe_name_len);
54 entry->xe_name_hash = cpu_to_le32(hash);
55
56 return;
57@@ -2109,18 +2096,6 @@ cleanup:
58 return ret;
59 }
60
61-static inline u32 ocfs2_xattr_hash_by_name(struct inode *inode,
62- int name_index,
63- const char *suffix_name)
64-{
65- struct xattr_handler *handler = ocfs2_xattr_handler(name_index);
66- char *prefix = handler->prefix;
67- int prefix_len = strlen(handler->prefix);
68-
69- return ocfs2_xattr_name_hash(inode, prefix, prefix_len,
70- (char *)suffix_name, strlen(suffix_name));
71-}
72-
73 /*
74 * Find the xattr extent rec which may contains name_hash.
75 * e_cpos will be the first name hash of the xattr rec.
76@@ -2411,7 +2386,7 @@ static int ocfs2_xattr_index_block_find(
77 struct ocfs2_extent_list *el = &xb_root->xt_list;
78 u64 p_blkno = 0;
79 u32 first_hash, num_clusters = 0;
80- u32 name_hash = ocfs2_xattr_hash_by_name(inode, name_index, name);
81+ u32 name_hash = ocfs2_xattr_name_hash(inode, name, strlen(name));
82
83 if (le16_to_cpu(el->l_next_free_rec) == 0)
84 return -ENODATA;
85@@ -4451,8 +4426,8 @@ static int ocfs2_xattr_set_in_bucket(str
86 size_t value_len;
87 char *val = (char *)xi->value;
88 struct ocfs2_xattr_entry *xe = xs->here;
89- u32 name_hash = ocfs2_xattr_hash_by_name(inode,
90- xi->name_index, xi->name);
91+ u32 name_hash = ocfs2_xattr_name_hash(inode, xi->name,
92+ strlen(xi->name));
93
94 if (!xs->not_found && !ocfs2_xattr_is_local(xe)) {
95 /*