aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ocfs2')
-rw-r--r--fs/ocfs2/xattr.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 1b77302b54ff..3478ad177b7f 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -157,6 +157,17 @@ static inline u16 ocfs2_xattr_max_xe_in_bucket(struct super_block *sb)
157#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)) 158#define bucket_xh(_b) ((struct ocfs2_xattr_header *)bucket_block((_b), 0))
159 159
160static void ocfs2_xattr_bucket_relse(struct inode *inode,
161 struct ocfs2_xattr_bucket *bucket)
162{
163 int i, blks = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
164
165 for (i = 0; i < blks; i++) {
166 brelse(bucket->bu_bhs[i]);
167 bucket->bu_bhs[i] = NULL;
168 }
169}
170
160static inline const char *ocfs2_xattr_prefix(int name_index) 171static inline const char *ocfs2_xattr_prefix(int name_index)
161{ 172{
162 struct xattr_handler *handler = NULL; 173 struct xattr_handler *handler = NULL;
@@ -820,8 +831,7 @@ static int ocfs2_xattr_block_get(struct inode *inode,
820 } 831 }
821 ret = size; 832 ret = size;
822cleanup: 833cleanup:
823 for (i = 0; i < OCFS2_XATTR_MAX_BLOCKS_PER_BUCKET; i++) 834 ocfs2_xattr_bucket_relse(inode, &xs->bucket);
824 brelse(xs->bucket.bu_bhs[i]);
825 memset(&xs->bucket, 0, sizeof(xs->bucket)); 835 memset(&xs->bucket, 0, sizeof(xs->bucket));
826 836
827 brelse(xs->xattr_bh); 837 brelse(xs->xattr_bh);
@@ -1932,7 +1942,6 @@ int ocfs2_xattr_set(struct inode *inode,
1932 struct buffer_head *di_bh = NULL; 1942 struct buffer_head *di_bh = NULL;
1933 struct ocfs2_dinode *di; 1943 struct ocfs2_dinode *di;
1934 int ret; 1944 int ret;
1935 u16 i, blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
1936 1945
1937 struct ocfs2_xattr_info xi = { 1946 struct ocfs2_xattr_info xi = {
1938 .name_index = name_index, 1947 .name_index = name_index,
@@ -2034,8 +2043,7 @@ cleanup:
2034 ocfs2_inode_unlock(inode, 1); 2043 ocfs2_inode_unlock(inode, 1);
2035 brelse(di_bh); 2044 brelse(di_bh);
2036 brelse(xbs.xattr_bh); 2045 brelse(xbs.xattr_bh);
2037 for (i = 0; i < blk_per_bucket; i++) 2046 ocfs2_xattr_bucket_relse(inode, &xbs.bucket);
2038 brelse(xbs.bucket.bu_bhs[i]);
2039 2047
2040 return ret; 2048 return ret;
2041} 2049}
@@ -2358,7 +2366,7 @@ static int ocfs2_iterate_xattr_buckets(struct inode *inode,
2358 xattr_bucket_func *func, 2366 xattr_bucket_func *func,
2359 void *para) 2367 void *para)
2360{ 2368{
2361 int i, j, ret = 0; 2369 int i, ret = 0;
2362 int blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb); 2370 int blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
2363 u32 bpc = ocfs2_xattr_buckets_per_cluster(OCFS2_SB(inode->i_sb)); 2371 u32 bpc = ocfs2_xattr_buckets_per_cluster(OCFS2_SB(inode->i_sb));
2364 u32 num_buckets = clusters * bpc; 2372 u32 num_buckets = clusters * bpc;
@@ -2395,14 +2403,12 @@ static int ocfs2_iterate_xattr_buckets(struct inode *inode,
2395 } 2403 }
2396 } 2404 }
2397 2405
2398 for (j = 0; j < blk_per_bucket; j++) 2406 ocfs2_xattr_bucket_relse(inode, &bucket);
2399 brelse(bucket.bu_bhs[j]);
2400 memset(&bucket, 0, sizeof(bucket)); 2407 memset(&bucket, 0, sizeof(bucket));
2401 } 2408 }
2402 2409
2403out: 2410out:
2404 for (j = 0; j < blk_per_bucket; j++) 2411 ocfs2_xattr_bucket_relse(inode, &bucket);
2405 brelse(bucket.bu_bhs[j]);
2406 2412
2407 return ret; 2413 return ret;
2408} 2414}
@@ -4554,11 +4560,10 @@ static int ocfs2_xattr_set_entry_index_block(struct inode *inode,
4554 struct ocfs2_xattr_header *xh; 4560 struct ocfs2_xattr_header *xh;
4555 struct ocfs2_xattr_entry *xe; 4561 struct ocfs2_xattr_entry *xe;
4556 u16 count, header_size, xh_free_start; 4562 u16 count, header_size, xh_free_start;
4557 int i, free, max_free, need, old; 4563 int free, max_free, need, old;
4558 size_t value_size = 0, name_len = strlen(xi->name); 4564 size_t value_size = 0, name_len = strlen(xi->name);
4559 size_t blocksize = inode->i_sb->s_blocksize; 4565 size_t blocksize = inode->i_sb->s_blocksize;
4560 int ret, allocation = 0; 4566 int ret, allocation = 0;
4561 u16 blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
4562 4567
4563 mlog_entry("Set xattr %s in xattr index block\n", xi->name); 4568 mlog_entry("Set xattr %s in xattr index block\n", xi->name);
4564 4569
@@ -4672,9 +4677,7 @@ try_again:
4672 goto out; 4677 goto out;
4673 } 4678 }
4674 4679
4675 for (i = 0; i < blk_per_bucket; i++) 4680 ocfs2_xattr_bucket_relse(inode, &xs->bucket);
4676 brelse(xs->bucket.bu_bhs[i]);
4677
4678 memset(&xs->bucket, 0, sizeof(xs->bucket)); 4681 memset(&xs->bucket, 0, sizeof(xs->bucket));
4679 4682
4680 ret = ocfs2_xattr_index_block_find(inode, xs->xattr_bh, 4683 ret = ocfs2_xattr_index_block_find(inode, xs->xattr_bh,