Commit 833f3d15 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] JBD: add some locking assertions

Drop in a few assertions to ensure that the locking rules are being adhered
to.
parent eba4b4b7
...@@ -1498,6 +1498,7 @@ void __journal_unfile_buffer(struct journal_head *jh) ...@@ -1498,6 +1498,7 @@ void __journal_unfile_buffer(struct journal_head *jh)
transaction_t *transaction; transaction_t *transaction;
struct buffer_head *bh = jh2bh(jh); struct buffer_head *bh = jh2bh(jh);
J_ASSERT_JH(jh, jbd_is_locked_bh_state(bh));
transaction = jh->b_transaction; transaction = jh->b_transaction;
if (transaction) if (transaction)
assert_spin_locked(&transaction->t_journal->j_list_lock); assert_spin_locked(&transaction->t_journal->j_list_lock);
...@@ -1924,6 +1925,7 @@ void __journal_file_buffer(struct journal_head *jh, ...@@ -1924,6 +1925,7 @@ void __journal_file_buffer(struct journal_head *jh,
int was_dirty = 0; int was_dirty = 0;
struct buffer_head *bh = jh2bh(jh); struct buffer_head *bh = jh2bh(jh);
J_ASSERT_JH(jh, jbd_is_locked_bh_state(bh));
assert_spin_locked(&transaction->t_journal->j_list_lock); assert_spin_locked(&transaction->t_journal->j_list_lock);
#ifdef __SMP__ #ifdef __SMP__
...@@ -2013,6 +2015,7 @@ void __journal_refile_buffer(struct journal_head *jh) ...@@ -2013,6 +2015,7 @@ void __journal_refile_buffer(struct journal_head *jh)
int was_dirty; int was_dirty;
struct buffer_head *bh = jh2bh(jh); struct buffer_head *bh = jh2bh(jh);
J_ASSERT_JH(jh, jbd_is_locked_bh_state(bh));
if (jh->b_transaction) if (jh->b_transaction)
assert_spin_locked(&jh->b_transaction->t_journal->j_list_lock); assert_spin_locked(&jh->b_transaction->t_journal->j_list_lock);
......
...@@ -322,6 +322,11 @@ static inline int jbd_trylock_bh_state(struct buffer_head *bh) ...@@ -322,6 +322,11 @@ static inline int jbd_trylock_bh_state(struct buffer_head *bh)
return bit_spin_trylock(BH_State, &bh->b_state); return bit_spin_trylock(BH_State, &bh->b_state);
} }
static inline int jbd_is_locked_bh_state(struct buffer_head *bh)
{
return bit_spin_is_locked(BH_State, &bh->b_state);
}
static inline void jbd_unlock_bh_state(struct buffer_head *bh) static inline void jbd_unlock_bh_state(struct buffer_head *bh)
{ {
bit_spin_unlock(BH_State, &bh->b_state); bit_spin_unlock(BH_State, &bh->b_state);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment