From 59d21d2c2e7bc24f848cdc750b0151087e94bafe Mon Sep 17 00:00:00 2001 From: Andrea Bolognani Date: Tue, 28 Dec 2021 19:08:00 +0100 Subject: [PATCH] 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 Reviewed-by: Neal Gompa Reviewed-by: Michal Privoznik --- src/storage/storage_util.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 728710153e..a680f14afc 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -43,16 +43,6 @@ # include #endif -#ifdef FICLONE -# define REFLINK_IOC_CLONE FICLONE -#elif WITH_LINUX_BTRFS_H -# include -# define REFLINK_IOC_CLONE BTRFS_IOC_CLONE -#elif WITH_XFS_XFS_H -# include -# 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