Lines Matching +full:straight +full:- +full:forward

1 // SPDX-License-Identifier: GPL-2.0+
7 * Copyright 1999 Red Hat Software --- All Rights Reserved
32 transaction_t *transaction = jh->b_cp_transaction; in __buffer_unlink()
34 jh->b_cpnext->b_cpprev = jh->b_cpprev; in __buffer_unlink()
35 jh->b_cpprev->b_cpnext = jh->b_cpnext; in __buffer_unlink()
36 if (transaction->t_checkpoint_list == jh) { in __buffer_unlink()
37 transaction->t_checkpoint_list = jh->b_cpnext; in __buffer_unlink()
38 if (transaction->t_checkpoint_list == jh) in __buffer_unlink()
39 transaction->t_checkpoint_list = NULL; in __buffer_unlink()
46 * Called under j-state_lock *only*. It will be unlocked if we have to wait
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()
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()
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()
104 mutex_unlock(&journal->j_checkpoint_mutex); 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()
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()
167 * journal straight away. 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()
183 if (transaction->t_chp_stats.cs_chp_time == 0) in jbd2_log_do_checkpoint()
184 transaction->t_chp_stats.cs_chp_time = jiffies; in jbd2_log_do_checkpoint()
185 this_tid = transaction->t_tid; in jbd2_log_do_checkpoint()
192 if (journal->j_checkpoint_transactions != transaction || in jbd2_log_do_checkpoint()
193 transaction->t_tid != this_tid) in jbd2_log_do_checkpoint()
197 while (transaction->t_checkpoint_list) { in jbd2_log_do_checkpoint()
198 jh = transaction->t_checkpoint_list; in jbd2_log_do_checkpoint()
201 if (jh->b_transaction != NULL) { in jbd2_log_do_checkpoint()
202 transaction_t *t = jh->b_transaction; in jbd2_log_do_checkpoint()
203 tid_t tid = t->t_tid; in jbd2_log_do_checkpoint()
205 transaction->t_chp_stats.cs_forced_to_close++; 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()
229 mutex_unlock(&journal->j_checkpoint_mutex); 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()
239 * re-adding into a new transaction, need to check in jbd2_log_do_checkpoint()
243 spin_unlock(&journal->j_list_lock); in jbd2_log_do_checkpoint()
257 !transaction->t_checkpoint_list) in jbd2_log_do_checkpoint()
264 * re-log logic once we release the j_list_lock, in jbd2_log_do_checkpoint()
271 journal->j_chkpt_bhs[batch_count++] = bh; in jbd2_log_do_checkpoint()
272 transaction->t_chp_stats.cs_written++; in jbd2_log_do_checkpoint()
273 transaction->t_checkpoint_list = jh->b_cpnext; 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()
288 spin_lock(&journal->j_list_lock); in jbd2_log_do_checkpoint()
293 spin_unlock(&journal->j_list_lock); in jbd2_log_do_checkpoint()
303 * superblock forward to remove those transactions from the log.
314 * buffers which should be written-back to the filesystem.
323 return -EIO; in jbd2_cleanup_journal_tail()
331 * --- perhaps by jbd2_log_do_checkpoint() --- are flushed out before 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()
349 * Find all the written-back checkpoint buffers in the given list
369 last_jh = jh->b_cpprev; in journal_shrink_one_cp_list()
372 next_jh = jh->b_cpnext; in journal_shrink_one_cp_list()
401 * Find 'nr_to_scan' written-back checkpoint buffers in the journal
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()
437 first_tid = transaction->t_tid; in jbd2_journal_shrink_checkpoint_list()
440 last_transaction = journal->j_checkpoint_transactions->t_cpprev; in jbd2_journal_shrink_checkpoint_list()
442 last_tid = last_transaction->t_tid; in jbd2_journal_shrink_checkpoint_list()
445 next_transaction = transaction->t_cpnext; in jbd2_journal_shrink_checkpoint_list()
446 tid = transaction->t_tid; in jbd2_journal_shrink_checkpoint_list()
448 freed = journal_shrink_one_cp_list(transaction->t_checkpoint_list, in jbd2_journal_shrink_checkpoint_list()
451 (*nr_to_scan) -= min(*nr_to_scan, freed); 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()
460 next_tid = next_transaction->t_tid; 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()
481 * Find all the written-back checkpoint buffers in the journal and release them.
497 transaction = journal->j_checkpoint_transactions; in __jbd2_journal_clean_checkpoint_list()
501 last_transaction = transaction->t_cpprev; in __jbd2_journal_clean_checkpoint_list()
505 next_transaction = transaction->t_cpnext; in __jbd2_journal_clean_checkpoint_list()
506 journal_shrink_one_cp_list(transaction->t_checkpoint_list, in __jbd2_journal_clean_checkpoint_list()
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()
542 spin_unlock(&journal->j_list_lock); in jbd2_journal_destroy_checkpoint()
549 * to disk (either by being write-back flushed to disk, or being
573 transaction = jh->b_cp_transaction; in __jbd2_journal_remove_checkpoint()
578 journal = transaction->t_journal; in __jbd2_journal_remove_checkpoint()
583 jh->b_cp_transaction = NULL; in __jbd2_journal_remove_checkpoint()
584 percpu_counter_dec(&journal->j_checkpoint_jh_count); in __jbd2_journal_remove_checkpoint()
588 if (transaction->t_checkpoint_list) in __jbd2_journal_remove_checkpoint()
600 if (transaction->t_state != T_FINISHED) in __jbd2_journal_remove_checkpoint()
607 stats = &transaction->t_chp_stats; in __jbd2_journal_remove_checkpoint()
608 if (stats->cs_chp_time) in __jbd2_journal_remove_checkpoint()
609 stats->cs_chp_time = jbd2_time_diff(stats->cs_chp_time, in __jbd2_journal_remove_checkpoint()
611 trace_jbd2_checkpoint_stats(journal->j_fs_dev->bd_dev, in __jbd2_journal_remove_checkpoint()
612 transaction->t_tid, stats); in __jbd2_journal_remove_checkpoint()
621 * list if it's clean. Returns -EBUSY if it is not clean, returns 1 if
630 if (jh->b_transaction) in jbd2_journal_try_remove_checkpoint()
631 return -EBUSY; in jbd2_journal_try_remove_checkpoint()
633 return -EBUSY; in jbd2_journal_try_remove_checkpoint()
636 return -EBUSY; in jbd2_journal_try_remove_checkpoint()
662 J_ASSERT_JH(jh, jh->b_cp_transaction == NULL); in __jbd2_journal_insert_checkpoint()
666 jh->b_cp_transaction = transaction; in __jbd2_journal_insert_checkpoint()
668 if (!transaction->t_checkpoint_list) { in __jbd2_journal_insert_checkpoint()
669 jh->b_cpnext = jh->b_cpprev = jh; in __jbd2_journal_insert_checkpoint()
671 jh->b_cpnext = transaction->t_checkpoint_list; in __jbd2_journal_insert_checkpoint()
672 jh->b_cpprev = transaction->t_checkpoint_list->b_cpprev; in __jbd2_journal_insert_checkpoint()
673 jh->b_cpprev->b_cpnext = jh; in __jbd2_journal_insert_checkpoint()
674 jh->b_cpnext->b_cpprev = jh; in __jbd2_journal_insert_checkpoint()
676 transaction->t_checkpoint_list = jh; in __jbd2_journal_insert_checkpoint()
677 percpu_counter_inc(&transaction->t_journal->j_checkpoint_jh_count); in __jbd2_journal_insert_checkpoint()
692 assert_spin_locked(&journal->j_list_lock); in __jbd2_journal_drop_transaction()
694 journal->j_shrink_transaction = NULL; in __jbd2_journal_drop_transaction()
695 if (transaction->t_cpnext) { in __jbd2_journal_drop_transaction()
696 transaction->t_cpnext->t_cpprev = transaction->t_cpprev; in __jbd2_journal_drop_transaction()
697 transaction->t_cpprev->t_cpnext = transaction->t_cpnext; 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()
700 transaction->t_cpnext; 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()
705 J_ASSERT(transaction->t_state == T_FINISHED); in __jbd2_journal_drop_transaction()
706 J_ASSERT(transaction->t_buffers == NULL); in __jbd2_journal_drop_transaction()
707 J_ASSERT(transaction->t_forget == NULL); in __jbd2_journal_drop_transaction()
708 J_ASSERT(transaction->t_shadow_list == NULL); in __jbd2_journal_drop_transaction()
709 J_ASSERT(transaction->t_checkpoint_list == NULL); in __jbd2_journal_drop_transaction()
710 J_ASSERT(atomic_read(&transaction->t_updates) == 0); 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()
716 jbd2_debug(1, "Dropping transaction %d, all done\n", transaction->t_tid); in __jbd2_journal_drop_transaction()