4

The Linux programmer's manual manpage fallocate(2) states:

If the FALLOC_FL_UNSHARE flag is specified in mode, shared file data extents will be made private to the file to guarantee that a subsequent write will not fail due to lack of space. Typically, this will be done by performing a copy-on-write operation on all shared data in the file. This flag may not be supported by all filesystems.

That's cool, but… How do I create shared file data extents in the first place?

Alexander Klauer
  • 957
  • 11
  • 18
  • Also see the [`fallocate (2)` man page](http://man7.org/linux/man-pages/man2/fallocate.2.html) and [fallocate vs posix_fallocate](https://stackoverflow.com/q/14063046/608639) on Stack Overflow. – jww Nov 17 '19 at 22:31

1 Answers1

3

Shared data extents are created when the underlying filesystem supports reflinks (example: XFS and BTRFS) and you perform a cp with the --reflink flag or use the ioctl_ficlonerange(2) syscall.

Looking at the kernel code, I see FALLOC_FL_UNSHARE_RANGE being handled only in case of XFS, so maybe this flag to fallocate works only on XFS as of now.

Alexander Klauer
  • 957
  • 11
  • 18
itisravi
  • 3,406
  • 3
  • 23
  • 30