core-admin/qubes
Rusty Bird 1695a732b8
file-reflink, a storage driver optimized for CoW filesystems
This adds the file-reflink storage driver. It is never selected
automatically for pool creation, especially not the creation of
'varlibqubes' (though it can be used if set up manually).

The code is quite small:

               reflink.py  lvm.py      file.py + block-snapshot
    sloccount  334 lines   447 (134%)  570 (171%)

Background: btrfs and XFS (but not yet ZFS) support instant copies of
individual files through the 'FICLONE' ioctl behind 'cp --reflink'.
Which file-reflink uses to snapshot VM image files without an extra
device-mapper layer. All the snapshots are essentially freestanding;
there's no functional origin vs. snapshot distinction.

In contrast to 'file'-on-btrfs, file-reflink inherently avoids
CoW-on-CoW. Which is a bigger issue now on R4.0, where even AppVMs'
private volumes are CoW. (And turning off the lower, filesystem-level
CoW for 'file'-on-btrfs images would turn off data checksums too, i.e.
protection against bit rot.)

Also in contrast to 'file', all storage features are supported,
including

    - any number of revisions_to_keep
    - volume.revert()
    - volume.is_outdated
    - online fstrim/discard

Example tree of a file-reflink pool - *-dirty.img are connected to Xen:

    - /var/lib/testpool/appvms/foo/volatile-dirty.img
    - /var/lib/testpool/appvms/foo/root-dirty.img
    - /var/lib/testpool/appvms/foo/root.img
    - /var/lib/testpool/appvms/foo/private-dirty.img
    - /var/lib/testpool/appvms/foo/private.img
    - /var/lib/testpool/appvms/foo/private.img@2018-01-02T03:04:05Z
    - /var/lib/testpool/appvms/foo/private.img@2018-01-02T04:05:06Z
    - /var/lib/testpool/appvms/foo/private.img@2018-01-02T05:06:07Z
    - /var/lib/testpool/appvms/bar/...
    - /var/lib/testpool/appvms/...
    - /var/lib/testpool/template-vms/fedora-26/...
    - /var/lib/testpool/template-vms/...

It looks similar to a 'file' pool tree, and in fact file-reflink is
drop-in compatible:

    $ qvm-shutdown --all --wait
    $ systemctl stop qubesd
    $ sed 's/ driver="file"/ driver="file-reflink"/g' -i.bak /var/lib/qubes/qubes.xml
    $ systemctl start qubesd
    $ sudo rm -f /path/to/pool/*/*/*-cow.img*

If the user tries to create a fresh file-reflink pool on a filesystem
that doesn't support reflinks, qvm-pool will abort and mention the
'setup_check=no' option. Which can be passed to force a fallback on
regular sparse copies, with of course lots of time/space overhead. The
same fallback code is also used when initially cloning a VM from a
foreign pool, or from another file-reflink pool on a different
mountpoint.

'journalctl -fu qubesd' will show all file-reflink copy/rename/remove
operations on VM creation/startup/shutdown/etc.
2018-02-12 21:20:05 +00:00
..
api Make 'qvm-volume revert' really use the latest revision 2018-01-20 23:20:23 +00:00
ext Merge remote-tracking branch 'qubesos/pr/185' 2018-01-22 15:32:57 +01:00
qmemman qmemman: fix early crash 2018-01-18 17:36:37 +01:00
storage file-reflink, a storage driver optimized for CoW filesystems 2018-02-12 21:20:05 +00:00
tests file-reflink, a storage driver optimized for CoW filesystems 2018-02-12 21:20:05 +00:00
tools qmemman: do not close stdout/stderr in daemon mode 2018-01-18 17:36:37 +01:00
vm Make AppVM/DispVM root volume rw to avoid CoW-on-CoW 2018-02-12 21:20:04 +00:00
__init__.py cache PropertyHolder.property_list and use O(1) property name lookups 2017-11-11 02:38:16 +01:00
app.py file-reflink, a storage driver optimized for CoW filesystems 2018-02-12 21:20:05 +00:00
backup.py vm/qubesvm: revert backup_timestamp to '%s' format 2018-01-12 05:34:45 +01:00
config.py Add IPv6 related VM properties 2017-12-07 01:40:30 +01:00
core2migration.py Make pylint happy 2017-12-21 18:19:10 +01:00
devices.py devices: clarify error on attaching non-persistent device to stopped VM 2017-10-21 04:05:16 +02:00
dochelpers.py Change license to LGPL v2.1+ 2017-10-12 00:11:50 +02:00
events.py events: add support for wildcard event handlers 2018-01-06 00:40:19 +01:00
exc.py Change license to LGPL v2.1+ 2017-10-12 00:11:50 +02:00
firewall.py firewall: skip expired rules 2017-10-21 03:35:00 +02:00
log.py Change license to LGPL v2.1+ 2017-10-12 00:11:50 +02:00
rngdoc.py Change license to LGPL v2.1+ 2017-10-12 00:11:50 +02:00
tarwriter.py Change license to LGPL v2.1+ 2017-10-12 00:11:50 +02:00
utils.py Change license to LGPL v2.1+ 2017-10-12 00:11:50 +02:00