Giuseppe Scrivano wrote:
> Hello,
>
> the BTRFS file system, avaiable on Linux since its 2.6.29 version,
> supports file cloning. This simple patch adds the support for this
> feature to the cp utility.
Thanks! I like it.
A few comments:
Doesn't that constant, 1074041865, have a symbolic name?
Maybe BTRFS_IOC_CLONE?
> Is there an easy and quick way to determine which file system is used by
> a file? Probably it would be safer to add a guard around the ioctl
> call.
Before thinking about that, I'd like to know the approximate cost
of the failing ioctl, e.g., on a kernel with btrfs support and
on one without, in case that makes a difference. I.e., what impact
would it have if left unprotected? Does it make a measurable difference
when copying 20K empty files on a tmpfs file system?
If necessary, we can avoid almost all of the per-file ioctl calls
via a map that associates each distinct device number encountered
with a boolean "is btrfs file system". gnulib's fts does something
similar, but its goal is to determine whether a different FS-specific
performance optimization is likely to help.