1 jbd2: don't call get_bh() before calling __jbd2_journal_remove_checkpoint()
3 The __jbd2_journal_remove_checkpoint() doesn't require an elevated
4 b_count; indeed, until the jh structure gets released by the call to
5 jbd2_journal_put_journal_head(), the bh's b_count is elevated by
6 virtue of the existence of the jh structure.
8 Suggested-by: Jan Kara <jack@suse.cz>
9 Reviewed-by: Jan Kara <jack@suse.cz>
10 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 fs/jbd2/checkpoint.c | 19 +++++--------------
13 1 file changed, 5 insertions(+), 14 deletions(-)
15 diff --git a/fs/jbd2/checkpoint.c b/fs/jbd2/checkpoint.c
16 index 18c7a8d..90d6091 100644
17 --- a/fs/jbd2/checkpoint.c
18 +++ b/fs/jbd2/checkpoint.c
19 @@ -96,15 +96,8 @@ static int __try_to_free_cp_buf(struct journal_head *jh)
21 if (jh->b_transaction == NULL && !buffer_locked(bh) &&
22 !buffer_dirty(bh) && !buffer_write_io_error(bh)) {
24 - * Get our reference so that bh cannot be freed before
28 JBUFFER_TRACE(jh, "remove from checkpoint list");
29 ret = __jbd2_journal_remove_checkpoint(jh) + 1;
30 - BUFFER_TRACE(bh, "release");
35 @@ -216,7 +209,7 @@ int jbd2_log_do_checkpoint(journal_t *journal)
36 struct buffer_head *bh;
37 transaction_t *transaction;
39 - int result, batch_count = 0, done = 0;
40 + int result, batch_count = 0;
42 jbd_debug(1, "Start checkpoint\n");
44 @@ -291,11 +284,9 @@ restart:
45 if (!buffer_dirty(bh)) {
46 if (unlikely(buffer_write_io_error(bh)) && !result)
49 BUFFER_TRACE(bh, "remove from checkpoint");
50 __jbd2_journal_remove_checkpoint(jh);
51 spin_unlock(&journal->j_list_lock);
56 @@ -338,12 +329,12 @@ restart2:
57 transaction->t_tid != this_tid)
60 - while (!done && transaction->t_checkpoint_io_list) {
61 + while (transaction->t_checkpoint_io_list) {
62 jh = transaction->t_checkpoint_io_list;
65 if (buffer_locked(bh)) {
66 spin_unlock(&journal->j_list_lock);
69 /* the journal_head may have gone by now */
70 BUFFER_TRACE(bh, "brelse");
71 @@ -359,8 +350,8 @@ restart2:
72 * know that it has been written out and so we can
73 * drop it from the list
75 - done = __jbd2_journal_remove_checkpoint(jh);
77 + if (__jbd2_journal_remove_checkpoint(jh))
81 spin_unlock(&journal->j_list_lock);