From: Gordan Bobic <gordan@bobich.net>
To: linux-btrfs@vger.kernel.org
Subject: Copy-on-write hard-links
Date: Thu, 10 Jun 2010 18:11:40 +0100 [thread overview]
Message-ID: <4C111CCC.8070103@bobich.net> (raw)
Is there a feature in btrfs to manually/explicitly mark hard-links to be
copy-on-write? My understanding is that this is what happens when a
snapshot is mounted rw and files modified.
Consider this scenario:
I have a base template fs. I make two snapshots of it that are
identical. The files in the template and both snapshots are hard-links
and have the same inode number.
I change a file in one of the snapshots, and it gets copied on write. I
make the same change in the other snapshot, and that, too, gets copied
on write. I now have two identical files that are not hard-links any more.
What happens if I remove one of those files and create a hard-link to
the file in the other snapshot? Will this implicitly become a
copy-on-write file or will the hard-link aspect in the traditional sense
be preserved? If I modify the file, will it end up modified in both? Is
there a way to explicitly set a COW flag (on a file with hard-links)?
The reason I am asking this is because I am looking into using either
VServer or LXC virtualization. VServer has a "hashify" feature that
works as I described (copy-on-write hard-linking identical files between
multiple guests). But VServer isn't, and is unlikely to ever be in the
mainline kernel. LXC is already in the mainline kernel, but relies on
the FS to provide this functionality. For future proofing reasons, I
would prefer to use LXC+btrfs, but hashify is too valuable a feature to
sacrifice for staying with the mainline. Also note that simple
block-level dedupe isn't sufficient for the full benefit in this context
- hard-linking has the additional benefit that multiple copies of DLLs
in multiple guests will not use separate memory when hard-linked (i.e.
their inodes are the same). This equates to a very substantial memory
saving (poor man's KSM) in addition to the disk space savings when there
are many guests.
TIA.
Gordan
next reply other threads:[~2010-06-10 17:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-10 17:11 Gordan Bobic [this message]
2010-06-10 20:00 ` Copy-on-write hard-links Chris Mason
2010-06-10 20:20 ` Gordan Bobic
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=4C111CCC.8070103@bobich.net \
--to=gordan@bobich.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).