Skip to content

Commit 1552199

Browse files
Luis Henriques (SUSE)gregkh
authored andcommitted
ext4: fix incorrect tid assumption in jbd2_journal_shrink_checkpoint_list()
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) <luis.henriques@linux.dev> Reviewed-by: Jan Kara <jack@suse.cz> Link: https://patch.msgid.link/20240724161119.13448-4-luis.henriques@linux.dev Signed-off-by: Theodore Ts'o <tytso@mit.edu> Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 80dccb8 commit 1552199

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
@@ -412,6 +412,7 @@ unsigned long jbd2_journal_shrink_checkpoint_list(journal_t *journal,
412412
tid_t tid = 0;
413413
unsigned long nr_freed = 0;
414414
unsigned long freed;
415+
bool first_set = false;
415416

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

434-
if (!first_tid)
435+
if (!first_set) {
435436
first_tid = transaction->t_tid;
437+
first_set = true;
438+
}
436439
last_transaction = journal->j_checkpoint_transactions->t_cpprev;
437440
next_transaction = transaction;
438441
last_tid = last_transaction->t_tid;
@@ -462,7 +465,7 @@ unsigned long jbd2_journal_shrink_checkpoint_list(journal_t *journal,
462465
spin_unlock(&journal->j_list_lock);
463466
cond_resched();
464467

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

0 commit comments

Comments
 (0)