linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Holger Hoffstätte" <holger.hoffstaette@googlemail.com>
To: "Austin S. Hemmelgarn" <ahferroin7@gmail.com>
Cc: linux-btrfs <linux-btrfs@vger.kernel.org>
Subject: Re: Stray 4k extents with slow buffered writes
Date: Thu, 3 Mar 2016 22:50:58 +0100	[thread overview]
Message-ID: <56D8B1C2.1040604@googlemail.com> (raw)
In-Reply-To: <56D8A2D4.2010907@gmail.com>

On 03/03/16 21:47, Austin S. Hemmelgarn wrote:
>> $mount | grep sdf
>> /dev/sdf1 on /mnt/usb type btrfs (rw,relatime,space_cache=v2,subvolid=5,subvol=/)
> Do you still see the same behavior with the old space_cache format?
> This appears to be an issue of space management and allocation, so
> this may be playing a part.

I just did the clear_cache,space_cache=v1 dance. Now a download with
bandwidth-limit=1M, dirty_expire=20s, commit=30 and *no* autodefrag
first ended up looking like this:

$filefrag -ek linux-4.5-rc6.tar.xz 
Filesystem type is: 9123683e
File size of linux-4.5-rc6.tar.xz is 88362576 (86292 blocks of 1024 bytes)
 ext:     logical_offset:        physical_offset: length:   expected: flags:
   0:        0..    7427:  227197920.. 227205347:   7428:            
   1:     7428..   33027:  227205348.. 227230947:  25600:            
   2:    33028..   53011:  227271164.. 227291147:  19984:  227230948:
   3:    53012..   72995:  227291148.. 227311131:  19984:            
   4:    72996..   86291:  227311132.. 227324427:  13296:             last,eof
linux-4.5-rc6.tar.xz: 2 extents found

Yay! But wait, there's more!

$sync
$filefrag -ek linux-4.5-rc6.tar.xz
Filesystem type is: 9123683e
File size of linux-4.5-rc6.tar.xz is 88362576 (86292 blocks of 1024 bytes)
 ext:     logical_offset:        physical_offset: length:   expected: flags:
   0:        0..    7423:  227197920.. 227205343:   7424:            
   1:     7424..    7427:  227169600.. 227169603:      4:  227205344:
   2:     7428..   33023:  227205348.. 227230943:  25596:  227169604:
   3:    33024..   33027:  227169604.. 227169607:      4:  227230944:
   4:    33028..   53007:  227271164.. 227291143:  19980:  227169608:
   5:    53008..   53011:  227230948.. 227230951:      4:  227291144:
   6:    53012..   72991:  227291148.. 227311127:  19980:  227230952:
   7:    72992..   72995:  227230952.. 227230955:      4:  227311128:
   8:    72996..   86291:  227311132.. 227324427:  13296:  227230956: last,eof
linux-4.5-rc6.tar.xz: 9 extents found

Now I'm like ¯\(ツ)/¯

With autodefrag the same happens, though it then eventually does the
merging from 4k -> 256k. I went searching for that hardcoded 256k value
and found it as default in ioctl.c:btrfs_defrag_file() when no threshold
has been passed, as is the case for autodefrag. I'll try to increase that
and see how much I can destroy.

Also, rsync with --bwlimit=1m does _not_ seem to create files like this:

$rsync (..)
$filefrag -ek linux-4.4.4.tar.bz2 
Filesystem type is: 9123683e
File size of linux-4.4.4.tar.bz2 is 105008928 (102548 blocks of 1024 bytes)
 ext:     logical_offset:        physical_offset: length:   expected: flags:
   0:        0..    4095:  227197920.. 227202015:   4096:            
   1:     4096..   25599:  227202016.. 227223519:  21504:            
   2:    25600..   51199:  227271164.. 227296763:  25600:  227223520:
   3:    51200..   76799:  227296764.. 227322363:  25600:            
   4:    76800..  102547:  227322364.. 227348111:  25748:             last,eof
linux-4.4.4.tar.bz2: 2 extents found

Which looks exactly as one would expect, probably - as Chris' mail
just explained - it doesn't use O_APPEND, whereas wget apparently does.

> I'd be somewhat curious to see if something similar happens on other
> filesystems with such low writeback timeouts.  My thought in this
> case is that the issue is that BTRFS's allocator isn't smart enough
> to try and merge new extents into existing ones when possible.

ext4 creates 1-2 extents, regardless of method.

Holger


  reply	other threads:[~2016-03-03 21:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-03 12:28 Stray 4k extents with slow buffered writes Holger Hoffstätte
2016-03-03 18:33 ` Liu Bo
2016-03-03 19:53   ` Holger Hoffstätte
2016-03-03 20:47     ` Austin S. Hemmelgarn
2016-03-03 21:50       ` Holger Hoffstätte [this message]
2016-03-03 22:13         ` Liu Bo
2016-03-04  1:37           ` Liu Bo
2016-03-04 12:17     ` Duncan
2016-03-03 20:55 ` 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=56D8B1C2.1040604@googlemail.com \
    --to=holger.hoffstaette@googlemail.com \
    --cc=ahferroin7@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).