Fix missing static function declaration
[ext4-patch-queue.git] / dont-elevate-b_count-before-calling-__jbd2_journal_remove_checkpoint
blobeb12eae05817f0fa05fa737d1670e000bcb91d79
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>
11 ---
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)) {
23 -               /*
24 -                * Get our reference so that bh cannot be freed before
25 -                * we unlock it
26 -                */
27 -               get_bh(bh);
28                 JBUFFER_TRACE(jh, "remove from checkpoint list");
29                 ret = __jbd2_journal_remove_checkpoint(jh) + 1;
30 -               BUFFER_TRACE(bh, "release");
31 -               __brelse(bh);
32         }
33         return ret;
34  }
35 @@ -216,7 +209,7 @@ int jbd2_log_do_checkpoint(journal_t *journal)
36         struct buffer_head      *bh;
37         transaction_t           *transaction;
38         tid_t                   this_tid;
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)
47                                 result = -EIO;
48 -                       get_bh(bh);
49                         BUFFER_TRACE(bh, "remove from checkpoint");
50                         __jbd2_journal_remove_checkpoint(jh);
51                         spin_unlock(&journal->j_list_lock);
52 -                       __brelse(bh);
53                         goto retry;
54                 }
55                 /*
56 @@ -338,12 +329,12 @@ restart2:
57             transaction->t_tid != this_tid)
58                 goto out;
60 -       while (!done && transaction->t_checkpoint_io_list) {
61 +       while (transaction->t_checkpoint_io_list) {
62                 jh = transaction->t_checkpoint_io_list;
63                 bh = jh2bh(jh);
64 -               get_bh(bh);
65                 if (buffer_locked(bh)) {
66                         spin_unlock(&journal->j_list_lock);
67 +                       get_bh(bh);
68                         wait_on_buffer(bh);
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
74                  */
75 -               done = __jbd2_journal_remove_checkpoint(jh);
76 -               __brelse(bh);
77 +               if (__jbd2_journal_remove_checkpoint(jh))
78 +                       break;
79         }
80  out:
81         spin_unlock(&journal->j_list_lock);