diff options
Diffstat (limited to 'fs/jbd2/commit.c')
-rw-r--r-- | fs/jbd2/commit.c | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c index 75716d3d2be0..f52e5e8049f1 100644 --- a/fs/jbd2/commit.c +++ b/fs/jbd2/commit.c | |||
@@ -150,11 +150,11 @@ static int journal_submit_commit_record(journal_t *journal, | |||
150 | */ | 150 | */ |
151 | if (ret == -EOPNOTSUPP && barrier_done) { | 151 | if (ret == -EOPNOTSUPP && barrier_done) { |
152 | printk(KERN_WARNING | 152 | printk(KERN_WARNING |
153 | "JBD: barrier-based sync failed on %s - " | 153 | "JBD2: Disabling barriers on %s, " |
154 | "disabling barriers\n", journal->j_devname); | 154 | "not supported by device\n", journal->j_devname); |
155 | spin_lock(&journal->j_state_lock); | 155 | write_lock(&journal->j_state_lock); |
156 | journal->j_flags &= ~JBD2_BARRIER; | 156 | journal->j_flags &= ~JBD2_BARRIER; |
157 | spin_unlock(&journal->j_state_lock); | 157 | write_unlock(&journal->j_state_lock); |
158 | 158 | ||
159 | /* And try again, without the barrier */ | 159 | /* And try again, without the barrier */ |
160 | lock_buffer(bh); | 160 | lock_buffer(bh); |
@@ -180,11 +180,11 @@ retry: | |||
180 | wait_on_buffer(bh); | 180 | wait_on_buffer(bh); |
181 | if (buffer_eopnotsupp(bh) && (journal->j_flags & JBD2_BARRIER)) { | 181 | if (buffer_eopnotsupp(bh) && (journal->j_flags & JBD2_BARRIER)) { |
182 | printk(KERN_WARNING | 182 | printk(KERN_WARNING |
183 | "JBD2: wait_on_commit_record: sync failed on %s - " | 183 | "JBD2: %s: disabling barries on %s - not supported " |
184 | "disabling barriers\n", journal->j_devname); | 184 | "by device\n", __func__, journal->j_devname); |
185 | spin_lock(&journal->j_state_lock); | 185 | write_lock(&journal->j_state_lock); |
186 | journal->j_flags &= ~JBD2_BARRIER; | 186 | journal->j_flags &= ~JBD2_BARRIER; |
187 | spin_unlock(&journal->j_state_lock); | 187 | write_unlock(&journal->j_state_lock); |
188 | 188 | ||
189 | lock_buffer(bh); | 189 | lock_buffer(bh); |
190 | clear_buffer_dirty(bh); | 190 | clear_buffer_dirty(bh); |
@@ -400,7 +400,7 @@ void jbd2_journal_commit_transaction(journal_t *journal) | |||
400 | jbd_debug(1, "JBD: starting commit of transaction %d\n", | 400 | jbd_debug(1, "JBD: starting commit of transaction %d\n", |
401 | commit_transaction->t_tid); | 401 | commit_transaction->t_tid); |
402 | 402 | ||
403 | spin_lock(&journal->j_state_lock); | 403 | write_lock(&journal->j_state_lock); |
404 | commit_transaction->t_state = T_LOCKED; | 404 | commit_transaction->t_state = T_LOCKED; |
405 | 405 | ||
406 | /* | 406 | /* |
@@ -417,23 +417,23 @@ void jbd2_journal_commit_transaction(journal_t *journal) | |||
417 | stats.run.rs_locked); | 417 | stats.run.rs_locked); |
418 | 418 | ||
419 | spin_lock(&commit_transaction->t_handle_lock); | 419 | spin_lock(&commit_transaction->t_handle_lock); |
420 | while (commit_transaction->t_updates) { | 420 | while (atomic_read(&commit_transaction->t_updates)) { |
421 | DEFINE_WAIT(wait); | 421 | DEFINE_WAIT(wait); |
422 | 422 | ||
423 | prepare_to_wait(&journal->j_wait_updates, &wait, | 423 | prepare_to_wait(&journal->j_wait_updates, &wait, |
424 | TASK_UNINTERRUPTIBLE); | 424 | TASK_UNINTERRUPTIBLE); |
425 | if (commit_transaction->t_updates) { | 425 | if (atomic_read(&commit_transaction->t_updates)) { |
426 | spin_unlock(&commit_transaction->t_handle_lock); | 426 | spin_unlock(&commit_transaction->t_handle_lock); |
427 | spin_unlock(&journal->j_state_lock); | 427 | write_unlock(&journal->j_state_lock); |
428 | schedule(); | 428 | schedule(); |
429 | spin_lock(&journal->j_state_lock); | 429 | write_lock(&journal->j_state_lock); |
430 | spin_lock(&commit_transaction->t_handle_lock); | 430 | spin_lock(&commit_transaction->t_handle_lock); |
431 | } | 431 | } |
432 | finish_wait(&journal->j_wait_updates, &wait); | 432 | finish_wait(&journal->j_wait_updates, &wait); |
433 | } | 433 | } |
434 | spin_unlock(&commit_transaction->t_handle_lock); | 434 | spin_unlock(&commit_transaction->t_handle_lock); |
435 | 435 | ||
436 | J_ASSERT (commit_transaction->t_outstanding_credits <= | 436 | J_ASSERT (atomic_read(&commit_transaction->t_outstanding_credits) <= |
437 | journal->j_max_transaction_buffers); | 437 | journal->j_max_transaction_buffers); |
438 | 438 | ||
439 | /* | 439 | /* |
@@ -497,7 +497,7 @@ void jbd2_journal_commit_transaction(journal_t *journal) | |||
497 | start_time = ktime_get(); | 497 | start_time = ktime_get(); |
498 | commit_transaction->t_log_start = journal->j_head; | 498 | commit_transaction->t_log_start = journal->j_head; |
499 | wake_up(&journal->j_wait_transaction_locked); | 499 | wake_up(&journal->j_wait_transaction_locked); |
500 | spin_unlock(&journal->j_state_lock); | 500 | write_unlock(&journal->j_state_lock); |
501 | 501 | ||
502 | jbd_debug (3, "JBD: commit phase 2\n"); | 502 | jbd_debug (3, "JBD: commit phase 2\n"); |
503 | 503 | ||
@@ -519,19 +519,20 @@ void jbd2_journal_commit_transaction(journal_t *journal) | |||
519 | * transaction! Now comes the tricky part: we need to write out | 519 | * transaction! Now comes the tricky part: we need to write out |
520 | * metadata. Loop over the transaction's entire buffer list: | 520 | * metadata. Loop over the transaction's entire buffer list: |
521 | */ | 521 | */ |
522 | spin_lock(&journal->j_state_lock); | 522 | write_lock(&journal->j_state_lock); |
523 | commit_transaction->t_state = T_COMMIT; | 523 | commit_transaction->t_state = T_COMMIT; |
524 | spin_unlock(&journal->j_state_lock); | 524 | write_unlock(&journal->j_state_lock); |
525 | 525 | ||
526 | trace_jbd2_commit_logging(journal, commit_transaction); | 526 | trace_jbd2_commit_logging(journal, commit_transaction); |
527 | stats.run.rs_logging = jiffies; | 527 | stats.run.rs_logging = jiffies; |
528 | stats.run.rs_flushing = jbd2_time_diff(stats.run.rs_flushing, | 528 | stats.run.rs_flushing = jbd2_time_diff(stats.run.rs_flushing, |
529 | stats.run.rs_logging); | 529 | stats.run.rs_logging); |
530 | stats.run.rs_blocks = commit_transaction->t_outstanding_credits; | 530 | stats.run.rs_blocks = |
531 | atomic_read(&commit_transaction->t_outstanding_credits); | ||
531 | stats.run.rs_blocks_logged = 0; | 532 | stats.run.rs_blocks_logged = 0; |
532 | 533 | ||
533 | J_ASSERT(commit_transaction->t_nr_buffers <= | 534 | J_ASSERT(commit_transaction->t_nr_buffers <= |
534 | commit_transaction->t_outstanding_credits); | 535 | atomic_read(&commit_transaction->t_outstanding_credits)); |
535 | 536 | ||
536 | err = 0; | 537 | err = 0; |
537 | descriptor = NULL; | 538 | descriptor = NULL; |
@@ -616,7 +617,7 @@ void jbd2_journal_commit_transaction(journal_t *journal) | |||
616 | * the free space in the log, but this counter is changed | 617 | * the free space in the log, but this counter is changed |
617 | * by jbd2_journal_next_log_block() also. | 618 | * by jbd2_journal_next_log_block() also. |
618 | */ | 619 | */ |
619 | commit_transaction->t_outstanding_credits--; | 620 | atomic_dec(&commit_transaction->t_outstanding_credits); |
620 | 621 | ||
621 | /* Bump b_count to prevent truncate from stumbling over | 622 | /* Bump b_count to prevent truncate from stumbling over |
622 | the shadowed buffer! @@@ This can go if we ever get | 623 | the shadowed buffer! @@@ This can go if we ever get |
@@ -977,7 +978,7 @@ restart_loop: | |||
977 | * __jbd2_journal_drop_transaction(). Otherwise we could race with | 978 | * __jbd2_journal_drop_transaction(). Otherwise we could race with |
978 | * other checkpointing code processing the transaction... | 979 | * other checkpointing code processing the transaction... |
979 | */ | 980 | */ |
980 | spin_lock(&journal->j_state_lock); | 981 | write_lock(&journal->j_state_lock); |
981 | spin_lock(&journal->j_list_lock); | 982 | spin_lock(&journal->j_list_lock); |
982 | /* | 983 | /* |
983 | * Now recheck if some buffers did not get attached to the transaction | 984 | * Now recheck if some buffers did not get attached to the transaction |
@@ -985,7 +986,7 @@ restart_loop: | |||
985 | */ | 986 | */ |
986 | if (commit_transaction->t_forget) { | 987 | if (commit_transaction->t_forget) { |
987 | spin_unlock(&journal->j_list_lock); | 988 | spin_unlock(&journal->j_list_lock); |
988 | spin_unlock(&journal->j_state_lock); | 989 | write_unlock(&journal->j_state_lock); |
989 | goto restart_loop; | 990 | goto restart_loop; |
990 | } | 991 | } |
991 | 992 | ||
@@ -1003,7 +1004,8 @@ restart_loop: | |||
1003 | * File the transaction statistics | 1004 | * File the transaction statistics |
1004 | */ | 1005 | */ |
1005 | stats.ts_tid = commit_transaction->t_tid; | 1006 | stats.ts_tid = commit_transaction->t_tid; |
1006 | stats.run.rs_handle_count = commit_transaction->t_handle_count; | 1007 | stats.run.rs_handle_count = |
1008 | atomic_read(&commit_transaction->t_handle_count); | ||
1007 | trace_jbd2_run_stats(journal->j_fs_dev->bd_dev, | 1009 | trace_jbd2_run_stats(journal->j_fs_dev->bd_dev, |
1008 | commit_transaction->t_tid, &stats.run); | 1010 | commit_transaction->t_tid, &stats.run); |
1009 | 1011 | ||
@@ -1037,7 +1039,7 @@ restart_loop: | |||
1037 | journal->j_average_commit_time*3) / 4; | 1039 | journal->j_average_commit_time*3) / 4; |
1038 | else | 1040 | else |
1039 | journal->j_average_commit_time = commit_time; | 1041 | journal->j_average_commit_time = commit_time; |
1040 | spin_unlock(&journal->j_state_lock); | 1042 | write_unlock(&journal->j_state_lock); |
1041 | 1043 | ||
1042 | if (commit_transaction->t_checkpoint_list == NULL && | 1044 | if (commit_transaction->t_checkpoint_list == NULL && |
1043 | commit_transaction->t_checkpoint_io_list == NULL) { | 1045 | commit_transaction->t_checkpoint_io_list == NULL) { |