1 jbd2: fold __wait_cp_io into jbd2_log_do_checkpoint()
3 __wait_cp_io() is only called by jbd2_log_do_checkpoint(). Fold it in
4 to make it a bit easier to understand.
6 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
8 fs/jbd2/checkpoint.c | 87 +++++++++++++++++++++++++++++++--------------------------------------------------------
9 1 file changed, 31 insertions(+), 56 deletions(-)
11 diff --git a/fs/jbd2/checkpoint.c b/fs/jbd2/checkpoint.c
12 index 993a187..22fcd50 100644
13 --- a/fs/jbd2/checkpoint.c
14 +++ b/fs/jbd2/checkpoint.c
15 @@ -183,58 +183,6 @@ void __jbd2_log_wait_for_space(journal_t *journal)
20 - * Clean up transaction's list of buffers submitted for io.
21 - * We wait for any pending IO to complete and remove any clean
22 - * buffers. Note that we take the buffers in the opposite ordering
23 - * from the one in which they were submitted for IO.
25 - * Return 0 on success, and return <0 if some buffers have failed
26 - * to be written out.
28 - * Called with j_list_lock held.
30 -static int __wait_cp_io(journal_t *journal, transaction_t *transaction)
32 - struct journal_head *jh;
33 - struct buffer_head *bh;
38 - this_tid = transaction->t_tid;
40 - /* Did somebody clean up the transaction in the meanwhile? */
41 - if (journal->j_checkpoint_transactions != transaction ||
42 - transaction->t_tid != this_tid)
44 - while (!released && transaction->t_checkpoint_io_list) {
45 - jh = transaction->t_checkpoint_io_list;
48 - if (buffer_locked(bh)) {
49 - spin_unlock(&journal->j_list_lock);
51 - /* the journal_head may have gone by now */
52 - BUFFER_TRACE(bh, "brelse");
54 - spin_lock(&journal->j_list_lock);
57 - if (unlikely(buffer_write_io_error(bh)))
61 - * Now in whatever state the buffer currently is, we know that
62 - * it has been written out and so we can drop it from the list
64 - released = __jbd2_journal_remove_checkpoint(jh);
72 __flush_batch(journal_t *journal, int *batch_count)
74 @@ -268,7 +216,7 @@ int jbd2_log_do_checkpoint(journal_t *journal)
75 struct buffer_head *bh;
76 transaction_t *transaction;
78 - int err, result, batch_count = 0;
79 + int result, batch_count = 0, done = 0;
81 jbd_debug(1, "Start checkpoint\n");
83 @@ -384,9 +332,36 @@ restart:
84 * Now we issued all of the transaction's buffers, let's deal
85 * with the buffers that are out for I/O.
87 - err = __wait_cp_io(journal, transaction);
91 + /* Did somebody clean up the transaction in the meanwhile? */
92 + if (journal->j_checkpoint_transactions != transaction ||
93 + transaction->t_tid != this_tid)
96 + while (!done && transaction->t_checkpoint_io_list) {
97 + jh = transaction->t_checkpoint_io_list;
100 + if (buffer_locked(bh)) {
101 + spin_unlock(&journal->j_list_lock);
102 + wait_on_buffer(bh);
103 + /* the journal_head may have gone by now */
104 + BUFFER_TRACE(bh, "brelse");
106 + spin_lock(&journal->j_list_lock);
109 + if (unlikely(buffer_write_io_error(bh)) && !result)
113 + * Now in whatever state the buffer currently is, we
114 + * know that it has been written out and so we can
115 + * drop it from the list
117 + done = __jbd2_journal_remove_checkpoint(jh);
121 spin_unlock(&journal->j_list_lock);