Skip to content

Commit 1b2f752

Browse files
pandafromspaceLukeNow
authored andcommitted
jbd2: wake up journal waiters in FIFO order, not LIFO
BugLink: https://bugs.launchpad.net/bugs/1996812 commit 34fc876 upstream. LIFO wakeup order is unfair and sometimes leads to a journal user not being able to get a journal handle for hundreds of transactions in a row. FIFO wakeup can make things more fair. Cc: stable@kernel.org Signed-off-by: Alexey Lyashkov <alexey.lyashkov@gmail.com> Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com> Link: https://lore.kernel.org/r/20220907165959.1137482-1-alexey.lyashkov@gmail.com Signed-off-by: Theodore Ts'o <tytso@mit.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Kamal Mostafa <kamal@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent 758b898 commit 1b2f752

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

fs/jbd2/commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
533533
journal->j_running_transaction = NULL;
534534
start_time = ktime_get();
535535
commit_transaction->t_log_start = journal->j_head;
536-
wake_up(&journal->j_wait_transaction_locked);
536+
wake_up_all(&journal->j_wait_transaction_locked);
537537
write_unlock(&journal->j_state_lock);
538538

539539
jbd_debug(3, "JBD2: commit phase 2a\n");

fs/jbd2/transaction.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ static void wait_transaction_locked(journal_t *journal)
149149
int need_to_start;
150150
tid_t tid = journal->j_running_transaction->t_tid;
151151

152-
prepare_to_wait(&journal->j_wait_transaction_locked, &wait,
152+
prepare_to_wait_exclusive(&journal->j_wait_transaction_locked, &wait,
153153
TASK_UNINTERRUPTIBLE);
154154
need_to_start = !tid_geq(journal->j_commit_request, tid);
155155
read_unlock(&journal->j_state_lock);
@@ -175,7 +175,7 @@ static void wait_transaction_switching(journal_t *journal)
175175
read_unlock(&journal->j_state_lock);
176176
return;
177177
}
178-
prepare_to_wait(&journal->j_wait_transaction_locked, &wait,
178+
prepare_to_wait_exclusive(&journal->j_wait_transaction_locked, &wait,
179179
TASK_UNINTERRUPTIBLE);
180180
read_unlock(&journal->j_state_lock);
181181
/*
@@ -810,7 +810,7 @@ void jbd2_journal_unlock_updates (journal_t *journal)
810810
write_lock(&journal->j_state_lock);
811811
--journal->j_barrier_count;
812812
write_unlock(&journal->j_state_lock);
813-
wake_up(&journal->j_wait_transaction_locked);
813+
wake_up_all(&journal->j_wait_transaction_locked);
814814
}
815815

816816
static void warn_dirty_buffer(struct buffer_head *bh)

0 commit comments

Comments
 (0)