aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/xattr.c
diff options
context:
space:
mode:
authorJoel Becker <joel.becker@oracle.com>2008-10-27 18:25:18 -0400
committerMark Fasheh <mfasheh@suse.com>2009-01-05 11:34:18 -0500
commit161d6f30f18c4a7e2b24705b6690cce3ff276eb9 (patch)
tree62c392076a86aa752e4fbc3c2611affad50b22ff /fs/ocfs2/xattr.c
parent178eeac354ea28828d5e94a3a7b51368c171d6a5 (diff)
ocfs2: Use buckets in ocfs2_defrag_xattr_bucket().
Use the ocfs2_xattr_bucket abstraction for reading and writing the bucket in ocfs2_defrag_xattr_bucket(). 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.c55
1 files changed, 23 insertions, 32 deletions
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 76969b922002..127a6285078a 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -2894,21 +2894,11 @@ static int ocfs2_defrag_xattr_bucket(struct inode *inode,
2894 struct ocfs2_xattr_header *xh; 2894 struct ocfs2_xattr_header *xh;
2895 char *entries, *buf, *bucket_buf = NULL; 2895 char *entries, *buf, *bucket_buf = NULL;
2896 u64 blkno = bucket_blkno(bucket); 2896 u64 blkno = bucket_blkno(bucket);
2897 u16 blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
2898 u16 xh_free_start; 2897 u16 xh_free_start;
2899 size_t blocksize = inode->i_sb->s_blocksize; 2898 size_t blocksize = inode->i_sb->s_blocksize;
2900 handle_t *handle; 2899 handle_t *handle;
2901 struct buffer_head **bhs;
2902 struct ocfs2_xattr_entry *xe; 2900 struct ocfs2_xattr_entry *xe;
2903 2901 struct ocfs2_xattr_bucket *wb = NULL;
2904 bhs = kzalloc(sizeof(struct buffer_head *) * blk_per_bucket,
2905 GFP_NOFS);
2906 if (!bhs)
2907 return -ENOMEM;
2908
2909 ret = ocfs2_read_blocks(inode, blkno, blk_per_bucket, bhs, 0);
2910 if (ret)
2911 goto out;
2912 2902
2913 /* 2903 /*
2914 * In order to make the operation more efficient and generic, 2904 * In order to make the operation more efficient and generic,
@@ -2922,11 +2912,21 @@ static int ocfs2_defrag_xattr_bucket(struct inode *inode,
2922 goto out; 2912 goto out;
2923 } 2913 }
2924 2914
2915 wb = ocfs2_xattr_bucket_new(inode);
2916 if (!wb) {
2917 ret = -ENOMEM;
2918 goto out;
2919 }
2920
2921 ret = ocfs2_read_xattr_bucket(wb, blkno);
2922 if (ret)
2923 goto out;
2924
2925 buf = bucket_buf; 2925 buf = bucket_buf;
2926 for (i = 0; i < blk_per_bucket; i++, buf += blocksize) 2926 for (i = 0; i < wb->bu_blocks; i++, buf += blocksize)
2927 memcpy(buf, bhs[i]->b_data, blocksize); 2927 memcpy(buf, bucket_block(wb, i), blocksize);
2928 2928
2929 handle = ocfs2_start_trans((OCFS2_SB(inode->i_sb)), blk_per_bucket); 2929 handle = ocfs2_start_trans((OCFS2_SB(inode->i_sb)), wb->bu_blocks);
2930 if (IS_ERR(handle)) { 2930 if (IS_ERR(handle)) {
2931 ret = PTR_ERR(handle); 2931 ret = PTR_ERR(handle);
2932 handle = NULL; 2932 handle = NULL;
@@ -2934,13 +2934,11 @@ static int ocfs2_defrag_xattr_bucket(struct inode *inode,
2934 goto out; 2934 goto out;
2935 } 2935 }
2936 2936
2937 for (i = 0; i < blk_per_bucket; i++) { 2937 ret = ocfs2_xattr_bucket_journal_access(handle, wb,
2938 ret = ocfs2_journal_access(handle, inode, bhs[i], 2938 OCFS2_JOURNAL_ACCESS_WRITE);
2939 OCFS2_JOURNAL_ACCESS_WRITE); 2939 if (ret < 0) {
2940 if (ret < 0) { 2940 mlog_errno(ret);
2941 mlog_errno(ret); 2941 goto commit;
2942 goto commit;
2943 }
2944 } 2942 }
2945 2943
2946 xh = (struct ocfs2_xattr_header *)bucket_buf; 2944 xh = (struct ocfs2_xattr_header *)bucket_buf;
@@ -3009,21 +3007,14 @@ static int ocfs2_defrag_xattr_bucket(struct inode *inode,
3009 cmp_xe, swap_xe); 3007 cmp_xe, swap_xe);
3010 3008
3011 buf = bucket_buf; 3009 buf = bucket_buf;
3012 for (i = 0; i < blk_per_bucket; i++, buf += blocksize) { 3010 for (i = 0; i < wb->bu_blocks; i++, buf += blocksize)
3013 memcpy(bhs[i]->b_data, buf, blocksize); 3011 memcpy(bucket_block(wb, i), buf, blocksize);
3014 ocfs2_journal_dirty(handle, bhs[i]); 3012 ocfs2_xattr_bucket_journal_dirty(handle, wb);
3015 }
3016 3013
3017commit: 3014commit:
3018 ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle); 3015 ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle);
3019out: 3016out:
3020 3017 ocfs2_xattr_bucket_free(wb);
3021 if (bhs) {
3022 for (i = 0; i < blk_per_bucket; i++)
3023 brelse(bhs[i]);
3024 }
3025 kfree(bhs);
3026
3027 kfree(bucket_buf); 3018 kfree(bucket_buf);
3028 return ret; 3019 return ret;
3029} 3020}