add patch move-error-report-out-of-atomic-context
[ext4-patch-queue.git] / simplify-calling-convention-around-jbd2_journal_clean_checkpoint_list
blob3cf59d184c6107c449be12c2c3f507d96e8b750b
1 jbd2: simplify calling convention around __jbd2_journal_clean_checkpoint_list
3 From: Jan Kara <jack@suse.cz>
5 __jbd2_journal_clean_checkpoint_list() returns number of buffers it
6 freed but noone was using the value so just stop doing that. This
7 also allows for simplifying the calling convention for
8 journal_clean_once_cp_list().
10 Signed-off-by: Jan Kara <jack@suse.cz>
11 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 ---
13  fs/jbd2/checkpoint.c | 56 ++++++++++++++++++++++++--------------------------------
14  include/linux/jbd2.h |  2 +-
15  2 files changed, 25 insertions(+), 33 deletions(-)
17 diff --git a/fs/jbd2/checkpoint.c b/fs/jbd2/checkpoint.c
18 index 3ab4c5e..988b32e 100644
19 --- a/fs/jbd2/checkpoint.c
20 +++ b/fs/jbd2/checkpoint.c
21 @@ -421,16 +421,15 @@ int jbd2_cleanup_journal_tail(journal_t *journal)
22   * release them.
23   *
24   * Called with j_list_lock held.
25 - * Returns number of buffers reaped (for debug)
26 + * Returns 1 if we freed the transaction, 0 otherwise.
27   */
29 -static int journal_clean_one_cp_list(struct journal_head *jh, int *released)
30 +static int journal_clean_one_cp_list(struct journal_head *jh)
31  {
32         struct journal_head *last_jh;
33         struct journal_head *next_jh = jh;
34 -       int ret, freed = 0;
35 +       int ret;
36 +       int freed = 0;
38 -       *released = 0;
39         if (!jh)
40                 return 0;
42 @@ -441,11 +440,9 @@ static int journal_clean_one_cp_list(struct journal_head *jh, int *released)
43                 ret = __try_to_free_cp_buf(jh);
44                 if (!ret)
45                         return freed;
46 -               freed++;
47 -               if (ret == 2) {
48 -                       *released = 1;
49 -                       return freed;
50 -               }
51 +               if (ret == 2)
52 +                       return 1;
53 +               freed = 1;
54                 /*
55                  * This function only frees up some memory
56                  * if possible so we dont have an obligation
57 @@ -465,53 +462,48 @@ static int journal_clean_one_cp_list(struct journal_head *jh, int *released)
58   * Find all the written-back checkpoint buffers in the journal and release them.
59   *
60   * Called with j_list_lock held.
61 - * Returns number of buffers reaped (for debug)
62   */
64 -int __jbd2_journal_clean_checkpoint_list(journal_t *journal)
65 +void __jbd2_journal_clean_checkpoint_list(journal_t *journal)
66  {
67         transaction_t *transaction, *last_transaction, *next_transaction;
68         int ret;
69 -       int freed = 0;
70 -       int released;
72         transaction = journal->j_checkpoint_transactions;
73         if (!transaction)
74 -               goto out;
75 +               return;
77         last_transaction = transaction->t_cpprev;
78         next_transaction = transaction;
79         do {
80                 transaction = next_transaction;
81                 next_transaction = transaction->t_cpnext;
82 -               ret = journal_clean_one_cp_list(transaction->
83 -                               t_checkpoint_list, &released);
84 +               ret = journal_clean_one_cp_list(transaction->t_checkpoint_list);
85                 /*
86                  * This function only frees up some memory if possible so we
87                  * dont have an obligation to finish processing. Bail out if
88                  * preemption requested:
89                  */
90 -               if (need_resched()) {
91 -                       freed += ret;
92 -                       goto out;
93 -               }
94 -               if (released) {
95 -                       freed += ret;
96 +               if (need_resched())
97 +                       return;
98 +               if (ret)
99                         continue;
100 -               }
101                 /*
102                  * It is essential that we are as careful as in the case of
103                  * t_checkpoint_list with removing the buffer from the list as
104                  * we can possibly see not yet submitted buffers on io_list
105                  */
106 -               ret += journal_clean_one_cp_list(transaction->
107 -                               t_checkpoint_io_list, &released);
108 -               freed += ret;
109 -               if (need_resched() || !ret)
110 -                       goto out;
111 +               ret = journal_clean_one_cp_list(transaction->
112 +                               t_checkpoint_io_list);
113 +               if (need_resched())
114 +                       return;
115 +               /*
116 +                * Stop scanning if we couldn't free the transaction. This
117 +                * avoids pointless scanning of transactions which still
118 +                * weren't checkpointed.
119 +                */
120 +               if (!ret)
121 +                       return;
122         } while (transaction != last_transaction);
123 -out:
124 -       return freed;
127  /*
128 diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
129 index 0dae71e..704b9a5 100644
130 --- a/include/linux/jbd2.h
131 +++ b/include/linux/jbd2.h
132 @@ -1042,7 +1042,7 @@ void jbd2_update_log_tail(journal_t *journal, tid_t tid, unsigned long block);
133  extern void jbd2_journal_commit_transaction(journal_t *);
135  /* Checkpoint list management */
136 -int __jbd2_journal_clean_checkpoint_list(journal_t *journal);
137 +void __jbd2_journal_clean_checkpoint_list(journal_t *journal);
138  int __jbd2_journal_remove_checkpoint(struct journal_head *);
139  void __jbd2_journal_insert_checkpoint(struct journal_head *, transaction_t *);