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_first()
34 jh->b_cpnext->b_cpprev = jh->b_cpprev; in __buffer_unlink_first()
35 jh->b_cpprev->b_cpnext = jh->b_cpnext; in __buffer_unlink_first()
36 if (transaction->t_checkpoint_list == jh) { in __buffer_unlink_first()
37 transaction->t_checkpoint_list = jh->b_cpnext; in __buffer_unlink_first()
38 if (transaction->t_checkpoint_list == jh) in __buffer_unlink_first()
39 transaction->t_checkpoint_list = NULL; in __buffer_unlink_first()
50 transaction_t *transaction = jh->b_cp_transaction; in __buffer_unlink()
53 if (transaction->t_checkpoint_io_list == jh) { in __buffer_unlink()
54 transaction->t_checkpoint_io_list = jh->b_cpnext; in __buffer_unlink()
55 if (transaction->t_checkpoint_io_list == jh) in __buffer_unlink()
56 transaction->t_checkpoint_io_list = NULL; in __buffer_unlink()
67 transaction_t *transaction = jh->b_cp_transaction; in __buffer_relink_io()
71 if (!transaction->t_checkpoint_io_list) { in __buffer_relink_io()
72 jh->b_cpnext = jh->b_cpprev = jh; in __buffer_relink_io()
74 jh->b_cpnext = transaction->t_checkpoint_io_list; in __buffer_relink_io()
75 jh->b_cpprev = transaction->t_checkpoint_io_list->b_cpprev; in __buffer_relink_io()
76 jh->b_cpprev->b_cpnext = jh; in __buffer_relink_io()
77 jh->b_cpnext->b_cpprev = jh; in __buffer_relink_io()
79 transaction->t_checkpoint_io_list = jh; in __buffer_relink_io()
91 return (jh->b_transaction || buffer_locked(bh) || buffer_dirty(bh)); in __cp_buffer_busy()
97 * Called under j-state_lock *only*. It will be unlocked if we have to wait
101 __acquires(&journal->j_state_lock) in __jbd2_log_wait_for_space()
102 __releases(&journal->j_state_lock) in __jbd2_log_wait_for_space()
105 /* assert_spin_locked(&journal->j_state_lock); */ in __jbd2_log_wait_for_space()
107 nblocks = journal->j_max_transaction_buffers; in __jbd2_log_wait_for_space()
109 write_unlock(&journal->j_state_lock); in __jbd2_log_wait_for_space()
110 mutex_lock_io(&journal->j_checkpoint_mutex); in __jbd2_log_wait_for_space()
123 write_lock(&journal->j_state_lock); in __jbd2_log_wait_for_space()
124 if (journal->j_flags & JBD2_ABORT) { in __jbd2_log_wait_for_space()
125 mutex_unlock(&journal->j_checkpoint_mutex); in __jbd2_log_wait_for_space()
128 spin_lock(&journal->j_list_lock); in __jbd2_log_wait_for_space()
131 int chkpt = journal->j_checkpoint_transactions != NULL; in __jbd2_log_wait_for_space()
134 if (journal->j_committing_transaction) in __jbd2_log_wait_for_space()
135 tid = journal->j_committing_transaction->t_tid; in __jbd2_log_wait_for_space()
136 spin_unlock(&journal->j_list_lock); in __jbd2_log_wait_for_space()
137 write_unlock(&journal->j_state_lock); in __jbd2_log_wait_for_space()
149 mutex_unlock(&journal->j_checkpoint_mutex); in __jbd2_log_wait_for_space()
151 write_lock(&journal->j_state_lock); in __jbd2_log_wait_for_space()
159 journal->j_devname); in __jbd2_log_wait_for_space()
161 jbd2_journal_abort(journal, -EIO); in __jbd2_log_wait_for_space()
163 write_lock(&journal->j_state_lock); in __jbd2_log_wait_for_space()
165 spin_unlock(&journal->j_list_lock); in __jbd2_log_wait_for_space()
167 mutex_unlock(&journal->j_checkpoint_mutex); in __jbd2_log_wait_for_space()
179 write_dirty_buffer(journal->j_chkpt_bhs[i], REQ_SYNC); in __flush_batch()
183 struct buffer_head *bh = journal->j_chkpt_bhs[i]; in __flush_batch()
211 * journal straight away. in jbd2_log_do_checkpoint()
223 spin_lock(&journal->j_list_lock); in jbd2_log_do_checkpoint()
224 if (!journal->j_checkpoint_transactions) in jbd2_log_do_checkpoint()
226 transaction = journal->j_checkpoint_transactions; in jbd2_log_do_checkpoint()
227 if (transaction->t_chp_stats.cs_chp_time == 0) in jbd2_log_do_checkpoint()
228 transaction->t_chp_stats.cs_chp_time = jiffies; in jbd2_log_do_checkpoint()
229 this_tid = transaction->t_tid; in jbd2_log_do_checkpoint()
236 if (journal->j_checkpoint_transactions != transaction || in jbd2_log_do_checkpoint()
237 transaction->t_tid != this_tid) in jbd2_log_do_checkpoint()
241 while (transaction->t_checkpoint_list) { in jbd2_log_do_checkpoint()
242 jh = transaction->t_checkpoint_list; in jbd2_log_do_checkpoint()
247 spin_unlock(&journal->j_list_lock); in jbd2_log_do_checkpoint()
254 if (jh->b_transaction != NULL) { in jbd2_log_do_checkpoint()
255 transaction_t *t = jh->b_transaction; in jbd2_log_do_checkpoint()
256 tid_t tid = t->t_tid; in jbd2_log_do_checkpoint()
258 transaction->t_chp_stats.cs_forced_to_close++; in jbd2_log_do_checkpoint()
259 spin_unlock(&journal->j_list_lock); in jbd2_log_do_checkpoint()
260 if (unlikely(journal->j_flags & JBD2_UNMOUNT)) in jbd2_log_do_checkpoint()
269 journal->j_devname, (unsigned long long) bh->b_blocknr); in jbd2_log_do_checkpoint()
282 mutex_unlock(&journal->j_checkpoint_mutex); in jbd2_log_do_checkpoint()
284 mutex_lock_io(&journal->j_checkpoint_mutex); in jbd2_log_do_checkpoint()
285 spin_lock(&journal->j_list_lock); in jbd2_log_do_checkpoint()
306 journal->j_chkpt_bhs[batch_count++] = bh; in jbd2_log_do_checkpoint()
308 transaction->t_chp_stats.cs_written++; in jbd2_log_do_checkpoint()
311 spin_needbreak(&journal->j_list_lock)) in jbd2_log_do_checkpoint()
317 spin_unlock(&journal->j_list_lock); in jbd2_log_do_checkpoint()
321 spin_lock(&journal->j_list_lock); in jbd2_log_do_checkpoint()
331 if (journal->j_checkpoint_transactions != transaction || in jbd2_log_do_checkpoint()
332 transaction->t_tid != this_tid) in jbd2_log_do_checkpoint()
335 while (transaction->t_checkpoint_io_list) { in jbd2_log_do_checkpoint()
336 jh = transaction->t_checkpoint_io_list; in jbd2_log_do_checkpoint()
340 spin_unlock(&journal->j_list_lock); in jbd2_log_do_checkpoint()
345 spin_lock(&journal->j_list_lock); in jbd2_log_do_checkpoint()
358 spin_unlock(&journal->j_list_lock); in jbd2_log_do_checkpoint()
368 * superblock forward to remove those transactions from the log.
379 * buffers which should be written-back to the filesystem.
388 return -EIO; in jbd2_cleanup_journal_tail()
396 * --- perhaps by jbd2_log_do_checkpoint() --- are flushed out before in jbd2_cleanup_journal_tail()
402 if (journal->j_flags & JBD2_BARRIER) in jbd2_cleanup_journal_tail()
403 blkdev_issue_flush(journal->j_fs_dev); in jbd2_cleanup_journal_tail()
414 * Find all the written-back checkpoint buffers in the given list and
428 last_jh = jh->b_cpprev; in journal_clean_one_cp_list()
431 next_jh = jh->b_cpnext; in journal_clean_one_cp_list()
454 * Find 'nr_to_scan' written-back checkpoint buffers in the given list
473 last_jh = jh->b_cpprev; in journal_shrink_one_cp_list()
476 next_jh = jh->b_cpnext; in journal_shrink_one_cp_list()
478 (*nr_to_scan)--; in journal_shrink_one_cp_list()
499 * Find 'nr_to_scan' written-back checkpoint buffers in the journal
516 spin_lock(&journal->j_list_lock); in jbd2_journal_shrink_checkpoint_list()
517 if (!journal->j_checkpoint_transactions) { in jbd2_journal_shrink_checkpoint_list()
518 spin_unlock(&journal->j_list_lock); in jbd2_journal_shrink_checkpoint_list()
528 if (journal->j_shrink_transaction) in jbd2_journal_shrink_checkpoint_list()
529 transaction = journal->j_shrink_transaction; in jbd2_journal_shrink_checkpoint_list()
531 transaction = journal->j_checkpoint_transactions; in jbd2_journal_shrink_checkpoint_list()
534 first_tid = transaction->t_tid; in jbd2_journal_shrink_checkpoint_list()
535 last_transaction = journal->j_checkpoint_transactions->t_cpprev; in jbd2_journal_shrink_checkpoint_list()
537 last_tid = last_transaction->t_tid; in jbd2_journal_shrink_checkpoint_list()
540 next_transaction = transaction->t_cpnext; in jbd2_journal_shrink_checkpoint_list()
541 tid = transaction->t_tid; in jbd2_journal_shrink_checkpoint_list()
544 nr_freed += journal_shrink_one_cp_list(transaction->t_checkpoint_list, in jbd2_journal_shrink_checkpoint_list()
548 if (need_resched() || spin_needbreak(&journal->j_list_lock)) in jbd2_journal_shrink_checkpoint_list()
553 nr_freed += journal_shrink_one_cp_list(transaction->t_checkpoint_io_list, in jbd2_journal_shrink_checkpoint_list()
557 if (need_resched() || spin_needbreak(&journal->j_list_lock)) in jbd2_journal_shrink_checkpoint_list()
562 journal->j_shrink_transaction = next_transaction; in jbd2_journal_shrink_checkpoint_list()
563 next_tid = next_transaction->t_tid; in jbd2_journal_shrink_checkpoint_list()
565 journal->j_shrink_transaction = NULL; in jbd2_journal_shrink_checkpoint_list()
569 spin_unlock(&journal->j_list_lock); in jbd2_journal_shrink_checkpoint_list()
575 nr_scanned -= *nr_to_scan; in jbd2_journal_shrink_checkpoint_list()
585 * Find all the written-back checkpoint buffers in the journal and release them.
595 transaction = journal->j_checkpoint_transactions; in __jbd2_journal_clean_checkpoint_list()
599 last_transaction = transaction->t_cpprev; in __jbd2_journal_clean_checkpoint_list()
603 next_transaction = transaction->t_cpnext; in __jbd2_journal_clean_checkpoint_list()
604 ret = journal_clean_one_cp_list(transaction->t_checkpoint_list, in __jbd2_journal_clean_checkpoint_list()
620 ret = journal_clean_one_cp_list(transaction-> in __jbd2_journal_clean_checkpoint_list()
645 spin_lock(&journal->j_list_lock); in jbd2_journal_destroy_checkpoint()
646 if (!journal->j_checkpoint_transactions) { in jbd2_journal_destroy_checkpoint()
647 spin_unlock(&journal->j_list_lock); in jbd2_journal_destroy_checkpoint()
651 spin_unlock(&journal->j_list_lock); in jbd2_journal_destroy_checkpoint()
658 * to disk (either by being write-back flushed to disk, or being
683 transaction = jh->b_cp_transaction; in __jbd2_journal_remove_checkpoint()
688 journal = transaction->t_journal; in __jbd2_journal_remove_checkpoint()
700 set_bit(JBD2_CHECKPOINT_IO_ERROR, &journal->j_atomic_flags); in __jbd2_journal_remove_checkpoint()
703 jh->b_cp_transaction = NULL; in __jbd2_journal_remove_checkpoint()
704 percpu_counter_dec(&journal->j_checkpoint_jh_count); in __jbd2_journal_remove_checkpoint()
708 if (transaction->t_checkpoint_list || transaction->t_checkpoint_io_list) in __jbd2_journal_remove_checkpoint()
720 if (transaction->t_state != T_FINISHED) in __jbd2_journal_remove_checkpoint()
727 stats = &transaction->t_chp_stats; in __jbd2_journal_remove_checkpoint()
728 if (stats->cs_chp_time) in __jbd2_journal_remove_checkpoint()
729 stats->cs_chp_time = jbd2_time_diff(stats->cs_chp_time, in __jbd2_journal_remove_checkpoint()
731 trace_jbd2_checkpoint_stats(journal->j_fs_dev->bd_dev, in __jbd2_journal_remove_checkpoint()
732 transaction->t_tid, stats); in __jbd2_journal_remove_checkpoint()
752 J_ASSERT_JH(jh, jh->b_cp_transaction == NULL); in __jbd2_journal_insert_checkpoint()
756 jh->b_cp_transaction = transaction; in __jbd2_journal_insert_checkpoint()
758 if (!transaction->t_checkpoint_list) { in __jbd2_journal_insert_checkpoint()
759 jh->b_cpnext = jh->b_cpprev = jh; in __jbd2_journal_insert_checkpoint()
761 jh->b_cpnext = transaction->t_checkpoint_list; in __jbd2_journal_insert_checkpoint()
762 jh->b_cpprev = transaction->t_checkpoint_list->b_cpprev; in __jbd2_journal_insert_checkpoint()
763 jh->b_cpprev->b_cpnext = jh; in __jbd2_journal_insert_checkpoint()
764 jh->b_cpnext->b_cpprev = jh; in __jbd2_journal_insert_checkpoint()
766 transaction->t_checkpoint_list = jh; in __jbd2_journal_insert_checkpoint()
767 percpu_counter_inc(&transaction->t_journal->j_checkpoint_jh_count); in __jbd2_journal_insert_checkpoint()
782 assert_spin_locked(&journal->j_list_lock); in __jbd2_journal_drop_transaction()
784 journal->j_shrink_transaction = NULL; in __jbd2_journal_drop_transaction()
785 if (transaction->t_cpnext) { in __jbd2_journal_drop_transaction()
786 transaction->t_cpnext->t_cpprev = transaction->t_cpprev; in __jbd2_journal_drop_transaction()
787 transaction->t_cpprev->t_cpnext = transaction->t_cpnext; in __jbd2_journal_drop_transaction()
788 if (journal->j_checkpoint_transactions == transaction) in __jbd2_journal_drop_transaction()
789 journal->j_checkpoint_transactions = in __jbd2_journal_drop_transaction()
790 transaction->t_cpnext; in __jbd2_journal_drop_transaction()
791 if (journal->j_checkpoint_transactions == transaction) in __jbd2_journal_drop_transaction()
792 journal->j_checkpoint_transactions = NULL; in __jbd2_journal_drop_transaction()
795 J_ASSERT(transaction->t_state == T_FINISHED); in __jbd2_journal_drop_transaction()
796 J_ASSERT(transaction->t_buffers == NULL); in __jbd2_journal_drop_transaction()
797 J_ASSERT(transaction->t_forget == NULL); in __jbd2_journal_drop_transaction()
798 J_ASSERT(transaction->t_shadow_list == NULL); in __jbd2_journal_drop_transaction()
799 J_ASSERT(transaction->t_checkpoint_list == NULL); in __jbd2_journal_drop_transaction()
800 J_ASSERT(transaction->t_checkpoint_io_list == NULL); in __jbd2_journal_drop_transaction()
801 J_ASSERT(atomic_read(&transaction->t_updates) == 0); in __jbd2_journal_drop_transaction()
802 J_ASSERT(journal->j_committing_transaction != transaction); in __jbd2_journal_drop_transaction()
803 J_ASSERT(journal->j_running_transaction != transaction); in __jbd2_journal_drop_transaction()
807 jbd2_debug(1, "Dropping transaction %d, all done\n", transaction->t_tid); in __jbd2_journal_drop_transaction()