Lines Matching defs: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)
50 __acquires(&journal->j_state_lock)
51 __releases(&journal->j_state_lock)
54 /* assert_spin_locked(&journal->j_state_lock); */
56 nblocks = journal->j_max_transaction_buffers;
57 while (jbd2_log_space_left(journal) < nblocks) {
58 write_unlock(&journal->j_state_lock);
59 mutex_lock_io(&journal->j_checkpoint_mutex);
65 * journal space by calling cleanup_journal_tail(), and if
69 * filesystem, so abort the journal and leave a stack
72 write_lock(&journal->j_state_lock);
73 if (journal->j_flags & JBD2_ABORT) {
74 mutex_unlock(&journal->j_checkpoint_mutex);
77 spin_lock(&journal->j_list_lock);
78 space_left = jbd2_log_space_left(journal);
80 int chkpt = journal->j_checkpoint_transactions != NULL;
83 if (journal->j_committing_transaction)
84 tid = journal->j_committing_transaction->t_tid;
85 spin_unlock(&journal->j_list_lock);
86 write_unlock(&journal->j_state_lock);
88 jbd2_log_do_checkpoint(journal);
89 } else if (jbd2_cleanup_journal_tail(journal) == 0) {
98 mutex_unlock(&journal->j_checkpoint_mutex);
99 jbd2_log_wait_commit(journal, tid);
100 write_lock(&journal->j_state_lock);
107 "journal space in %s\n", __func__,
108 journal->j_devname);
110 jbd2_journal_abort(journal, -EIO);
112 write_lock(&journal->j_state_lock);
114 spin_unlock(&journal->j_list_lock);
116 mutex_unlock(&journal->j_checkpoint_mutex);
121 __flush_batch(journal_t *journal, int *batch_count)
128 write_dirty_buffer(journal->j_chkpt_bhs[i], REQ_SYNC);
132 struct buffer_head *bh = journal->j_chkpt_bhs[i];
135 journal->j_chkpt_bhs[i] = NULL;
145 * The journal should be locked before calling this function.
148 int jbd2_log_do_checkpoint(journal_t *journal)
161 * journal straight away.
163 result = jbd2_cleanup_journal_tail(journal);
164 trace_jbd2_checkpoint(journal, result);
173 spin_lock(&journal->j_list_lock);
174 if (!journal->j_checkpoint_transactions)
176 transaction = journal->j_checkpoint_transactions;
186 if (journal->j_checkpoint_transactions != transaction ||
200 spin_unlock(&journal->j_list_lock);
201 if (unlikely(journal->j_flags & JBD2_UNMOUNT))
203 * The journal thread is dead; so
210 journal->j_devname, (unsigned long long) bh->b_blocknr);
213 __flush_batch(journal, &batch_count);
214 jbd2_log_start_commit(journal, tid);
223 mutex_unlock(&journal->j_checkpoint_mutex);
224 jbd2_log_wait_commit(journal, tid);
225 mutex_lock_io(&journal->j_checkpoint_mutex);
226 spin_lock(&journal->j_list_lock);
237 spin_unlock(&journal->j_list_lock);
265 journal->j_chkpt_bhs[batch_count++] = bh;
271 need_resched() || spin_needbreak(&journal->j_list_lock) ||
272 jh2bh(transaction->t_checkpoint_list) == journal->j_chkpt_bhs[0])
278 spin_unlock(&journal->j_list_lock);
281 __flush_batch(journal, &batch_count);
282 spin_lock(&journal->j_list_lock);
287 spin_unlock(&journal->j_list_lock);
288 result = jbd2_cleanup_journal_tail(journal);
294 * Check the list of checkpoint transactions for the journal to see if
296 * in the journal superblock. If so, we can instantly roll the
301 * Called with the journal lock held.
305 * main filesystem area rather than to the journal, so it can proceed
311 int jbd2_cleanup_journal_tail(journal_t *journal)
316 if (is_journal_aborted(journal))
319 if (!jbd2_journal_get_log_tail(journal, &first_tid, &blocknr))
326 * we drop the transactions from the journal. It's unlikely this will
327 * be necessary, especially with an appropriately sized journal, but we
331 if (journal->j_flags & JBD2_BARRIER)
332 blkdev_issue_flush(journal->j_fs_dev);
334 return __jbd2_update_log_tail(journal, first_tid, blocknr);
397 * Find 'nr_to_scan' written-back checkpoint buffers in the journal
403 unsigned long jbd2_journal_shrink_checkpoint_list(journal_t *journal,
414 spin_lock(&journal->j_list_lock);
415 if (!journal->j_checkpoint_transactions) {
416 spin_unlock(&journal->j_list_lock);
426 if (journal->j_shrink_transaction)
427 transaction = journal->j_shrink_transaction;
429 transaction = journal->j_checkpoint_transactions;
433 last_transaction = journal->j_checkpoint_transactions->t_cpprev;
447 if (need_resched() || spin_needbreak(&journal->j_list_lock))
452 journal->j_shrink_transaction = next_transaction;
455 journal->j_shrink_transaction = NULL;
459 spin_unlock(&journal->j_list_lock);
465 trace_jbd2_shrink_checkpoint_list(journal, first_tid, tid, last_tid,
474 * Find all the written-back checkpoint buffers in the journal and release them.
479 void __jbd2_journal_clean_checkpoint_list(journal_t *journal, bool destroy)
485 transaction = journal->j_checkpoint_transactions;
515 * Remove buffers from all checkpoint lists as journal is aborted and we just
518 void jbd2_journal_destroy_checkpoint(journal_t *journal)
525 spin_lock(&journal->j_list_lock);
526 if (!journal->j_checkpoint_transactions) {
527 spin_unlock(&journal->j_list_lock);
530 __jbd2_journal_clean_checkpoint_list(journal, true);
531 spin_unlock(&journal->j_list_lock);
558 journal_t *journal;
568 journal = transaction->t_journal;
574 * may become inconsistent. We cannot abort the journal here since
577 * journal here and we abort the journal later from a better context.
580 set_bit(JBD2_CHECKPOINT_IO_ERROR, &journal->j_atomic_flags);
584 percpu_counter_dec(&journal->j_checkpoint_jh_count);
611 trace_jbd2_checkpoint_stats(journal->j_fs_dev->bd_dev,
614 __jbd2_journal_drop_transaction(journal, transaction);
654 * Called with the journal locked.
686 * Called with the journal locked.
690 void __jbd2_journal_drop_transaction(journal_t *journal, transaction_t *transaction)
692 assert_spin_locked(&journal->j_list_lock);
694 journal->j_shrink_transaction = NULL;
698 if (journal->j_checkpoint_transactions == transaction)
699 journal->j_checkpoint_transactions =
701 if (journal->j_checkpoint_transactions == transaction)
702 journal->j_checkpoint_transactions = NULL;
711 J_ASSERT(journal->j_committing_transaction != transaction);
712 J_ASSERT(journal->j_running_transaction != transaction);
714 trace_jbd2_drop_transaction(journal, transaction);