From 279f167ff0e1244e9aaa35fbeab80993e949c710 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Tue, 30 Oct 2018 10:43:50 -0400 Subject: [PATCH] add patch avoid-long-hold-times --- avoid-long-hold-times | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++ series | 2 ++ timestamps | 7 ++++--- 3 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 avoid-long-hold-times diff --git a/avoid-long-hold-times b/avoid-long-hold-times new file mode 100644 index 00000000..93bb60c2 --- /dev/null +++ b/avoid-long-hold-times @@ -0,0 +1,56 @@ +jbd2: avoid long hold times of j_state_lock while committing a transaction + +From: Jan Kara + +We can hold j_state_lock for writing at the beginning of +jbd2_journal_commit_transaction() for a rather long time (reportedly +for 30 ms) due cleaning revoke bits of all revoked buffers under +it. The handling of revoke tables as well as cleaning of +t_reserved_list, and checkpoint lists does not need j_state_lock for +anything. Furthermore the transaction is in T_LOCKED state and we +waited for all outstanding handles so nobody is going to be adding +anything to the transaction. + +Just drop the lock for unnecessary operations. + +Reported-and-tested-by: Adrian Hunter +Signed-off-by: Jan Kara +Signed-off-by: Theodore Ts'o +--- + fs/jbd2/commit.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c +index 150cc030b4d7..356b75fa3101 100644 +--- a/fs/jbd2/commit.c ++++ b/fs/jbd2/commit.c +@@ -422,6 +422,7 @@ void jbd2_journal_commit_transaction(journal_t *journal) + stats.run.rs_locked); + stats.run.rs_running = jbd2_time_diff(commit_transaction->t_start, + stats.run.rs_locked); ++ write_unlock(&journal->j_state_lock); + + spin_lock(&commit_transaction->t_handle_lock); + while (atomic_read(&commit_transaction->t_updates)) { +@@ -431,9 +432,7 @@ void jbd2_journal_commit_transaction(journal_t *journal) + TASK_UNINTERRUPTIBLE); + if (atomic_read(&commit_transaction->t_updates)) { + spin_unlock(&commit_transaction->t_handle_lock); +- write_unlock(&journal->j_state_lock); + schedule(); +- write_lock(&journal->j_state_lock); + spin_lock(&commit_transaction->t_handle_lock); + } + finish_wait(&journal->j_wait_updates, &wait); +@@ -505,6 +504,7 @@ void jbd2_journal_commit_transaction(journal_t *journal) + atomic_sub(atomic_read(&journal->j_reserved_credits), + &commit_transaction->t_outstanding_credits); + ++ write_lock(&journal->j_state_lock); + trace_jbd2_commit_flushing(journal, commit_transaction); + stats.run.rs_flushing = jiffies; + stats.run.rs_locked = jbd2_time_diff(stats.run.rs_locked, +-- +2.16.4 + + diff --git a/series b/series index a55bb9df..69e7a135 100644 --- a/series +++ b/series @@ -1,5 +1,7 @@ # 33458eaba4df +avoid-long-hold-times + #################################################### # unstable patches #################################################### diff --git a/timestamps b/timestamps index e2a1d86c..3ac08d4e 100755 --- a/timestamps +++ b/timestamps @@ -33,6 +33,7 @@ touch -d @1539351369 cleaner touch -d @1539351429 load-jmap-from-journal touch -d @1539351489 disable-writeback touch -d @1539351549 add-ext4-journal-lazy-mount-option -touch -d @1540565571 series -touch -d @1540567894 status -touch -d @1540567901 timestamps +touch -d @1540910337 avoid-long-hold-times +touch -d @1540910601 series +touch -d @1540910611 status +touch -d @1540910621 timestamps -- 2.11.4.GIT