1 From: Joel Becker <joel.becker@oracle.com>
2 Date: Fri, 24 Oct 2008 17:16:48 -0700
3 Subject: ocfs2: Provide a wrapper to brelse() xattr bucket buffers.
6 A common theme is walking all the buffer heads on an ocfs2_xattr_bucket
7 and releasing them. Let's wrap that.
9 Signed-off-by: Joel Becker <joel.becker@oracle.com>
10 Signed-off-by: Mark Fasheh <mfasheh@suse.com>
12 fs/ocfs2/xattr.c | 33 ++++++++++++++++++---------------
13 1 files changed, 18 insertions(+), 15 deletions(-)
15 diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
16 index 1b77302..3478ad1 100644
17 --- a/fs/ocfs2/xattr.c
18 +++ b/fs/ocfs2/xattr.c
19 @@ -157,6 +157,17 @@ static inline u16 ocfs2_xattr_max_xe_in_bucket(struct super_block *sb)
20 #define bucket_block(_b, _n) ((_b)->bu_bhs[(_n)]->b_data)
21 #define bucket_xh(_b) ((struct ocfs2_xattr_header *)bucket_block((_b), 0))
23 +static void ocfs2_xattr_bucket_relse(struct inode *inode,
24 + struct ocfs2_xattr_bucket *bucket)
26 + int i, blks = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
28 + for (i = 0; i < blks; i++) {
29 + brelse(bucket->bu_bhs[i]);
30 + bucket->bu_bhs[i] = NULL;
34 static inline const char *ocfs2_xattr_prefix(int name_index)
36 struct xattr_handler *handler = NULL;
37 @@ -820,8 +831,7 @@ static int ocfs2_xattr_block_get(struct inode *inode,
41 - for (i = 0; i < OCFS2_XATTR_MAX_BLOCKS_PER_BUCKET; i++)
42 - brelse(xs->bucket.bu_bhs[i]);
43 + ocfs2_xattr_bucket_relse(inode, &xs->bucket);
44 memset(&xs->bucket, 0, sizeof(xs->bucket));
47 @@ -1932,7 +1942,6 @@ int ocfs2_xattr_set(struct inode *inode,
48 struct buffer_head *di_bh = NULL;
49 struct ocfs2_dinode *di;
51 - u16 i, blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
53 struct ocfs2_xattr_info xi = {
54 .name_index = name_index,
55 @@ -2034,8 +2043,7 @@ cleanup:
56 ocfs2_inode_unlock(inode, 1);
59 - for (i = 0; i < blk_per_bucket; i++)
60 - brelse(xbs.bucket.bu_bhs[i]);
61 + ocfs2_xattr_bucket_relse(inode, &xbs.bucket);
65 @@ -2358,7 +2366,7 @@ static int ocfs2_iterate_xattr_buckets(struct inode *inode,
66 xattr_bucket_func *func,
71 int blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
72 u32 bpc = ocfs2_xattr_buckets_per_cluster(OCFS2_SB(inode->i_sb));
73 u32 num_buckets = clusters * bpc;
74 @@ -2395,14 +2403,12 @@ static int ocfs2_iterate_xattr_buckets(struct inode *inode,
78 - for (j = 0; j < blk_per_bucket; j++)
79 - brelse(bucket.bu_bhs[j]);
80 + ocfs2_xattr_bucket_relse(inode, &bucket);
81 memset(&bucket, 0, sizeof(bucket));
85 - for (j = 0; j < blk_per_bucket; j++)
86 - brelse(bucket.bu_bhs[j]);
87 + ocfs2_xattr_bucket_relse(inode, &bucket);
91 @@ -4554,11 +4560,10 @@ static int ocfs2_xattr_set_entry_index_block(struct inode *inode,
92 struct ocfs2_xattr_header *xh;
93 struct ocfs2_xattr_entry *xe;
94 u16 count, header_size, xh_free_start;
95 - int i, free, max_free, need, old;
96 + int free, max_free, need, old;
97 size_t value_size = 0, name_len = strlen(xi->name);
98 size_t blocksize = inode->i_sb->s_blocksize;
99 int ret, allocation = 0;
100 - u16 blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
102 mlog_entry("Set xattr %s in xattr index block\n", xi->name);
104 @@ -4672,9 +4677,7 @@ try_again:
108 - for (i = 0; i < blk_per_bucket; i++)
109 - brelse(xs->bucket.bu_bhs[i]);
111 + ocfs2_xattr_bucket_relse(inode, &xs->bucket);
112 memset(&xs->bucket, 0, sizeof(xs->bucket));
114 ret = ocfs2_xattr_index_block_find(inode, xs->xattr_bh,