Lines Matching refs:journal
49 void __jbd2_log_wait_for_space(journal_t *journal) in __jbd2_log_wait_for_space() argument
50 __acquires(&journal->j_state_lock) in __jbd2_log_wait_for_space()
51 __releases(&journal->j_state_lock) in __jbd2_log_wait_for_space()
56 nblocks = journal->j_max_transaction_buffers; in __jbd2_log_wait_for_space()
57 while (jbd2_log_space_left(journal) < nblocks) { in __jbd2_log_wait_for_space()
58 write_unlock(&journal->j_state_lock); in __jbd2_log_wait_for_space()
59 mutex_lock_io(&journal->j_checkpoint_mutex); in __jbd2_log_wait_for_space()
72 write_lock(&journal->j_state_lock); in __jbd2_log_wait_for_space()
73 if (journal->j_flags & JBD2_ABORT) { in __jbd2_log_wait_for_space()
74 mutex_unlock(&journal->j_checkpoint_mutex); in __jbd2_log_wait_for_space()
77 spin_lock(&journal->j_list_lock); in __jbd2_log_wait_for_space()
78 space_left = jbd2_log_space_left(journal); in __jbd2_log_wait_for_space()
80 int chkpt = journal->j_checkpoint_transactions != NULL; in __jbd2_log_wait_for_space()
84 if (journal->j_committing_transaction) { in __jbd2_log_wait_for_space()
85 tid = journal->j_committing_transaction->t_tid; in __jbd2_log_wait_for_space()
88 spin_unlock(&journal->j_list_lock); in __jbd2_log_wait_for_space()
89 write_unlock(&journal->j_state_lock); in __jbd2_log_wait_for_space()
91 jbd2_log_do_checkpoint(journal); in __jbd2_log_wait_for_space()
92 } else if (jbd2_cleanup_journal_tail(journal) <= 0) { in __jbd2_log_wait_for_space()
104 mutex_unlock(&journal->j_checkpoint_mutex); in __jbd2_log_wait_for_space()
105 jbd2_log_wait_commit(journal, tid); in __jbd2_log_wait_for_space()
106 write_lock(&journal->j_state_lock); in __jbd2_log_wait_for_space()
114 journal->j_devname); in __jbd2_log_wait_for_space()
116 jbd2_journal_abort(journal, -EIO); in __jbd2_log_wait_for_space()
118 write_lock(&journal->j_state_lock); in __jbd2_log_wait_for_space()
120 spin_unlock(&journal->j_list_lock); in __jbd2_log_wait_for_space()
122 mutex_unlock(&journal->j_checkpoint_mutex); in __jbd2_log_wait_for_space()
127 __flush_batch(journal_t *journal, int *batch_count) in __flush_batch() argument
134 write_dirty_buffer(journal->j_chkpt_bhs[i], REQ_SYNC); in __flush_batch()
138 struct buffer_head *bh = journal->j_chkpt_bhs[i]; in __flush_batch()
141 journal->j_chkpt_bhs[i] = NULL; in __flush_batch()
154 int jbd2_log_do_checkpoint(journal_t *journal) in jbd2_log_do_checkpoint() argument
169 result = jbd2_cleanup_journal_tail(journal); in jbd2_log_do_checkpoint()
170 trace_jbd2_checkpoint(journal, result); in jbd2_log_do_checkpoint()
179 spin_lock(&journal->j_list_lock); in jbd2_log_do_checkpoint()
180 if (!journal->j_checkpoint_transactions) in jbd2_log_do_checkpoint()
182 transaction = journal->j_checkpoint_transactions; in jbd2_log_do_checkpoint()
192 if (journal->j_checkpoint_transactions != transaction || in jbd2_log_do_checkpoint()
206 spin_unlock(&journal->j_list_lock); in jbd2_log_do_checkpoint()
207 if (unlikely(journal->j_flags & JBD2_UNMOUNT)) in jbd2_log_do_checkpoint()
216 journal->j_devname, (unsigned long long) bh->b_blocknr); in jbd2_log_do_checkpoint()
219 __flush_batch(journal, &batch_count); in jbd2_log_do_checkpoint()
220 jbd2_log_start_commit(journal, tid); in jbd2_log_do_checkpoint()
229 mutex_unlock(&journal->j_checkpoint_mutex); in jbd2_log_do_checkpoint()
230 jbd2_log_wait_commit(journal, tid); in jbd2_log_do_checkpoint()
231 mutex_lock_io(&journal->j_checkpoint_mutex); in jbd2_log_do_checkpoint()
232 spin_lock(&journal->j_list_lock); in jbd2_log_do_checkpoint()
243 spin_unlock(&journal->j_list_lock); in jbd2_log_do_checkpoint()
271 journal->j_chkpt_bhs[batch_count++] = bh; in jbd2_log_do_checkpoint()
277 need_resched() || spin_needbreak(&journal->j_list_lock) || in jbd2_log_do_checkpoint()
278 jh2bh(transaction->t_checkpoint_list) == journal->j_chkpt_bhs[0]) in jbd2_log_do_checkpoint()
284 spin_unlock(&journal->j_list_lock); in jbd2_log_do_checkpoint()
287 __flush_batch(journal, &batch_count); in jbd2_log_do_checkpoint()
288 spin_lock(&journal->j_list_lock); in jbd2_log_do_checkpoint()
293 spin_unlock(&journal->j_list_lock); in jbd2_log_do_checkpoint()
294 result = jbd2_cleanup_journal_tail(journal); in jbd2_log_do_checkpoint()
317 int jbd2_cleanup_journal_tail(journal_t *journal) in jbd2_cleanup_journal_tail() argument
322 if (is_journal_aborted(journal)) in jbd2_cleanup_journal_tail()
325 if (!jbd2_journal_get_log_tail(journal, &first_tid, &blocknr)) in jbd2_cleanup_journal_tail()
337 if (journal->j_flags & JBD2_BARRIER) in jbd2_cleanup_journal_tail()
338 blkdev_issue_flush(journal->j_fs_dev); in jbd2_cleanup_journal_tail()
340 return __jbd2_update_log_tail(journal, first_tid, blocknr); in jbd2_cleanup_journal_tail()
407 unsigned long jbd2_journal_shrink_checkpoint_list(journal_t *journal, in jbd2_journal_shrink_checkpoint_list() argument
419 spin_lock(&journal->j_list_lock); in jbd2_journal_shrink_checkpoint_list()
420 if (!journal->j_checkpoint_transactions) { in jbd2_journal_shrink_checkpoint_list()
421 spin_unlock(&journal->j_list_lock); in jbd2_journal_shrink_checkpoint_list()
431 if (journal->j_shrink_transaction) in jbd2_journal_shrink_checkpoint_list()
432 transaction = journal->j_shrink_transaction; in jbd2_journal_shrink_checkpoint_list()
434 transaction = journal->j_checkpoint_transactions; in jbd2_journal_shrink_checkpoint_list()
440 last_transaction = journal->j_checkpoint_transactions->t_cpprev; in jbd2_journal_shrink_checkpoint_list()
454 if (need_resched() || spin_needbreak(&journal->j_list_lock)) in jbd2_journal_shrink_checkpoint_list()
459 journal->j_shrink_transaction = next_transaction; in jbd2_journal_shrink_checkpoint_list()
462 journal->j_shrink_transaction = NULL; in jbd2_journal_shrink_checkpoint_list()
466 spin_unlock(&journal->j_list_lock); in jbd2_journal_shrink_checkpoint_list()
469 if (*nr_to_scan && journal->j_shrink_transaction) in jbd2_journal_shrink_checkpoint_list()
472 trace_jbd2_shrink_checkpoint_list(journal, first_tid, tid, last_tid, in jbd2_journal_shrink_checkpoint_list()
489 void __jbd2_journal_clean_checkpoint_list(journal_t *journal, in __jbd2_journal_clean_checkpoint_list() argument
497 transaction = journal->j_checkpoint_transactions; in __jbd2_journal_clean_checkpoint_list()
529 void jbd2_journal_destroy_checkpoint(journal_t *journal) in jbd2_journal_destroy_checkpoint() argument
536 spin_lock(&journal->j_list_lock); in jbd2_journal_destroy_checkpoint()
537 if (!journal->j_checkpoint_transactions) { in jbd2_journal_destroy_checkpoint()
538 spin_unlock(&journal->j_list_lock); in jbd2_journal_destroy_checkpoint()
541 __jbd2_journal_clean_checkpoint_list(journal, JBD2_SHRINK_DESTROY); in jbd2_journal_destroy_checkpoint()
542 spin_unlock(&journal->j_list_lock); in jbd2_journal_destroy_checkpoint()
569 journal_t *journal; in __jbd2_journal_remove_checkpoint() local
578 journal = transaction->t_journal; in __jbd2_journal_remove_checkpoint()
584 percpu_counter_dec(&journal->j_checkpoint_jh_count); in __jbd2_journal_remove_checkpoint()
611 trace_jbd2_checkpoint_stats(journal->j_fs_dev->bd_dev, in __jbd2_journal_remove_checkpoint()
614 __jbd2_journal_drop_transaction(journal, transaction); in __jbd2_journal_remove_checkpoint()
690 void __jbd2_journal_drop_transaction(journal_t *journal, transaction_t *transaction) in __jbd2_journal_drop_transaction() argument
692 assert_spin_locked(&journal->j_list_lock); in __jbd2_journal_drop_transaction()
694 journal->j_shrink_transaction = NULL; in __jbd2_journal_drop_transaction()
698 if (journal->j_checkpoint_transactions == transaction) in __jbd2_journal_drop_transaction()
699 journal->j_checkpoint_transactions = in __jbd2_journal_drop_transaction()
701 if (journal->j_checkpoint_transactions == transaction) in __jbd2_journal_drop_transaction()
702 journal->j_checkpoint_transactions = NULL; in __jbd2_journal_drop_transaction()
711 J_ASSERT(journal->j_committing_transaction != transaction); in __jbd2_journal_drop_transaction()
712 J_ASSERT(journal->j_running_transaction != transaction); in __jbd2_journal_drop_transaction()
714 trace_jbd2_drop_transaction(journal, transaction); in __jbd2_journal_drop_transaction()