aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/xattr.c
diff options
context:
space:
mode:
authorJoel Becker <joel.becker@oracle.com>2008-10-24 21:54:43 -0400
committerMark Fasheh <mfasheh@suse.com>2009-01-05 11:34:17 -0500
commit4980c6daba967124ed6420032960abd2b48412e2 (patch)
treec5220ec03222db04972ddba0daaca6c112f51b57 /fs/ocfs2/xattr.c
parent1224be020f62ada3e19822feeac3840abf80de3e (diff)
ocfs2: Copy xattr buckets with a dedicated function.
Now that the places that copy whole buckets are using struct ocfs2_xattr_bucket, we can do the copy in a dedicated function. Signed-off-by: Joel Becker <joel.becker@oracle.com> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs/ocfs2/xattr.c')
-rw-r--r--fs/ocfs2/xattr.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 99aefe4ea750..71d9e7bdd30a 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -240,6 +240,19 @@ static void ocfs2_xattr_bucket_journal_dirty(handle_t *handle,
240 ocfs2_journal_dirty(handle, bucket->bu_bhs[i]); 240 ocfs2_journal_dirty(handle, bucket->bu_bhs[i]);
241} 241}
242 242
243static void ocfs2_xattr_bucket_copy_data(struct inode *inode,
244 struct ocfs2_xattr_bucket *dest,
245 struct ocfs2_xattr_bucket *src)
246{
247 int i;
248 int blocksize = inode->i_sb->s_blocksize;
249 int blks = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
250
251 for (i = 0; i < blks; i++) {
252 memcpy(bucket_block(dest, i), bucket_block(src, i),
253 blocksize);
254 }
255}
243 256
244static inline const char *ocfs2_xattr_prefix(int name_index) 257static inline const char *ocfs2_xattr_prefix(int name_index)
245{ 258{
@@ -3299,9 +3312,7 @@ static int ocfs2_divide_xattr_bucket(struct inode *inode,
3299 } 3312 }
3300 3313
3301 /* copy the whole bucket to the new first. */ 3314 /* copy the whole bucket to the new first. */
3302 for (i = 0; i < blk_per_bucket; i++) 3315 ocfs2_xattr_bucket_copy_data(inode, &t_bucket, &s_bucket);
3303 memcpy(bucket_block(&t_bucket, i), bucket_block(&s_bucket, i),
3304 blocksize);
3305 3316
3306 /* update the new bucket. */ 3317 /* update the new bucket. */
3307 xh = bucket_xh(&t_bucket); 3318 xh = bucket_xh(&t_bucket);
@@ -3410,9 +3421,7 @@ static int ocfs2_cp_xattr_bucket(struct inode *inode,
3410 u64 t_blkno, 3421 u64 t_blkno,
3411 int t_is_new) 3422 int t_is_new)
3412{ 3423{
3413 int ret, i; 3424 int ret;
3414 int blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
3415 int blocksize = inode->i_sb->s_blocksize;
3416 struct ocfs2_xattr_bucket s_bucket, t_bucket; 3425 struct ocfs2_xattr_bucket s_bucket, t_bucket;
3417 3426
3418 BUG_ON(s_blkno == t_blkno); 3427 BUG_ON(s_blkno == t_blkno);
@@ -3443,10 +3452,7 @@ static int ocfs2_cp_xattr_bucket(struct inode *inode,
3443 if (ret) 3452 if (ret)
3444 goto out; 3453 goto out;
3445 3454
3446 for (i = 0; i < blk_per_bucket; i++) { 3455 ocfs2_xattr_bucket_copy_data(inode, &t_bucket, &s_bucket);
3447 memcpy(bucket_block(&t_bucket, i), bucket_block(&s_bucket, i),
3448 blocksize);
3449 }
3450 ocfs2_xattr_bucket_journal_dirty(handle, inode, &t_bucket); 3456 ocfs2_xattr_bucket_journal_dirty(handle, inode, &t_bucket);
3451 3457
3452out: 3458out: