From: Nirbheek Chauhan <nirbheek.chauhan@gmail.com>
To: Freddie Cash <fjwcash@gmail.com>
Cc: Chris Mason <chris.mason@oracle.com>,
linux-btrfs <linux-btrfs@vger.kernel.org>
Subject: Re: "Appending" data to the middle of a file using btrfs-specific features
Date: Tue, 7 Dec 2010 02:00:09 +0530 [thread overview]
Message-ID: <AANLkTikst-_dbPT7GLaEq8R7X7xjAgVGezpQEisEhFNp@mail.gmail.com> (raw)
In-Reply-To: <AANLkTinxioDVnbSB1p8wg2z1WP4Hhk0oMqqFJg6DGAgR@mail.gmail.com>
On Tue, Dec 7, 2010 at 1:05 AM, Freddie Cash <fjwcash@gmail.com> wrote:
> On Mon, Dec 6, 2010 at 11:14 AM, Nirbheek Chauhan
> <nirbheek.chauhan@gmail.com> wrote:
>> As an aside, my primary motivation for this was that doing an
>> incremental backup of things like git bare repositories and database=
s
>> using btrfs subvolume snapshots is expensive w.r.t. disk space. Even
>> though rsync calculates a binary delta before transferring data, it
>> has to write everything out (except if just appending). So in that
>> case, each "incremental" backup is hardly so.
>
> Since btrfs is Copy-on-Write, have you experimented with --inplace on
> the rsync command-line? =C2=A0That way, rsync writes the changes "ove=
r-top"
> of the existing file, thus allowing btrfs to only write out the block=
s
> that have changed, via CoW?
>
> We do this with our ZFS rsync backups, and found disk usage to go way
> down over the default "write out new data to new file, rename overtop=
"
> method that rsync uses.
>
> There's also the --no-whole-file option which causes rsync to only
> send delta changes for existing files, another useful feature with Co=
W
> filesystems.
>
I had tried the --inplace option, but it didn't seem to do anything
for me, so I didn't explore that further. However, after following
your suggestion and retrying with --no-whole-file, I see that the
behaviour is quite different! It seems that --whole-file is enabled by
default for local file transfers, and so --inplace had no effect.
But the behaviour of --inplace is not entirely to write out *only* the
blocks that have changed. From what I could make out, it does the
following:
(1) Calculate a delta b/w the src and trg files
(2) Seek to the first difference in the target file
(3) Start writing data
I'm glossing over the final step because I didn't look deeper, but I
think you can safely assume that after the first difference, all data
is rewritten. So this is halfway between "rewrite the whole file" and
"write only the changed bits into the file". It doesn't actually use
any CoW features from what I can see. There is lots of room for btrfs
reflinking magic. :)
Note that I tested this behaviour on a btrfs partition with a vanilla
rsync-3.0.7 tarball; the copy you use with ZFS might be doing some CoW
magic.
Thanks for the tip!
--=20
~Nirbheek Chauhan
Gentoo GNOME+Mozilla Team
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" =
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2010-12-06 20:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-06 12:41 "Appending" data to the middle of a file using btrfs-specific features Nirbheek Chauhan
2010-12-06 16:05 ` Chris Mason
2010-12-06 19:14 ` Nirbheek Chauhan
2010-12-06 19:33 ` Chris Mason
2010-12-06 19:35 ` Freddie Cash
2010-12-06 20:30 ` Nirbheek Chauhan [this message]
2010-12-06 20:42 ` Freddie Cash
2010-12-07 7:38 ` Nirbheek Chauhan
2010-12-07 7:50 ` Andrey Kuzmin
[not found] ` <4CFE0A81.9040102@electric-spoon.com>
2010-12-07 11:29 ` Nirbheek Chauhan
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=AANLkTikst-_dbPT7GLaEq8R7X7xjAgVGezpQEisEhFNp@mail.gmail.com \
--to=nirbheek.chauhan@gmail.com \
--cc=chris.mason@oracle.com \
--cc=fjwcash@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).