Re: [patch V2 7/7] fs/jbd2: Free journal head outside of locked region

From: Thomas Gleixner
Date: Thu Aug 01 2019 - 14:09:18 EST


On Thu, 1 Aug 2019, Jan Kara wrote:
> On Thu 01-08-19 03:01:33, Thomas Gleixner wrote:
> > On PREEMPT_RT bit-spinlocks have the same semantics as on PREEMPT_RT=n,
> > i.e. they disable preemption. That means functions which are not safe to be
> > called in preempt disabled context on RT trigger a might_sleep() assert.
> Looks mostly good. Just a small suggestion for simplification below:
>
> > @@ -2559,11 +2568,14 @@ void jbd2_journal_put_journal_head(struc
> > J_ASSERT_JH(jh, jh->b_jcount > 0);
> > --jh->b_jcount;
> > if (!jh->b_jcount) {
> > - __journal_remove_journal_head(bh);
> > + size_t b_size = __journal_remove_journal_head(bh);
> > +
> > jbd_unlock_bh_journal_head(bh);
> > + journal_release_journal_head(jh, b_size);
> > __brelse(bh);
>
> The bh is pinned until you call __brelse(bh) above and bh->b_size doesn't
> change during the lifetime of the buffer. So there's no need of
> fetching bh->b_size in __journal_remove_journal_head() and passing it back.
> You can just:
>
> journal_release_journal_head(jh, bh->b_size);

Ah. Nice. I assumed that this would be possible, but then my ignorance
induced paranoia won.

Thanks,

tglx