[PATCH] Allow cross subvolume reflinks (2nd attempt)

From: Alexander Block
Date: Wed Jun 20 2012 - 06:35:09 EST


Hello,

This is the second attempt to bring in cross subvolume reflinks into btrfs.
The first attempt was NAKed due to missing vfs mount checks and a clear
description of what btrfs subvolumes are and probably also why cross
subvolume reflinks are ok in the case of btrfs. This version of the patch
comes from David and is in SUSE kernels since a long time, so it is tested
and working. The patch also does proper vfs mount checks, so cross mount
point reflinks are not possible with this patch. It only allows cross
reflinks between two subvolumes which are in the same mount point.

As requested in the older discussion, I'll try to describe what subvolumes
in btrfs are. From the users point of view, a subvolume is just a directory
in the mounted fs with its own inode space. This means, that two inodes
with the same number from different subvolumes are different files.
Parallel to the sub directory form, a subvolume may be mounted in its own
vfs mount point (I'm however not sure if this is already possible or just
planned). Internally, a btrfs subvolume is a separate btree, containing
all the metadata needed to store the fs of the subvolume.
Additionally to the subvolumes, btrfs has snapshots, which are basically
the same as subvolumes, with the difference that they share metadata and
data with the snapshot origin/parent. Everything that applies to
subvolumes also applies to snapshots.

The clone ioctl requires the destination file to be already existing and
opened for writing. This means that we do not touch any vfs semantics
regarding creation/opening of files. The ioctl only copies the extents
information from the source to the destination, doing proper access
checks before. In my opinion, we can compare the clone ioctl to the
sendfile syscall, with the difference that we don't copy data but the
information where the data lies.

Link to the old discussion:
http://thread.gmane.org/gmane.comp.file-systems.btrfs/9864
Only PATCH 2/2 is of interrest now. The discussion also contains some
arguments why cross subvolume reflinks are a good thing, but I think
this should not be the matter of the new discussion.

Alex.

David Sterba (1):
btrfs: allow cross-subvolume file clone

fs/btrfs/ioctl.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

--
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/