[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210409025131.4114078-14-willy@infradead.org>
Date: Fri, 9 Apr 2021 03:51:27 +0100
From: "Matthew Wilcox (Oracle)" <willy@...radead.org>
To: neilb@...e.de, peterz@...radead.org, mingo@...hat.com,
will@...nel.org, longman@...hat.com, boqun.feng@...il.com,
tglx@...utronix.de, bigeasy@...utronix.de
Cc: "Matthew Wilcox (Oracle)" <willy@...radead.org>,
linux-kernel@...r.kernel.org
Subject: [PATCH 13/17] jbd2: Add jbd2_jh_lock
Allow lockdep to track the journal bit spin locks.
Signed-off-by: Matthew Wilcox (Oracle) <willy@...radead.org>
---
fs/jbd2/journal.c | 18 ++++++++++--------
include/linux/jbd2.h | 10 ++++++----
2 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 2dc944442802..9c5f4b99157b 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -2733,6 +2733,8 @@ static void journal_free_journal_head(struct journal_head *jh)
* jbd2_journal_put_journal_head(jh);
*/
+static DEFINE_SPLIT_LOCK(jbd2_jh_lock);
+
/*
* Give a buffer_head a journal_head.
*
@@ -2747,7 +2749,7 @@ struct journal_head *jbd2_journal_add_journal_head(struct buffer_head *bh)
if (!buffer_jbd(bh))
new_jh = journal_alloc_journal_head();
- jbd_lock_bh_journal_head(bh);
+ jbd_lock_bh_journal_head(bh, &jbd2_jh_lock);
if (buffer_jbd(bh)) {
jh = bh2jh(bh);
} else {
@@ -2756,7 +2758,7 @@ struct journal_head *jbd2_journal_add_journal_head(struct buffer_head *bh)
(bh->b_page && bh->b_page->mapping));
if (!new_jh) {
- jbd_unlock_bh_journal_head(bh);
+ jbd_unlock_bh_journal_head(bh, &jbd2_jh_lock);
goto repeat;
}
@@ -2769,7 +2771,7 @@ struct journal_head *jbd2_journal_add_journal_head(struct buffer_head *bh)
BUFFER_TRACE(bh, "added journal_head");
}
jh->b_jcount++;
- jbd_unlock_bh_journal_head(bh);
+ jbd_unlock_bh_journal_head(bh, &jbd2_jh_lock);
if (new_jh)
journal_free_journal_head(new_jh);
return bh->b_private;
@@ -2783,12 +2785,12 @@ struct journal_head *jbd2_journal_grab_journal_head(struct buffer_head *bh)
{
struct journal_head *jh = NULL;
- jbd_lock_bh_journal_head(bh);
+ jbd_lock_bh_journal_head(bh, &jbd2_jh_lock);
if (buffer_jbd(bh)) {
jh = bh2jh(bh);
jh->b_jcount++;
}
- jbd_unlock_bh_journal_head(bh);
+ jbd_unlock_bh_journal_head(bh, &jbd2_jh_lock);
return jh;
}
@@ -2831,16 +2833,16 @@ void jbd2_journal_put_journal_head(struct journal_head *jh)
{
struct buffer_head *bh = jh2bh(jh);
- jbd_lock_bh_journal_head(bh);
+ jbd_lock_bh_journal_head(bh, &jbd2_jh_lock);
J_ASSERT_JH(jh, jh->b_jcount > 0);
--jh->b_jcount;
if (!jh->b_jcount) {
__journal_remove_journal_head(bh);
- jbd_unlock_bh_journal_head(bh);
+ jbd_unlock_bh_journal_head(bh, &jbd2_jh_lock);
journal_release_journal_head(jh, bh->b_size);
__brelse(bh);
} else {
- jbd_unlock_bh_journal_head(bh);
+ jbd_unlock_bh_journal_head(bh, &jbd2_jh_lock);
}
}
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index 99d3cd051ac3..bf32cee8b1e2 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -348,14 +348,16 @@ static inline struct journal_head *bh2jh(struct buffer_head *bh)
return bh->b_private;
}
-static inline void jbd_lock_bh_journal_head(struct buffer_head *bh)
+static inline void jbd_lock_bh_journal_head(struct buffer_head *bh,
+ struct split_lock *sl)
{
- bit_spin_lock(BH_JournalHead, &bh->b_state);
+ bit_spin_lock(BH_JournalHead, &bh->b_state, sl);
}
-static inline void jbd_unlock_bh_journal_head(struct buffer_head *bh)
+static inline void jbd_unlock_bh_journal_head(struct buffer_head *bh,
+ struct split_lock *sl)
{
- bit_spin_unlock(BH_JournalHead, &bh->b_state);
+ bit_spin_unlock(BH_JournalHead, &bh->b_state, sl);
}
#define J_ASSERT(assert) BUG_ON(!(assert))
--
2.30.2
Powered by blists - more mailing lists