Bug 1054903

Summary: The subvolume behaviour of the default BTRFS scheme prevents reflink (COW) copies of files between subvolumes
Product: [Fedora] Fedora Reporter: James Hogarth <james.hogarth>
Component: python-blivetAssignee: David Lehman <dlehman>
Status: CLOSED WONTFIX QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 20CC: amulhern, bcl, dlehman, g.kaviyarasu, james.hogarth, jonathan, vanmeeuwen+fedora
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-01-20 14:54:49 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description James Hogarth 2014-01-17 17:51:45 UTC
Description of problem:
The kernel in Fedora 20 supports cross-subvolume COW so that cp --reflinks=always will use the same extents to avoid using extra disk space and save time on copies. 

If a BTRFS filesystem has subvolumes created within /home or within / via btrfs sub create then COW will work within these.

If multiple mounts are used targeting specific subvolumes (via the subvol= option) then cp is unable to carry out COW between these and has to do a full duplication of extents taking up space and time.

Anaconda should not create multiple mount points but rather provide a /home subvolume within the root subvolume so that it's possible cp --reflink=always from /home to other locations (think downloaded isos in ~/Downloads to /var/lib/libvirt/images for VMs).

Version-Release number of selected component (if applicable):
Fedora 20 install from the current installer tree

How reproducible:
Always

Steps to Reproduce:
1. Do an install of Fedora 20 picking the default BTRFS layout
2. Try to copy a file via cp --reflink=always form somewhere in ${HOME} to anywhere in the root filesystem.... watch it fail.
3. Use btrfs sub create testsubvol within the home or root subvolumes and cp --reflink=always within root (or home) subvolume that it exists in and watch COW work.

Actual results:
cp: failed to clone ‘/tmptest/filename.tar.gz’ from ‘filename.tar.gz’: Invalid cross-device link

Expected results:
A reflink copy to work between the subvolumes 

Additional info:
This kernel commit was found when asking on the mailing lists about the behaviour:

http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=362a20c5e27614739c4

As such it is working as (currently) designed from the kernel point of view which is why as an anaconda filesystem layout it would be nicer having /home (and any other subvolumes) not directly being mounted in fstab with the subvol= option but rather just being there naturally...

Comment 1 David Lehman 2014-12-02 19:38:14 UTC
Your suggested approach precludes removing an old root subvolume while preserving the home subvol, no?

Comment 2 David Lehman 2015-01-20 14:54:49 UTC
In short, this is an expected consequence of the layout we chose. The main feature of this layout is the ability to remove/replace subvolumes that occcupy certain mountpoint (eg: /) while preserving other subvolumes (eg: /home). If your personal preference is the ability to do reflink copies between subvolumes you are free to create a layout to accommodate this.

Comment 3 James Hogarth 2015-03-09 11:58:46 UTC
Clearing needs info flag

Agreed layout is needed to preserve /home and if desired user can change afterwards.