From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-it0-f51.google.com ([209.85.214.51]:33456 "EHLO mail-it0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751400AbeCEQRm (ORCPT ); Mon, 5 Mar 2018 11:17:42 -0500 Received: by mail-it0-f51.google.com with SMTP id w19so9641793ite.0 for ; Mon, 05 Mar 2018 08:17:42 -0800 (PST) Subject: Re: btrfs space used issue To: Christoph Hellwig Cc: linux-btrfs@vger.kernel.org References: <9d98d11a-0c30-56eb-efa9-889237592b4b@gmail.com> <20180305152827.GA27477@infradead.org> From: "Austin S. Hemmelgarn" Message-ID: <94411d71-b9b7-b0ee-f61d-5c4a93b1ad41@gmail.com> Date: Mon, 5 Mar 2018 11:17:35 -0500 MIME-Version: 1.0 In-Reply-To: <20180305152827.GA27477@infradead.org> Content-Type: text/plain; charset=utf-8; format=flowed Sender: linux-btrfs-owner@vger.kernel.org List-ID: On 2018-03-05 10:28, Christoph Hellwig wrote: > On Sat, Mar 03, 2018 at 06:59:26AM +0000, Duncan wrote: >> Indeed. Preallocation with COW doesn't make the sense it does on an >> overwrite-in-place filesystem. > > It makes a whole lot of sense, it just is a little harder to implement. > > There is no reason not to preallocate specific space, or if you aren't > forced to be fully log structured by the medium, specific blocks to > COW into. It just isn't quite as trivial as for a rewrite in place > file system to implement. Yes, there's generally no reason not to pre-allocate space, but given how BTRFS implements pre-allocation, it doesn't make sense to do so pretty much at all for anything but NOCOW files, as it doesn't even guarantee that you'll be able to write however much data you pre-allocated space for (and it doesn't matter whether you use fallocate or just write out a run of zeroes, either way does not work in a manner consistent with how other filesystems do). There's been discussion before about this, arising from the (completely illogical given how fallocate is expected to behave) behavior that you can fallocate more than half the free space on a BTRFS volume but will then fail writes with -ENOSPC part way through actually writing data to the pre-allocated space you just reserved (and that it can fail for other reasons too with -ENOSPC).