From owner-freebsd-hackers@freebsd.org Sat Apr 13 20:28:58 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 731211582474 for ; Sat, 13 Apr 2019 20:28:58 +0000 (UTC) (envelope-from asomers@gmail.com) Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3220E6A5AB for ; Sat, 13 Apr 2019 20:28:57 +0000 (UTC) (envelope-from asomers@gmail.com) Received: by mail-lf1-f41.google.com with SMTP id h5so7140814lfm.1 for ; Sat, 13 Apr 2019 13:28:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=BqzffvplxlN5yAEX+9RMdaHZadSajvfH6V0RlAZR/Ag=; b=VmidJHpvJLoT3ipk6fwnl3/rXZI+5UD7QPeTAXtQdPYta7FTN7MsKtWPHEzHIpKnOT mp3/YexI3zV9pg5vG2oqeDWzy1UoskWCPZEFATBV8l1rkLUxNBFr/SwScXqxtNtQYIYM N8s5SHFm+fr2uiL2nOJJYul6j6J36m6lC6TThvnxXzOLg16Yk6CWA08pagz9y/EON+22 /ff+NIQ88RdmPyh4QKDnzVu900HZR8E9nAz0SP3EtntpYZtrVVTEyIFRPS+QYkEd5vSJ 4T9FiYzf5Mcla3rkrysw5oeyAWNLxX1VFzrBYMiIjhZzgAv2Pee8FiSy0sLWzq1TdKX4 D0Ug== X-Gm-Message-State: APjAAAVujdmtSJjzfQoXf51t8eYZJwCUedr1rOoTwhr0Ts5/8gwU9n9+ 9dBJh7vLTfOyKt5yXzMhHZawM6T+A3RQyt8zU90= X-Google-Smtp-Source: APXvYqz1j6c9LHEv4zYJ6B8uqLbFjXd1lYcBcPP3imPa8ZmZvFfS1K4ZCs6Gt23rIK820c4TMqHh5RV9X1Fl8CA3Abw= X-Received: by 2002:a19:7719:: with SMTP id s25mr4186516lfc.69.1555187330219; Sat, 13 Apr 2019 13:28:50 -0700 (PDT) MIME-Version: 1.0 References: <20190413154340.GJ1923@kib.kiev.ua> <201904131946.x3DJkPIk097337@chez.mckusick.com> In-Reply-To: <201904131946.x3DJkPIk097337@chez.mckusick.com> From: Alan Somers Date: Sat, 13 Apr 2019 14:28:38 -0600 Message-ID: Subject: Re: When can a struct buf's b_lblkno field by < 0 ? To: Kirk McKusick Cc: Konstantin Belousov , FreeBSD Hackers Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 3220E6A5AB X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; spf=pass (mx1.freebsd.org: domain of asomers@gmail.com designates 209.85.167.41 as permitted sender) smtp.mailfrom=asomers@gmail.com X-Spamd-Result: default: False [-3.16 / 15.00]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17]; TO_DN_ALL(0.00)[]; MX_GOOD(-0.01)[cached: alt3.gmail-smtp-in.l.google.com]; NEURAL_HAM_SHORT(-0.82)[-0.820,0]; FORGED_SENDER(0.30)[asomers@freebsd.org,asomers@gmail.com]; IP_SCORE(-1.33)[ip: (-0.54), ipnet: 209.85.128.0/17(-3.87), asn: 15169(-2.19), country: US(-0.06)]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; FROM_NEQ_ENVFROM(0.00)[asomers@freebsd.org,asomers@gmail.com]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; SUBJECT_ENDS_QUESTION(1.00)[]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; DMARC_NA(0.00)[freebsd.org]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[41.167.85.209.list.dnswl.org : 127.0.5.0]; RCVD_TLS_LAST(0.00)[]; RWL_MAILSPIKE_POSSIBLE(0.00)[41.167.85.209.rep.mailspike.net : 127.0.0.17]; RCVD_COUNT_TWO(0.00)[2]; FREEMAIL_CC(0.00)[gmail.com] 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 20:28:58 -0000 On Sat, Apr 13, 2019 at 1:37 PM Kirk McKusick wrote: > > > 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 So I think you're saying that the last loop is indeed necessary, except when b_lblkno == 0 ?