1 From: Joel Becker <joel.becker@oracle.com>
2 Date: Fri, 24 Oct 2008 18:54:43 -0700
3 Subject: ocfs2: Copy xattr buckets with a dedicated function.
6 Now that the places that copy whole buckets are using struct
7 ocfs2_xattr_bucket, we can do the copy in a dedicated function.
9 Signed-off-by: Joel Becker <joel.becker@oracle.com>
10 Signed-off-by: Mark Fasheh <mfasheh@suse.com>
12 fs/ocfs2/xattr.c | 26 ++++++++++++++++----------
13 1 files changed, 16 insertions(+), 10 deletions(-)
15 diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
16 index 99aefe4..71d9e7b 100644
17 --- a/fs/ocfs2/xattr.c
18 +++ b/fs/ocfs2/xattr.c
19 @@ -240,6 +240,19 @@ static void ocfs2_xattr_bucket_journal_dirty(handle_t *handle,
20 ocfs2_journal_dirty(handle, bucket->bu_bhs[i]);
23 +static void ocfs2_xattr_bucket_copy_data(struct inode *inode,
24 + struct ocfs2_xattr_bucket *dest,
25 + struct ocfs2_xattr_bucket *src)
28 + int blocksize = inode->i_sb->s_blocksize;
29 + int blks = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
31 + for (i = 0; i < blks; i++) {
32 + memcpy(bucket_block(dest, i), bucket_block(src, i),
37 static inline const char *ocfs2_xattr_prefix(int name_index)
39 @@ -3299,9 +3312,7 @@ static int ocfs2_divide_xattr_bucket(struct inode *inode,
42 /* copy the whole bucket to the new first. */
43 - for (i = 0; i < blk_per_bucket; i++)
44 - memcpy(bucket_block(&t_bucket, i), bucket_block(&s_bucket, i),
46 + ocfs2_xattr_bucket_copy_data(inode, &t_bucket, &s_bucket);
48 /* update the new bucket. */
49 xh = bucket_xh(&t_bucket);
50 @@ -3410,9 +3421,7 @@ static int ocfs2_cp_xattr_bucket(struct inode *inode,
55 - int blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
56 - int blocksize = inode->i_sb->s_blocksize;
58 struct ocfs2_xattr_bucket s_bucket, t_bucket;
60 BUG_ON(s_blkno == t_blkno);
61 @@ -3443,10 +3452,7 @@ static int ocfs2_cp_xattr_bucket(struct inode *inode,
65 - for (i = 0; i < blk_per_bucket; i++) {
66 - memcpy(bucket_block(&t_bucket, i), bucket_block(&s_bucket, i),
69 + ocfs2_xattr_bucket_copy_data(inode, &t_bucket, &s_bucket);
70 ocfs2_xattr_bucket_journal_dirty(handle, inode, &t_bucket);