diff options
| author | Jan Kara <jack@suse.cz> | 2016-09-22 11:44:06 -0400 |
|---|---|---|
| committer | Theodore Ts'o <tytso@mit.edu> | 2016-09-22 11:44:06 -0400 |
| commit | e03a9976afce6634826d56c33531dd10bb9a9166 (patch) | |
| tree | 5cd08ff2ed8a983a96f485680416e840fd095194 /fs/jbd2 | |
| parent | 7c5f6b320b59cb4a674750bbb29a248b5bae7641 (diff) | |
jbd2: fix lockdep annotation in add_transaction_credits()
Thomas has reported a lockdep splat hitting in
add_transaction_credits(). The problem is that that function calls
jbd2_might_wait_for_commit() while holding j_state_lock which is wrong
(we do not really wait for transaction commit while holding that lock).
Fix the problem by moving jbd2_might_wait_for_commit() into places where
we are ready to wait for transaction commit and thus j_state_lock is
unlocked.
Cc: stable@vger.kernel.org
Fixes: 1eaa566d368b214d99cbb973647c1b0b8102a9ae
Reported-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/jbd2')
| -rw-r--r-- | fs/jbd2/transaction.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c index b5bc3e249163..3d8246a9faa4 100644 --- a/fs/jbd2/transaction.c +++ b/fs/jbd2/transaction.c | |||
| @@ -159,6 +159,7 @@ static void wait_transaction_locked(journal_t *journal) | |||
| 159 | read_unlock(&journal->j_state_lock); | 159 | read_unlock(&journal->j_state_lock); |
| 160 | if (need_to_start) | 160 | if (need_to_start) |
| 161 | jbd2_log_start_commit(journal, tid); | 161 | jbd2_log_start_commit(journal, tid); |
| 162 | jbd2_might_wait_for_commit(journal); | ||
| 162 | schedule(); | 163 | schedule(); |
| 163 | finish_wait(&journal->j_wait_transaction_locked, &wait); | 164 | finish_wait(&journal->j_wait_transaction_locked, &wait); |
| 164 | } | 165 | } |
| @@ -182,8 +183,6 @@ static int add_transaction_credits(journal_t *journal, int blocks, | |||
| 182 | int needed; | 183 | int needed; |
| 183 | int total = blocks + rsv_blocks; | 184 | int total = blocks + rsv_blocks; |
| 184 | 185 | ||
| 185 | jbd2_might_wait_for_commit(journal); | ||
| 186 | |||
| 187 | /* | 186 | /* |
| 188 | * If the current transaction is locked down for commit, wait | 187 | * If the current transaction is locked down for commit, wait |
| 189 | * for the lock to be released. | 188 | * for the lock to be released. |
| @@ -214,6 +213,7 @@ static int add_transaction_credits(journal_t *journal, int blocks, | |||
| 214 | if (atomic_read(&journal->j_reserved_credits) + total > | 213 | if (atomic_read(&journal->j_reserved_credits) + total > |
| 215 | journal->j_max_transaction_buffers) { | 214 | journal->j_max_transaction_buffers) { |
| 216 | read_unlock(&journal->j_state_lock); | 215 | read_unlock(&journal->j_state_lock); |
| 216 | jbd2_might_wait_for_commit(journal); | ||
| 217 | wait_event(journal->j_wait_reserved, | 217 | wait_event(journal->j_wait_reserved, |
| 218 | atomic_read(&journal->j_reserved_credits) + total <= | 218 | atomic_read(&journal->j_reserved_credits) + total <= |
| 219 | journal->j_max_transaction_buffers); | 219 | journal->j_max_transaction_buffers); |
| @@ -238,6 +238,7 @@ static int add_transaction_credits(journal_t *journal, int blocks, | |||
| 238 | if (jbd2_log_space_left(journal) < jbd2_space_needed(journal)) { | 238 | if (jbd2_log_space_left(journal) < jbd2_space_needed(journal)) { |
| 239 | atomic_sub(total, &t->t_outstanding_credits); | 239 | atomic_sub(total, &t->t_outstanding_credits); |
| 240 | read_unlock(&journal->j_state_lock); | 240 | read_unlock(&journal->j_state_lock); |
| 241 | jbd2_might_wait_for_commit(journal); | ||
| 241 | write_lock(&journal->j_state_lock); | 242 | write_lock(&journal->j_state_lock); |
| 242 | if (jbd2_log_space_left(journal) < jbd2_space_needed(journal)) | 243 | if (jbd2_log_space_left(journal) < jbd2_space_needed(journal)) |
| 243 | __jbd2_log_wait_for_space(journal); | 244 | __jbd2_log_wait_for_space(journal); |
| @@ -255,6 +256,7 @@ static int add_transaction_credits(journal_t *journal, int blocks, | |||
| 255 | sub_reserved_credits(journal, rsv_blocks); | 256 | sub_reserved_credits(journal, rsv_blocks); |
| 256 | atomic_sub(total, &t->t_outstanding_credits); | 257 | atomic_sub(total, &t->t_outstanding_credits); |
| 257 | read_unlock(&journal->j_state_lock); | 258 | read_unlock(&journal->j_state_lock); |
| 259 | jbd2_might_wait_for_commit(journal); | ||
| 258 | wait_event(journal->j_wait_reserved, | 260 | wait_event(journal->j_wait_reserved, |
| 259 | atomic_read(&journal->j_reserved_credits) + rsv_blocks | 261 | atomic_read(&journal->j_reserved_credits) + rsv_blocks |
| 260 | <= journal->j_max_transaction_buffers / 2); | 262 | <= journal->j_max_transaction_buffers / 2); |
