Skip to content

Commit dc6e8d6

Browse files
committed
jbd2: don't call get_bh() before calling __jbd2_journal_remove_checkpoint()
The __jbd2_journal_remove_checkpoint() doesn't require an elevated b_count; indeed, until the jh structure gets released by the call to jbd2_journal_put_journal_head(), the bh's b_count is elevated by virtue of the existence of the jh structure. Suggested-by: Jan Kara <jack@suse.cz> Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent 754cfed commit dc6e8d6

1 file changed

Lines changed: 5 additions & 14 deletions

File tree

‎fs/jbd2/checkpoint.c‎

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,8 @@ static int __try_to_free_cp_buf(struct journal_head *jh)
9696

9797
if (jh->b_transaction == NULL && !buffer_locked(bh) &&
9898
!buffer_dirty(bh) && !buffer_write_io_error(bh)) {
99-
/*
100-
* Get our reference so that bh cannot be freed before
101-
* we unlock it
102-
*/
103-
get_bh(bh);
10499
JBUFFER_TRACE(jh, "remove from checkpoint list");
105100
ret = __jbd2_journal_remove_checkpoint(jh) + 1;
106-
BUFFER_TRACE(bh, "release");
107-
__brelse(bh);
108101
}
109102
return ret;
110103
}
@@ -216,7 +209,7 @@ int jbd2_log_do_checkpoint(journal_t *journal)
216209
struct buffer_head *bh;
217210
transaction_t *transaction;
218211
tid_t this_tid;
219-
int result, batch_count = 0, done = 0;
212+
int result, batch_count = 0;
220213

221214
jbd_debug(1, "Start checkpoint\n");
222215

@@ -291,11 +284,9 @@ int jbd2_log_do_checkpoint(journal_t *journal)
291284
if (!buffer_dirty(bh)) {
292285
if (unlikely(buffer_write_io_error(bh)) && !result)
293286
result = -EIO;
294-
get_bh(bh);
295287
BUFFER_TRACE(bh, "remove from checkpoint");
296288
__jbd2_journal_remove_checkpoint(jh);
297289
spin_unlock(&journal->j_list_lock);
298-
__brelse(bh);
299290
goto retry;
300291
}
301292
/*
@@ -338,12 +329,12 @@ int jbd2_log_do_checkpoint(journal_t *journal)
338329
transaction->t_tid != this_tid)
339330
goto out;
340331

341-
while (!done && transaction->t_checkpoint_io_list) {
332+
while (transaction->t_checkpoint_io_list) {
342333
jh = transaction->t_checkpoint_io_list;
343334
bh = jh2bh(jh);
344-
get_bh(bh);
345335
if (buffer_locked(bh)) {
346336
spin_unlock(&journal->j_list_lock);
337+
get_bh(bh);
347338
wait_on_buffer(bh);
348339
/* the journal_head may have gone by now */
349340
BUFFER_TRACE(bh, "brelse");
@@ -359,8 +350,8 @@ int jbd2_log_do_checkpoint(journal_t *journal)
359350
* know that it has been written out and so we can
360351
* drop it from the list
361352
*/
362-
done = __jbd2_journal_remove_checkpoint(jh);
363-
__brelse(bh);
353+
if (__jbd2_journal_remove_checkpoint(jh))
354+
break;
364355
}
365356
out:
366357
spin_unlock(&journal->j_list_lock);

0 commit comments

Comments
 (0)