aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/xattr.c
diff options
context:
space:
mode:
authorJoel Becker <joel.becker@oracle.com>2008-10-24 19:21:03 -0400
committerMark Fasheh <mfasheh@suse.com>2009-01-05 11:34:16 -0500
commit9c7759aa670918a48f0c6e06779cd20f2781a2ac (patch)
treeda91ec1b046904504b53f9d356c899321ec3f382 /fs/ocfs2/xattr.c
parent4ac6032d6c92f0ac65cf5bc56b68557b3f099b66 (diff)
ocfs2: Convenient access to an xattr bucket's block number.
The xattr code often wants to know the block number of an xattr bucket. This is usually found by dereferencing the first bh 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/ocfs2/xattr.c')
-rw-r--r--fs/ocfs2/xattr.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 9c0ee42eb931..3cf8e80b2b6c 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -154,6 +154,8 @@ static inline u16 ocfs2_xattr_max_xe_in_bucket(struct super_block *sb)
154 return len / sizeof(struct ocfs2_xattr_entry); 154 return len / sizeof(struct ocfs2_xattr_entry);
155} 155}
156 156
157#define bucket_blkno(_b) ((_b)->bu_bhs[0]->b_blocknr)
158
157static inline const char *ocfs2_xattr_prefix(int name_index) 159static inline const char *ocfs2_xattr_prefix(int name_index)
158{ 160{
159 struct xattr_handler *handler = NULL; 161 struct xattr_handler *handler = NULL;
@@ -2290,7 +2292,7 @@ static int ocfs2_xattr_bucket_find(struct inode *inode,
2290 * If we have found the xattr enty, read all the blocks in 2292 * If we have found the xattr enty, read all the blocks in
2291 * this bucket. 2293 * this bucket.
2292 */ 2294 */
2293 ret = ocfs2_read_blocks(inode, xs->bucket.bu_bhs[0]->b_blocknr + 1, 2295 ret = ocfs2_read_blocks(inode, bucket_blkno(&xs->bucket) + 1,
2294 blk_per_bucket - 1, &xs->bucket.bu_bhs[1], 2296 blk_per_bucket - 1, &xs->bucket.bu_bhs[1],
2295 0); 2297 0);
2296 if (ret) { 2298 if (ret) {
@@ -2300,7 +2302,7 @@ static int ocfs2_xattr_bucket_find(struct inode *inode,
2300 2302
2301 xs->here = &xs->header->xh_entries[index]; 2303 xs->here = &xs->header->xh_entries[index];
2302 mlog(0, "find xattr %s in bucket %llu, entry = %u\n", name, 2304 mlog(0, "find xattr %s in bucket %llu, entry = %u\n", name,
2303 (unsigned long long)xs->bucket.bu_bhs[0]->b_blocknr, index); 2305 (unsigned long long)bucket_blkno(&xs->bucket), index);
2304 } else 2306 } else
2305 ret = -ENODATA; 2307 ret = -ENODATA;
2306 2308
@@ -2637,7 +2639,7 @@ static int ocfs2_xattr_update_xattr_search(struct inode *inode,
2637 if (!xs->not_found) { 2639 if (!xs->not_found) {
2638 if (OCFS2_XATTR_BUCKET_SIZE != blocksize) { 2640 if (OCFS2_XATTR_BUCKET_SIZE != blocksize) {
2639 ret = ocfs2_read_blocks(inode, 2641 ret = ocfs2_read_blocks(inode,
2640 xs->bucket.bu_bhs[0]->b_blocknr + 1, 2642 bucket_blkno(&xs->bucket) + 1,
2641 blk_per_bucket - 1, &xs->bucket.bu_bhs[1], 2643 blk_per_bucket - 1, &xs->bucket.bu_bhs[1],
2642 0); 2644 0);
2643 if (ret) { 2645 if (ret) {
@@ -2835,7 +2837,7 @@ static int ocfs2_defrag_xattr_bucket(struct inode *inode,
2835 size_t end, offset, len, value_len; 2837 size_t end, offset, len, value_len;
2836 struct ocfs2_xattr_header *xh; 2838 struct ocfs2_xattr_header *xh;
2837 char *entries, *buf, *bucket_buf = NULL; 2839 char *entries, *buf, *bucket_buf = NULL;
2838 u64 blkno = bucket->bu_bhs[0]->b_blocknr; 2840 u64 blkno = bucket_blkno(bucket);
2839 u16 blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb); 2841 u16 blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
2840 u16 xh_free_start; 2842 u16 xh_free_start;
2841 size_t blocksize = inode->i_sb->s_blocksize; 2843 size_t blocksize = inode->i_sb->s_blocksize;
@@ -4124,11 +4126,11 @@ static int ocfs2_xattr_set_entry_in_bucket(struct inode *inode,
4124 4126
4125 mlog(0, "Set xattr entry len = %lu index = %d in bucket %llu\n", 4127 mlog(0, "Set xattr entry len = %lu index = %d in bucket %llu\n",
4126 (unsigned long)xi->value_len, xi->name_index, 4128 (unsigned long)xi->value_len, xi->name_index,
4127 (unsigned long long)xs->bucket.bu_bhs[0]->b_blocknr); 4129 (unsigned long long)bucket_blkno(&xs->bucket));
4128 4130
4129 if (!xs->bucket.bu_bhs[1]) { 4131 if (!xs->bucket.bu_bhs[1]) {
4130 ret = ocfs2_read_blocks(inode, 4132 ret = ocfs2_read_blocks(inode,
4131 xs->bucket.bu_bhs[0]->b_blocknr + 1, 4133 bucket_blkno(&xs->bucket) + 1,
4132 blk_per_bucket - 1, &xs->bucket.bu_bhs[1], 4134 blk_per_bucket - 1, &xs->bucket.bu_bhs[1],
4133 0); 4135 0);
4134 if (ret) { 4136 if (ret) {
@@ -4540,7 +4542,7 @@ static int ocfs2_check_xattr_bucket_collision(struct inode *inode,
4540 xh->xh_entries[0].xe_name_hash) { 4542 xh->xh_entries[0].xe_name_hash) {
4541 mlog(ML_ERROR, "Too much hash collision in xattr bucket %llu, " 4543 mlog(ML_ERROR, "Too much hash collision in xattr bucket %llu, "
4542 "hash = %u\n", 4544 "hash = %u\n",
4543 (unsigned long long)bucket->bu_bhs[0]->b_blocknr, 4545 (unsigned long long)bucket_blkno(bucket),
4544 le32_to_cpu(xh->xh_entries[0].xe_name_hash)); 4546 le32_to_cpu(xh->xh_entries[0].xe_name_hash));
4545 return -ENOSPC; 4547 return -ENOSPC;
4546 } 4548 }
@@ -4574,7 +4576,7 @@ try_again:
4574 4576
4575 mlog_bug_on_msg(header_size > blocksize, "bucket %llu has header size " 4577 mlog_bug_on_msg(header_size > blocksize, "bucket %llu has header size "
4576 "of %u which exceed block size\n", 4578 "of %u which exceed block size\n",
4577 (unsigned long long)xs->bucket.bu_bhs[0]->b_blocknr, 4579 (unsigned long long)bucket_blkno(&xs->bucket),
4578 header_size); 4580 header_size);
4579 4581
4580 if (xi->value && xi->value_len > OCFS2_XATTR_INLINE_SIZE) 4582 if (xi->value && xi->value_len > OCFS2_XATTR_INLINE_SIZE)
@@ -4614,7 +4616,7 @@ try_again:
4614 mlog(0, "xs->not_found = %d, in xattr bucket %llu: free = %d, " 4616 mlog(0, "xs->not_found = %d, in xattr bucket %llu: free = %d, "
4615 "need = %d, max_free = %d, xh_free_start = %u, xh_name_value_len =" 4617 "need = %d, max_free = %d, xh_free_start = %u, xh_name_value_len ="
4616 " %u\n", xs->not_found, 4618 " %u\n", xs->not_found,
4617 (unsigned long long)xs->bucket.bu_bhs[0]->b_blocknr, 4619 (unsigned long long)bucket_blkno(&xs->bucket),
4618 free, need, max_free, le16_to_cpu(xh->xh_free_start), 4620 free, need, max_free, le16_to_cpu(xh->xh_free_start),
4619 le16_to_cpu(xh->xh_name_value_len)); 4621 le16_to_cpu(xh->xh_name_value_len));
4620 4622