linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Zygo Blaxell <ce3g8jdj@umail.furryterror.org>
Cc: Lennart Poettering <lennart@poettering.net>, linux-btrfs@vger.kernel.org
Subject: Re: price to pay for nocow file bit?
Date: Fri, 9 Jan 2015 16:41:03 +0100	[thread overview]
Message-ID: <20150109154103.GA3685@twin.jikos.cz> (raw)
In-Reply-To: <20150108183620.GA12857@hungrycats.org>

On Thu, Jan 08, 2015 at 01:36:21PM -0500, Zygo Blaxell wrote:
> Hmmm...it seems the handwaving about tail-packing that I was previously
> ignoring is important after all.
> 
> A few quick tests with filefrag show that btrfs isn't doing full
> tail-packing, only small file allocation (i.e. files smaller than 4096
> bytes get stored inline, and nothing else does, not even sparse files
> with a single 1-byte extent at offset != 0).  Thus the inline storage
> avoids fragmentation only to the minimum extent possible.

That's right, btrfs does not do the reiserfs-style tail packing, and
IMHO will never do that. This brings a lot of code complexity than it's
worth in the end.

> Short appends to the end of the file effectively become modifications
> of the last block of the file.  That triggers CoW on the append, and if
> we're doing lots of tiny writes the file becomes extremely fragmented
> (exactly the worst case of one fragment per block).  A mix of big and
> small appends seems to use fallocated space for those writes that cover
> complete blocks, which is arguably worse than not fallocating at all.
> 
> So fallocate will not help until btrfs learns to do tail-packing, or
> some other way to avoid this problem.
> 
> > > This would work on ext4, xfs, and others, and provide the same benefit
> > > (or even better) without filesystem-specific code.  journald would
> > > preallocate a contiguous chunk past the end of the file for appends,
> > > and
> > 
> > That's precisely what we do. But journald's write pattern is not
> > purely appending to files, it's "append something to the end, then
> > link it up in the beginning". And for the "append" part we are
> > fine with fallocate(). It's the "link up" part that completely fucks
> > up fragmentation so far.
> 
> Wrong theory but same result.  The writes at the beginning just keep
> replacing a single extent over and over, which has a worst-case effect
> of adding a single fragment to the beginning of a file that would not
> otherwise be fragmented.  The appends are causing fragmentation all
> by themselves.  :-P

OTOH, the appending write and the header rewrite happen at roughly same
time so the actual block allocations may end up close to each other as
well. But yes, one cannot rely on that.

  reply	other threads:[~2015-01-09 15:41 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-07 17:43 price to pay for nocow file bit? Lennart Poettering
2015-01-07 20:10 ` Josef Bacik
2015-01-07 21:05   ` Goffredo Baroncelli
2015-01-07 22:06     ` Josef Bacik
2015-01-08  6:30   ` Duncan
2015-01-10 12:00     ` Martin Steigerwald
2015-01-10 12:23       ` Martin Steigerwald
2015-01-08  8:24   ` Chris Murphy
2015-01-08  8:35     ` Koen Kooi
2015-01-08 13:30   ` Lennart Poettering
2015-01-08 18:24     ` Konstantinos Skarlatos
2015-01-08 18:48       ` Goffredo Baroncelli
2015-01-09 15:52     ` David Sterba
2015-01-10 10:30       ` Martin Steigerwald
2015-01-11 20:39     ` Chris Murphy
2015-01-08 15:56 ` Zygo Blaxell
2015-01-08 16:53   ` Lennart Poettering
2015-01-08 18:36     ` Zygo Blaxell
2015-01-09 15:41       ` David Sterba [this message]
2015-01-09 16:14         ` Zygo Blaxell
2015-01-08 20:42     ` Roger Binns
2015-01-15 19:06     ` Chris Mason

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=20150109154103.GA3685@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=ce3g8jdj@umail.furryterror.org \
    --cc=lennart@poettering.net \
    --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).