[RFC(RAP) 00/14] xfs: add reflink and dedupe support

Darrick J. Wong
2015-06-25T23:39:16Z

Hi all,

This is a RFC-quality pass at kernel support for mapping multiple file
logical blocks to the same physical block, more commonly known as
reflinking. It is a single [block, refcount] tree to track the
reference counts of extents of physical blocks. There's also a bunch
of support code that provides the desired copy-on-write behavior,
userland interfaces to reflink, query the status of, and un-reflink
files.

The patch set is based on the current (4.2) for-next branch plus
Dave's rmap RFC patches. There are still a lot of bugs in this code;
I'm not sure that I've gotten the locking and the transaction
handling correct. Deadlocks and hangs due to the log being full are
unfortunately common, but light exercise shows that it works well
enough as a proof of concept.

The ioctl interface to XFS reflink looks surprisingly like the btrfs
ioctl interface <cough> -- you can reflink a file, reflink subranges
of a file, or dedupe subranges of files. (Dedupe also checks file
blocks, though I have a feeling it's racy.) To un-reflink a file,
simply chattr +C it to mark it no-cow. xfs_fsr can be better at
that, though. :)

If you're going to start using this mess, you're going to want to pull
my xfsprogs dev tree[1], which itself is also based on xfsprogs
for-next and the userland rmap support bits. I've not had time to get
reflink and rmap to work together.

I've also prepared a bunch of xfstests[2] to exercise the userland
interfaces.

This is an extraordinary way to eat your data. Enjoy!

Comments and questions are, as always, welcome.

--D

[1] https://github.com/djwong/xfsprogs/commits/for-next
[2] https://github.com/djwong/xfstests/commits/master