linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Ted Tso <tytso@mit.edu>
Cc: linux-ext4@vger.kernel.org, Eryu Guan <eguan@redhat.com>,
	Jan Kara <jack@suse.cz>
Subject: [PATCH 4/4] jbd2: Track more dependencies on transaction commit
Date: Thu, 16 Jun 2016 12:42:16 +0200	[thread overview]
Message-ID: <1466073736-30447-5-git-send-email-jack@suse.cz> (raw)
In-Reply-To: <1466073736-30447-1-git-send-email-jack@suse.cz>

So far we were tracking only dependency on transaction commit due to
starting a new handle (which may require commit to start a new
transaction). Now add tracking also for other cases where we wait for
transaction commit. This way lockdep can catch deadlocks e. g. because we
call jbd2_journal_stop() for a synchronous handle with some locks held
which rank below transaction start.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/jbd2/journal.c     | 1 +
 fs/jbd2/transaction.c | 4 ++++
 include/linux/jbd2.h  | 6 ++++++
 3 files changed, 11 insertions(+)

diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 208e4058040b..fc1d7a39b082 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -691,6 +691,7 @@ int jbd2_log_wait_commit(journal_t *journal, tid_t tid)
 {
 	int err = 0;
 
+	jbd2_might_wait_for_commit(journal);
 	read_lock(&journal->j_state_lock);
 #ifdef CONFIG_JBD2_DEBUG
 	if (!tid_geq(journal->j_commit_request, tid)) {
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index c0065040c5be..b5bc3e249163 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -182,6 +182,8 @@ static int add_transaction_credits(journal_t *journal, int blocks,
 	int needed;
 	int total = blocks + rsv_blocks;
 
+	jbd2_might_wait_for_commit(journal);
+
 	/*
 	 * If the current transaction is locked down for commit, wait
 	 * for the lock to be released.
@@ -695,6 +697,8 @@ void jbd2_journal_lock_updates(journal_t *journal)
 {
 	DEFINE_WAIT(wait);
 
+	jbd2_might_wait_for_commit(journal);
+
 	write_lock(&journal->j_state_lock);
 	++journal->j_barrier_count;
 
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index f6232b28eadc..64f8b594dd5a 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -1045,6 +1045,12 @@ struct journal_s
 #endif
 };
 
+#define jbd2_might_wait_for_commit(j) \
+	do { \
+		rwsem_acquire(&j->j_trans_commit_map, 0, 0, _THIS_IP_); \
+		rwsem_release(&j->j_trans_commit_map, 1, _THIS_IP_); \
+	} while (0)
+
 /* journal feature predicate functions */
 #define JBD2_FEATURE_COMPAT_FUNCS(name, flagname) \
 static inline bool jbd2_has_feature_##name(journal_t *j) \
-- 
2.6.6


  parent reply	other threads:[~2016-06-16 10:42 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-16 10:42 [PATCH 0/4] ext4: Fix deadlock during page writeback Jan Kara
2016-06-16 10:42 ` [PATCH 1/4] " Jan Kara
2016-06-30 15:05   ` Theodore Ts'o
2016-07-01  9:09     ` Jan Kara
2016-07-01 16:53       ` Theodore Ts'o
2016-07-01 17:40         ` Jan Kara
2016-07-01 21:26           ` Theodore Ts'o
2016-07-04 14:00             ` Jan Kara
2016-07-04 15:20               ` Theodore Ts'o
2016-07-04 15:47                 ` Jan Kara
2016-07-05  2:43                   ` Theodore Ts'o
2016-07-06  7:04                     ` Jan Kara
2016-07-04 14:14             ` Theodore Ts'o
2016-07-04 15:51               ` Jan Kara
2016-07-05  3:38                 ` Theodore Ts'o
2016-07-06  7:51                   ` Jan Kara
2016-07-06 12:35                     ` Theodore Ts'o
2016-07-06 12:52                       ` Jan Kara
2016-07-06 14:27                         ` Theodore Ts'o
2016-07-06 14:41                           ` Jan Kara
2016-06-16 10:42 ` [PATCH 2/4] jbd2: Move lockdep instrumentation for jbd2 handles Jan Kara
2016-06-30 15:34   ` Theodore Ts'o
2016-06-16 10:42 ` [PATCH 3/4] jbd2: Move lockdep tracking to journal_s Jan Kara
2016-06-16 11:42   ` kbuild test robot
2016-06-30 15:40   ` Theodore Ts'o
2016-06-16 10:42 ` Jan Kara [this message]
2016-06-30 15:45   ` [PATCH 4/4] jbd2: Track more dependencies on transaction commit Theodore Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1466073736-30447-5-git-send-email-jack@suse.cz \
    --to=jack@suse.cz \
    --cc=eguan@redhat.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).