Gentoo Archives: gentoo-user

From: Rich Freeman <rich0@g.o>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] btrfs and sparse VM image files
Date: Mon, 19 May 2014 13:03:13
Message-Id: CAGfcS_n-2LTNXPxAymqZ0UTw6TpCOaLwN3ux3cyu8VOozM9ETA@mail.gmail.com
In Reply to: Re: [gentoo-user] btrfs and sparse VM image files by Neil Bothwick
1 On Mon, May 19, 2014 at 7:01 AM, Neil Bothwick <neil@××××××××××.uk> wrote:
2 > On Mon, 19 May 2014 12:07:32 +0200, Marc Stürmer wrote:
3 >
4 >> Just take a look at the official Gotchas Page of BTRFS, which can be
5 >> found here:
6 >>
7 >> https://btrfs.wiki.kernel.org/index.php/Gotchas
8 >>
9 >> Putting virtual image files on Btrfs is something that the developers
10 >> still do not recommend at all, and that's with reason!
11 >
12 > The page you linked to does not actually state that. There are plenty of
13 > hints and sideways references but little concrete information about what
14 > is safe with the current release - hence my question.
15
16 I haven't had significant issues with casually running VMs on btrfs,
17 but right now I wouldn't say the performance is spectacular. I do
18 have my VM images set to use COW - I'd rather take a performance hit
19 than not have data protected. If performance were a big concern I'd
20 probably end up setting up an ext4 on mdadm+lvm, but I really don't
21 want to go splitting up my drives as managing that was a real pain in
22 the past (mdadm is much less flexible than btrfs when you have drives
23 of differing sizes).
24
25 >
26 >> If you really do want to put them up a COW filesystem, you should try
27 >> ZFS on Linux instead, otherwise go with XFS or ext4 - in that kind of
28 >> order.
29 >
30 > They are already on ZFS but I am investigating btrfs as an alternative to
31 > ZFS. ZFS and ext4 would mean losing the volume management that ZFS and
32 > btrfs offer, not to mention forcing a repartition.
33
34 How does ZFS prevent fragmentation? Does it use COW for all writes (I
35 thought it did)? The fundamental issue is that data is never
36 overwritten in place. That means that if you change one block in a 2GB
37 file, you end up with two extents for the file, until things get bad
38 enough that the OS ends up copying the entire file into a single
39 extent. Maybe another strategy (if there aren't any impacted
40 snapshots) is to overwrite data in place using a journal when you have
41 a file with many random writes (basically like journal=data mode on
42 ext4). That would be a bit like creating a second extent and then
43 when there is time moving it back on top of the first extent.
44
45 Once you have a snapshot I'd think you'd never be able to prevent
46 fragmentation, though I guess if you're clever you could merge extents
47 that share common snapshots.
48
49 Has ZFS actually been shown to perform well for VMs in comparison to
50 ext4? If so, I wonder how they do it.
51
52 Rich