Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+105 -105
+2
fs/ext4/ext4.h
··· 2149 2149 extern void ext4_kvfree(void *ptr); 2150 2150 extern int ext4_alloc_flex_bg_array(struct super_block *sb, 2151 2151 ext4_group_t ngroup); 2152 + extern const char *ext4_decode_error(struct super_block *sb, int errno, 2153 + char nbuf[16]); 2152 2154 extern __printf(4, 5) 2153 2155 void __ext4_error(struct super_block *, const char *, unsigned int, 2154 2156 const char *, ...);
+101
fs/ext4/ext4_jbd2.c
··· 6 6 7 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 110 int __ext4_journal_get_write_access(const char *where, unsigned int line, 10 111 handle_t *handle, struct buffer_head *bh) 11 112 {
+2 -105
fs/ext4/super.c
··· 69 69 static void ext4_clear_journal_err(struct super_block *sb, 70 70 struct ext4_super_block *es); 71 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 72 static int ext4_remount(struct super_block *sb, int *flags, char *data); 75 73 static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf); 76 74 static int ext4_unfreeze(struct super_block *sb); ··· 294 296 } 295 297 296 298 297 - /* Just increment the non-pointer handle value */ 298 - static handle_t *ext4_get_nojournal(void) 299 - { 300 - handle_t *handle = current->journal_info; 301 - unsigned long ref_cnt = (unsigned long)handle; 302 - 303 - BUG_ON(ref_cnt >= EXT4_NOJOURNAL_MAX_REF_COUNT); 304 - 305 - ref_cnt++; 306 - handle = (handle_t *)ref_cnt; 307 - 308 - current->journal_info = handle; 309 - return handle; 310 - } 311 - 312 - 313 - /* Decrement the non-pointer handle value */ 314 - static void ext4_put_nojournal(handle_t *handle) 315 - { 316 - unsigned long ref_cnt = (unsigned long)handle; 317 - 318 - BUG_ON(ref_cnt == 0); 319 - 320 - ref_cnt--; 321 - handle = (handle_t *)ref_cnt; 322 - 323 - current->journal_info = handle; 324 - } 325 - 326 - /* 327 - * Wrappers for jbd2_journal_start/end. 328 - */ 329 - handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks) 330 - { 331 - journal_t *journal; 332 - 333 - trace_ext4_journal_start(sb, nblocks, _RET_IP_); 334 - if (sb->s_flags & MS_RDONLY) 335 - return ERR_PTR(-EROFS); 336 - 337 - WARN_ON(sb->s_writers.frozen == SB_FREEZE_COMPLETE); 338 - journal = EXT4_SB(sb)->s_journal; 339 - if (!journal) 340 - return ext4_get_nojournal(); 341 - /* 342 - * Special case here: if the journal has aborted behind our 343 - * backs (eg. EIO in the commit thread), then we still need to 344 - * take the FS itself readonly cleanly. 345 - */ 346 - if (is_journal_aborted(journal)) { 347 - ext4_abort(sb, "Detected aborted journal"); 348 - return ERR_PTR(-EROFS); 349 - } 350 - return jbd2_journal_start(journal, nblocks); 351 - } 352 - 353 - int __ext4_journal_stop(const char *where, unsigned int line, handle_t *handle) 354 - { 355 - struct super_block *sb; 356 - int err; 357 - int rc; 358 - 359 - if (!ext4_handle_valid(handle)) { 360 - ext4_put_nojournal(handle); 361 - return 0; 362 - } 363 - sb = handle->h_transaction->t_journal->j_private; 364 - err = handle->h_err; 365 - rc = jbd2_journal_stop(handle); 366 - 367 - if (!err) 368 - err = rc; 369 - if (err) 370 - __ext4_std_error(sb, where, line, err); 371 - return err; 372 - } 373 - 374 - void ext4_journal_abort_handle(const char *caller, unsigned int line, 375 - const char *err_fn, struct buffer_head *bh, 376 - handle_t *handle, int err) 377 - { 378 - char nbuf[16]; 379 - const char *errstr = ext4_decode_error(NULL, err, nbuf); 380 - 381 - BUG_ON(!ext4_handle_valid(handle)); 382 - 383 - if (bh) 384 - BUFFER_TRACE(bh, "abort"); 385 - 386 - if (!handle->h_err) 387 - handle->h_err = err; 388 - 389 - if (is_handle_aborted(handle)) 390 - return; 391 - 392 - printk(KERN_ERR "EXT4-fs: %s:%d: aborting transaction: %s in %s\n", 393 - caller, line, errstr, err_fn); 394 - 395 - jbd2_journal_abort_handle(handle); 396 - } 397 - 398 299 static void __save_error_info(struct super_block *sb, const char *func, 399 300 unsigned int line) 400 301 { ··· 479 582 ext4_handle_error(inode->i_sb); 480 583 } 481 584 482 - static const char *ext4_decode_error(struct super_block *sb, int errno, 483 - char nbuf[16]) 585 + const char *ext4_decode_error(struct super_block *sb, int errno, 586 + char nbuf[16]) 484 587 { 485 588 char *errstr = NULL; 486 589