Gentoo Archives: gentoo-dev

From: Nirbheek Chauhan <nirbheek@g.o>
To: "Michał Górny" <mgorny@g.o>
Cc: gentoo-dev@l.g.o, rich0@g.o
Subject: Re: [gentoo-dev] Re: proj/portage:master commit in: pym/portage/dbapi/
Date: Sat, 26 Nov 2011 16:32:06
Message-Id: CADqQcK49=XAevNBNOzORYajS1NsAPDXvO1x3erz9-_E9ViF8qw@mail.gmail.com
In Reply to: Re: [gentoo-dev] Re: proj/portage:master commit in: pym/portage/dbapi/ by "Michał Górny"
1 On Sat, Nov 26, 2011 at 9:38 PM, Michał Górny <mgorny@g.o> wrote:
2 > On Sat, 26 Nov 2011 21:28:51 +0530
3 > Nirbheek Chauhan <nirbheek@g.o> wrote:
4 >> There are still a few specific cases in which CoW would indeed be
5 >> useful. IIRC, reflinking of files works across btrfs *subvolumes*, and
6 >> such a copy would normally be detected as a cross-device move.
7 >
8 > For such a thing, shouldn't rename() work neat anyway?
9 >
10
11 No, because reflink is an ioctl that works directly on the FS level by
12 sharing data blocks, and should theoretically not bother about the
13 file hierarchy. On the other hand, rename() is a userland API and must
14 behave itself.
15
16 >> Another use would be an patch-merge which makes use of *ranged
17 >> reflinks* to only CoW copy those parts of the file that were
18 >> changed[1]. rsync has support for this, but only while appending to
19 >> files (--append-verify --no-whole-file).
20 >
21 > So, it'd be like:
22 > 1) CoW-dup old file,
23 > 2) patch-merge into the duped old file,
24 > 3) replace.
25 >
26 > Am I understanding correctly?
27 >
28
29 You can do that, or perhaps you can just do the patch-merge in-place.
30 Not sure about the crash guarantees in the latter case. The former
31 (rename) is documented here:
32 https://btrfs.wiki.kernel.org/articles/f/a/q/FAQ_1fe9.html#What_are_the_crash_guarantees_of_overwrite-by-rename.3F
33
34 But in all this, the hard part is really the "patch-merge" for
35 anything except appends. ;)
36
37 --
38 ~Nirbheek Chauhan
39
40 Gentoo GNOME+Mozilla Team