aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2016-06-30 11:39:38 -0400
committerTheodore Ts'o <tytso@mit.edu>2016-06-30 11:39:38 -0400
commitab714aff4f744f52f0beae93ed441f2f5585eb7a (patch)
tree2c62c6356d6445d05492d3838e2acfc27db4192c
parent7a4b188f0c0b49ed8ae41489494a9669ad7f1f8c (diff)
jbd2: move lockdep tracking to journal_s
Currently lockdep map is tracked in each journal handle. To be able to expand lockdep support to cover also other cases where we depend on transaction commit and where handle is not available, move lockdep map into struct journal_s. Since this makes the lockdep map shared for all handles, we have to use rwsem_acquire_read() for acquisitions now. Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r--fs/jbd2/journal.c4
-rw-r--r--fs/jbd2/transaction.c11
-rw-r--r--include/linux/jbd2.h17
3 files changed, 20 insertions, 12 deletions
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index b31852f76f46..208e4058040b 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -1091,6 +1091,7 @@ static void jbd2_stats_proc_exit(journal_t *journal)
1091 1091
1092static journal_t * journal_init_common (void) 1092static journal_t * journal_init_common (void)
1093{ 1093{
1094 static struct lock_class_key jbd2_trans_commit_key;
1094 journal_t *journal; 1095 journal_t *journal;
1095 int err; 1096 int err;
1096 1097
@@ -1126,6 +1127,9 @@ static journal_t * journal_init_common (void)
1126 1127
1127 spin_lock_init(&journal->j_history_lock); 1128 spin_lock_init(&journal->j_history_lock);
1128 1129
1130 lockdep_init_map(&journal->j_trans_commit_map, "jbd2_handle",
1131 &jbd2_trans_commit_key, 0);
1132
1129 return journal; 1133 return journal;
1130} 1134}
1131 1135
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index 41249538c047..c0065040c5be 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -382,13 +382,11 @@ repeat:
382 read_unlock(&journal->j_state_lock); 382 read_unlock(&journal->j_state_lock);
383 current->journal_info = handle; 383 current->journal_info = handle;
384 384
385 lock_map_acquire(&handle->h_lockdep_map); 385 rwsem_acquire_read(&journal->j_trans_commit_map, 0, 0, _THIS_IP_);
386 jbd2_journal_free_transaction(new_transaction); 386 jbd2_journal_free_transaction(new_transaction);
387 return 0; 387 return 0;
388} 388}
389 389
390static struct lock_class_key jbd2_handle_key;
391
392/* Allocate a new handle. This should probably be in a slab... */ 390/* Allocate a new handle. This should probably be in a slab... */
393static handle_t *new_handle(int nblocks) 391static handle_t *new_handle(int nblocks)
394{ 392{
@@ -398,9 +396,6 @@ static handle_t *new_handle(int nblocks)
398 handle->h_buffer_credits = nblocks; 396 handle->h_buffer_credits = nblocks;
399 handle->h_ref = 1; 397 handle->h_ref = 1;
400 398
401 lockdep_init_map(&handle->h_lockdep_map, "jbd2_handle",
402 &jbd2_handle_key, 0);
403
404 return handle; 399 return handle;
405} 400}
406 401
@@ -672,7 +667,7 @@ int jbd2__journal_restart(handle_t *handle, int nblocks, gfp_t gfp_mask)
672 if (need_to_start) 667 if (need_to_start)
673 jbd2_log_start_commit(journal, tid); 668 jbd2_log_start_commit(journal, tid);
674 669
675 lock_map_release(&handle->h_lockdep_map); 670 rwsem_release(&journal->j_trans_commit_map, 1, _THIS_IP_);
676 handle->h_buffer_credits = nblocks; 671 handle->h_buffer_credits = nblocks;
677 ret = start_this_handle(journal, handle, gfp_mask); 672 ret = start_this_handle(journal, handle, gfp_mask);
678 return ret; 673 return ret;
@@ -1750,7 +1745,7 @@ int jbd2_journal_stop(handle_t *handle)
1750 wake_up(&journal->j_wait_transaction_locked); 1745 wake_up(&journal->j_wait_transaction_locked);
1751 } 1746 }
1752 1747
1753 lock_map_release(&handle->h_lockdep_map); 1748 rwsem_release(&journal->j_trans_commit_map, 1, _THIS_IP_);
1754 1749
1755 if (wait_for_commit) 1750 if (wait_for_commit)
1756 err = jbd2_log_wait_commit(journal, tid); 1751 err = jbd2_log_wait_commit(journal, tid);
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index efb232c5f668..3d210cbe4e1b 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -491,10 +491,6 @@ struct jbd2_journal_handle
491 491
492 unsigned long h_start_jiffies; 492 unsigned long h_start_jiffies;
493 unsigned int h_requested_credits; 493 unsigned int h_requested_credits;
494
495#ifdef CONFIG_DEBUG_LOCK_ALLOC
496 struct lockdep_map h_lockdep_map;
497#endif
498}; 494};
499 495
500 496
@@ -793,6 +789,7 @@ jbd2_time_diff(unsigned long start, unsigned long end)
793 * @j_proc_entry: procfs entry for the jbd statistics directory 789 * @j_proc_entry: procfs entry for the jbd statistics directory
794 * @j_stats: Overall statistics 790 * @j_stats: Overall statistics
795 * @j_private: An opaque pointer to fs-private information. 791 * @j_private: An opaque pointer to fs-private information.
792 * @j_trans_commit_map: Lockdep entity to track transaction commit dependencies
796 */ 793 */
797 794
798struct journal_s 795struct journal_s
@@ -1035,6 +1032,18 @@ struct journal_s
1035 1032
1036 /* Precomputed journal UUID checksum for seeding other checksums */ 1033 /* Precomputed journal UUID checksum for seeding other checksums */
1037 __u32 j_csum_seed; 1034 __u32 j_csum_seed;
1035
1036#ifdef CONFIG_DEBUG_LOCK_ALLOC
1037 /*
1038 * Lockdep entity to track transaction commit dependencies. Handles
1039 * hold this "lock" for read, when we wait for commit, we acquire the
1040 * "lock" for writing. This matches the properties of jbd2 journalling
1041 * where the running transaction has to wait for all handles to be
1042 * dropped to commit that transaction and also acquiring a handle may
1043 * require transaction commit to finish.
1044 */
1045 struct lockdep_map j_trans_commit_map;
1046#endif
1038}; 1047};
1039 1048
1040/* journal feature predicate functions */ 1049/* journal feature predicate functions */