Skip to content

Commit dd589b0

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

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

fs/ext4/inode.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5279,8 +5279,9 @@ static void ext4_wait_for_tail_page_commit(struct inode *inode)
52795279
{
52805280
unsigned offset;
52815281
journal_t *journal = EXT4_SB(inode->i_sb)->s_journal;
5282-
tid_t commit_tid = 0;
5282+
tid_t commit_tid;
52835283
int ret;
5284+
bool has_transaction;
52845285

52855286
offset = inode->i_size & (PAGE_SIZE - 1);
52865287
/*
@@ -5305,12 +5306,14 @@ static void ext4_wait_for_tail_page_commit(struct inode *inode)
53055306
folio_put(folio);
53065307
if (ret != -EBUSY)
53075308
return;
5308-
commit_tid = 0;
5309+
has_transaction = false;
53095310
read_lock(&journal->j_state_lock);
5310-
if (journal->j_committing_transaction)
5311+
if (journal->j_committing_transaction) {
53115312
commit_tid = journal->j_committing_transaction->t_tid;
5313+
has_transaction = true;
5314+
}
53125315
read_unlock(&journal->j_state_lock);
5313-
if (commit_tid)
5316+
if (has_transaction)
53145317
jbd2_log_wait_commit(journal, commit_tid);
53155318
}
53165319
}

0 commit comments

Comments
 (0)