aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJoel Becker <joel.becker@oracle.com>2008-10-24 19:57:21 -0400
committerMark Fasheh <mfasheh@suse.com>2009-01-05 11:34:16 -0500
commit51def39f0cabd46131c7c4df08751cb0cb9433d1 (patch)
treed4845849f9e6bdee106c06453161e0c28f1fd429 /fs
parent9c7759aa670918a48f0c6e06779cd20f2781a2ac (diff)
ocfs2: Convenient access to xattr bucket data blocks.
The xattr code often wants to access the data pointer for blocks in an xattr bucket. This is usually found by dereferencing the bh array hanging off of the ocfs2_xattr_bucket structure. Rather than do this all the time, let's provide a nice little macro. The idea is ripped from the ocfs2_path code. Signed-off-by: Joel Becker <joel.becker@oracle.com> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/ocfs2/xattr.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 3cf8e80b2b6c..8594df36640e 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -155,6 +155,7 @@ static inline u16 ocfs2_xattr_max_xe_in_bucket(struct super_block *sb)
155} 155}
156 156
157#define bucket_blkno(_b) ((_b)->bu_bhs[0]->b_blocknr) 157#define bucket_blkno(_b) ((_b)->bu_bhs[0]->b_blocknr)
158#define bucket_block(_b, _n) ((_b)->bu_bhs[(_n)]->b_data)
158 159
159static inline const char *ocfs2_xattr_prefix(int name_index) 160static inline const char *ocfs2_xattr_prefix(int name_index)
160{ 161{
@@ -801,7 +802,7 @@ static int ocfs2_xattr_block_get(struct inode *inode,
801 i, 802 i,
802 &block_off, 803 &block_off,
803 &name_offset); 804 &name_offset);
804 xs->base = xs->bucket.bu_bhs[block_off]->b_data; 805 xs->base = bucket_block(&xs->bucket, block_off);
805 } 806 }
806 if (ocfs2_xattr_is_local(xs->here)) { 807 if (ocfs2_xattr_is_local(xs->here)) {
807 memcpy(buffer, (void *)xs->base + 808 memcpy(buffer, (void *)xs->base +
@@ -2280,11 +2281,11 @@ static int ocfs2_xattr_bucket_find(struct inode *inode,
2280 } 2281 }
2281 xs->bucket.bu_bhs[0] = lower_bh; 2282 xs->bucket.bu_bhs[0] = lower_bh;
2282 xs->bucket.bu_xh = (struct ocfs2_xattr_header *) 2283 xs->bucket.bu_xh = (struct ocfs2_xattr_header *)
2283 xs->bucket.bu_bhs[0]->b_data; 2284 bucket_block(&xs->bucket, 0);
2284 lower_bh = NULL; 2285 lower_bh = NULL;
2285 2286
2286 xs->header = xs->bucket.bu_xh; 2287 xs->header = xs->bucket.bu_xh;
2287 xs->base = xs->bucket.bu_bhs[0]->b_data; 2288 xs->base = bucket_block(&xs->bucket, 0);
2288 xs->end = xs->base + inode->i_sb->s_blocksize; 2289 xs->end = xs->base + inode->i_sb->s_blocksize;
2289 2290
2290 if (found) { 2291 if (found) {
@@ -2378,7 +2379,7 @@ static int ocfs2_iterate_xattr_buckets(struct inode *inode,
2378 goto out; 2379 goto out;
2379 } 2380 }
2380 2381
2381 bucket.bu_xh = (struct ocfs2_xattr_header *)bucket.bu_bhs[0]->b_data; 2382 bucket.bu_xh = (struct ocfs2_xattr_header *)bucket_block(&bucket, 0);
2382 /* 2383 /*
2383 * The real bucket num in this series of blocks is stored 2384 * The real bucket num in this series of blocks is stored
2384 * in the 1st bucket. 2385 * in the 1st bucket.
@@ -2457,7 +2458,7 @@ static int ocfs2_list_xattr_bucket(struct inode *inode,
2457 if (ret) 2458 if (ret)
2458 break; 2459 break;
2459 2460
2460 name = (const char *)bucket->bu_bhs[block_off]->b_data + 2461 name = (const char *)bucket_block(bucket, block_off) +
2461 new_offset; 2462 new_offset;
2462 ret = ocfs2_xattr_list_entry(xl->buffer, 2463 ret = ocfs2_xattr_list_entry(xl->buffer,
2463 xl->buffer_size, 2464 xl->buffer_size,
@@ -2630,7 +2631,7 @@ static int ocfs2_xattr_update_xattr_search(struct inode *inode,
2630 2631
2631 xs->bucket.bu_bhs[0] = new_bh; 2632 xs->bucket.bu_bhs[0] = new_bh;
2632 get_bh(new_bh); 2633 get_bh(new_bh);
2633 xs->bucket.bu_xh = (struct ocfs2_xattr_header *)xs->bucket.bu_bhs[0]->b_data; 2634 xs->bucket.bu_xh = (struct ocfs2_xattr_header *)bucket_block(&xs->bucket, 0);
2634 xs->header = xs->bucket.bu_xh; 2635 xs->header = xs->bucket.bu_xh;
2635 2636
2636 xs->base = new_bh->b_data; 2637 xs->base = new_bh->b_data;
@@ -3931,7 +3932,7 @@ static inline char *ocfs2_xattr_bucket_get_val(struct inode *inode,
3931 int block_off = offs >> inode->i_sb->s_blocksize_bits; 3932 int block_off = offs >> inode->i_sb->s_blocksize_bits;
3932 3933
3933 offs = offs % inode->i_sb->s_blocksize; 3934 offs = offs % inode->i_sb->s_blocksize;
3934 return bucket->bu_bhs[block_off]->b_data + offs; 3935 return bucket_block(bucket, block_off) + offs;
3935} 3936}
3936 3937
3937/* 3938/*