Skip to content

Commit 7a6443e

Browse files
Luis Henriques (SUSE)tytso
authored andcommitted
ext4: fix incorrect tid assumption in jbd2_journal_shrink_checkpoint_list()
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]
1 parent 9720906 commit 7a6443e

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
@@ -413,6 +413,7 @@ unsigned long jbd2_journal_shrink_checkpoint_list(journal_t *journal,
413413
tid_t tid = 0;
414414
unsigned long nr_freed = 0;
415415
unsigned long freed;
416+
bool first_set = false;
416417

417418
again:
418419
spin_lock(&journal->j_list_lock);
@@ -432,8 +433,10 @@ unsigned long jbd2_journal_shrink_checkpoint_list(journal_t *journal,
432433
else
433434
transaction = journal->j_checkpoint_transactions;
434435

435-
if (!first_tid)
436+
if (!first_set) {
436437
first_tid = transaction->t_tid;
438+
first_set = true;
439+
}
437440
last_transaction = journal->j_checkpoint_transactions->t_cpprev;
438441
next_transaction = transaction;
439442
last_tid = last_transaction->t_tid;
@@ -463,7 +466,7 @@ unsigned long jbd2_journal_shrink_checkpoint_list(journal_t *journal,
463466
spin_unlock(&journal->j_list_lock);
464467
cond_resched();
465468

466-
if (*nr_to_scan && next_tid)
469+
if (*nr_to_scan && journal->j_shrink_transaction)
467470
goto again;
468471
out:
469472
trace_jbd2_shrink_checkpoint_list(journal, first_tid, tid, last_tid,

0 commit comments

Comments
 (0)