Lines Matching full:journal

44  * __jbd2_log_wait_for_space: wait until there is space in the 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()
54 /* assert_spin_locked(&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()
65 * journal space by calling cleanup_journal_tail(), and if in __jbd2_log_wait_for_space()
69 * filesystem, so abort the journal and leave a stack 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()
95 * journal was aborted due to an error. 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()
113 "journal space in %s\n", __func__, 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()
151 * The journal should be locked before calling this function.
154 int jbd2_log_do_checkpoint(journal_t *journal) in jbd2_log_do_checkpoint() argument
167 * journal straight away. in jbd2_log_do_checkpoint()
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()
209 * The journal thread is dead; so 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()
300 * Check the list of checkpoint transactions for the journal to see if
302 * in the journal superblock. If so, we can instantly roll the
307 * Called with the journal lock held.
311 * main filesystem area rather than to the journal, so it can proceed
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()
332 * we drop the transactions from the journal. It's unlikely this will in jbd2_cleanup_journal_tail()
333 * be necessary, especially with an appropriately sized journal, but we 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()
403 * Find 'nr_to_scan' written-back checkpoint buffers in the journal
409 unsigned long jbd2_journal_shrink_checkpoint_list(journal_t *journal, in jbd2_journal_shrink_checkpoint_list() argument
421 spin_lock(&journal->j_list_lock); in jbd2_journal_shrink_checkpoint_list()
422 if (!journal->j_checkpoint_transactions) { in jbd2_journal_shrink_checkpoint_list()
423 spin_unlock(&journal->j_list_lock); in jbd2_journal_shrink_checkpoint_list()
433 if (journal->j_shrink_transaction) in jbd2_journal_shrink_checkpoint_list()
434 transaction = journal->j_shrink_transaction; in jbd2_journal_shrink_checkpoint_list()
436 transaction = journal->j_checkpoint_transactions; in jbd2_journal_shrink_checkpoint_list()
442 last_transaction = journal->j_checkpoint_transactions->t_cpprev; in jbd2_journal_shrink_checkpoint_list()
456 if (need_resched() || spin_needbreak(&journal->j_list_lock)) in jbd2_journal_shrink_checkpoint_list()
461 journal->j_shrink_transaction = next_transaction; in jbd2_journal_shrink_checkpoint_list()
464 journal->j_shrink_transaction = NULL; in jbd2_journal_shrink_checkpoint_list()
468 spin_unlock(&journal->j_list_lock); in jbd2_journal_shrink_checkpoint_list()
471 if (*nr_to_scan && journal->j_shrink_transaction) in jbd2_journal_shrink_checkpoint_list()
474 trace_jbd2_shrink_checkpoint_list(journal, first_tid, tid, last_tid, in jbd2_journal_shrink_checkpoint_list()
483 * Find all the written-back checkpoint buffers in the journal and release them.
488 void __jbd2_journal_clean_checkpoint_list(journal_t *journal, bool destroy) in __jbd2_journal_clean_checkpoint_list() argument
494 transaction = journal->j_checkpoint_transactions; in __jbd2_journal_clean_checkpoint_list()
524 * Remove buffers from all checkpoint lists as journal is aborted and we just
527 void jbd2_journal_destroy_checkpoint(journal_t *journal) in jbd2_journal_destroy_checkpoint() argument
534 spin_lock(&journal->j_list_lock); in jbd2_journal_destroy_checkpoint()
535 if (!journal->j_checkpoint_transactions) { in jbd2_journal_destroy_checkpoint()
536 spin_unlock(&journal->j_list_lock); in jbd2_journal_destroy_checkpoint()
539 __jbd2_journal_clean_checkpoint_list(journal, true); in jbd2_journal_destroy_checkpoint()
540 spin_unlock(&journal->j_list_lock); in jbd2_journal_destroy_checkpoint()
567 journal_t *journal; in __jbd2_journal_remove_checkpoint() local
577 journal = transaction->t_journal; in __jbd2_journal_remove_checkpoint()
583 * may become inconsistent. We cannot abort the journal here since in __jbd2_journal_remove_checkpoint()
586 * journal here and we abort the journal later from a better context. in __jbd2_journal_remove_checkpoint()
589 set_bit(JBD2_CHECKPOINT_IO_ERROR, &journal->j_atomic_flags); in __jbd2_journal_remove_checkpoint()
593 percpu_counter_dec(&journal->j_checkpoint_jh_count); in __jbd2_journal_remove_checkpoint()
620 trace_jbd2_checkpoint_stats(journal->j_fs_dev->bd_dev, in __jbd2_journal_remove_checkpoint()
623 __jbd2_journal_drop_transaction(journal, transaction); in __jbd2_journal_remove_checkpoint()
663 * Called with the journal locked.
695 * Called with the journal locked.
699 void __jbd2_journal_drop_transaction(journal_t *journal, transaction_t *transaction) in __jbd2_journal_drop_transaction() argument
701 assert_spin_locked(&journal->j_list_lock); in __jbd2_journal_drop_transaction()
703 journal->j_shrink_transaction = NULL; in __jbd2_journal_drop_transaction()
707 if (journal->j_checkpoint_transactions == transaction) in __jbd2_journal_drop_transaction()
708 journal->j_checkpoint_transactions = in __jbd2_journal_drop_transaction()
710 if (journal->j_checkpoint_transactions == transaction) in __jbd2_journal_drop_transaction()
711 journal->j_checkpoint_transactions = NULL; in __jbd2_journal_drop_transaction()
720 J_ASSERT(journal->j_committing_transaction != transaction); in __jbd2_journal_drop_transaction()
721 J_ASSERT(journal->j_running_transaction != transaction); in __jbd2_journal_drop_transaction()
723 trace_jbd2_drop_transaction(journal, transaction); in __jbd2_journal_drop_transaction()