linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chris Mason <chris.mason@oracle.com>
To: Hugo Mills <hugo-lkml@carfax.org.uk>, linux-btrfs@vger.kernel.org
Subject: Re: Odd block-count behaviour
Date: Thu, 17 Jun 2010 05:16:27 -0400	[thread overview]
Message-ID: <20100617091627.GJ27466@think> (raw)
In-Reply-To: <20100616124730.GA1727@vlad.carfax.org.uk>

On Wed, Jun 16, 2010 at 01:47:30PM +0100, Hugo Mills wrote:
>    Hi,
> 
>    I've just been copying large quantities of data from one btrfs
> volume to another, and while watching the progress of the copy, I've
> noticed something odd.
> 
> $ mv source-dir dest-dir
> $ watch du -ms source-dir dest-dir
> 
>    This gives me a count of the size of the source and target
> directories, every 2 seconds. As expected, the size of the source dir
> stays constant, and the size of the destination directory increases.
> Except when it doesn't.
> 
>    Occasionally, while copying, the size of the dest-dir *drops* by
> several (tens of) megabytes. I'm not too worried about this, as it all
> seems to be copying the data OK, but it just seems a bit odd, and was
> wondering of there was a sane explanation for this behaviour.

If the files are small, they can be packed into the metadata btree.  But
this doesn't happen until the file is actually written.

So we start with a worst case estimate on the number of blocks the file
will consume (4k) and then when it is actually written we update the
metadata to reflect the number of blocks it is actually using (maybe 1
or 2).

You can see this with a test:

mkdir testdir
cd testdir
dd if=/dev/zero of=foo bs=512 count=1
du -k .
sync
du -k .

-chris


      reply	other threads:[~2010-06-17  9:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-16 12:47 Odd block-count behaviour Hugo Mills
2010-06-17  9:16 ` Chris Mason [this message]

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=20100617091627.GJ27466@think \
    --to=chris.mason@oracle.com \
    --cc=hugo-lkml@carfax.org.uk \
    --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).