]>
Commit | Line | Data |
---|---|---|
2cb7cef9 BS |
1 | From: Joel Becker <joel.becker@oracle.com> |
2 | Subject: ocfs2: Switch over to JBD2. | |
3 | Patch-mainline: 2.6.28? | |
4 | References: FATE302877 | |
5 | ||
6 | ocfs2 wants JBD2 for many reasons, not the least of which is that JBD is | |
7 | limiting our maximum filesystem size. | |
8 | ||
9 | It's a pretty trivial change. Most functions are just renamed. The | |
10 | only functional change is moving to Jan's inode-based ordered data mode. | |
11 | It's better, too. | |
12 | ||
13 | Because JBD2 reads and writes JBD journals, this is compatible with any | |
14 | existing filesystem. It can even interact with JBD-based ocfs2 as long | |
15 | as the journal is formated for JBD. | |
16 | ||
17 | We provide a compatibility option so that paranoid people can still use | |
18 | JBD for the time being. This will go away shortly. | |
19 | ||
20 | [ Moved call of ocfs2_begin_ordered_truncate() from ocfs2_delete_inode() to | |
21 | ocfs2_truncate_for_delete(). --Mark ] | |
22 | ||
23 | Signed-off-by: Joel Becker <joel.becker@oracle.com> | |
24 | Signed-off-by: Mark Fasheh <mfasheh@suse.com> | |
25 | --- | |
26 | fs/Kconfig | 40 +++++++++++++-------- | |
27 | fs/ocfs2/alloc.c | 28 +++++---------- | |
28 | fs/ocfs2/aops.c | 21 ++++++++--- | |
29 | fs/ocfs2/file.c | 14 +++++-- | |
30 | fs/ocfs2/inode.c | 5 ++ | |
31 | fs/ocfs2/inode.h | 1 | |
32 | fs/ocfs2/journal.c | 72 ++++++++++++++++++++------------------ | |
33 | fs/ocfs2/journal.h | 25 +++++++++++-- | |
34 | fs/ocfs2/ocfs2.h | 7 +++ | |
35 | fs/ocfs2/ocfs2_jbd_compat.h | 82 ++++++++++++++++++++++++++++++++++++++++++++ | |
36 | fs/ocfs2/super.c | 10 +++-- | |
37 | fs/ocfs2/uptodate.c | 6 ++- | |
38 | 12 files changed, 227 insertions(+), 84 deletions(-) | |
39 | create mode 100644 fs/ocfs2/ocfs2_jbd_compat.h | |
40 | ||
41 | --- a/fs/Kconfig | |
42 | +++ b/fs/Kconfig | |
43 | @@ -206,17 +206,16 @@ config JBD | |
44 | tristate | |
45 | help | |
46 | This is a generic journalling layer for block devices. It is | |
47 | - currently used by the ext3 and OCFS2 file systems, but it could | |
48 | - also be used to add journal support to other file systems or block | |
49 | + currently used by the ext3 file system, but it could also be | |
50 | + used to add journal support to other file systems or block | |
51 | devices such as RAID or LVM. | |
52 | ||
53 | - If you are using the ext3 or OCFS2 file systems, you need to | |
54 | - say Y here. If you are not using ext3 OCFS2 then you will probably | |
55 | - want to say N. | |
56 | + If you are using the ext3 file system, you need to say Y here. | |
57 | + If you are not using ext3 then you will probably want to say N. | |
58 | ||
59 | To compile this device as a module, choose M here: the module will be | |
60 | - called jbd. If you are compiling ext3 or OCFS2 into the kernel, | |
61 | - you cannot compile this code as a module. | |
62 | + called jbd. If you are compiling ext3 into the kernel, you | |
63 | + cannot compile this code as a module. | |
64 | ||
65 | config JBD_DEBUG | |
66 | bool "JBD (ext3) debugging support" | |
67 | @@ -240,16 +239,17 @@ config JBD2 | |
68 | help | |
69 | This is a generic journaling layer for block devices that support | |
70 | both 32-bit and 64-bit block numbers. It is currently used by | |
71 | - the ext4dev/ext4 filesystem, but it could also be used to add | |
72 | - journal support to other file systems or block devices such | |
73 | - as RAID or LVM. | |
74 | + the ext4dev/ext4 and OCFS2 filesystems, but it could also be | |
75 | + used to add journal support to other file systems or block | |
76 | + devices such as RAID or LVM. | |
77 | ||
78 | - If you are using ext4dev/ext4, you need to say Y here. If you are not | |
79 | - using ext4dev/ext4 then you will probably want to say N. | |
80 | + If you are using ext4dev/ext4 or OCFS2, you need to say Y here. | |
81 | + If you are not using ext4dev/ext4 or OCFS2 then you will | |
82 | + probably want to say N. | |
83 | ||
84 | To compile this device as a module, choose M here. The module will be | |
85 | - called jbd2. If you are compiling ext4dev/ext4 into the kernel, | |
86 | - you cannot compile this code as a module. | |
87 | + called jbd2. If you are compiling ext4dev/ext4 or OCFS2 into the | |
88 | + kernel, you cannot compile this code as a module. | |
89 | ||
90 | config JBD2_DEBUG | |
91 | bool "JBD2 (ext4dev/ext4) debugging support" | |
92 | @@ -426,7 +426,7 @@ config OCFS2_FS | |
93 | tristate "OCFS2 file system support" | |
94 | depends on NET && SYSFS | |
95 | select CONFIGFS_FS | |
96 | - select JBD | |
97 | + select JBD2 | |
98 | select CRC32 | |
99 | help | |
100 | OCFS2 is a general purpose extent based shared disk cluster file | |
101 | @@ -497,6 +497,16 @@ config OCFS2_DEBUG_FS | |
102 | this option for debugging only as it is likely to decrease | |
103 | performance of the filesystem. | |
104 | ||
105 | +config OCFS2_COMPAT_JBD | |
106 | + bool "Use JBD for compatibility" | |
107 | + depends on OCFS2_FS | |
108 | + default n | |
109 | + select JBD | |
110 | + help | |
111 | + The ocfs2 filesystem now uses JBD2 for its journalling. JBD2 | |
112 | + is backwards compatible with JBD. It is safe to say N here. | |
113 | + However, if you really want to use the original JBD, say Y here. | |
114 | + | |
115 | endif # BLOCK | |
116 | ||
117 | config DNOTIFY | |
118 | --- a/fs/ocfs2/alloc.c | |
119 | +++ b/fs/ocfs2/alloc.c | |
120 | @@ -6430,20 +6430,13 @@ bail: | |
121 | return status; | |
122 | } | |
123 | ||
124 | -static int ocfs2_writeback_zero_func(handle_t *handle, struct buffer_head *bh) | |
125 | +static int ocfs2_zero_func(handle_t *handle, struct buffer_head *bh) | |
126 | { | |
127 | set_buffer_uptodate(bh); | |
128 | mark_buffer_dirty(bh); | |
129 | return 0; | |
130 | } | |
131 | ||
132 | -static int ocfs2_ordered_zero_func(handle_t *handle, struct buffer_head *bh) | |
133 | -{ | |
134 | - set_buffer_uptodate(bh); | |
135 | - mark_buffer_dirty(bh); | |
136 | - return ocfs2_journal_dirty_data(handle, bh); | |
137 | -} | |
138 | - | |
139 | static void ocfs2_map_and_dirty_page(struct inode *inode, handle_t *handle, | |
140 | unsigned int from, unsigned int to, | |
141 | struct page *page, int zero, u64 *phys) | |
142 | @@ -6462,17 +6455,18 @@ static void ocfs2_map_and_dirty_page(str | |
143 | * here if they aren't - ocfs2_map_page_blocks() | |
144 | * might've skipped some | |
145 | */ | |
146 | - if (ocfs2_should_order_data(inode)) { | |
147 | - ret = walk_page_buffers(handle, | |
148 | - page_buffers(page), | |
149 | - from, to, &partial, | |
150 | - ocfs2_ordered_zero_func); | |
151 | - if (ret < 0) | |
152 | - mlog_errno(ret); | |
153 | - } else { | |
154 | + ret = walk_page_buffers(handle, page_buffers(page), | |
155 | + from, to, &partial, | |
156 | + ocfs2_zero_func); | |
157 | + if (ret < 0) | |
158 | + mlog_errno(ret); | |
159 | + else if (ocfs2_should_order_data(inode)) { | |
160 | + ret = ocfs2_jbd2_file_inode(handle, inode); | |
161 | +#ifdef CONFIG_OCFS2_COMPAT_JBD | |
162 | ret = walk_page_buffers(handle, page_buffers(page), | |
163 | from, to, &partial, | |
164 | - ocfs2_writeback_zero_func); | |
165 | + ocfs2_journal_dirty_data); | |
166 | +#endif | |
167 | if (ret < 0) | |
168 | mlog_errno(ret); | |
169 | } | |
170 | --- a/fs/ocfs2/aops.c | |
171 | +++ b/fs/ocfs2/aops.c | |
172 | @@ -485,11 +485,14 @@ handle_t *ocfs2_start_walk_page_trans(st | |
173 | } | |
174 | ||
175 | if (ocfs2_should_order_data(inode)) { | |
176 | + ret = ocfs2_jbd2_file_inode(handle, inode); | |
177 | +#ifdef CONFIG_OCFS2_COMPAT_JBD | |
178 | ret = walk_page_buffers(handle, | |
179 | page_buffers(page), | |
180 | from, to, NULL, | |
181 | ocfs2_journal_dirty_data); | |
182 | - if (ret < 0) | |
183 | +#endif | |
184 | + if (ret < 0) | |
185 | mlog_errno(ret); | |
186 | } | |
187 | out: | |
188 | @@ -669,7 +672,7 @@ static void ocfs2_invalidatepage(struct | |
189 | { | |
190 | journal_t *journal = OCFS2_SB(page->mapping->host->i_sb)->journal->j_journal; | |
191 | ||
192 | - journal_invalidatepage(journal, page, offset); | |
193 | + jbd2_journal_invalidatepage(journal, page, offset); | |
194 | } | |
195 | ||
196 | static int ocfs2_releasepage(struct page *page, gfp_t wait) | |
197 | @@ -678,7 +681,7 @@ static int ocfs2_releasepage(struct page | |
198 | ||
199 | if (!page_has_buffers(page)) | |
200 | return 0; | |
201 | - return journal_try_to_free_buffers(journal, page, wait); | |
202 | + return jbd2_journal_try_to_free_buffers(journal, page, wait); | |
203 | } | |
204 | ||
205 | static ssize_t ocfs2_direct_IO(int rw, | |
206 | @@ -1074,11 +1077,15 @@ static void ocfs2_write_failure(struct i | |
207 | tmppage = wc->w_pages[i]; | |
208 | ||
209 | if (page_has_buffers(tmppage)) { | |
210 | - if (ocfs2_should_order_data(inode)) | |
211 | + if (ocfs2_should_order_data(inode)) { | |
212 | + ocfs2_jbd2_file_inode(wc->w_handle, inode); | |
213 | +#ifdef CONFIG_OCFS2_COMPAT_JBD | |
214 | walk_page_buffers(wc->w_handle, | |
215 | page_buffers(tmppage), | |
216 | from, to, NULL, | |
217 | ocfs2_journal_dirty_data); | |
218 | +#endif | |
219 | + } | |
220 | ||
221 | block_commit_write(tmppage, from, to); | |
222 | } | |
223 | @@ -1917,11 +1924,15 @@ int ocfs2_write_end_nolock(struct addres | |
224 | } | |
225 | ||
226 | if (page_has_buffers(tmppage)) { | |
227 | - if (ocfs2_should_order_data(inode)) | |
228 | + if (ocfs2_should_order_data(inode)) { | |
229 | + ocfs2_jbd2_file_inode(wc->w_handle, inode); | |
230 | +#ifdef CONFIG_OCFS2_COMPAT_JBD | |
231 | walk_page_buffers(wc->w_handle, | |
232 | page_buffers(tmppage), | |
233 | from, to, NULL, | |
234 | ocfs2_journal_dirty_data); | |
235 | +#endif | |
236 | + } | |
237 | block_commit_write(tmppage, from, to); | |
238 | } | |
239 | } | |
240 | --- a/fs/ocfs2/file.c | |
241 | +++ b/fs/ocfs2/file.c | |
242 | @@ -185,7 +185,7 @@ static int ocfs2_sync_file(struct file * | |
243 | goto bail; | |
244 | ||
245 | journal = osb->journal->j_journal; | |
246 | - err = journal_force_commit(journal); | |
247 | + err = jbd2_journal_force_commit(journal); | |
248 | ||
249 | bail: | |
250 | mlog_exit(err); | |
251 | @@ -941,9 +941,15 @@ int ocfs2_setattr(struct dentry *dentry, | |
252 | goto bail_unlock; | |
253 | } | |
254 | ||
255 | - if (i_size_read(inode) > attr->ia_size) | |
256 | + if (i_size_read(inode) > attr->ia_size) { | |
257 | + if (ocfs2_should_order_data(inode)) { | |
258 | + status = ocfs2_begin_ordered_truncate(inode, | |
259 | + attr->ia_size); | |
260 | + if (status) | |
261 | + goto bail_unlock; | |
262 | + } | |
263 | status = ocfs2_truncate_file(inode, bh, attr->ia_size); | |
264 | - else | |
265 | + } else | |
266 | status = ocfs2_extend_file(inode, bh, attr->ia_size); | |
267 | if (status < 0) { | |
268 | if (status != -ENOSPC) | |
269 | @@ -1888,7 +1894,7 @@ out_dio: | |
270 | */ | |
271 | if (old_size != i_size_read(inode) || | |
272 | old_clusters != OCFS2_I(inode)->ip_clusters) { | |
273 | - ret = journal_force_commit(osb->journal->j_journal); | |
274 | + ret = jbd2_journal_force_commit(osb->journal->j_journal); | |
275 | if (ret < 0) | |
276 | written = ret; | |
277 | } | |
278 | --- a/fs/ocfs2/inode.c | |
279 | +++ b/fs/ocfs2/inode.c | |
280 | @@ -523,6 +523,9 @@ static int ocfs2_truncate_for_delete(str | |
281 | * data and fast symlinks. | |
282 | */ | |
283 | if (fe->i_clusters) { | |
284 | + if (ocfs2_should_order_data(inode)) | |
285 | + ocfs2_begin_ordered_truncate(inode, 0); | |
286 | + | |
287 | handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); | |
288 | if (IS_ERR(handle)) { | |
289 | status = PTR_ERR(handle); | |
290 | @@ -1089,6 +1092,8 @@ void ocfs2_clear_inode(struct inode *ino | |
291 | oi->ip_last_trans = 0; | |
292 | oi->ip_dir_start_lookup = 0; | |
293 | oi->ip_blkno = 0ULL; | |
294 | + jbd2_journal_release_jbd_inode(OCFS2_SB(inode->i_sb)->journal->j_journal, | |
295 | + &oi->ip_jinode); | |
296 | ||
297 | bail: | |
298 | mlog_exit_void(); | |
299 | --- a/fs/ocfs2/inode.h | |
300 | +++ b/fs/ocfs2/inode.h | |
301 | @@ -71,6 +71,7 @@ struct ocfs2_inode_info | |
302 | struct ocfs2_extent_map ip_extent_map; | |
303 | ||
304 | struct inode vfs_inode; | |
305 | + struct jbd2_inode ip_jinode; | |
306 | }; | |
307 | ||
308 | /* | |
309 | --- a/fs/ocfs2/journal.c | |
310 | +++ b/fs/ocfs2/journal.c | |
311 | @@ -215,9 +215,9 @@ static int ocfs2_commit_cache(struct ocf | |
312 | goto finally; | |
313 | } | |
314 | ||
315 | - journal_lock_updates(journal->j_journal); | |
316 | - status = journal_flush(journal->j_journal); | |
317 | - journal_unlock_updates(journal->j_journal); | |
318 | + jbd2_journal_lock_updates(journal->j_journal); | |
319 | + status = jbd2_journal_flush(journal->j_journal); | |
320 | + jbd2_journal_unlock_updates(journal->j_journal); | |
321 | if (status < 0) { | |
322 | up_write(&journal->j_trans_barrier); | |
323 | mlog_errno(status); | |
324 | @@ -264,7 +264,7 @@ handle_t *ocfs2_start_trans(struct ocfs2 | |
325 | ||
326 | down_read(&osb->journal->j_trans_barrier); | |
327 | ||
328 | - handle = journal_start(journal, max_buffs); | |
329 | + handle = jbd2_journal_start(journal, max_buffs); | |
330 | if (IS_ERR(handle)) { | |
331 | up_read(&osb->journal->j_trans_barrier); | |
332 | ||
333 | @@ -290,7 +290,7 @@ int ocfs2_commit_trans(struct ocfs2_supe | |
334 | ||
335 | BUG_ON(!handle); | |
336 | ||
337 | - ret = journal_stop(handle); | |
338 | + ret = jbd2_journal_stop(handle); | |
339 | if (ret < 0) | |
340 | mlog_errno(ret); | |
341 | ||
342 | @@ -304,7 +304,7 @@ int ocfs2_commit_trans(struct ocfs2_supe | |
343 | * transaction. extend_trans will either extend the current handle by | |
344 | * nblocks, or commit it and start a new one with nblocks credits. | |
345 | * | |
346 | - * This might call journal_restart() which will commit dirty buffers | |
347 | + * This might call jbd2_journal_restart() which will commit dirty buffers | |
348 | * and then restart the transaction. Before calling | |
349 | * ocfs2_extend_trans(), any changed blocks should have been | |
350 | * dirtied. After calling it, all blocks which need to be changed must | |
351 | @@ -332,7 +332,7 @@ int ocfs2_extend_trans(handle_t *handle, | |
352 | #ifdef CONFIG_OCFS2_DEBUG_FS | |
353 | status = 1; | |
354 | #else | |
355 | - status = journal_extend(handle, nblocks); | |
356 | + status = jbd2_journal_extend(handle, nblocks); | |
357 | if (status < 0) { | |
358 | mlog_errno(status); | |
359 | goto bail; | |
360 | @@ -340,8 +340,10 @@ int ocfs2_extend_trans(handle_t *handle, | |
361 | #endif | |
362 | ||
363 | if (status > 0) { | |
364 | - mlog(0, "journal_extend failed, trying journal_restart\n"); | |
365 | - status = journal_restart(handle, nblocks); | |
366 | + mlog(0, | |
367 | + "jbd2_journal_extend failed, trying " | |
368 | + "jbd2_journal_restart\n"); | |
369 | + status = jbd2_journal_restart(handle, nblocks); | |
370 | if (status < 0) { | |
371 | mlog_errno(status); | |
372 | goto bail; | |
373 | @@ -393,11 +395,11 @@ int ocfs2_journal_access(handle_t *handl | |
374 | switch (type) { | |
375 | case OCFS2_JOURNAL_ACCESS_CREATE: | |
376 | case OCFS2_JOURNAL_ACCESS_WRITE: | |
377 | - status = journal_get_write_access(handle, bh); | |
378 | + status = jbd2_journal_get_write_access(handle, bh); | |
379 | break; | |
380 | ||
381 | case OCFS2_JOURNAL_ACCESS_UNDO: | |
382 | - status = journal_get_undo_access(handle, bh); | |
383 | + status = jbd2_journal_get_undo_access(handle, bh); | |
384 | break; | |
385 | ||
386 | default: | |
387 | @@ -422,7 +424,7 @@ int ocfs2_journal_dirty(handle_t *handle | |
388 | mlog_entry("(bh->b_blocknr=%llu)\n", | |
389 | (unsigned long long)bh->b_blocknr); | |
390 | ||
391 | - status = journal_dirty_metadata(handle, bh); | |
392 | + status = jbd2_journal_dirty_metadata(handle, bh); | |
393 | if (status < 0) | |
394 | mlog(ML_ERROR, "Could not dirty metadata buffer. " | |
395 | "(bh->b_blocknr=%llu)\n", | |
396 | @@ -432,6 +434,7 @@ int ocfs2_journal_dirty(handle_t *handle | |
397 | return status; | |
398 | } | |
399 | ||
400 | +#ifdef CONFIG_OCFS2_COMPAT_JBD | |
401 | int ocfs2_journal_dirty_data(handle_t *handle, | |
402 | struct buffer_head *bh) | |
403 | { | |
404 | @@ -443,8 +446,9 @@ int ocfs2_journal_dirty_data(handle_t *h | |
405 | ||
406 | return err; | |
407 | } | |
408 | +#endif | |
409 | ||
410 | -#define OCFS2_DEFAULT_COMMIT_INTERVAL (HZ * JBD_DEFAULT_MAX_COMMIT_AGE) | |
411 | +#define OCFS2_DEFAULT_COMMIT_INTERVAL (HZ * JBD2_DEFAULT_MAX_COMMIT_AGE) | |
412 | ||
413 | void ocfs2_set_journal_params(struct ocfs2_super *osb) | |
414 | { | |
415 | @@ -457,9 +461,9 @@ void ocfs2_set_journal_params(struct ocf | |
416 | spin_lock(&journal->j_state_lock); | |
417 | journal->j_commit_interval = commit_interval; | |
418 | if (osb->s_mount_opt & OCFS2_MOUNT_BARRIER) | |
419 | - journal->j_flags |= JFS_BARRIER; | |
420 | + journal->j_flags |= JBD2_BARRIER; | |
421 | else | |
422 | - journal->j_flags &= ~JFS_BARRIER; | |
423 | + journal->j_flags &= ~JBD2_BARRIER; | |
424 | spin_unlock(&journal->j_state_lock); | |
425 | } | |
426 | ||
427 | @@ -524,14 +528,14 @@ int ocfs2_journal_init(struct ocfs2_jour | |
428 | mlog(0, "inode->ip_clusters = %u\n", OCFS2_I(inode)->ip_clusters); | |
429 | ||
430 | /* call the kernels journal init function now */ | |
431 | - j_journal = journal_init_inode(inode); | |
432 | + j_journal = jbd2_journal_init_inode(inode); | |
433 | if (j_journal == NULL) { | |
434 | mlog(ML_ERROR, "Linux journal layer error\n"); | |
435 | status = -EINVAL; | |
436 | goto done; | |
437 | } | |
438 | ||
439 | - mlog(0, "Returned from journal_init_inode\n"); | |
440 | + mlog(0, "Returned from jbd2_journal_init_inode\n"); | |
441 | mlog(0, "j_journal->j_maxlen = %u\n", j_journal->j_maxlen); | |
442 | ||
443 | *dirty = (le32_to_cpu(di->id1.journal1.ij_flags) & | |
444 | @@ -639,7 +643,7 @@ void ocfs2_journal_shutdown(struct ocfs2 | |
445 | if (journal->j_state != OCFS2_JOURNAL_LOADED) | |
446 | goto done; | |
447 | ||
448 | - /* need to inc inode use count as journal_destroy will iput. */ | |
449 | + /* need to inc inode use count - jbd2_journal_destroy will iput. */ | |
450 | if (!igrab(inode)) | |
451 | BUG(); | |
452 | ||
453 | @@ -668,9 +672,9 @@ void ocfs2_journal_shutdown(struct ocfs2 | |
454 | BUG_ON(atomic_read(&(osb->journal->j_num_trans)) != 0); | |
455 | ||
456 | if (ocfs2_mount_local(osb)) { | |
457 | - journal_lock_updates(journal->j_journal); | |
458 | - status = journal_flush(journal->j_journal); | |
459 | - journal_unlock_updates(journal->j_journal); | |
460 | + jbd2_journal_lock_updates(journal->j_journal); | |
461 | + status = jbd2_journal_flush(journal->j_journal); | |
462 | + jbd2_journal_unlock_updates(journal->j_journal); | |
463 | if (status < 0) | |
464 | mlog_errno(status); | |
465 | } | |
466 | @@ -686,7 +690,7 @@ void ocfs2_journal_shutdown(struct ocfs2 | |
467 | } | |
468 | ||
469 | /* Shutdown the kernel journal system */ | |
470 | - journal_destroy(journal->j_journal); | |
471 | + jbd2_journal_destroy(journal->j_journal); | |
472 | ||
473 | OCFS2_I(inode)->ip_open_count--; | |
474 | ||
475 | @@ -711,15 +715,15 @@ static void ocfs2_clear_journal_error(st | |
476 | { | |
477 | int olderr; | |
478 | ||
479 | - olderr = journal_errno(journal); | |
480 | + olderr = jbd2_journal_errno(journal); | |
481 | if (olderr) { | |
482 | mlog(ML_ERROR, "File system error %d recorded in " | |
483 | "journal %u.\n", olderr, slot); | |
484 | mlog(ML_ERROR, "File system on device %s needs checking.\n", | |
485 | sb->s_id); | |
486 | ||
487 | - journal_ack_err(journal); | |
488 | - journal_clear_err(journal); | |
489 | + jbd2_journal_ack_err(journal); | |
490 | + jbd2_journal_clear_err(journal); | |
491 | } | |
492 | } | |
493 | ||
494 | @@ -734,7 +738,7 @@ int ocfs2_journal_load(struct ocfs2_jour | |
495 | ||
496 | osb = journal->j_osb; | |
497 | ||
498 | - status = journal_load(journal->j_journal); | |
499 | + status = jbd2_journal_load(journal->j_journal); | |
500 | if (status < 0) { | |
501 | mlog(ML_ERROR, "Failed to load journal!\n"); | |
502 | goto done; | |
503 | @@ -778,7 +782,7 @@ int ocfs2_journal_wipe(struct ocfs2_jour | |
504 | ||
505 | BUG_ON(!journal); | |
506 | ||
507 | - status = journal_wipe(journal->j_journal, full); | |
508 | + status = jbd2_journal_wipe(journal->j_journal, full); | |
509 | if (status < 0) { | |
510 | mlog_errno(status); | |
511 | goto bail; | |
512 | @@ -1229,19 +1233,19 @@ static int ocfs2_replay_journal(struct o | |
513 | } | |
514 | ||
515 | mlog(0, "calling journal_init_inode\n"); | |
516 | - journal = journal_init_inode(inode); | |
517 | + journal = jbd2_journal_init_inode(inode); | |
518 | if (journal == NULL) { | |
519 | mlog(ML_ERROR, "Linux journal layer error\n"); | |
520 | status = -EIO; | |
521 | goto done; | |
522 | } | |
523 | ||
524 | - status = journal_load(journal); | |
525 | + status = jbd2_journal_load(journal); | |
526 | if (status < 0) { | |
527 | mlog_errno(status); | |
528 | if (!igrab(inode)) | |
529 | BUG(); | |
530 | - journal_destroy(journal); | |
531 | + jbd2_journal_destroy(journal); | |
532 | goto done; | |
533 | } | |
534 | ||
535 | @@ -1249,9 +1253,9 @@ static int ocfs2_replay_journal(struct o | |
536 | ||
537 | /* wipe the journal */ | |
538 | mlog(0, "flushing the journal.\n"); | |
539 | - journal_lock_updates(journal); | |
540 | - status = journal_flush(journal); | |
541 | - journal_unlock_updates(journal); | |
542 | + jbd2_journal_lock_updates(journal); | |
543 | + status = jbd2_journal_flush(journal); | |
544 | + jbd2_journal_unlock_updates(journal); | |
545 | if (status < 0) | |
546 | mlog_errno(status); | |
547 | ||
548 | @@ -1272,7 +1276,7 @@ static int ocfs2_replay_journal(struct o | |
549 | if (!igrab(inode)) | |
550 | BUG(); | |
551 | ||
552 | - journal_destroy(journal); | |
553 | + jbd2_journal_destroy(journal); | |
554 | ||
555 | done: | |
556 | /* drop the lock on this nodes journal */ | |
557 | --- a/fs/ocfs2/journal.h | |
558 | +++ b/fs/ocfs2/journal.h | |
559 | @@ -27,7 +27,12 @@ | |
560 | #define OCFS2_JOURNAL_H | |
561 | ||
562 | #include <linux/fs.h> | |
563 | -#include <linux/jbd.h> | |
564 | +#ifndef CONFIG_OCFS2_COMPAT_JBD | |
565 | +# include <linux/jbd2.h> | |
566 | +#else | |
567 | +# include <linux/jbd.h> | |
568 | +# include "ocfs2_jbd_compat.h" | |
569 | +#endif | |
570 | ||
571 | enum ocfs2_journal_state { | |
572 | OCFS2_JOURNAL_FREE = 0, | |
573 | @@ -215,8 +220,8 @@ static inline void ocfs2_checkpoint_inod | |
574 | * buffer. Will have to call ocfs2_journal_dirty once | |
575 | * we've actually dirtied it. Type is one of . or . | |
576 | * ocfs2_journal_dirty - Mark a journalled buffer as having dirty data. | |
577 | - * ocfs2_journal_dirty_data - Indicate that a data buffer should go out before | |
578 | - * the current handle commits. | |
579 | + * ocfs2_jbd2_file_inode - Mark an inode so that its data goes out before | |
580 | + * the current handle commits. | |
581 | */ | |
582 | ||
583 | /* You must always start_trans with a number of buffs > 0, but it's | |
584 | @@ -268,8 +273,10 @@ int ocfs2_journal_acces | |
585 | */ | |
586 | int ocfs2_journal_dirty(handle_t *handle, | |
587 | struct buffer_head *bh); | |
588 | +#ifdef CONFIG_OCFS2_COMPAT_JBD | |
589 | int ocfs2_journal_dirty_data(handle_t *handle, | |
590 | struct buffer_head *bh); | |
591 | +#endif | |
592 | ||
593 | /* | |
594 | * Credit Macros: | |
595 | @@ -430,4 +437,16 @@ static inline int ocfs2_calc_tree_trunc_ | |
596 | return credits; | |
597 | } | |
598 | ||
599 | +static inline int ocfs2_jbd2_file_inode(handle_t *handle, struct inode *inode) | |
600 | +{ | |
601 | + return jbd2_journal_file_inode(handle, &OCFS2_I(inode)->ip_jinode); | |
602 | +} | |
603 | + | |
604 | +static inline int ocfs2_begin_ordered_truncate(struct inode *inode, | |
605 | + loff_t new_size) | |
606 | +{ | |
607 | + return jbd2_journal_begin_ordered_truncate(&OCFS2_I(inode)->ip_jinode, | |
608 | + new_size); | |
609 | +} | |
610 | + | |
611 | #endif /* OCFS2_JOURNAL_H */ | |
612 | --- a/fs/ocfs2/ocfs2.h | |
613 | +++ b/fs/ocfs2/ocfs2.h | |
614 | @@ -34,7 +34,12 @@ | |
615 | #include <linux/workqueue.h> | |
616 | #include <linux/kref.h> | |
617 | #include <linux/mutex.h> | |
618 | -#include <linux/jbd.h> | |
619 | +#ifndef CONFIG_OCFS2_COMPAT_JBD | |
620 | +# include <linux/jbd2.h> | |
621 | +#else | |
622 | +# include <linux/jbd.h> | |
623 | +# include "ocfs2_jbd_compat.h" | |
624 | +#endif | |
625 | ||
626 | /* For union ocfs2_dlm_lksb */ | |
627 | #include "stackglue.h" | |
628 | --- /dev/null | |
629 | +++ b/fs/ocfs2/ocfs2_jbd_compat.h | |
630 | @@ -0,0 +1,82 @@ | |
631 | +/* -*- mode: c; c-basic-offset: 8; -*- | |
632 | + * vim: noexpandtab sw=8 ts=8 sts=0: | |
633 | + * | |
634 | + * ocfs2_jbd_compat.h | |
635 | + * | |
636 | + * Compatibility defines for JBD. | |
637 | + * | |
638 | + * Copyright (C) 2008 Oracle. All rights reserved. | |
639 | + * | |
640 | + * This program is free software; you can redistribute it and/or | |
641 | + * modify it under the terms of the GNU General Public | |
642 | + * License version 2 as published by the Free Software Foundation. | |
643 | + * | |
644 | + * This program is distributed in the hope that it will be useful, | |
645 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
646 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
647 | + * General Public License for more details. | |
648 | + */ | |
649 | + | |
650 | +#ifndef OCFS2_JBD_COMPAT_H | |
651 | +#define OCFS2_JBD_COMPAT_H | |
652 | + | |
653 | +#ifndef CONFIG_OCFS2_COMPAT_JBD | |
654 | +# error Should not have been included | |
655 | +#endif | |
656 | + | |
657 | +struct jbd2_inode { | |
658 | + unsigned int dummy; | |
659 | +}; | |
660 | + | |
661 | +#define JBD2_BARRIER JFS_BARRIER | |
662 | +#define JBD2_DEFAULT_MAX_COMMIT_AGE JBD_DEFAULT_MAX_COMMIT_AGE | |
663 | + | |
664 | +#define jbd2_journal_ack_err journal_ack_err | |
665 | +#define jbd2_journal_clear_err journal_clear_err | |
666 | +#define jbd2_journal_destroy journal_destroy | |
667 | +#define jbd2_journal_dirty_metadata journal_dirty_metadata | |
668 | +#define jbd2_journal_errno journal_errno | |
669 | +#define jbd2_journal_extend journal_extend | |
670 | +#define jbd2_journal_flush journal_flush | |
671 | +#define jbd2_journal_force_commit journal_force_commit | |
672 | +#define jbd2_journal_get_write_access journal_get_write_access | |
673 | +#define jbd2_journal_get_undo_access journal_get_undo_access | |
674 | +#define jbd2_journal_init_inode journal_init_inode | |
675 | +#define jbd2_journal_invalidatepage journal_invalidatepage | |
676 | +#define jbd2_journal_load journal_load | |
677 | +#define jbd2_journal_lock_updates journal_lock_updates | |
678 | +#define jbd2_journal_restart journal_restart | |
679 | +#define jbd2_journal_start journal_start | |
680 | +#define jbd2_journal_start_commit journal_start_commit | |
681 | +#define jbd2_journal_stop journal_stop | |
682 | +#define jbd2_journal_try_to_free_buffers journal_try_to_free_buffers | |
683 | +#define jbd2_journal_unlock_updates journal_unlock_updates | |
684 | +#define jbd2_journal_wipe journal_wipe | |
685 | +#define jbd2_log_wait_commit log_wait_commit | |
686 | + | |
687 | +static inline int jbd2_journal_file_inode(handle_t *handle, | |
688 | + struct jbd2_inode *inode) | |
689 | +{ | |
690 | + return 0; | |
691 | +} | |
692 | + | |
693 | +static inline int jbd2_journal_begin_ordered_truncate(struct jbd2_inode *inode, | |
694 | + loff_t new_size) | |
695 | +{ | |
696 | + return 0; | |
697 | +} | |
698 | + | |
699 | +static inline void jbd2_journal_init_jbd_inode(struct jbd2_inode *jinode, | |
700 | + struct inode *inode) | |
701 | +{ | |
702 | + return; | |
703 | +} | |
704 | + | |
705 | +static inline void jbd2_journal_release_jbd_inode(journal_t *journal, | |
706 | + struct jbd2_inode *jinode) | |
707 | +{ | |
708 | + return; | |
709 | +} | |
710 | + | |
711 | + | |
712 | +#endif /* OCFS2_JBD_COMPAT_H */ | |
713 | --- a/fs/ocfs2/super.c | |
714 | +++ b/fs/ocfs2/super.c | |
715 | @@ -212,10 +212,11 @@ static int ocfs2_sync_fs(struct super_bl | |
716 | ocfs2_schedule_truncate_log_flush(osb, 0); | |
717 | } | |
718 | ||
719 | - if (journal_start_commit(OCFS2_SB(sb)->journal->j_journal, &target)) { | |
720 | + if (jbd2_journal_start_commit(OCFS2_SB(sb)->journal->j_journal, | |
721 | + &target)) { | |
722 | if (wait) | |
723 | - log_wait_commit(OCFS2_SB(sb)->journal->j_journal, | |
724 | - target); | |
725 | + jbd2_log_wait_commit(OCFS2_SB(sb)->journal->j_journal, | |
726 | + target); | |
727 | } | |
728 | return 0; | |
729 | } | |
730 | @@ -332,6 +333,7 @@ static struct inode *ocfs2_alloc_inode(s | |
731 | if (!oi) | |
732 | return NULL; | |
733 | ||
734 | + jbd2_journal_init_jbd_inode(&oi->ip_jinode, &oi->vfs_inode); | |
735 | return &oi->vfs_inode; | |
736 | } | |
737 | ||
738 | @@ -895,7 +897,7 @@ static int ocfs2_parse_options(struct su | |
739 | if (option < 0) | |
740 | return 0; | |
741 | if (option == 0) | |
742 | - option = JBD_DEFAULT_MAX_COMMIT_AGE; | |
743 | + option = JBD2_DEFAULT_MAX_COMMIT_AGE; | |
744 | mopt->commit_interval = HZ * option; | |
745 | break; | |
746 | case Opt_localalloc: | |
747 | --- a/fs/ocfs2/uptodate.c | |
748 | +++ b/fs/ocfs2/uptodate.c | |
749 | @@ -53,7 +53,11 @@ | |
750 | #include <linux/highmem.h> | |
751 | #include <linux/buffer_head.h> | |
752 | #include <linux/rbtree.h> | |
753 | -#include <linux/jbd.h> | |
754 | +#ifndef CONFIG_OCFS2_COMPAT_JBD | |
755 | +# include <linux/jbd2.h> | |
756 | +#else | |
757 | +# include <linux/jbd.h> | |
758 | +#endif | |
759 | ||
760 | #define MLOG_MASK_PREFIX ML_UPTODATE | |
761 |