Skip to content

Commit 2bcfc2d

Browse files
Luis Henriques (SUSE)gregkh
authored andcommitted
ext4: fix incorrect tid assumption in __jbd2_log_wait_for_space()
commit 9720906 upstream. Function __jbd2_log_wait_for_space() assumes that '0' is not a valid value for transaction IDs, which is incorrect. Don't assume that and invoke jbd2_log_wait_commit() if the journal had a committing transaction instead. 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]>
1 parent 0ddc7a7 commit 2bcfc2d

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
@@ -115,17 +115,20 @@ __releases(&journal->j_state_lock)
115115
if (space_left < nblocks) {
116116
int chkpt = journal->j_checkpoint_transactions != NULL;
117117
tid_t tid = 0;
118+
bool has_transaction = false;
118119

119-
if (journal->j_committing_transaction)
120+
if (journal->j_committing_transaction) {
120121
tid = journal->j_committing_transaction->t_tid;
122+
has_transaction = true;
123+
}
121124
spin_unlock(&journal->j_list_lock);
122125
write_unlock(&journal->j_state_lock);
123126
if (chkpt) {
124127
jbd2_log_do_checkpoint(journal);
125128
} else if (jbd2_cleanup_journal_tail(journal) == 0) {
126129
/* We were able to recover space; yay! */
127130
;
128-
} else if (tid) {
131+
} else if (has_transaction) {
129132
/*
130133
* jbd2_journal_commit_transaction() may want
131134
* to take the checkpoint_mutex if JBD2_FLUSHED

0 commit comments

Comments
 (0)