]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/patches/suse-2.6.27.25/patches.suse/ocfs2-Wrap-journal_access-journal_dirty-for-xattr-b.patch
Updated xen patches taken from suse.
[people/teissler/ipfire-2.x.git] / src / patches / suse-2.6.27.25 / patches.suse / ocfs2-Wrap-journal_access-journal_dirty-for-xattr-b.patch
1 From: Joel Becker <joel.becker@oracle.com>
2 Date: Fri, 24 Oct 2008 18:47:33 -0700
3 Subject: ocfs2: Wrap journal_access/journal_dirty for xattr buckets.
4 Patch-mainline: 2.6.29
5
6 A common action is to call ocfs2_journal_access() and
7 ocfs2_journal_dirty() on the buffer heads of an xattr bucket. Let's
8 create nice wrappers.
9
10 While we're there, let's drop the places that try to be smart by writing
11 only the first and last blocks of a bucket. A bucket is contiguous, so
12 writing the whole thing is actually more efficient.
13
14 Signed-off-by: Joel Becker <joel.becker@oracle.com>
15 Signed-off-by: Mark Fasheh <mfasheh@suse.com>
16 ---
17 fs/ocfs2/xattr.c | 140 +++++++++++++++++++++++++-----------------------------
18 1 files changed, 64 insertions(+), 76 deletions(-)
19
20 diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
21 index fa13fa4..99aefe4 100644
22 --- a/fs/ocfs2/xattr.c
23 +++ b/fs/ocfs2/xattr.c
24 @@ -210,6 +210,37 @@ static int ocfs2_read_xattr_bucket(struct inode *inode,
25 return rc;
26 }
27
28 +static int ocfs2_xattr_bucket_journal_access(handle_t *handle,
29 + struct inode *inode,
30 + struct ocfs2_xattr_bucket *bucket,
31 + int type)
32 +{
33 + int i, rc = 0;
34 + int blks = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
35 +
36 + for (i = 0; i < blks; i++) {
37 + rc = ocfs2_journal_access(handle, inode,
38 + bucket->bu_bhs[i], type);
39 + if (rc) {
40 + mlog_errno(rc);
41 + break;
42 + }
43 + }
44 +
45 + return rc;
46 +}
47 +
48 +static void ocfs2_xattr_bucket_journal_dirty(handle_t *handle,
49 + struct inode *inode,
50 + struct ocfs2_xattr_bucket *bucket)
51 +{
52 + int i, blks = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
53 +
54 + for (i = 0; i < blks; i++)
55 + ocfs2_journal_dirty(handle, bucket->bu_bhs[i]);
56 +}
57 +
58 +
59 static inline const char *ocfs2_xattr_prefix(int name_index)
60 {
61 struct xattr_handler *handler = NULL;
62 @@ -3218,8 +3249,8 @@ static int ocfs2_divide_xattr_bucket(struct inode *inode,
63 goto out;
64 }
65
66 - ret = ocfs2_journal_access(handle, inode, s_bucket.bu_bhs[0],
67 - OCFS2_JOURNAL_ACCESS_WRITE);
68 + ret = ocfs2_xattr_bucket_journal_access(handle, inode, &s_bucket,
69 + OCFS2_JOURNAL_ACCESS_WRITE);
70 if (ret) {
71 mlog_errno(ret);
72 goto out;
73 @@ -3235,15 +3266,13 @@ static int ocfs2_divide_xattr_bucket(struct inode *inode,
74 goto out;
75 }
76
77 - for (i = 0; i < blk_per_bucket; i++) {
78 - ret = ocfs2_journal_access(handle, inode, t_bucket.bu_bhs[i],
79 - new_bucket_head ?
80 - OCFS2_JOURNAL_ACCESS_CREATE :
81 - OCFS2_JOURNAL_ACCESS_WRITE);
82 - if (ret) {
83 - mlog_errno(ret);
84 - goto out;
85 - }
86 + ret = ocfs2_xattr_bucket_journal_access(handle, inode, &t_bucket,
87 + new_bucket_head ?
88 + OCFS2_JOURNAL_ACCESS_CREATE :
89 + OCFS2_JOURNAL_ACCESS_WRITE);
90 + if (ret) {
91 + mlog_errno(ret);
92 + goto out;
93 }
94
95 xh = bucket_xh(&s_bucket);
96 @@ -3339,11 +3368,7 @@ set_num_buckets:
97 else
98 xh->xh_num_buckets = 0;
99
100 - for (i = 0; i < blk_per_bucket; i++) {
101 - ocfs2_journal_dirty(handle, t_bucket.bu_bhs[i]);
102 - if (ret)
103 - mlog_errno(ret);
104 - }
105 + ocfs2_xattr_bucket_journal_dirty(handle, inode, &t_bucket);
106
107 /* store the first_hash of the new bucket. */
108 if (first_hash)
109 @@ -3364,9 +3389,7 @@ set_num_buckets:
110 xh->xh_free_start = cpu_to_le16(name_offset);
111 xh->xh_name_value_len = cpu_to_le16(name_value_len);
112
113 - ocfs2_journal_dirty(handle, s_bucket.bu_bhs[0]);
114 - if (ret)
115 - mlog_errno(ret);
116 + ocfs2_xattr_bucket_journal_dirty(handle, inode, &s_bucket);
117
118 out:
119 ocfs2_xattr_bucket_relse(inode, &s_bucket);
120 @@ -3413,20 +3436,18 @@ static int ocfs2_cp_xattr_bucket(struct inode *inode,
121 if (ret)
122 goto out;
123
124 - for (i = 0; i < blk_per_bucket; i++) {
125 - ret = ocfs2_journal_access(handle, inode, t_bucket.bu_bhs[i],
126 - t_is_new ?
127 - OCFS2_JOURNAL_ACCESS_CREATE :
128 - OCFS2_JOURNAL_ACCESS_WRITE);
129 - if (ret)
130 - goto out;
131 - }
132 + ret = ocfs2_xattr_bucket_journal_access(handle, inode, &t_bucket,
133 + t_is_new ?
134 + OCFS2_JOURNAL_ACCESS_CREATE :
135 + OCFS2_JOURNAL_ACCESS_WRITE);
136 + if (ret)
137 + goto out;
138
139 for (i = 0; i < blk_per_bucket; i++) {
140 memcpy(bucket_block(&t_bucket, i), bucket_block(&s_bucket, i),
141 blocksize);
142 - ocfs2_journal_dirty(handle, t_bucket.bu_bhs[i]);
143 }
144 + ocfs2_xattr_bucket_journal_dirty(handle, inode, &t_bucket);
145
146 out:
147 ocfs2_xattr_bucket_relse(inode, &s_bucket);
148 @@ -3799,9 +3820,9 @@ static int ocfs2_extend_xattr_bucket(struct inode *inode,
149
150 /*
151 * We will touch all the buckets after the start_bh(include it).
152 - * Add one more bucket and modify the first_bh.
153 + * Then we add one more bucket.
154 */
155 - credits = end_blk - start_blk + 2 * blk_per_bucket + 1;
156 + credits = end_blk - start_blk + 3 * blk_per_bucket + 1;
157 handle = ocfs2_start_trans(osb, credits);
158 if (IS_ERR(handle)) {
159 ret = PTR_ERR(handle);
160 @@ -4077,33 +4098,6 @@ set_new_name_value:
161 return;
162 }
163
164 -static int ocfs2_xattr_bucket_handle_journal(struct inode *inode,
165 - handle_t *handle,
166 - struct ocfs2_xattr_search *xs,
167 - struct buffer_head **bhs,
168 - u16 bh_num)
169 -{
170 - int ret = 0, off, block_off;
171 - struct ocfs2_xattr_entry *xe = xs->here;
172 -
173 - /*
174 - * First calculate all the blocks we should journal_access
175 - * and journal_dirty. The first block should always be touched.
176 - */
177 - ret = ocfs2_journal_dirty(handle, bhs[0]);
178 - if (ret)
179 - mlog_errno(ret);
180 -
181 - /* calc the data. */
182 - off = le16_to_cpu(xe->xe_name_offset);
183 - block_off = off >> inode->i_sb->s_blocksize_bits;
184 - ret = ocfs2_journal_dirty(handle, bhs[block_off]);
185 - if (ret)
186 - mlog_errno(ret);
187 -
188 - return ret;
189 -}
190 -
191 /*
192 * Set the xattr entry in the specified bucket.
193 * The bucket is indicated by xs->bucket and it should have the enough
194 @@ -4115,7 +4109,7 @@ static int ocfs2_xattr_set_entry_in_bucket(struct inode *inode,
195 u32 name_hash,
196 int local)
197 {
198 - int i, ret;
199 + int ret;
200 handle_t *handle = NULL;
201 u16 blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
202 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
203 @@ -4143,22 +4137,16 @@ static int ocfs2_xattr_set_entry_in_bucket(struct inode *inode,
204 goto out;
205 }
206
207 - for (i = 0; i < blk_per_bucket; i++) {
208 - ret = ocfs2_journal_access(handle, inode, xs->bucket.bu_bhs[i],
209 - OCFS2_JOURNAL_ACCESS_WRITE);
210 - if (ret < 0) {
211 - mlog_errno(ret);
212 - goto out;
213 - }
214 + ret = ocfs2_xattr_bucket_journal_access(handle, inode, &xs->bucket,
215 + OCFS2_JOURNAL_ACCESS_WRITE);
216 + if (ret < 0) {
217 + mlog_errno(ret);
218 + goto out;
219 }
220
221 ocfs2_xattr_set_entry_normal(inode, xi, xs, name_hash, local);
222 + ocfs2_xattr_bucket_journal_dirty(handle, inode, &xs->bucket);
223
224 - /*Only dirty the blocks we have touched in set xattr. */
225 - ret = ocfs2_xattr_bucket_handle_journal(inode, handle, xs,
226 - xs->bucket.bu_bhs, blk_per_bucket);
227 - if (ret)
228 - mlog_errno(ret);
229 out:
230 ocfs2_commit_trans(osb, handle);
231
232 @@ -4398,15 +4386,16 @@ static void ocfs2_xattr_bucket_remove_xs(struct inode *inode,
233 le16_to_cpu(xh->xh_count) - 1];
234 int ret = 0;
235
236 - handle = ocfs2_start_trans((OCFS2_SB(inode->i_sb)), 1);
237 + handle = ocfs2_start_trans((OCFS2_SB(inode->i_sb)),
238 + ocfs2_blocks_per_xattr_bucket(inode->i_sb));
239 if (IS_ERR(handle)) {
240 ret = PTR_ERR(handle);
241 mlog_errno(ret);
242 return;
243 }
244
245 - ret = ocfs2_journal_access(handle, inode, xs->bucket.bu_bhs[0],
246 - OCFS2_JOURNAL_ACCESS_WRITE);
247 + ret = ocfs2_xattr_bucket_journal_access(handle, inode, &xs->bucket,
248 + OCFS2_JOURNAL_ACCESS_WRITE);
249 if (ret) {
250 mlog_errno(ret);
251 goto out_commit;
252 @@ -4418,9 +4407,8 @@ static void ocfs2_xattr_bucket_remove_xs(struct inode *inode,
253 memset(last, 0, sizeof(struct ocfs2_xattr_entry));
254 le16_add_cpu(&xh->xh_count, -1);
255
256 - ret = ocfs2_journal_dirty(handle, xs->bucket.bu_bhs[0]);
257 - if (ret < 0)
258 - mlog_errno(ret);
259 + ocfs2_xattr_bucket_journal_dirty(handle, inode, &xs->bucket);
260 +
261 out_commit:
262 ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle);
263 }
264 --
265 1.5.6
266