Skip to content

Commit

Permalink
jbd2: track more dependencies on transaction commit
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jan Kara authored and Theodore Ts'o committed Jun 30, 2016
1 parent ab714af commit 1eaa566
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions fs/jbd2/journal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
4 changes: 4 additions & 0 deletions fs/jbd2/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;

Expand Down
6 changes: 6 additions & 0 deletions include/linux/jbd2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down

0 comments on commit 1eaa566

Please sign in to comment.