Skip to content

Commit 88fe1ac

Browse files
committed
jbd2: fold __wait_cp_io into jbd2_log_do_checkpoint()
__wait_cp_io() is only called by jbd2_log_do_checkpoint(). Fold it in to make it a bit easier to understand. Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent be1158c commit 88fe1ac

1 file changed

Lines changed: 31 additions & 56 deletions

File tree

‎fs/jbd2/checkpoint.c‎

Lines changed: 31 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -183,58 +183,6 @@ void __jbd2_log_wait_for_space(journal_t *journal)
183183
}
184184
}
185185

186-
/*
187-
* Clean up transaction's list of buffers submitted for io.
188-
* We wait for any pending IO to complete and remove any clean
189-
* buffers. Note that we take the buffers in the opposite ordering
190-
* from the one in which they were submitted for IO.
191-
*
192-
* Return 0 on success, and return <0 if some buffers have failed
193-
* to be written out.
194-
*
195-
* Called with j_list_lock held.
196-
*/
197-
static int __wait_cp_io(journal_t *journal, transaction_t *transaction)
198-
{
199-
struct journal_head *jh;
200-
struct buffer_head *bh;
201-
tid_t this_tid;
202-
int released = 0;
203-
int ret = 0;
204-
205-
this_tid = transaction->t_tid;
206-
restart:
207-
/* Did somebody clean up the transaction in the meanwhile? */
208-
if (journal->j_checkpoint_transactions != transaction ||
209-
transaction->t_tid != this_tid)
210-
return ret;
211-
while (!released && transaction->t_checkpoint_io_list) {
212-
jh = transaction->t_checkpoint_io_list;
213-
bh = jh2bh(jh);
214-
get_bh(bh);
215-
if (buffer_locked(bh)) {
216-
spin_unlock(&journal->j_list_lock);
217-
wait_on_buffer(bh);
218-
/* the journal_head may have gone by now */
219-
BUFFER_TRACE(bh, "brelse");
220-
__brelse(bh);
221-
spin_lock(&journal->j_list_lock);
222-
goto restart;
223-
}
224-
if (unlikely(buffer_write_io_error(bh)))
225-
ret = -EIO;
226-
227-
/*
228-
* Now in whatever state the buffer currently is, we know that
229-
* it has been written out and so we can drop it from the list
230-
*/
231-
released = __jbd2_journal_remove_checkpoint(jh);
232-
__brelse(bh);
233-
}
234-
235-
return ret;
236-
}
237-
238186
static void
239187
__flush_batch(journal_t *journal, int *batch_count)
240188
{
@@ -268,7 +216,7 @@ int jbd2_log_do_checkpoint(journal_t *journal)
268216
struct buffer_head *bh;
269217
transaction_t *transaction;
270218
tid_t this_tid;
271-
int err, result, batch_count = 0;
219+
int result, batch_count = 0, done = 0;
272220

273221
jbd_debug(1, "Start checkpoint\n");
274222

@@ -384,9 +332,36 @@ int jbd2_log_do_checkpoint(journal_t *journal)
384332
* Now we issued all of the transaction's buffers, let's deal
385333
* with the buffers that are out for I/O.
386334
*/
387-
err = __wait_cp_io(journal, transaction);
388-
if (!result)
389-
result = err;
335+
restart2:
336+
/* Did somebody clean up the transaction in the meanwhile? */
337+
if (journal->j_checkpoint_transactions != transaction ||
338+
transaction->t_tid != this_tid)
339+
goto out;
340+
341+
while (!done && transaction->t_checkpoint_io_list) {
342+
jh = transaction->t_checkpoint_io_list;
343+
bh = jh2bh(jh);
344+
get_bh(bh);
345+
if (buffer_locked(bh)) {
346+
spin_unlock(&journal->j_list_lock);
347+
wait_on_buffer(bh);
348+
/* the journal_head may have gone by now */
349+
BUFFER_TRACE(bh, "brelse");
350+
__brelse(bh);
351+
spin_lock(&journal->j_list_lock);
352+
goto restart2;
353+
}
354+
if (unlikely(buffer_write_io_error(bh)) && !result)
355+
result = -EIO;
356+
357+
/*
358+
* Now in whatever state the buffer currently is, we
359+
* know that it has been written out and so we can
360+
* drop it from the list
361+
*/
362+
done = __jbd2_journal_remove_checkpoint(jh);
363+
__brelse(bh);
364+
}
390365
out:
391366
spin_unlock(&journal->j_list_lock);
392367
if (result < 0)

0 commit comments

Comments
 (0)