Re: btrfs space used issue
From: Austin S. Hemmelgarn <hidden>
Date: 2018-03-05 16:17:42
On 2018-03-05 10:28, Christoph Hellwig wrote:
On Sat, Mar 03, 2018 at 06:59:26AM +0000, Duncan wrote:quoted
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).