storage: Use the FICLONE ioctl unconditionally on Linux

According to ioctl_ficlonerange(2)

  These ioctl operations [FICLONE and FICLONERANGE] first
  appeared in Linux 4.5. They were previously known as
  BTRFS_IOC_CLONE and BTRFS_IOC_CLONE_RANGE, and were private
  to Btrfs.

We no longer target any distro that comes with a kernel older
than 4.5, so we can stop looking for the btrfs and xfs
specific versions of the constant and just use the generic
version directly.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Andrea Bolognani 2021-12-28 19:08:00 +01:00
parent 5cd76ef97f
commit 59d21d2c2e

View File

@ -43,16 +43,6 @@
# include <selinux/selinux.h>
#endif
#ifdef FICLONE
# define REFLINK_IOC_CLONE FICLONE
#elif WITH_LINUX_BTRFS_H
# include <linux/btrfs.h>
# define REFLINK_IOC_CLONE BTRFS_IOC_CLONE
#elif WITH_XFS_XFS_H
# include <xfs/xfs.h>
# define REFLINK_IOC_CLONE XFS_IOC_CLONE
#endif
#include "datatypes.h"
#include "virerror.h"
#include "viralloc.h"
@ -109,11 +99,11 @@ virStorageBackendNamespaceInit(int poolType,
* Perform the O(1) btrfs clone operation, if possible.
* Upon success, return 0. Otherwise, return -1 and set errno.
*/
#ifdef REFLINK_IOC_CLONE
#ifdef __linux__
static inline int
reflinkCloneFile(int dest_fd, int src_fd)
{
return ioctl(dest_fd, REFLINK_IOC_CLONE, src_fd);
return ioctl(dest_fd, FICLONE, src_fd);
}
#else
static inline int