Skip to content

Commit d87fe29

Browse files
pandafromspacegregkh
authored andcommitted
jbd2: wake up journal waiters in FIFO order, not LIFO
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: [email protected] Signed-off-by: Alexey Lyashkov <[email protected]> Reviewed-by: Ritesh Harjani (IBM) <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 7434626 commit d87fe29

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

fs/jbd2/commit.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
581581
journal->j_running_transaction = NULL;
582582
start_time = ktime_get();
583583
commit_transaction->t_log_start = journal->j_head;
584-
wake_up(&journal->j_wait_transaction_locked);
584+
wake_up_all(&journal->j_wait_transaction_locked);
585585
write_unlock(&journal->j_state_lock);
586586

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

fs/jbd2/transaction.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ static void wait_transaction_locked(journal_t *journal)
173173
int need_to_start;
174174
tid_t tid = journal->j_running_transaction->t_tid;
175175

176-
prepare_to_wait(&journal->j_wait_transaction_locked, &wait,
176+
prepare_to_wait_exclusive(&journal->j_wait_transaction_locked, &wait,
177177
TASK_UNINTERRUPTIBLE);
178178
need_to_start = !tid_geq(journal->j_commit_request, tid);
179179
read_unlock(&journal->j_state_lock);
@@ -199,7 +199,7 @@ static void wait_transaction_switching(journal_t *journal)
199199
read_unlock(&journal->j_state_lock);
200200
return;
201201
}
202-
prepare_to_wait(&journal->j_wait_transaction_locked, &wait,
202+
prepare_to_wait_exclusive(&journal->j_wait_transaction_locked, &wait,
203203
TASK_UNINTERRUPTIBLE);
204204
read_unlock(&journal->j_state_lock);
205205
/*
@@ -911,7 +911,7 @@ void jbd2_journal_unlock_updates (journal_t *journal)
911911
write_lock(&journal->j_state_lock);
912912
--journal->j_barrier_count;
913913
write_unlock(&journal->j_state_lock);
914-
wake_up(&journal->j_wait_transaction_locked);
914+
wake_up_all(&journal->j_wait_transaction_locked);
915915
}
916916

917917
static void warn_dirty_buffer(struct buffer_head *bh)

0 commit comments

Comments
 (0)