1 From: Joel Becker <joel.becker@oracle.com>
2 Date: Fri, 24 Oct 2008 16:57:21 -0700
3 Subject: ocfs2: Convenient access to xattr bucket data blocks.
6 The xattr code often wants to access the data pointer for blocks in an
7 xattr bucket. This is usually found by dereferencing the bh array
8 hanging off of the ocfs2_xattr_bucket structure. Rather than do this
9 all the time, let's provide a nice little macro. The idea is ripped
10 from the ocfs2_path code.
12 Signed-off-by: Joel Becker <joel.becker@oracle.com>
13 Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 fs/ocfs2/xattr.c | 15 ++++++++-------
16 1 files changed, 8 insertions(+), 7 deletions(-)
18 diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
19 index 3cf8e80..8594df3 100644
20 --- a/fs/ocfs2/xattr.c
21 +++ b/fs/ocfs2/xattr.c
22 @@ -155,6 +155,7 @@ static inline u16 ocfs2_xattr_max_xe_in_bucket(struct super_block *sb)
25 #define bucket_blkno(_b) ((_b)->bu_bhs[0]->b_blocknr)
26 +#define bucket_block(_b, _n) ((_b)->bu_bhs[(_n)]->b_data)
28 static inline const char *ocfs2_xattr_prefix(int name_index)
30 @@ -801,7 +802,7 @@ static int ocfs2_xattr_block_get(struct inode *inode,
34 - xs->base = xs->bucket.bu_bhs[block_off]->b_data;
35 + xs->base = bucket_block(&xs->bucket, block_off);
37 if (ocfs2_xattr_is_local(xs->here)) {
38 memcpy(buffer, (void *)xs->base +
39 @@ -2280,11 +2281,11 @@ static int ocfs2_xattr_bucket_find(struct inode *inode,
41 xs->bucket.bu_bhs[0] = lower_bh;
42 xs->bucket.bu_xh = (struct ocfs2_xattr_header *)
43 - xs->bucket.bu_bhs[0]->b_data;
44 + bucket_block(&xs->bucket, 0);
47 xs->header = xs->bucket.bu_xh;
48 - xs->base = xs->bucket.bu_bhs[0]->b_data;
49 + xs->base = bucket_block(&xs->bucket, 0);
50 xs->end = xs->base + inode->i_sb->s_blocksize;
53 @@ -2378,7 +2379,7 @@ static int ocfs2_iterate_xattr_buckets(struct inode *inode,
57 - bucket.bu_xh = (struct ocfs2_xattr_header *)bucket.bu_bhs[0]->b_data;
58 + bucket.bu_xh = (struct ocfs2_xattr_header *)bucket_block(&bucket, 0);
60 * The real bucket num in this series of blocks is stored
62 @@ -2457,7 +2458,7 @@ static int ocfs2_list_xattr_bucket(struct inode *inode,
66 - name = (const char *)bucket->bu_bhs[block_off]->b_data +
67 + name = (const char *)bucket_block(bucket, block_off) +
69 ret = ocfs2_xattr_list_entry(xl->buffer,
71 @@ -2630,7 +2631,7 @@ static int ocfs2_xattr_update_xattr_search(struct inode *inode,
73 xs->bucket.bu_bhs[0] = new_bh;
75 - xs->bucket.bu_xh = (struct ocfs2_xattr_header *)xs->bucket.bu_bhs[0]->b_data;
76 + xs->bucket.bu_xh = (struct ocfs2_xattr_header *)bucket_block(&xs->bucket, 0);
77 xs->header = xs->bucket.bu_xh;
79 xs->base = new_bh->b_data;
80 @@ -3931,7 +3932,7 @@ static inline char *ocfs2_xattr_bucket_get_val(struct inode *inode,
81 int block_off = offs >> inode->i_sb->s_blocksize_bits;
83 offs = offs % inode->i_sb->s_blocksize;
84 - return bucket->bu_bhs[block_off]->b_data + offs;
85 + return bucket_block(bucket, block_off) + offs;