Lines Matching defs:journal

95  * __jbd2_log_wait_for_space: wait until there is space in the journal.
100 void __jbd2_log_wait_for_space(journal_t *journal)
101 __acquires(&journal->j_state_lock)
102 __releases(&journal->j_state_lock)
105 /* assert_spin_locked(&journal->j_state_lock); */
107 nblocks = journal->j_max_transaction_buffers;
108 while (jbd2_log_space_left(journal) < nblocks) {
109 write_unlock(&journal->j_state_lock);
110 mutex_lock_io(&journal->j_checkpoint_mutex);
116 * journal space by calling cleanup_journal_tail(), and if
120 * filesystem, so abort the journal and leave a stack
123 write_lock(&journal->j_state_lock);
124 if (journal->j_flags & JBD2_ABORT) {
125 mutex_unlock(&journal->j_checkpoint_mutex);
128 spin_lock(&journal->j_list_lock);
129 space_left = jbd2_log_space_left(journal);
131 int chkpt = journal->j_checkpoint_transactions != NULL;
134 if (journal->j_committing_transaction)
135 tid = journal->j_committing_transaction->t_tid;
136 spin_unlock(&journal->j_list_lock);
137 write_unlock(&journal->j_state_lock);
139 jbd2_log_do_checkpoint(journal);
140 } else if (jbd2_cleanup_journal_tail(journal) == 0) {
149 mutex_unlock(&journal->j_checkpoint_mutex);
150 jbd2_log_wait_commit(journal, tid);
151 write_lock(&journal->j_state_lock);
158 "journal space in %s\n", __func__,
159 journal->j_devname);
161 jbd2_journal_abort(journal, -EIO);
163 write_lock(&journal->j_state_lock);
165 spin_unlock(&journal->j_list_lock);
167 mutex_unlock(&journal->j_checkpoint_mutex);
172 __flush_batch(journal_t *journal, int *batch_count)
179 write_dirty_buffer(journal->j_chkpt_bhs[i], REQ_SYNC);
183 struct buffer_head *bh = journal->j_chkpt_bhs[i];
195 * The journal should be locked before calling this function.
198 int jbd2_log_do_checkpoint(journal_t *journal)
211 * journal straight away.
213 result = jbd2_cleanup_journal_tail(journal);
214 trace_jbd2_checkpoint(journal, result);
223 spin_lock(&journal->j_list_lock);
224 if (!journal->j_checkpoint_transactions)
226 transaction = journal->j_checkpoint_transactions;
236 if (journal->j_checkpoint_transactions != transaction ||
247 spin_unlock(&journal->j_list_lock);
259 spin_unlock(&journal->j_list_lock);
260 if (unlikely(journal->j_flags & JBD2_UNMOUNT))
262 * The journal thread is dead; so
269 journal->j_devname, (unsigned long long) bh->b_blocknr);
272 __flush_batch(journal, &batch_count);
273 jbd2_log_start_commit(journal, tid);
282 mutex_unlock(&journal->j_checkpoint_mutex);
283 jbd2_log_wait_commit(journal, tid);
284 mutex_lock_io(&journal->j_checkpoint_mutex);
285 spin_lock(&journal->j_list_lock);
297 * possibly block, while still holding the journal
306 journal->j_chkpt_bhs[batch_count++] = bh;
311 spin_needbreak(&journal->j_list_lock))
317 spin_unlock(&journal->j_list_lock);
320 __flush_batch(journal, &batch_count);
321 spin_lock(&journal->j_list_lock);
331 if (journal->j_checkpoint_transactions != transaction ||
340 spin_unlock(&journal->j_list_lock);
345 spin_lock(&journal->j_list_lock);
358 spin_unlock(&journal->j_list_lock);
359 result = jbd2_cleanup_journal_tail(journal);
365 * Check the list of checkpoint transactions for the journal to see if
367 * in the journal superblock. If so, we can instantly roll the
372 * Called with the journal lock held.
376 * main filesystem area rather than to the journal, so it can proceed
382 int jbd2_cleanup_journal_tail(journal_t *journal)
387 if (is_journal_aborted(journal))
390 if (!jbd2_journal_get_log_tail(journal, &first_tid, &blocknr))
397 * we drop the transactions from the journal. It's unlikely this will
398 * be necessary, especially with an appropriately sized journal, but we
402 if (journal->j_flags & JBD2_BARRIER)
403 blkdev_issue_flush(journal->j_fs_dev, GFP_NOFS);
405 return __jbd2_update_log_tail(journal, first_tid, blocknr);
499 * Find 'nr_to_scan' written-back checkpoint buffers in the journal
505 unsigned long jbd2_journal_shrink_checkpoint_list(journal_t *journal,
516 spin_lock(&journal->j_list_lock);
517 if (!journal->j_checkpoint_transactions) {
518 spin_unlock(&journal->j_list_lock);
528 if (journal->j_shrink_transaction)
529 transaction = journal->j_shrink_transaction;
531 transaction = journal->j_checkpoint_transactions;
535 last_transaction = journal->j_checkpoint_transactions->t_cpprev;
548 if (need_resched() || spin_needbreak(&journal->j_list_lock))
557 if (need_resched() || spin_needbreak(&journal->j_list_lock))
562 journal->j_shrink_transaction = next_transaction;
565 journal->j_shrink_transaction = NULL;
569 spin_unlock(&journal->j_list_lock);
576 trace_jbd2_shrink_checkpoint_list(journal, first_tid, tid, last_tid,
585 * Find all the written-back checkpoint buffers in the journal and release them.
590 void __jbd2_journal_clean_checkpoint_list(journal_t *journal, bool destroy)
595 transaction = journal->j_checkpoint_transactions;
635 * Remove buffers from all checkpoint lists as journal is aborted and we just
638 void jbd2_journal_destroy_checkpoint(journal_t *journal)
645 spin_lock(&journal->j_list_lock);
646 if (!journal->j_checkpoint_transactions) {
647 spin_unlock(&journal->j_list_lock);
650 __jbd2_journal_clean_checkpoint_list(journal, true);
651 spin_unlock(&journal->j_list_lock);
678 journal_t *journal;
688 journal = transaction->t_journal;
694 * may become inconsistent. We cannot abort the journal here since
697 * journal here and we abort the journal later from a better context.
700 set_bit(JBD2_CHECKPOINT_IO_ERROR, &journal->j_atomic_flags);
704 percpu_counter_dec(&journal->j_checkpoint_jh_count);
731 trace_jbd2_checkpoint_stats(journal->j_fs_dev->bd_dev,
734 __jbd2_journal_drop_transaction(journal, transaction);
744 * Called with the journal locked.
776 * Called with the journal locked.
780 void __jbd2_journal_drop_transaction(journal_t *journal, transaction_t *transaction)
782 assert_spin_locked(&journal->j_list_lock);
784 journal->j_shrink_transaction = NULL;
788 if (journal->j_checkpoint_transactions == transaction)
789 journal->j_checkpoint_transactions =
791 if (journal->j_checkpoint_transactions == transaction)
792 journal->j_checkpoint_transactions = NULL;
802 J_ASSERT(journal->j_committing_transaction != transaction);
803 J_ASSERT(journal->j_running_transaction != transaction);
805 trace_jbd2_drop_transaction(journal, transaction);