[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240227212546.110340-1-phill@thesusis.net>
Date: Tue, 27 Feb 2024 16:25:46 -0500
From: Phillip Susi <phill@...susis.net>
To: tytso@....edu
Cc: linux-ext4@...r.kernel.org,
Phillip Susi <phill@...susis.net>
Subject: [PATCH] [RFC] Fix jbd2 to stop waking up sleeping disks on sync
I noticed that every time I sync ( which happens automatically when
you suspend to ram ), ext4 issues a flush to the block device, even
though there have been no writes to flush. This appears to be because
jbd2_trans_will_send_data_barrier() returns a 0 when no transaction
has been started. The intent appears to be that a transaction that
has completed should return 0, and that when there is NO transaction,
it should return a 1, but the tests were in the wrong order, leading
to the 0 to be returned before checking for the absense of a
transaction at all. Reversing the order allows my disk to remain in
runtime_pm when syncing.
I *think* this is correct, but I'm not very familliar with jbd2, so it
may have unintended consequences. What do you think?
---
fs/jbd2/journal.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index b6c114c11b97..be13dae767be 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -632,14 +632,16 @@ int jbd2_trans_will_send_data_barrier(journal_t *journal, tid_t tid)
if (!(journal->j_flags & JBD2_BARRIER))
return 0;
read_lock(&journal->j_state_lock);
- /* Transaction already committed? */
- if (tid_geq(journal->j_commit_sequence, tid))
- goto out;
commit_trans = journal->j_committing_transaction;
if (!commit_trans || commit_trans->t_tid != tid) {
ret = 1;
goto out;
}
+ /* Transaction already committed? */
+ if (tid_geq(journal->j_commit_sequence, tid))
+ {
+ goto out;
+ }
/*
* Transaction is being committed and we already proceeded to
* submitting a flush to fs partition?
--
2.43.0
Powered by blists - more mailing lists