]> xenbits.xensource.com Git - libvirt.git/commitdiff
storage: Use the FICLONE ioctl unconditionally on Linux
authorAndrea Bolognani <abologna@redhat.com>
Tue, 28 Dec 2021 18:08:00 +0000 (19:08 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Tue, 4 Jan 2022 14:45:45 +0000 (15:45 +0100)
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>
src/storage/storage_util.c

index 728710153e7382d29723abb3c63eaac17573bcc9..a680f14afc1ef163ae0c3d1a8734747df63f2b09 100644 (file)
 # 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