diff options
author | Jan Kara <jack@suse.cz> | 2016-06-30 11:40:54 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2016-06-30 11:40:54 -0400 |
commit | 1eaa566d368b214d99cbb973647c1b0b8102a9ae (patch) | |
tree | 30f6f17f9dbc22a3ca6ff014c1c38a69f645c00d | |
parent | ab714aff4f744f52f0beae93ed441f2f5585eb7a (diff) |
jbd2: track more dependencies on transaction commit
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>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r-- | fs/jbd2/journal.c | 1 | ||||
-rw-r--r-- | fs/jbd2/transaction.c | 4 | ||||
-rw-r--r-- | include/linux/jbd2.h | 6 |
3 files changed, 11 insertions, 0 deletions
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) | |||
691 | { | 691 | { |
692 | int err = 0; | 692 | int err = 0; |
693 | 693 | ||
694 | jbd2_might_wait_for_commit(journal); | ||
694 | read_lock(&journal->j_state_lock); | 695 | read_lock(&journal->j_state_lock); |
695 | #ifdef CONFIG_JBD2_DEBUG | 696 | #ifdef CONFIG_JBD2_DEBUG |
696 | if (!tid_geq(journal->j_commit_request, tid)) { | 697 | 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, | |||
182 | int needed; | 182 | int needed; |
183 | int total = blocks + rsv_blocks; | 183 | int total = blocks + rsv_blocks; |
184 | 184 | ||
185 | jbd2_might_wait_for_commit(journal); | ||
186 | |||
185 | /* | 187 | /* |
186 | * If the current transaction is locked down for commit, wait | 188 | * If the current transaction is locked down for commit, wait |
187 | * for the lock to be released. | 189 | * for the lock to be released. |
@@ -695,6 +697,8 @@ void jbd2_journal_lock_updates(journal_t *journal) | |||
695 | { | 697 | { |
696 | DEFINE_WAIT(wait); | 698 | DEFINE_WAIT(wait); |
697 | 699 | ||
700 | jbd2_might_wait_for_commit(journal); | ||
701 | |||
698 | write_lock(&journal->j_state_lock); | 702 | write_lock(&journal->j_state_lock); |
699 | ++journal->j_barrier_count; | 703 | ++journal->j_barrier_count; |
700 | 704 | ||
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h index 3d210cbe4e1b..dfaa1f4dcb0c 100644 --- a/include/linux/jbd2.h +++ b/include/linux/jbd2.h | |||
@@ -1046,6 +1046,12 @@ struct journal_s | |||
1046 | #endif | 1046 | #endif |
1047 | }; | 1047 | }; |
1048 | 1048 | ||
1049 | #define jbd2_might_wait_for_commit(j) \ | ||
1050 | do { \ | ||
1051 | rwsem_acquire(&j->j_trans_commit_map, 0, 0, _THIS_IP_); \ | ||
1052 | rwsem_release(&j->j_trans_commit_map, 1, _THIS_IP_); \ | ||
1053 | } while (0) | ||
1054 | |||
1049 | /* journal feature predicate functions */ | 1055 | /* journal feature predicate functions */ |
1050 | #define JBD2_FEATURE_COMPAT_FUNCS(name, flagname) \ | 1056 | #define JBD2_FEATURE_COMPAT_FUNCS(name, flagname) \ |
1051 | static inline bool jbd2_has_feature_##name(journal_t *j) \ | 1057 | static inline bool jbd2_has_feature_##name(journal_t *j) \ |