]> git.ipfire.org Git - ipfire-2.x.git/blame - src/patches/suse-2.6.27.39/patches.suse/ocfs2-Convenient-access-to-an-xattr-bucket-s-header.patch
Imported linux-2.6.27.39 suse/xen patches.
[ipfire-2.x.git] / src / patches / suse-2.6.27.39 / patches.suse / ocfs2-Convenient-access-to-an-xattr-bucket-s-header.patch
CommitLineData
2cb7cef9
BS
1From: Joel Becker <joel.becker@oracle.com>
2Date: Fri, 24 Oct 2008 17:04:49 -0700
3Subject: ocfs2: Convenient access to an xattr bucket's header.
4Patch-mainline: 2.6.29
5
6The xattr code often wants to access the ocfs2_xattr_header at the start
7of an bucket. Rather than walk the pointer chains, let's just create
8another nice macro. As a side benefit, we can get rid of the mostly
9spurious ->bu_xh element on the bucket structure. The idea is ripped
10from the ocfs2_path code.
11
12Signed-off-by: Joel Becker <joel.becker@oracle.com>
13Signed-off-by: Mark Fasheh <mfasheh@suse.com>
14---
15 fs/ocfs2/xattr.c | 28 ++++++++++++----------------
16 1 files changed, 12 insertions(+), 16 deletions(-)
17
18diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
19index 8594df3..1b77302 100644
20--- a/fs/ocfs2/xattr.c
21+++ b/fs/ocfs2/xattr.c
22@@ -62,7 +62,6 @@ struct ocfs2_xattr_def_value_root {
23
24 struct ocfs2_xattr_bucket {
25 struct buffer_head *bu_bhs[OCFS2_XATTR_MAX_BLOCKS_PER_BUCKET];
26- struct ocfs2_xattr_header *bu_xh;
27 };
28
29 #define OCFS2_XATTR_ROOT_SIZE (sizeof(struct ocfs2_xattr_def_value_root))
30@@ -156,6 +155,7 @@ static inline u16 ocfs2_xattr_max_xe_in_bucket(struct super_block *sb)
31
32 #define bucket_blkno(_b) ((_b)->bu_bhs[0]->b_blocknr)
33 #define bucket_block(_b, _n) ((_b)->bu_bhs[(_n)]->b_data)
34+#define bucket_xh(_b) ((struct ocfs2_xattr_header *)bucket_block((_b), 0))
35
36 static inline const char *ocfs2_xattr_prefix(int name_index)
37 {
38@@ -798,7 +798,7 @@ static int ocfs2_xattr_block_get(struct inode *inode,
39
40 if (le16_to_cpu(xb->xb_flags) & OCFS2_XATTR_INDEXED) {
41 ret = ocfs2_xattr_bucket_get_name_value(inode,
42- xs->bucket.bu_xh,
43+ bucket_xh(&xs->bucket),
44 i,
45 &block_off,
46 &name_offset);
47@@ -2280,11 +2280,9 @@ static int ocfs2_xattr_bucket_find(struct inode *inode,
48 bh = NULL;
49 }
50 xs->bucket.bu_bhs[0] = lower_bh;
51- xs->bucket.bu_xh = (struct ocfs2_xattr_header *)
52- bucket_block(&xs->bucket, 0);
53 lower_bh = NULL;
54
55- xs->header = xs->bucket.bu_xh;
56+ xs->header = bucket_xh(&xs->bucket);
57 xs->base = bucket_block(&xs->bucket, 0);
58 xs->end = xs->base + inode->i_sb->s_blocksize;
59
60@@ -2379,17 +2377,16 @@ static int ocfs2_iterate_xattr_buckets(struct inode *inode,
61 goto out;
62 }
63
64- bucket.bu_xh = (struct ocfs2_xattr_header *)bucket_block(&bucket, 0);
65 /*
66 * The real bucket num in this series of blocks is stored
67 * in the 1st bucket.
68 */
69 if (i == 0)
70- num_buckets = le16_to_cpu(bucket.bu_xh->xh_num_buckets);
71+ num_buckets = le16_to_cpu(bucket_xh(&bucket)->xh_num_buckets);
72
73 mlog(0, "iterating xattr bucket %llu, first hash %u\n",
74 (unsigned long long)blkno,
75- le32_to_cpu(bucket.bu_xh->xh_entries[0].xe_name_hash));
76+ le32_to_cpu(bucket_xh(&bucket)->xh_entries[0].xe_name_hash));
77 if (func) {
78 ret = func(inode, &bucket, para);
79 if (ret) {
80@@ -2444,14 +2441,14 @@ static int ocfs2_list_xattr_bucket(struct inode *inode,
81 int i, block_off, new_offset;
82 const char *prefix, *name;
83
84- for (i = 0 ; i < le16_to_cpu(bucket->bu_xh->xh_count); i++) {
85- struct ocfs2_xattr_entry *entry = &bucket->bu_xh->xh_entries[i];
86+ for (i = 0 ; i < le16_to_cpu(bucket_xh(bucket)->xh_count); i++) {
87+ struct ocfs2_xattr_entry *entry = &bucket_xh(bucket)->xh_entries[i];
88 type = ocfs2_xattr_get_type(entry);
89 prefix = ocfs2_xattr_prefix(type);
90
91 if (prefix) {
92 ret = ocfs2_xattr_bucket_get_name_value(inode,
93- bucket->bu_xh,
94+ bucket_xh(bucket),
95 i,
96 &block_off,
97 &new_offset);
98@@ -2631,8 +2628,7 @@ static int ocfs2_xattr_update_xattr_search(struct inode *inode,
99
100 xs->bucket.bu_bhs[0] = new_bh;
101 get_bh(new_bh);
102- xs->bucket.bu_xh = (struct ocfs2_xattr_header *)bucket_block(&xs->bucket, 0);
103- xs->header = xs->bucket.bu_xh;
104+ xs->header = bucket_xh(&xs->bucket);
105
106 xs->base = new_bh->b_data;
107 xs->end = xs->base + inode->i_sb->s_blocksize;
108@@ -4398,7 +4394,7 @@ static void ocfs2_xattr_bucket_remove_xs(struct inode *inode,
109 struct ocfs2_xattr_search *xs)
110 {
111 handle_t *handle = NULL;
112- struct ocfs2_xattr_header *xh = xs->bucket.bu_xh;
113+ struct ocfs2_xattr_header *xh = bucket_xh(&xs->bucket);
114 struct ocfs2_xattr_entry *last = &xh->xh_entries[
115 le16_to_cpu(xh->xh_count) - 1];
116 int ret = 0;
117@@ -4533,7 +4529,7 @@ static int ocfs2_check_xattr_bucket_collision(struct inode *inode,
118 struct ocfs2_xattr_bucket *bucket,
119 const char *name)
120 {
121- struct ocfs2_xattr_header *xh = bucket->bu_xh;
122+ struct ocfs2_xattr_header *xh = bucket_xh(bucket);
123 u32 name_hash = ocfs2_xattr_name_hash(inode, name, strlen(name));
124
125 if (name_hash != le32_to_cpu(xh->xh_entries[0].xe_name_hash))
126@@ -4703,7 +4699,7 @@ static int ocfs2_delete_xattr_in_bucket(struct inode *inode,
127 void *para)
128 {
129 int ret = 0;
130- struct ocfs2_xattr_header *xh = bucket->bu_xh;
131+ struct ocfs2_xattr_header *xh = bucket_xh(bucket);
132 u16 i;
133 struct ocfs2_xattr_entry *xe;
134
135--
1361.5.6
137