1 From: Tao Ma <tao.ma@oracle.com>
2 Date: Thu, 6 Nov 2008 08:10:47 +0800
3 Subject: ocfs2/xattr: Remove additional bucket allocation in bucket defragment.
6 Joel has refactored xattr bucket and make xattr bucket a general
7 wrapper. So in ocfs2_defrag_xattr_bucket, we have already passed the
8 bucket in, so there is no need to allocate a new one and read it.
10 Signed-off-by: Tao Ma <tao.ma@oracle.com>
11 Signed-off-by: Joel Becker <joel.becker@oracle.com>
12 Signed-off-by: Mark Fasheh <mfasheh@suse.com>
14 fs/ocfs2/xattr.c | 26 +++++++-------------------
15 1 files changed, 7 insertions(+), 19 deletions(-)
17 diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
18 index 029a9f4..87cf39d 100644
19 --- a/fs/ocfs2/xattr.c
20 +++ b/fs/ocfs2/xattr.c
21 @@ -2898,7 +2898,6 @@ static int ocfs2_defrag_xattr_bucket(struct inode *inode,
22 size_t blocksize = inode->i_sb->s_blocksize;
24 struct ocfs2_xattr_entry *xe;
25 - struct ocfs2_xattr_bucket *wb = NULL;
28 * In order to make the operation more efficient and generic,
29 @@ -2912,21 +2911,11 @@ static int ocfs2_defrag_xattr_bucket(struct inode *inode,
33 - wb = ocfs2_xattr_bucket_new(inode);
39 - ret = ocfs2_read_xattr_bucket(wb, blkno);
44 - for (i = 0; i < wb->bu_blocks; i++, buf += blocksize)
45 - memcpy(buf, bucket_block(wb, i), blocksize);
46 + for (i = 0; i < bucket->bu_blocks; i++, buf += blocksize)
47 + memcpy(buf, bucket_block(bucket, i), blocksize);
49 - handle = ocfs2_start_trans((OCFS2_SB(inode->i_sb)), wb->bu_blocks);
50 + handle = ocfs2_start_trans((OCFS2_SB(inode->i_sb)), bucket->bu_blocks);
52 ret = PTR_ERR(handle);
54 @@ -2934,7 +2923,7 @@ static int ocfs2_defrag_xattr_bucket(struct inode *inode,
58 - ret = ocfs2_xattr_bucket_journal_access(handle, wb,
59 + ret = ocfs2_xattr_bucket_journal_access(handle, bucket,
60 OCFS2_JOURNAL_ACCESS_WRITE);
63 @@ -3007,14 +2996,13 @@ static int ocfs2_defrag_xattr_bucket(struct inode *inode,
67 - for (i = 0; i < wb->bu_blocks; i++, buf += blocksize)
68 - memcpy(bucket_block(wb, i), buf, blocksize);
69 - ocfs2_xattr_bucket_journal_dirty(handle, wb);
70 + for (i = 0; i < bucket->bu_blocks; i++, buf += blocksize)
71 + memcpy(bucket_block(bucket, i), buf, blocksize);
72 + ocfs2_xattr_bucket_journal_dirty(handle, bucket);
75 ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle);
77 - ocfs2_xattr_bucket_free(wb);