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 /fs/ext4/super.c | |
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>
Diffstat (limited to 'fs/ext4/super.c')
-rw-r--r-- | fs/ext4/super.c | 107 |
1 files changed, 2 insertions, 105 deletions
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 | ||