linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chris Mason <chris.mason@oracle.com>
To: Liu Bo <liubo2009@cn.fujitsu.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [RFC PATCH v2] Btrfs: improve space count for files with fragments
Date: Thu, 26 Apr 2012 13:14:30 -0400	[thread overview]
Message-ID: <20120426171430.GP22794@shiny> (raw)
In-Reply-To: <1335422363-31198-1-git-send-email-liubo2009@cn.fujitsu.com>

On Thu, Apr 26, 2012 at 02:39:23PM +0800, Liu Bo wrote:
> Here is a simple scenario:
> $ dd if=/dev/zero of=/mnt/btrfs/foobar bs=1k count=20;sync
> $ btrfs fi df /mnt/btrfs
> 
> we get 20K used, but then
> $ dd if=/dev/zero of=/mnt/btrfs/foobar bs=1k count=4 seek=4 conv=notrunc;sync
> $ btrfs fi df /mnt/btrfs
> 
> we get 24K used.
> Here is the problem, it is possible that an _unshared_ file with lots of
> fragments costs nearly double space than its i_size, like:
> 0k              20k
> | --- extent --- |      turned to be on disk    <---  extent --->  <-- A -->
>      | - A - |                                  | -------------- | | ----- |
>      1k      19k                                       20k + 18k = 38k
> 
>                         but what users want is  <---  extent --->  <-- A -->
>                                                 | --- |     | -- | | ----- |
>                                                     1k + 1k + 18k = 20k
> so 18k is wasted.
> 
> With the current backref design, there is no easy way to fix this, because it
> needs to touch several subtle parts, such as delayed ref stuff, extent backref.
> 
> So here I give it a try by splitting the extent which we're processing(the idea
> comes from Chris :)).
> 
> The benifits:
> As the above example shows, we'll get three individual extents: 1k + 1k + 18k,
> with their checksums are well splitted.
> 
> The defects:
> Yes, it makes the code much uglier.  And since we've disabled the merging of
> delayed refs, we'll get some performance regression.
> 
> NOTE:
> The patch may still have some bugs since we need more time to tune the subtle
> things.

Thanks for working on this.  Could you please explain in detail what the
pinned extents do?

-chris

  reply	other threads:[~2012-04-26 17:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-26  6:39 [RFC PATCH v2] Btrfs: improve space count for files with fragments Liu Bo
2012-04-26 17:14 ` Chris Mason [this message]
2012-04-27  1:44   ` Liu Bo
2012-05-09 17:29     ` David Sterba
2012-05-10  1:11       ` Liu Bo

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=20120426171430.GP22794@shiny \
    --to=chris.mason@oracle.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=liubo2009@cn.fujitsu.com \
    /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).