Skip to content

Commit 37f2e37

Browse files
Luis Henriques (SUSE)mehmetb0
authored andcommitted
ext4: fix incorrect tid assumption in jbd2_journal_shrink_checkpoint_list()
BugLink: https://bugs.launchpad.net/bugs/2086242 commit 7a6443e upstream. Function jbd2_journal_shrink_checkpoint_list() assumes that '0' is not a valid value for transaction IDs, which is incorrect. Don't assume that and use two extra boolean variables to control the loop iterations and keep track of the first and last tid. Signed-off-by: Luis Henriques (SUSE) <[email protected]> Reviewed-by: Jan Kara <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Theodore Ts'o <[email protected]> Cc: [email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Koichiro Den <[email protected]> Signed-off-by: Roxana Nicolescu <[email protected]>
1 parent 062387a commit 37f2e37

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

fs/jbd2/checkpoint.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ unsigned long jbd2_journal_shrink_checkpoint_list(journal_t *journal,
427427
tid_t tid = 0;
428428
unsigned long nr_freed = 0;
429429
unsigned long freed;
430+
bool first_set = false;
430431

431432
again:
432433
spin_lock(&journal->j_list_lock);
@@ -446,8 +447,10 @@ unsigned long jbd2_journal_shrink_checkpoint_list(journal_t *journal,
446447
else
447448
transaction = journal->j_checkpoint_transactions;
448449

449-
if (!first_tid)
450+
if (!first_set) {
450451
first_tid = transaction->t_tid;
452+
first_set = true;
453+
}
451454
last_transaction = journal->j_checkpoint_transactions->t_cpprev;
452455
next_transaction = transaction;
453456
last_tid = last_transaction->t_tid;
@@ -477,7 +480,7 @@ unsigned long jbd2_journal_shrink_checkpoint_list(journal_t *journal,
477480
spin_unlock(&journal->j_list_lock);
478481
cond_resched();
479482

480-
if (*nr_to_scan && next_tid)
483+
if (*nr_to_scan && journal->j_shrink_transaction)
481484
goto again;
482485
out:
483486
trace_jbd2_shrink_checkpoint_list(journal, first_tid, tid, last_tid,

0 commit comments

Comments
 (0)