]>
Commit | Line | Data |
---|---|---|
00e5a55c BS |
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. | |
4 | Patch-mainline: 2.6.29 | |
5 | ||
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. | |
11 | ||
12 | Signed-off-by: Joel Becker <joel.becker@oracle.com> | |
13 | Signed-off-by: Mark Fasheh <mfasheh@suse.com> | |
14 | --- | |
15 | fs/ocfs2/xattr.c | 15 ++++++++------- | |
16 | 1 files changed, 8 insertions(+), 7 deletions(-) | |
17 | ||
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) | |
23 | } | |
24 | ||
25 | #define bucket_blkno(_b) ((_b)->bu_bhs[0]->b_blocknr) | |
26 | +#define bucket_block(_b, _n) ((_b)->bu_bhs[(_n)]->b_data) | |
27 | ||
28 | static inline const char *ocfs2_xattr_prefix(int name_index) | |
29 | { | |
30 | @@ -801,7 +802,7 @@ static int ocfs2_xattr_block_get(struct inode *inode, | |
31 | i, | |
32 | &block_off, | |
33 | &name_offset); | |
34 | - xs->base = xs->bucket.bu_bhs[block_off]->b_data; | |
35 | + xs->base = bucket_block(&xs->bucket, block_off); | |
36 | } | |
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, | |
40 | } | |
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); | |
45 | lower_bh = NULL; | |
46 | ||
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; | |
51 | ||
52 | if (found) { | |
53 | @@ -2378,7 +2379,7 @@ static int ocfs2_iterate_xattr_buckets(struct inode *inode, | |
54 | goto out; | |
55 | } | |
56 | ||
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); | |
59 | /* | |
60 | * The real bucket num in this series of blocks is stored | |
61 | * in the 1st bucket. | |
62 | @@ -2457,7 +2458,7 @@ static int ocfs2_list_xattr_bucket(struct inode *inode, | |
63 | if (ret) | |
64 | break; | |
65 | ||
66 | - name = (const char *)bucket->bu_bhs[block_off]->b_data + | |
67 | + name = (const char *)bucket_block(bucket, block_off) + | |
68 | new_offset; | |
69 | ret = ocfs2_xattr_list_entry(xl->buffer, | |
70 | xl->buffer_size, | |
71 | @@ -2630,7 +2631,7 @@ static int ocfs2_xattr_update_xattr_search(struct inode *inode, | |
72 | ||
73 | xs->bucket.bu_bhs[0] = new_bh; | |
74 | get_bh(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; | |
78 | ||
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; | |
82 | ||
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; | |
86 | } | |
87 | ||
88 | /* | |
89 | -- | |
90 | 1.5.6 | |
91 |