linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Austin S. Hemmelgarn" <ahferroin7@gmail.com>
To: Henk Slager <eye1tm@gmail.com>
Cc: linux-btrfs <linux-btrfs@vger.kernel.org>
Subject: Re: Is autodefrag recommended?
Date: Tue, 5 Sep 2017 09:00:35 -0400	[thread overview]
Message-ID: <60a91979-5452-4935-d20b-cf593e2c868c@gmail.com> (raw)
In-Reply-To: <CAPmG0jZApuPggvJ98Ko9Yps+N3ixNjAEzTgfDNWoqa2a_Tdd2w@mail.gmail.com>

On 2017-09-05 08:49, Henk Slager wrote:
> On Tue, Sep 5, 2017 at 1:45 PM, Austin S. Hemmelgarn
> <ahferroin7@gmail.com> wrote:
> 
>>>    - You end up duplicating more data than is strictly necessary. This
>>>      is, IIRC, something like 128 KiB for a write.
>>
>> FWIW< I'm pretty sure you can mitigate this first issue by running a regular
>> defrag on a semi-regular basis (monthly is what I would probably suggest).
> 
> No, both autodefrag and regular defrag duplicate data, so if you keep
> snapshots around for weeks or months, it can eat up a significant
> amount of space.
> 
I'm not talking about data duplication due to broken reflinks, I'm 
talking about data duplication due to how partial extent rewrites are 
handled in BTRFS.

As a more illustrative example, suppose you've got a 256k file that has 
just one extent.  Such a file will require 256k of space for the data 
Now rewrite from 128k to 192k.  The file now technically takes up 320k, 
because the region you rewrote is still allocated in the original extent.

I know that sub-extent-size reflinks are handled like this (in the above 
example, if you instead use the CLONE ioctl to create a new file 
reflinking that range, then delete the original, the remaining 192k of 
space in the extent ends up unreferenced, but gets kept around until the 
referenced region is no longer referenced (and the easiest way to ensure 
this is to either rewrite the whole file, or defragment it)), and I'm 
pretty sure from reading the code that mid-extent writes are handled 
this way too, in which case, a full defrag can reclaim that space.

  reply	other threads:[~2017-09-05 13:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-04  9:31 Is autodefrag recommended? Marat Khalili
2017-09-04 10:23 ` Henk Slager
2017-09-04 10:34 ` Duncan
2017-09-04 11:09   ` Henk Slager
2017-09-04 22:27     ` Duncan
2017-09-04 10:54 ` Hugo Mills
2017-09-05 11:45   ` Austin S. Hemmelgarn
2017-09-05 12:49     ` Henk Slager
2017-09-05 13:00       ` Austin S. Hemmelgarn [this message]
2017-09-05 12:36 ` A L
2017-09-05 14:01 ` Is autodefrag recommended? -- re-duplication??? Marat Khalili
2017-09-05 14:39   ` Hugo Mills

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=60a91979-5452-4935-d20b-cf593e2c868c@gmail.com \
    --to=ahferroin7@gmail.com \
    --cc=eye1tm@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).