Skip to content

Commit 062387a

Browse files
Luis Henriques (SUSE)mehmetb0
authored andcommitted
ext4: fix incorrect tid assumption in ext4_wait_for_tail_page_commit()
BugLink: https://bugs.launchpad.net/bugs/2086242 commit dd589b0 upstream. 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] Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Koichiro Den <[email protected]> Signed-off-by: Roxana Nicolescu <[email protected]>
1 parent b9cebd8 commit 062387a

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
@@ -5301,8 +5301,9 @@ static void ext4_wait_for_tail_page_commit(struct inode *inode)
53015301
struct page *page;
53025302
unsigned offset;
53035303
journal_t *journal = EXT4_SB(inode->i_sb)->s_journal;
5304-
tid_t commit_tid = 0;
5304+
tid_t commit_tid;
53055305
int ret;
5306+
bool has_transaction;
53065307

53075308
offset = inode->i_size & (PAGE_SIZE - 1);
53085309
/*
@@ -5327,12 +5328,14 @@ static void ext4_wait_for_tail_page_commit(struct inode *inode)
53275328
put_page(page);
53285329
if (ret != -EBUSY)
53295330
return;
5330-
commit_tid = 0;
5331+
has_transaction = false;
53315332
read_lock(&journal->j_state_lock);
5332-
if (journal->j_committing_transaction)
5333+
if (journal->j_committing_transaction) {
53335334
commit_tid = journal->j_committing_transaction->t_tid;
5335+
has_transaction = true;
5336+
}
53345337
read_unlock(&journal->j_state_lock);
5335-
if (commit_tid)
5338+
if (has_transaction)
53365339
jbd2_log_wait_commit(journal, commit_tid);
53375340
}
53385341
}

0 commit comments

Comments
 (0)