diff options
author | Theodore Ts'o <tytso@mit.edu> | 2013-02-08 13:00:31 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2013-02-08 13:00:31 -0500 |
commit | 722887ddc8982ff40e40b650fbca9ae1e56259bc (patch) | |
tree | da828f9362ed7983a4162a8b1c1404e8b628d704 | |
parent | 343d9c283c9847da043fda3e76e3197f27b667dd (diff) |
ext4: move the jbd2 wrapper functions out of super.c
Move the jbd2 wrapper functions which start and stop handles out of
super.c, where they don't really logically belong, and into
ext4_jbd2.c.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
-rw-r--r-- | fs/ext4/ext4.h | 2 | ||||
-rw-r--r-- | fs/ext4/ext4_jbd2.c | 101 | ||||
-rw-r--r-- | fs/ext4/super.c | 107 |
3 files changed, 105 insertions, 105 deletions
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index d93393eb5f2d..a5ae87c51401 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h | |||
@@ -2149,6 +2149,8 @@ extern void *ext4_kvzalloc(size_t size, gfp_t flags); | |||
2149 | extern void ext4_kvfree(void *ptr); | 2149 | extern void ext4_kvfree(void *ptr); |
2150 | extern int ext4_alloc_flex_bg_array(struct super_block *sb, | 2150 | extern int ext4_alloc_flex_bg_array(struct super_block *sb, |
2151 | ext4_group_t ngroup); | 2151 | ext4_group_t ngroup); |
2152 | extern const char *ext4_decode_error(struct super_block *sb, int errno, | ||
2153 | char nbuf[16]); | ||
2152 | extern __printf(4, 5) | 2154 | extern __printf(4, 5) |
2153 | void __ext4_error(struct super_block *, const char *, unsigned int, | 2155 | void __ext4_error(struct super_block *, const char *, unsigned int, |
2154 | const char *, ...); | 2156 | const char *, ...); |
diff --git a/fs/ext4/ext4_jbd2.c b/fs/ext4/ext4_jbd2.c index b4323ba846b5..6f6114525535 100644 --- a/fs/ext4/ext4_jbd2.c +++ b/fs/ext4/ext4_jbd2.c | |||
@@ -6,6 +6,107 @@ | |||
6 | 6 | ||
7 | #include <trace/events/ext4.h> | 7 | #include <trace/events/ext4.h> |
8 | 8 | ||
9 | /* Just increment the non-pointer handle value */ | ||
10 | static handle_t *ext4_get_nojournal(void) | ||
11 | { | ||
12 | handle_t *handle = current->journal_info; | ||
13 | unsigned long ref_cnt = (unsigned long)handle; | ||
14 | |||
15 | BUG_ON(ref_cnt >= EXT4_NOJOURNAL_MAX_REF_COUNT); | ||
16 | |||
17 | ref_cnt++; | ||
18 | handle = (handle_t *)ref_cnt; | ||
19 | |||
20 | current->journal_info = handle; | ||
21 | return handle; | ||
22 | } | ||
23 | |||
24 | |||
25 | /* Decrement the non-pointer handle value */ | ||
26 | static void ext4_put_nojournal(handle_t *handle) | ||
27 | { | ||
28 | unsigned long ref_cnt = (unsigned long)handle; | ||
29 | |||
30 | BUG_ON(ref_cnt == 0); | ||
31 | |||
32 | ref_cnt--; | ||
33 | handle = (handle_t *)ref_cnt; | ||
34 | |||
35 | current->journal_info = handle; | ||
36 | } | ||
37 | |||
38 | /* | ||
39 | * Wrappers for jbd2_journal_start/end. | ||
40 | */ | ||
41 | handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks) | ||
42 | { | ||
43 | journal_t *journal; | ||
44 | |||
45 | trace_ext4_journal_start(sb, nblocks, _RET_IP_); | ||
46 | if (sb->s_flags & MS_RDONLY) | ||
47 | return ERR_PTR(-EROFS); | ||
48 | |||
49 | WARN_ON(sb->s_writers.frozen == SB_FREEZE_COMPLETE); | ||
50 | journal = EXT4_SB(sb)->s_journal; | ||
51 | if (!journal) | ||
52 | return ext4_get_nojournal(); | ||
53 | /* | ||
54 | * Special case here: if the journal has aborted behind our | ||
55 | * backs (eg. EIO in the commit thread), then we still need to | ||
56 | * take the FS itself readonly cleanly. | ||
57 | */ | ||
58 | if (is_journal_aborted(journal)) { | ||
59 | ext4_abort(sb, "Detected aborted journal"); | ||
60 | return ERR_PTR(-EROFS); | ||
61 | } | ||
62 | return jbd2_journal_start(journal, nblocks); | ||
63 | } | ||
64 | |||
65 | int __ext4_journal_stop(const char *where, unsigned int line, handle_t *handle) | ||
66 | { | ||
67 | struct super_block *sb; | ||
68 | int err; | ||
69 | int rc; | ||
70 | |||
71 | if (!ext4_handle_valid(handle)) { | ||
72 | ext4_put_nojournal(handle); | ||
73 | return 0; | ||
74 | } | ||
75 | sb = handle->h_transaction->t_journal->j_private; | ||
76 | err = handle->h_err; | ||
77 | rc = jbd2_journal_stop(handle); | ||
78 | |||
79 | if (!err) | ||
80 | err = rc; | ||
81 | if (err) | ||
82 | __ext4_std_error(sb, where, line, err); | ||
83 | return err; | ||
84 | } | ||
85 | |||
86 | void ext4_journal_abort_handle(const char *caller, unsigned int line, | ||
87 | const char *err_fn, struct buffer_head *bh, | ||
88 | handle_t *handle, int err) | ||
89 | { | ||
90 | char nbuf[16]; | ||
91 | const char *errstr = ext4_decode_error(NULL, err, nbuf); | ||
92 | |||
93 | BUG_ON(!ext4_handle_valid(handle)); | ||
94 | |||
95 | if (bh) | ||
96 | BUFFER_TRACE(bh, "abort"); | ||
97 | |||
98 | if (!handle->h_err) | ||
99 | handle->h_err = err; | ||
100 | |||
101 | if (is_handle_aborted(handle)) | ||
102 | return; | ||
103 | |||
104 | printk(KERN_ERR "EXT4-fs: %s:%d: aborting transaction: %s in %s\n", | ||
105 | caller, line, errstr, err_fn); | ||
106 | |||
107 | jbd2_journal_abort_handle(handle); | ||
108 | } | ||
109 | |||
9 | int __ext4_journal_get_write_access(const char *where, unsigned int line, | 110 | int __ext4_journal_get_write_access(const char *where, unsigned int line, |
10 | handle_t *handle, struct buffer_head *bh) | 111 | handle_t *handle, struct buffer_head *bh) |
11 | { | 112 | { |
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 2e1f94704b1f..cb9d67fbc8f0 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -69,8 +69,6 @@ static void ext4_mark_recovery_complete(struct super_block *sb, | |||
69 | static void ext4_clear_journal_err(struct super_block *sb, | 69 | static void ext4_clear_journal_err(struct super_block *sb, |
70 | struct ext4_super_block *es); | 70 | struct ext4_super_block *es); |
71 | static int ext4_sync_fs(struct super_block *sb, int wait); | 71 | static int ext4_sync_fs(struct super_block *sb, int wait); |
72 | static const char *ext4_decode_error(struct super_block *sb, int errno, | ||
73 | char nbuf[16]); | ||
74 | static int ext4_remount(struct super_block *sb, int *flags, char *data); | 72 | static int ext4_remount(struct super_block *sb, int *flags, char *data); |
75 | static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf); | 73 | static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf); |
76 | static int ext4_unfreeze(struct super_block *sb); | 74 | static int ext4_unfreeze(struct super_block *sb); |
@@ -296,107 +294,6 @@ void ext4_itable_unused_set(struct super_block *sb, | |||
296 | } | 294 | } |
297 | 295 | ||
298 | 296 | ||
299 | /* Just increment the non-pointer handle value */ | ||
300 | static handle_t *ext4_get_nojournal(void) | ||
301 | { | ||
302 | handle_t *handle = current->journal_info; | ||
303 | unsigned long ref_cnt = (unsigned long)handle; | ||
304 | |||
305 | BUG_ON(ref_cnt >= EXT4_NOJOURNAL_MAX_REF_COUNT); | ||
306 | |||
307 | ref_cnt++; | ||
308 | handle = (handle_t *)ref_cnt; | ||
309 | |||
310 | current->journal_info = handle; | ||
311 | return handle; | ||
312 | } | ||
313 | |||
314 | |||
315 | /* Decrement the non-pointer handle value */ | ||
316 | static void ext4_put_nojournal(handle_t *handle) | ||
317 | { | ||
318 | unsigned long ref_cnt = (unsigned long)handle; | ||
319 | |||
320 | BUG_ON(ref_cnt == 0); | ||
321 | |||
322 | ref_cnt--; | ||
323 | handle = (handle_t *)ref_cnt; | ||
324 | |||
325 | current->journal_info = handle; | ||
326 | } | ||
327 | |||
328 | /* | ||
329 | * Wrappers for jbd2_journal_start/end. | ||
330 | */ | ||
331 | handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks) | ||
332 | { | ||
333 | journal_t *journal; | ||
334 | |||
335 | trace_ext4_journal_start(sb, nblocks, _RET_IP_); | ||
336 | if (sb->s_flags & MS_RDONLY) | ||
337 | return ERR_PTR(-EROFS); | ||
338 | |||
339 | WARN_ON(sb->s_writers.frozen == SB_FREEZE_COMPLETE); | ||
340 | journal = EXT4_SB(sb)->s_journal; | ||
341 | if (!journal) | ||
342 | return ext4_get_nojournal(); | ||
343 | /* | ||
344 | * Special case here: if the journal has aborted behind our | ||
345 | * backs (eg. EIO in the commit thread), then we still need to | ||
346 | * take the FS itself readonly cleanly. | ||
347 | */ | ||
348 | if (is_journal_aborted(journal)) { | ||
349 | ext4_abort(sb, "Detected aborted journal"); | ||
350 | return ERR_PTR(-EROFS); | ||
351 | } | ||
352 | return jbd2_journal_start(journal, nblocks); | ||
353 | } | ||
354 | |||
355 | int __ext4_journal_stop(const char *where, unsigned int line, handle_t *handle) | ||
356 | { | ||
357 | struct super_block *sb; | ||
358 | int err; | ||
359 | int rc; | ||
360 | |||
361 | if (!ext4_handle_valid(handle)) { | ||
362 | ext4_put_nojournal(handle); | ||
363 | return 0; | ||
364 | } | ||
365 | sb = handle->h_transaction->t_journal->j_private; | ||
366 | err = handle->h_err; | ||
367 | rc = jbd2_journal_stop(handle); | ||
368 | |||
369 | if (!err) | ||
370 | err = rc; | ||
371 | if (err) | ||
372 | __ext4_std_error(sb, where, line, err); | ||
373 | return err; | ||
374 | } | ||
375 | |||
376 | void ext4_journal_abort_handle(const char *caller, unsigned int line, | ||
377 | const char *err_fn, struct buffer_head *bh, | ||
378 | handle_t *handle, int err) | ||
379 | { | ||
380 | char nbuf[16]; | ||
381 | const char *errstr = ext4_decode_error(NULL, err, nbuf); | ||
382 | |||
383 | BUG_ON(!ext4_handle_valid(handle)); | ||
384 | |||
385 | if (bh) | ||
386 | BUFFER_TRACE(bh, "abort"); | ||
387 | |||
388 | if (!handle->h_err) | ||
389 | handle->h_err = err; | ||
390 | |||
391 | if (is_handle_aborted(handle)) | ||
392 | return; | ||
393 | |||
394 | printk(KERN_ERR "EXT4-fs: %s:%d: aborting transaction: %s in %s\n", | ||
395 | caller, line, errstr, err_fn); | ||
396 | |||
397 | jbd2_journal_abort_handle(handle); | ||
398 | } | ||
399 | |||
400 | static void __save_error_info(struct super_block *sb, const char *func, | 297 | static void __save_error_info(struct super_block *sb, const char *func, |
401 | unsigned int line) | 298 | unsigned int line) |
402 | { | 299 | { |
@@ -582,8 +479,8 @@ void ext4_error_file(struct file *file, const char *function, | |||
582 | ext4_handle_error(inode->i_sb); | 479 | ext4_handle_error(inode->i_sb); |
583 | } | 480 | } |
584 | 481 | ||
585 | static const char *ext4_decode_error(struct super_block *sb, int errno, | 482 | const char *ext4_decode_error(struct super_block *sb, int errno, |
586 | char nbuf[16]) | 483 | char nbuf[16]) |
587 | { | 484 | { |
588 | char *errstr = NULL; | 485 | char *errstr = NULL; |
589 | 486 | ||