juicefs icon indicating copy to clipboard operation
juicefs copied to clipboard

support cp --reflink

Open davies opened this issue 2 years ago • 3 comments

cp --reflink is used to create a clone of file without copying the data, similar to copy_file_range, but using ioctl().

Here is output from strace cp --reflink a b

open("a", O_RDONLY)              = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=10615232, ...}) = 0
open("b", O_WRONLY|O_TRUNC)    = 4
fstat(4, {st_mode=S_IFREG|0755, st_size=0, ...}) = 0
ioctl(4, BTRFS_IOC_CLONE or FICLONE, 3) = -1 EOPNOTSUPP (Operation not supported)

davies avatar Apr 19 '22 09:04 davies

cp --reflink might be more complex, it can support directory level fast cp.

It's mainly a feature of btrfs, zfs and xfs(recent version).

xuning97 avatar Apr 20 '22 03:04 xuning97

Or more precisely, a directory level snapshot (read only could be enough)

xuning97 avatar Apr 20 '22 03:04 xuning97

But even the support of file level "cp --reflink" is also much better than cp in object storage ;-)

xuning97 avatar Apr 20 '22 03:04 xuning97