]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
jbd2: track more dependencies on transaction commit
authorJan Kara <jack@suse.cz>
Thu, 30 Jun 2016 15:40:54 +0000 (11:40 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 30 Jun 2016 15:40:54 +0000 (11:40 -0400)
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>
fs/jbd2/journal.c
fs/jbd2/transaction.c
include/linux/jbd2.h

index 208e4058040b65a3af7066596a27a0622830b317..fc1d7a39b082e58e570a7c15e1ee834773e8bfb6 100644 (file)
@@ -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)) {
index c0065040c5bebe13f877f7c48768663978d45439..b5bc3e24916329a44616433f1ab4340b5c8aa58c 100644 (file)
@@ -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;
 
index 3d210cbe4e1b905f99d6780659ec88cda5d927c1..dfaa1f4dcb0c54911c16a8683a38dabbfb4dcb0f 100644 (file)
@@ -1046,6 +1046,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) \