From owner-freebsd-hackers@freebsd.org Sat Apr 13 19:37:47 2019 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2C7CB158179B for ; Sat, 13 Apr 2019 19:37:47 +0000 (UTC) (envelope-from mckusick@mckusick.com) Received: from chez.mckusick.com (chez.mckusick.com [70.36.157.235]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A49C38FAE0; Sat, 13 Apr 2019 19:37:46 +0000 (UTC) (envelope-from mckusick@mckusick.com) Received: from chez.mckusick.com (localhost [IPv6:::1]) by chez.mckusick.com (8.15.2/8.15.2) with ESMTP id x3DJkPIk097337; Sat, 13 Apr 2019 12:46:25 -0700 (PDT) (envelope-from mckusick@mckusick.com) Message-Id: <201904131946.x3DJkPIk097337@chez.mckusick.com> From: Kirk McKusick To: Konstantin Belousov Subject: Re: When can a struct buf's b_lblkno field by < 0 ? cc: Alan Somers , FreeBSD Hackers X-URL: http://WWW.McKusick.COM/ Reply-To: Kirk McKusick In-reply-to: <20190413154340.GJ1923@kib.kiev.ua> Comments: In-reply-to Konstantin Belousov message dated "Sat, 13 Apr 2019 18:43:40 +0300." MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <97335.1555184785.1@chez.mckusick.com> Date: Sat, 13 Apr 2019 12:46:25 -0700 X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,MISSING_MID, UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on chez.mckusick.com X-Rspamd-Queue-Id: A49C38FAE0 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.96 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[]; NEURAL_HAM_SHORT(-0.96)[-0.962,0] X-Mailman-Approved-At: Sat, 13 Apr 2019 20:02:36 +0000 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Apr 2019 19:37:47 -0000 > Date: Sat, 13 Apr 2019 18:43:40 +0300 > From: Konstantin Belousov > To: Kirk McKusick > Cc: Alan Somers , > FreeBSD Hackers > 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