add patch fix-checkpoint-list-cleanup
[ext4-patch-queue.git] / fix-checkpoint-list-cleanup
blobde1fea318f802e6f08297a0f2acb069708700719
1 jbd2: fix checkpoint list cleanup
3 From: Jan Kara <jack@suse.com>
5 Unlike comments and expectation of callers journal_clean_one_cp_list()
6 returned 1 not only if it freed the transaction but also if it freed
7 some buffers in the transaction. That could make
8 __jbd2_journal_clean_checkpoint_list() skip processing
9 t_checkpoint_io_list and continue with processing the next transaction.
10 This is mostly a cosmetic issue since the only result is we can
11 sometimes free less memory than we could. But it's still worth fixing.
12 Fix journal_clean_one_cp_list() to return 1 only if the transaction was
13 really freed.
15 Fixes: 50849db32a9f529235a84bcc84a6b8e631b1d0ec
16 Signed-off-by: Jan Kara <jack@suse.com>
17 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
18 Cc: stable@vger.kernel.org
19 ---
20  fs/jbd2/checkpoint.c | 8 +++-----
21  1 file changed, 3 insertions(+), 5 deletions(-)
23 diff --git a/fs/jbd2/checkpoint.c b/fs/jbd2/checkpoint.c
24 index 8c44654ce274..684996c8a3a4 100644
25 --- a/fs/jbd2/checkpoint.c
26 +++ b/fs/jbd2/checkpoint.c
27 @@ -427,7 +427,6 @@ static int journal_clean_one_cp_list(struct journal_head *jh, bool destroy)
28         struct journal_head *last_jh;
29         struct journal_head *next_jh = jh;
30         int ret;
31 -       int freed = 0;
33         if (!jh)
34                 return 0;
35 @@ -441,10 +440,9 @@ static int journal_clean_one_cp_list(struct journal_head *jh, bool destroy)
36                 else
37                         ret = __jbd2_journal_remove_checkpoint(jh) + 1;
38                 if (!ret)
39 -                       return freed;
40 +                       return 0;
41                 if (ret == 2)
42                         return 1;
43 -               freed = 1;
44                 /*
45                  * This function only frees up some memory
46                  * if possible so we dont have an obligation
47 @@ -452,10 +450,10 @@ static int journal_clean_one_cp_list(struct journal_head *jh, bool destroy)
48                  * requested:
49                  */
50                 if (need_resched())
51 -                       return freed;
52 +                       return 0;
53         } while (jh != last_jh);
55 -       return freed;
56 +       return 0;
57  }
59  /*
60 -- 
61 2.1.4