Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 13 Apr 2019 12:46:25 -0700
From:      Kirk McKusick <mckusick@mckusick.com>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        Alan Somers <asomers@freebsd.org>, FreeBSD Hackers <freebsd-hackers@freebsd.org>
Subject:   Re: When can a struct buf's b_lblkno field by < 0 ?
Message-ID:  <201904131946.x3DJkPIk097337@chez.mckusick.com>
In-Reply-To: <20190413154340.GJ1923@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
> Date: Sat, 13 Apr 2019 18:43:40 +0300
> From: Konstantin Belousov <kostikbel@gmail.com>
> To: Kirk McKusick <mckusick@mckusick.com>
> Cc: Alan Somers <asomers@freebsd.org>,
>         FreeBSD Hackers <freebsd-hackers@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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201904131946.x3DJkPIk097337>