]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/patches/suse-2.6.27.31/patches.suse/ocfs2-Use-buckets-in-ocfs2_defrag_xattr_bucket.patch
Move xen patchset to new version's subdir.
[people/pmueller/ipfire-2.x.git] / src / patches / suse-2.6.27.31 / patches.suse / ocfs2-Use-buckets-in-ocfs2_defrag_xattr_bucket.patch
CommitLineData
00e5a55c
BS
1From: Joel Becker <joel.becker@oracle.com>
2Date: Mon, 27 Oct 2008 15:25:18 -0700
3Subject: ocfs2: Use buckets in ocfs2_defrag_xattr_bucket().
4Patch-mainline: 2.6.29
5
6Use the ocfs2_xattr_bucket abstraction for reading and writing the
7bucket in ocfs2_defrag_xattr_bucket().
8
9Signed-off-by: Joel Becker <joel.becker@oracle.com>
10Signed-off-by: Mark Fasheh <mfasheh@suse.com>
11---
12 fs/ocfs2/xattr.c | 55 ++++++++++++++++++++++-------------------------------
13 1 files changed, 23 insertions(+), 32 deletions(-)
14
15diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
16index 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);
24 u16 xh_free_start;
25 size_t blocksize = inode->i_sb->s_blocksize;
26 handle_t *handle;
27- struct buffer_head **bhs;
28 struct ocfs2_xattr_entry *xe;
29-
30- bhs = kzalloc(sizeof(struct buffer_head *) * blk_per_bucket,
31- GFP_NOFS);
32- if (!bhs)
33- return -ENOMEM;
34-
35- ret = ocfs2_read_blocks(inode, blkno, blk_per_bucket, bhs, 0);
36- if (ret)
37- goto out;
38+ struct ocfs2_xattr_bucket *wb = NULL;
39
40 /*
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,
43 goto out;
44 }
45
46+ wb = ocfs2_xattr_bucket_new(inode);
47+ if (!wb) {
48+ ret = -ENOMEM;
49+ goto out;
50+ }
51+
52+ ret = ocfs2_read_xattr_bucket(wb, blkno);
53+ if (ret)
54+ goto out;
55+
56 buf = bucket_buf;
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);
61
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);
64 if (IS_ERR(handle)) {
65 ret = PTR_ERR(handle);
66 handle = NULL;
67@@ -2934,13 +2934,11 @@ static int ocfs2_defrag_xattr_bucket(struct inode *inode,
68 goto out;
69 }
70
71- for (i = 0; i < blk_per_bucket; i++) {
72- ret = ocfs2_journal_access(handle, inode, bhs[i],
73- OCFS2_JOURNAL_ACCESS_WRITE);
74- if (ret < 0) {
75- mlog_errno(ret);
76- goto commit;
77- }
78+ ret = ocfs2_xattr_bucket_journal_access(handle, wb,
79+ OCFS2_JOURNAL_ACCESS_WRITE);
80+ if (ret < 0) {
81+ mlog_errno(ret);
82+ goto commit;
83 }
84
85 xh = (struct ocfs2_xattr_header *)bucket_buf;
86@@ -3009,21 +3007,14 @@ static int ocfs2_defrag_xattr_bucket(struct inode *inode,
87 cmp_xe, swap_xe);
88
89 buf = bucket_buf;
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]);
93- }
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);
97
98 commit:
99 ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle);
100 out:
101-
102- if (bhs) {
103- for (i = 0; i < blk_per_bucket; i++)
104- brelse(bhs[i]);
105- }
106- kfree(bhs);
107-
108+ ocfs2_xattr_bucket_free(wb);
109 kfree(bucket_buf);
110 return ret;
111 }
112--
1131.5.6
114