#define bucket_block(_b, _n) ((_b)->bu_bhs[(_n)]->b_data)
#define bucket_xh(_b) ((struct ocfs2_xattr_header *)bucket_block((_b), 0))
+static void ocfs2_xattr_bucket_relse(struct inode *inode,
+ struct ocfs2_xattr_bucket *bucket)
+{
+ int i, blks = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
+
+ for (i = 0; i < blks; i++) {
+ brelse(bucket->bu_bhs[i]);
+ bucket->bu_bhs[i] = NULL;
+ }
+}
+
static inline const char *ocfs2_xattr_prefix(int name_index)
{
struct xattr_handler *handler = NULL;
}
ret = size;
cleanup:
- for (i = 0; i < OCFS2_XATTR_MAX_BLOCKS_PER_BUCKET; i++)
- brelse(xs->bucket.bu_bhs[i]);
+ ocfs2_xattr_bucket_relse(inode, &xs->bucket);
memset(&xs->bucket, 0, sizeof(xs->bucket));
brelse(xs->xattr_bh);
struct buffer_head *di_bh = NULL;
struct ocfs2_dinode *di;
int ret;
- u16 i, blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
struct ocfs2_xattr_info xi = {
.name_index = name_index,
ocfs2_inode_unlock(inode, 1);
brelse(di_bh);
brelse(xbs.xattr_bh);
- for (i = 0; i < blk_per_bucket; i++)
- brelse(xbs.bucket.bu_bhs[i]);
+ ocfs2_xattr_bucket_relse(inode, &xbs.bucket);
return ret;
}
xattr_bucket_func *func,
void *para)
{
- int i, j, ret = 0;
+ int i, ret = 0;
int blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
u32 bpc = ocfs2_xattr_buckets_per_cluster(OCFS2_SB(inode->i_sb));
u32 num_buckets = clusters * bpc;
}
}
- for (j = 0; j < blk_per_bucket; j++)
- brelse(bucket.bu_bhs[j]);
+ ocfs2_xattr_bucket_relse(inode, &bucket);
memset(&bucket, 0, sizeof(bucket));
}
out:
- for (j = 0; j < blk_per_bucket; j++)
- brelse(bucket.bu_bhs[j]);
+ ocfs2_xattr_bucket_relse(inode, &bucket);
return ret;
}
struct ocfs2_xattr_header *xh;
struct ocfs2_xattr_entry *xe;
u16 count, header_size, xh_free_start;
- int i, free, max_free, need, old;
+ int free, max_free, need, old;
size_t value_size = 0, name_len = strlen(xi->name);
size_t blocksize = inode->i_sb->s_blocksize;
int ret, allocation = 0;
- u16 blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
mlog_entry("Set xattr %s in xattr index block\n", xi->name);
goto out;
}
- for (i = 0; i < blk_per_bucket; i++)
- brelse(xs->bucket.bu_bhs[i]);
-
+ ocfs2_xattr_bucket_relse(inode, &xs->bucket);
memset(&xs->bucket, 0, sizeof(xs->bucket));
ret = ocfs2_xattr_index_block_find(inode, xs->xattr_bh,