From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-it0-f43.google.com ([209.85.214.43]:38277 "EHLO mail-it0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751251AbdHCRZj (ORCPT ); Thu, 3 Aug 2017 13:25:39 -0400 Received: by mail-it0-f43.google.com with SMTP id h199so674632ith.1 for ; Thu, 03 Aug 2017 10:25:38 -0700 (PDT) Subject: Re: Massive loss of disk space To: Marat Khalili , kreijack@inwind.it, linux-btrfs@vger.kernel.org Cc: pwm , Hugo Mills References: <20170801122039.GX7140@carfax.org.uk> <7f2b5c3a-2f5c-e857-d2dc-3ea16b58ecaf@gmail.com> <798a9077-bcbd-076c-a458-3403010ce8ac@libero.it> From: "Austin S. Hemmelgarn" Message-ID: <2face7a2-2992-d3ad-01f6-8e167bc9d55e@gmail.com> Date: Thu, 3 Aug 2017 13:25:34 -0400 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Sender: linux-btrfs-owner@vger.kernel.org List-ID: On 2017-08-03 13:15, Marat Khalili wrote: > On August 3, 2017 7:01:06 PM GMT+03:00, Goffredo Baroncelli >> The file is physically extended >> >> ghigo@venice:/tmp$ fallocate -l 1000 foo.txt > > For clarity let's replace the fallocate above with: > $ head -c 1000 foo.txt > >> ghigo@venice:/tmp$ ls -l foo.txt >> -rw-r--r-- 1 ghigo ghigo 1000 Aug 3 18:00 foo.txt >> ghigo@venice:/tmp$ fallocate -o 500 -l 1000 foo.txt >> ghigo@venice:/tmp$ ls -l foo.txt >> -rw-r--r-- 1 ghigo ghigo 1500 Aug 3 18:00 foo.txt >> ghigo@venice:/tmp$ > > According to explanation by Austin the foo.txt at this point somehow occupies 2000 bytes of space because I can reflink it and then write another 1000 bytes of data into it without losing 1000 bytes I already have or getting out of drive space. (Or is it only true while there are open file handles?) > OK, I think there may be some misunderstanding here. By 'CoW unwritten extents', I mean that when we write to the extent, a CoW operation happens, instead of the data being written directly into the extent. In this case, it has nothing to do with reflinking, and Goffredo is correct that if your filesystem is small enough, the second fallocate will fail there.