Re: [patch V2 6/7] fs/jbd2: Make state lock a spinlock

From: Peter Zijlstra
Date: Thu Aug 01 2019 - 07:29:28 EST


On Thu, Aug 01, 2019 at 03:01:32AM +0200, Thomas Gleixner wrote:

> @@ -1931,7 +1932,7 @@ static void __jbd2_journal_temp_unlink_b
> transaction_t *transaction;
> struct buffer_head *bh = jh2bh(jh);
>
> - J_ASSERT_JH(jh, jbd_is_locked_bh_state(bh));
> + assert_spin_locked(&jh->state_lock);
> transaction = jh->b_transaction;
> if (transaction)
> assert_spin_locked(&transaction->t_journal->j_list_lock);

> @@ -2415,7 +2416,7 @@ void __jbd2_journal_file_buffer(struct j
> int was_dirty = 0;
> struct buffer_head *bh = jh2bh(jh);
>
> - J_ASSERT_JH(jh, jbd_is_locked_bh_state(bh));
> + assert_spin_locked(&jh->state_lock);
> assert_spin_locked(&transaction->t_journal->j_list_lock);
>
> J_ASSERT_JH(jh, jh->b_jlist < BJ_Types);

> @@ -2500,7 +2501,7 @@ void __jbd2_journal_refile_buffer(struct
> int was_dirty, jlist;
> struct buffer_head *bh = jh2bh(jh);
>
> - J_ASSERT_JH(jh, jbd_is_locked_bh_state(bh));
> + assert_spin_locked(&jh->state_lock);
> if (jh->b_transaction)
> assert_spin_locked(&jh->b_transaction->t_journal->j_list_lock);
>

Do those want to be:

lockdep_assert_held(&jh->state_lock);

instead? The difference is of course that lockdep_assert_held() requires
the current context to hold the lock, where assert_*_locked() merely
checks _someone_ holds it.