When can a struct buf's b_lblkno field by < 0 ?

Alan Somers asomers at freebsd.org
Sat Apr 13 20:28:58 UTC 2019


On Sat, Apr 13, 2019 at 1:37 PM Kirk McKusick <mckusick at mckusick.com> wrote:
>
> > Date: Sat, 13 Apr 2019 18:43:40 +0300
> > From: Konstantin Belousov <kostikbel at gmail.com>
> > To: Kirk McKusick <mckusick at mckusick.com>
> > Cc: Alan Somers <asomers at freebsd.org>,
> >         FreeBSD Hackers <freebsd-hackers at freebsd.org>
> > Subject: Re: When can a struct buf's b_lblkno field by < 0 ?
> >
> > On Sat, Apr 13, 2019 at 08:23:54AM -0700, Kirk McKusick wrote:
> >
> >> I don't have much to add to kib's commentary. The change in -r112182
> >> was not meant to have functional change, just reduce indentation and
> >> get rid of unnecessary code. The change should have been to
> >> (bp->b_lblkno >= 0), but the effect is that if logical data block 0
> >> is in the cache and dirty it will be unnecessarily written. At that
> >> time all partial truncations were done synchronously, hence the
> >> flushing of all the meta-data. With the additional of journaled soft
> >> updates, it became possible to do partial truncations asynchronously.
> >
> > Do you agree with the statement that the last loop in vtruncbuf() is
> > useless ? Its removal could only make a difference for ffs_truncate(),
> > and there, I do not think that b(a)write() is enough to ensure that the
> > indirect buffers are clean, due to dependencies.
>
> When running with soft updates, they will ensure that everything happens
> in the right order. When running without them, the last loop is needed
> to ensure that the file is consistent before the length is set. This
> consistency is ensured because we do a bufobj_wwait() after falling out
> of the loop which will wait until all the bawrite()s have completed.
>
>         Kirk

So I think you're saying that the last loop is indeed necessary,
except when b_lblkno == 0 ?


More information about the freebsd-hackers mailing list