diff options
author | Joel Becker <joel.becker@oracle.com> | 2008-10-24 20:04:49 -0400 |
---|---|---|
committer | Mark Fasheh <mfasheh@suse.com> | 2009-01-05 11:34:16 -0500 |
commit | 3e6329463e3a5c311e1d607ff3db735a18b6d67a (patch) | |
tree | 9c27f3e08be43e93f69103561f197d2beee22c97 /fs/ocfs2/xattr.c | |
parent | 51def39f0cabd46131c7c4df08751cb0cb9433d1 (diff) |
ocfs2: Convenient access to an xattr bucket's header.
The xattr code often wants to access the ocfs2_xattr_header at the start
of an bucket. Rather than walk the pointer chains, let's just create
another nice macro. As a side benefit, we can get rid of the mostly
spurious ->bu_xh element on the bucket structure. 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/ocfs2/xattr.c')
-rw-r--r-- | fs/ocfs2/xattr.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c index 8594df36640e..1b77302b54ff 100644 --- a/fs/ocfs2/xattr.c +++ b/fs/ocfs2/xattr.c | |||
@@ -62,7 +62,6 @@ struct ocfs2_xattr_def_value_root { | |||
62 | 62 | ||
63 | struct ocfs2_xattr_bucket { | 63 | struct ocfs2_xattr_bucket { |
64 | struct buffer_head *bu_bhs[OCFS2_XATTR_MAX_BLOCKS_PER_BUCKET]; | 64 | struct buffer_head *bu_bhs[OCFS2_XATTR_MAX_BLOCKS_PER_BUCKET]; |
65 | struct ocfs2_xattr_header *bu_xh; | ||
66 | }; | 65 | }; |
67 | 66 | ||
68 | #define OCFS2_XATTR_ROOT_SIZE (sizeof(struct ocfs2_xattr_def_value_root)) | 67 | #define OCFS2_XATTR_ROOT_SIZE (sizeof(struct ocfs2_xattr_def_value_root)) |
@@ -156,6 +155,7 @@ static inline u16 ocfs2_xattr_max_xe_in_bucket(struct super_block *sb) | |||
156 | 155 | ||
157 | #define bucket_blkno(_b) ((_b)->bu_bhs[0]->b_blocknr) | 156 | #define bucket_blkno(_b) ((_b)->bu_bhs[0]->b_blocknr) |
158 | #define bucket_block(_b, _n) ((_b)->bu_bhs[(_n)]->b_data) | 157 | #define bucket_block(_b, _n) ((_b)->bu_bhs[(_n)]->b_data) |
158 | #define bucket_xh(_b) ((struct ocfs2_xattr_header *)bucket_block((_b), 0)) | ||
159 | 159 | ||
160 | static inline const char *ocfs2_xattr_prefix(int name_index) | 160 | static inline const char *ocfs2_xattr_prefix(int name_index) |
161 | { | 161 | { |
@@ -798,7 +798,7 @@ static int ocfs2_xattr_block_get(struct inode *inode, | |||
798 | 798 | ||
799 | if (le16_to_cpu(xb->xb_flags) & OCFS2_XATTR_INDEXED) { | 799 | if (le16_to_cpu(xb->xb_flags) & OCFS2_XATTR_INDEXED) { |
800 | ret = ocfs2_xattr_bucket_get_name_value(inode, | 800 | ret = ocfs2_xattr_bucket_get_name_value(inode, |
801 | xs->bucket.bu_xh, | 801 | bucket_xh(&xs->bucket), |
802 | i, | 802 | i, |
803 | &block_off, | 803 | &block_off, |
804 | &name_offset); | 804 | &name_offset); |
@@ -2280,11 +2280,9 @@ static int ocfs2_xattr_bucket_find(struct inode *inode, | |||
2280 | bh = NULL; | 2280 | bh = NULL; |
2281 | } | 2281 | } |
2282 | xs->bucket.bu_bhs[0] = lower_bh; | 2282 | xs->bucket.bu_bhs[0] = lower_bh; |
2283 | xs->bucket.bu_xh = (struct ocfs2_xattr_header *) | ||
2284 | bucket_block(&xs->bucket, 0); | ||
2285 | lower_bh = NULL; | 2283 | lower_bh = NULL; |
2286 | 2284 | ||
2287 | xs->header = xs->bucket.bu_xh; | 2285 | xs->header = bucket_xh(&xs->bucket); |
2288 | xs->base = bucket_block(&xs->bucket, 0); | 2286 | xs->base = bucket_block(&xs->bucket, 0); |
2289 | xs->end = xs->base + inode->i_sb->s_blocksize; | 2287 | xs->end = xs->base + inode->i_sb->s_blocksize; |
2290 | 2288 | ||
@@ -2379,17 +2377,16 @@ static int ocfs2_iterate_xattr_buckets(struct inode *inode, | |||
2379 | goto out; | 2377 | goto out; |
2380 | } | 2378 | } |
2381 | 2379 | ||
2382 | bucket.bu_xh = (struct ocfs2_xattr_header *)bucket_block(&bucket, 0); | ||
2383 | /* | 2380 | /* |
2384 | * The real bucket num in this series of blocks is stored | 2381 | * The real bucket num in this series of blocks is stored |
2385 | * in the 1st bucket. | 2382 | * in the 1st bucket. |
2386 | */ | 2383 | */ |
2387 | if (i == 0) | 2384 | if (i == 0) |
2388 | num_buckets = le16_to_cpu(bucket.bu_xh->xh_num_buckets); | 2385 | num_buckets = le16_to_cpu(bucket_xh(&bucket)->xh_num_buckets); |
2389 | 2386 | ||
2390 | mlog(0, "iterating xattr bucket %llu, first hash %u\n", | 2387 | mlog(0, "iterating xattr bucket %llu, first hash %u\n", |
2391 | (unsigned long long)blkno, | 2388 | (unsigned long long)blkno, |
2392 | le32_to_cpu(bucket.bu_xh->xh_entries[0].xe_name_hash)); | 2389 | le32_to_cpu(bucket_xh(&bucket)->xh_entries[0].xe_name_hash)); |
2393 | if (func) { | 2390 | if (func) { |
2394 | ret = func(inode, &bucket, para); | 2391 | ret = func(inode, &bucket, para); |
2395 | if (ret) { | 2392 | if (ret) { |
@@ -2444,14 +2441,14 @@ static int ocfs2_list_xattr_bucket(struct inode *inode, | |||
2444 | int i, block_off, new_offset; | 2441 | int i, block_off, new_offset; |
2445 | const char *prefix, *name; | 2442 | const char *prefix, *name; |
2446 | 2443 | ||
2447 | for (i = 0 ; i < le16_to_cpu(bucket->bu_xh->xh_count); i++) { | 2444 | for (i = 0 ; i < le16_to_cpu(bucket_xh(bucket)->xh_count); i++) { |
2448 | struct ocfs2_xattr_entry *entry = &bucket->bu_xh->xh_entries[i]; | 2445 | struct ocfs2_xattr_entry *entry = &bucket_xh(bucket)->xh_entries[i]; |
2449 | type = ocfs2_xattr_get_type(entry); | 2446 | type = ocfs2_xattr_get_type(entry); |
2450 | prefix = ocfs2_xattr_prefix(type); | 2447 | prefix = ocfs2_xattr_prefix(type); |
2451 | 2448 | ||
2452 | if (prefix) { | 2449 | if (prefix) { |
2453 | ret = ocfs2_xattr_bucket_get_name_value(inode, | 2450 | ret = ocfs2_xattr_bucket_get_name_value(inode, |
2454 | bucket->bu_xh, | 2451 | bucket_xh(bucket), |
2455 | i, | 2452 | i, |
2456 | &block_off, | 2453 | &block_off, |
2457 | &new_offset); | 2454 | &new_offset); |
@@ -2631,8 +2628,7 @@ static int ocfs2_xattr_update_xattr_search(struct inode *inode, | |||
2631 | 2628 | ||
2632 | xs->bucket.bu_bhs[0] = new_bh; | 2629 | xs->bucket.bu_bhs[0] = new_bh; |
2633 | get_bh(new_bh); | 2630 | get_bh(new_bh); |
2634 | xs->bucket.bu_xh = (struct ocfs2_xattr_header *)bucket_block(&xs->bucket, 0); | 2631 | xs->header = bucket_xh(&xs->bucket); |
2635 | xs->header = xs->bucket.bu_xh; | ||
2636 | 2632 | ||
2637 | xs->base = new_bh->b_data; | 2633 | xs->base = new_bh->b_data; |
2638 | xs->end = xs->base + inode->i_sb->s_blocksize; | 2634 | xs->end = xs->base + inode->i_sb->s_blocksize; |
@@ -4398,7 +4394,7 @@ static void ocfs2_xattr_bucket_remove_xs(struct inode *inode, | |||
4398 | struct ocfs2_xattr_search *xs) | 4394 | struct ocfs2_xattr_search *xs) |
4399 | { | 4395 | { |
4400 | handle_t *handle = NULL; | 4396 | handle_t *handle = NULL; |
4401 | struct ocfs2_xattr_header *xh = xs->bucket.bu_xh; | 4397 | struct ocfs2_xattr_header *xh = bucket_xh(&xs->bucket); |
4402 | struct ocfs2_xattr_entry *last = &xh->xh_entries[ | 4398 | struct ocfs2_xattr_entry *last = &xh->xh_entries[ |
4403 | le16_to_cpu(xh->xh_count) - 1]; | 4399 | le16_to_cpu(xh->xh_count) - 1]; |
4404 | int ret = 0; | 4400 | int ret = 0; |
@@ -4533,7 +4529,7 @@ static int ocfs2_check_xattr_bucket_collision(struct inode *inode, | |||
4533 | struct ocfs2_xattr_bucket *bucket, | 4529 | struct ocfs2_xattr_bucket *bucket, |
4534 | const char *name) | 4530 | const char *name) |
4535 | { | 4531 | { |
4536 | struct ocfs2_xattr_header *xh = bucket->bu_xh; | 4532 | struct ocfs2_xattr_header *xh = bucket_xh(bucket); |
4537 | u32 name_hash = ocfs2_xattr_name_hash(inode, name, strlen(name)); | 4533 | u32 name_hash = ocfs2_xattr_name_hash(inode, name, strlen(name)); |
4538 | 4534 | ||
4539 | if (name_hash != le32_to_cpu(xh->xh_entries[0].xe_name_hash)) | 4535 | if (name_hash != le32_to_cpu(xh->xh_entries[0].xe_name_hash)) |
@@ -4703,7 +4699,7 @@ static int ocfs2_delete_xattr_in_bucket(struct inode *inode, | |||
4703 | void *para) | 4699 | void *para) |
4704 | { | 4700 | { |
4705 | int ret = 0; | 4701 | int ret = 0; |
4706 | struct ocfs2_xattr_header *xh = bucket->bu_xh; | 4702 | struct ocfs2_xattr_header *xh = bucket_xh(bucket); |
4707 | u16 i; | 4703 | u16 i; |
4708 | struct ocfs2_xattr_entry *xe; | 4704 | struct ocfs2_xattr_entry *xe; |
4709 | 4705 | ||