Skip to contentSkip to conversation

jbd2: wake up journal waiters in FIFO order, not LIFO

PATCH Applied Alexey Lyashkov 2 participants 2 messages Sep 12, 2022 – Sep 30, 2022 Journalling layer for block devices (JBD2)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 jbd2: wake up journal waiters in FIFO order, not LIFO

From: Andrew Perepechko <[email protected]>

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.

---
 fs/jbd2/commit.c      | 2 +-
 fs/jbd2/transaction.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
fs/jbd2/commit.c +1 -1
index b2b2bc9b88d9..ec2b55879e3a 100644
@@ -570,7 +570,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
 	journal->j_running_transaction = NULL;
 	start_time = ktime_get();
 	commit_transaction->t_log_start = journal->j_head;
-	wake_up(&journal->j_wait_transaction_locked);
+	wake_up_all(&journal->j_wait_transaction_locked);
 	write_unlock(&journal->j_state_lock);
 
 	jbd2_debug(3, "JBD2: commit phase 2a\n");
fs/jbd2/transaction.c +3 -3
index e1be93ccd81c..6a404ac1c178 100644
@@ -168,7 +168,7 @@ static void wait_transaction_locked(journal_t *journal)
 	int need_to_start;
 	tid_t tid = journal->j_running_transaction->t_tid;
 
-	prepare_to_wait(&journal->j_wait_transaction_locked, &wait,
+	prepare_to_wait_exclusive(&journal->j_wait_transaction_locked, &wait,
 			TASK_UNINTERRUPTIBLE);
 	need_to_start = !tid_geq(journal->j_commit_request, tid);
 	read_unlock(&journal->j_state_lock);
@@ -194,7 +194,7 @@ static void wait_transaction_switching(journal_t *journal)
 		read_unlock(&journal->j_state_lock);
 		return;
 	}
-	prepare_to_wait(&journal->j_wait_transaction_locked, &wait,
+	prepare_to_wait_exclusive(&journal->j_wait_transaction_locked, &wait,
 			TASK_UNINTERRUPTIBLE);
 	read_unlock(&journal->j_state_lock);
 	/*
@@ -920,7 +920,7 @@ void jbd2_journal_unlock_updates (journal_t *journal)
 	write_lock(&journal->j_state_lock);
 	--journal->j_barrier_count;
 	write_unlock(&journal->j_state_lock);
-	wake_up(&journal->j_wait_transaction_locked);
+	wake_up_all(&journal->j_wait_transaction_locked);
 }
 
 static void warn_dirty_buffer(struct buffer_head *bh)
Signature · 1 line
2.31.1
maintainer Applied
#1 lore raw
Quoted 9 lines · Alexey Lyashkov

From: Andrew Perepechko <[email protected]>

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.

[...]

Applied, thanks!

[1/1] jbd2: wake up journal waiters in FIFO order, not LIFO

      commit: 2bf6739025dcfca3a24fbc73b8f2dbd979c0e4c9

Best regards,

Signature · 1 line
Theodore Ts'o <[email protected]>