1 From: Joel Becker <joel.becker@oracle.com>
2 Date: Mon, 27 Oct 2008 15:25:18 -0700
3 Subject: ocfs2: Use buckets in ocfs2_defrag_xattr_bucket().
6 Use the ocfs2_xattr_bucket abstraction for reading and writing the
7 bucket in ocfs2_defrag_xattr_bucket().
9 Signed-off-by: Joel Becker <joel.becker@oracle.com>
10 Signed-off-by: Mark Fasheh <mfasheh@suse.com>
12 fs/ocfs2/xattr.c | 55 ++++++++++++++++++++++-------------------------------
13 1 files changed, 23 insertions(+), 32 deletions(-)
15 diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
16 index 76969b9..127a628 100644
17 --- a/fs/ocfs2/xattr.c
18 +++ b/fs/ocfs2/xattr.c
19 @@ -2894,21 +2894,11 @@ static int ocfs2_defrag_xattr_bucket(struct inode *inode,
20 struct ocfs2_xattr_header *xh;
21 char *entries, *buf, *bucket_buf = NULL;
22 u64 blkno = bucket_blkno(bucket);
23 - u16 blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
25 size_t blocksize = inode->i_sb->s_blocksize;
27 - struct buffer_head **bhs;
28 struct ocfs2_xattr_entry *xe;
30 - bhs = kzalloc(sizeof(struct buffer_head *) * blk_per_bucket,
35 - ret = ocfs2_read_blocks(inode, blkno, blk_per_bucket, bhs, 0);
38 + struct ocfs2_xattr_bucket *wb = NULL;
41 * In order to make the operation more efficient and generic,
42 @@ -2922,11 +2912,21 @@ static int ocfs2_defrag_xattr_bucket(struct inode *inode,
46 + wb = ocfs2_xattr_bucket_new(inode);
52 + ret = ocfs2_read_xattr_bucket(wb, blkno);
57 - for (i = 0; i < blk_per_bucket; i++, buf += blocksize)
58 - memcpy(buf, bhs[i]->b_data, blocksize);
59 + for (i = 0; i < wb->bu_blocks; i++, buf += blocksize)
60 + memcpy(buf, bucket_block(wb, i), blocksize);
62 - handle = ocfs2_start_trans((OCFS2_SB(inode->i_sb)), blk_per_bucket);
63 + handle = ocfs2_start_trans((OCFS2_SB(inode->i_sb)), wb->bu_blocks);
65 ret = PTR_ERR(handle);
67 @@ -2934,13 +2934,11 @@ static int ocfs2_defrag_xattr_bucket(struct inode *inode,
71 - for (i = 0; i < blk_per_bucket; i++) {
72 - ret = ocfs2_journal_access(handle, inode, bhs[i],
73 - OCFS2_JOURNAL_ACCESS_WRITE);
78 + ret = ocfs2_xattr_bucket_journal_access(handle, wb,
79 + OCFS2_JOURNAL_ACCESS_WRITE);
85 xh = (struct ocfs2_xattr_header *)bucket_buf;
86 @@ -3009,21 +3007,14 @@ static int ocfs2_defrag_xattr_bucket(struct inode *inode,
90 - for (i = 0; i < blk_per_bucket; i++, buf += blocksize) {
91 - memcpy(bhs[i]->b_data, buf, blocksize);
92 - ocfs2_journal_dirty(handle, bhs[i]);
94 + for (i = 0; i < wb->bu_blocks; i++, buf += blocksize)
95 + memcpy(bucket_block(wb, i), buf, blocksize);
96 + ocfs2_xattr_bucket_journal_dirty(handle, wb);
99 ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle);
103 - for (i = 0; i < blk_per_bucket; i++)
108 + ocfs2_xattr_bucket_free(wb);