commit.c (339b042bb408877dcb734d896cdb52dd20600aab) | commit.c (879c5e6b7cb4c689d08ca9b2e353d8ab3dc425d5) |
---|---|
1/* 2 * linux/fs/jbd2/commit.c 3 * 4 * Written by Stephen C. Tweedie <sct@redhat.com>, 1998 5 * 6 * Copyright 1998 Red Hat corp --- All Rights Reserved 7 * 8 * This file is part of the Linux kernel and is made available under 9 * the terms of the GNU General Public License, version 2, or at your 10 * option, any later version, incorporated herein by reference. 11 * 12 * Journal commit routines for the generic filesystem journaling code; 13 * part of the ext2fs journaling system. 14 */ 15 16#include <linux/time.h> 17#include <linux/fs.h> 18#include <linux/jbd2.h> | 1/* 2 * linux/fs/jbd2/commit.c 3 * 4 * Written by Stephen C. Tweedie <sct@redhat.com>, 1998 5 * 6 * Copyright 1998 Red Hat corp --- All Rights Reserved 7 * 8 * This file is part of the Linux kernel and is made available under 9 * the terms of the GNU General Public License, version 2, or at your 10 * option, any later version, incorporated herein by reference. 11 * 12 * Journal commit routines for the generic filesystem journaling code; 13 * part of the ext2fs journaling system. 14 */ 15 16#include <linux/time.h> 17#include <linux/fs.h> 18#include <linux/jbd2.h> |
19#include <linux/marker.h> | |
20#include <linux/errno.h> 21#include <linux/slab.h> 22#include <linux/mm.h> 23#include <linux/pagemap.h> 24#include <linux/jiffies.h> 25#include <linux/crc32.h> 26#include <linux/writeback.h> 27#include <linux/backing-dev.h> 28#include <linux/bio.h> | 19#include <linux/errno.h> 20#include <linux/slab.h> 21#include <linux/mm.h> 22#include <linux/pagemap.h> 23#include <linux/jiffies.h> 24#include <linux/crc32.h> 25#include <linux/writeback.h> 26#include <linux/backing-dev.h> 27#include <linux/bio.h> |
28#include <trace/events/jbd2.h> |
|
29 30/* 31 * Default IO end handler for temporary BJ_IO buffer_heads. 32 */ 33static void journal_end_buffer_io_sync(struct buffer_head *bh, int uptodate) 34{ 35 BUFFER_TRACE(bh, ""); 36 if (uptodate) --- 211 unchanged lines hidden (view full) --- 248 jinode->i_flags |= JI_COMMIT_RUNNING; 249 spin_unlock(&journal->j_list_lock); 250 /* 251 * submit the inode data buffers. We use writepage 252 * instead of writepages. Because writepages can do 253 * block allocation with delalloc. We need to write 254 * only allocated blocks here. 255 */ | 29 30/* 31 * Default IO end handler for temporary BJ_IO buffer_heads. 32 */ 33static void journal_end_buffer_io_sync(struct buffer_head *bh, int uptodate) 34{ 35 BUFFER_TRACE(bh, ""); 36 if (uptodate) --- 211 unchanged lines hidden (view full) --- 248 jinode->i_flags |= JI_COMMIT_RUNNING; 249 spin_unlock(&journal->j_list_lock); 250 /* 251 * submit the inode data buffers. We use writepage 252 * instead of writepages. Because writepages can do 253 * block allocation with delalloc. We need to write 254 * only allocated blocks here. 255 */ |
256 trace_jbd2_submit_inode_data(jinode->i_vfs_inode); |
|
256 err = journal_submit_inode_data_buffers(mapping); 257 if (!ret) 258 ret = err; 259 spin_lock(&journal->j_list_lock); 260 J_ASSERT(jinode->i_transaction == commit_transaction); 261 jinode->i_flags &= ~JI_COMMIT_RUNNING; 262 wake_up_bit(&jinode->i_flags, __JI_COMMIT_RUNNING); 263 } --- 125 unchanged lines hidden (view full) --- 389 } 390 391 J_ASSERT(journal->j_running_transaction != NULL); 392 J_ASSERT(journal->j_committing_transaction == NULL); 393 394 commit_transaction = journal->j_running_transaction; 395 J_ASSERT(commit_transaction->t_state == T_RUNNING); 396 | 257 err = journal_submit_inode_data_buffers(mapping); 258 if (!ret) 259 ret = err; 260 spin_lock(&journal->j_list_lock); 261 J_ASSERT(jinode->i_transaction == commit_transaction); 262 jinode->i_flags &= ~JI_COMMIT_RUNNING; 263 wake_up_bit(&jinode->i_flags, __JI_COMMIT_RUNNING); 264 } --- 125 unchanged lines hidden (view full) --- 390 } 391 392 J_ASSERT(journal->j_running_transaction != NULL); 393 J_ASSERT(journal->j_committing_transaction == NULL); 394 395 commit_transaction = journal->j_running_transaction; 396 J_ASSERT(commit_transaction->t_state == T_RUNNING); 397 |
397 trace_mark(jbd2_start_commit, "dev %s transaction %d", 398 journal->j_devname, commit_transaction->t_tid); | 398 trace_jbd2_start_commit(journal, commit_transaction); |
399 jbd_debug(1, "JBD: starting commit of transaction %d\n", 400 commit_transaction->t_tid); 401 402 spin_lock(&journal->j_state_lock); 403 commit_transaction->t_state = T_LOCKED; 404 405 /* 406 * Use plugged writes here, since we want to submit several before 407 * we unplug the device. We don't do explicit unplugging in here, 408 * instead we rely on sync_buffer() doing the unplug for us. 409 */ 410 if (commit_transaction->t_synchronous_commit) 411 write_op = WRITE_SYNC_PLUG; | 399 jbd_debug(1, "JBD: starting commit of transaction %d\n", 400 commit_transaction->t_tid); 401 402 spin_lock(&journal->j_state_lock); 403 commit_transaction->t_state = T_LOCKED; 404 405 /* 406 * Use plugged writes here, since we want to submit several before 407 * we unplug the device. We don't do explicit unplugging in here, 408 * instead we rely on sync_buffer() doing the unplug for us. 409 */ 410 if (commit_transaction->t_synchronous_commit) 411 write_op = WRITE_SYNC_PLUG; |
412 trace_jbd2_commit_locking(journal, commit_transaction); |
|
412 stats.u.run.rs_wait = commit_transaction->t_max_wait; 413 stats.u.run.rs_locked = jiffies; 414 stats.u.run.rs_running = jbd2_time_diff(commit_transaction->t_start, 415 stats.u.run.rs_locked); 416 417 spin_lock(&commit_transaction->t_handle_lock); 418 while (commit_transaction->t_updates) { 419 DEFINE_WAIT(wait); --- 59 unchanged lines hidden (view full) --- 479 480 jbd_debug (3, "JBD: commit phase 1\n"); 481 482 /* 483 * Switch to a new revoke table. 484 */ 485 jbd2_journal_switch_revoke_table(journal); 486 | 413 stats.u.run.rs_wait = commit_transaction->t_max_wait; 414 stats.u.run.rs_locked = jiffies; 415 stats.u.run.rs_running = jbd2_time_diff(commit_transaction->t_start, 416 stats.u.run.rs_locked); 417 418 spin_lock(&commit_transaction->t_handle_lock); 419 while (commit_transaction->t_updates) { 420 DEFINE_WAIT(wait); --- 59 unchanged lines hidden (view full) --- 480 481 jbd_debug (3, "JBD: commit phase 1\n"); 482 483 /* 484 * Switch to a new revoke table. 485 */ 486 jbd2_journal_switch_revoke_table(journal); 487 |
488 trace_jbd2_commit_flushing(journal, commit_transaction); |
|
487 stats.u.run.rs_flushing = jiffies; 488 stats.u.run.rs_locked = jbd2_time_diff(stats.u.run.rs_locked, 489 stats.u.run.rs_flushing); 490 491 commit_transaction->t_state = T_FLUSH; 492 journal->j_committing_transaction = commit_transaction; 493 journal->j_running_transaction = NULL; 494 start_time = ktime_get(); --- 20 unchanged lines hidden (view full) --- 515 * Way to go: we have now written out all of the data for a 516 * transaction! Now comes the tricky part: we need to write out 517 * metadata. Loop over the transaction's entire buffer list: 518 */ 519 spin_lock(&journal->j_state_lock); 520 commit_transaction->t_state = T_COMMIT; 521 spin_unlock(&journal->j_state_lock); 522 | 489 stats.u.run.rs_flushing = jiffies; 490 stats.u.run.rs_locked = jbd2_time_diff(stats.u.run.rs_locked, 491 stats.u.run.rs_flushing); 492 493 commit_transaction->t_state = T_FLUSH; 494 journal->j_committing_transaction = commit_transaction; 495 journal->j_running_transaction = NULL; 496 start_time = ktime_get(); --- 20 unchanged lines hidden (view full) --- 517 * Way to go: we have now written out all of the data for a 518 * transaction! Now comes the tricky part: we need to write out 519 * metadata. Loop over the transaction's entire buffer list: 520 */ 521 spin_lock(&journal->j_state_lock); 522 commit_transaction->t_state = T_COMMIT; 523 spin_unlock(&journal->j_state_lock); 524 |
525 trace_jbd2_commit_logging(journal, commit_transaction); |
|
523 stats.u.run.rs_logging = jiffies; 524 stats.u.run.rs_flushing = jbd2_time_diff(stats.u.run.rs_flushing, 525 stats.u.run.rs_logging); 526 stats.u.run.rs_blocks = commit_transaction->t_outstanding_credits; 527 stats.u.run.rs_blocks_logged = 0; 528 529 J_ASSERT(commit_transaction->t_nr_buffers <= 530 commit_transaction->t_outstanding_credits); --- 518 unchanged lines hidden (view full) --- 1049 commit_transaction; 1050 } 1051 } 1052 spin_unlock(&journal->j_list_lock); 1053 1054 if (journal->j_commit_callback) 1055 journal->j_commit_callback(journal, commit_transaction); 1056 | 526 stats.u.run.rs_logging = jiffies; 527 stats.u.run.rs_flushing = jbd2_time_diff(stats.u.run.rs_flushing, 528 stats.u.run.rs_logging); 529 stats.u.run.rs_blocks = commit_transaction->t_outstanding_credits; 530 stats.u.run.rs_blocks_logged = 0; 531 532 J_ASSERT(commit_transaction->t_nr_buffers <= 533 commit_transaction->t_outstanding_credits); --- 518 unchanged lines hidden (view full) --- 1052 commit_transaction; 1053 } 1054 } 1055 spin_unlock(&journal->j_list_lock); 1056 1057 if (journal->j_commit_callback) 1058 journal->j_commit_callback(journal, commit_transaction); 1059 |
1057 trace_mark(jbd2_end_commit, "dev %s transaction %d head %d", 1058 journal->j_devname, commit_transaction->t_tid, 1059 journal->j_tail_sequence); | 1060 trace_jbd2_end_commit(journal, commit_transaction); |
1060 jbd_debug(1, "JBD: commit %d complete, head %d\n", 1061 journal->j_commit_sequence, journal->j_tail_sequence); 1062 if (to_free) 1063 kfree(commit_transaction); 1064 1065 wake_up(&journal->j_wait_done_commit); 1066} | 1061 jbd_debug(1, "JBD: commit %d complete, head %d\n", 1062 journal->j_commit_sequence, journal->j_tail_sequence); 1063 if (to_free) 1064 kfree(commit_transaction); 1065 1066 wake_up(&journal->j_wait_done_commit); 1067} |