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

From: Jan Kara
Date: Fri Aug 02 2019 - 09:32:27 EST


On Thu 01-08-19 13:28:49, Peter Zijlstra wrote:
> 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.

Yeah, jbd2 doesn't play any weird locking tricks so lockdep_assert_held()
is fine. I'll replace those when I'm updating the patch.

Honza

--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR