Skip to content

Commit 81727a6

Browse files
jankaraBrian Maly
authored andcommitted
jbd: don't wait (forever) for stale tid caused by wraparound
Orabug: 27734012 In the case where an inode has a very stale transaction id (tid) in i_datasync_tid or i_sync_tid, it's possible that after a very large (2**31) number of transactions, that the tid number space might wrap, causing tid_geq()'s calculations to fail. Commit d9b0193 "jbd: fix fsync() tid wraparound bug" attempted to fix this problem, but it only avoided kjournald spinning forever by fixing the logic in jbd_log_start_commit(). Signed-off-by: Jan Kara <[email protected]> (cherry picked from commit e678a4f) Signed-off-by: Brian Maly <[email protected]> Conflicts: fs/jbd/journal.c Signed-off-by: Junxiao Bi <[email protected]> Reviewed-by: Ashish Samant <[email protected]> Signed-off-by: Brian Maly <[email protected]>
1 parent 16ef4da commit 81727a6

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

fs/jbd/journal.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,16 @@ int log_wait_commit(journal_t *journal, tid_t tid)
558558
spin_unlock(&journal->j_state_lock);
559559
#endif
560560
spin_lock(&journal->j_state_lock);
561+
/*
562+
* Not running or committing trans? Must be already committed. This
563+
* saves us from waiting for a *long* time when tid overflows.
564+
*/
565+
if (!((journal->j_running_transaction &&
566+
journal->j_running_transaction->t_tid == tid) ||
567+
(journal->j_committing_transaction &&
568+
journal->j_committing_transaction->t_tid == tid)))
569+
goto out_unlock;
570+
561571
while (tid_gt(tid, journal->j_commit_sequence)) {
562572
jbd_debug(1, "JBD: want %d, j_commit_sequence=%d\n",
563573
tid, journal->j_commit_sequence);
@@ -567,6 +577,7 @@ int log_wait_commit(journal_t *journal, tid_t tid)
567577
!tid_gt(tid, journal->j_commit_sequence));
568578
spin_lock(&journal->j_state_lock);
569579
}
580+
out_unlock:
570581
spin_unlock(&journal->j_state_lock);
571582

572583
if (unlikely(is_journal_aborted(journal))) {

0 commit comments

Comments
 (0)