]> xenbits.xensource.com Git - libvirt.git/commitdiff
storage: Rename btrfsCloneFile to support other filesystems.
authorJulio Faracco <jcfaracco@gmail.com>
Fri, 6 Jul 2018 13:43:01 +0000 (10:43 -0300)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 6 Jul 2018 14:56:56 +0000 (16:56 +0200)
This commit renames and adds other macros to support aother filesystems
when a reflink is performed. After that, XFS filesystems (and others)
with reflink support will be able to clone.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1565004

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/storage/storage_util.c

index a701a75702b2c0056e3675dc39d9478e48099d29..da99043e0a5bbb508801521a23a6fa4f86adcc32 100644 (file)
 
 #if HAVE_LINUX_BTRFS_H
 # include <linux/btrfs.h>
+# define REFLINK_IOC_CLONE BTRFS_IOC_CLONE
+#elif HAVE_XFS_XFS_H
+# include <xfs/xfs.h>
+# define REFLINK_IOC_CLONE XFS_IOC_CLONE
+#elif defined(FICLONE)
+# define REFLINK_IOC_CLONE FICLONE
 #endif
 
 #include "datatypes.h"
@@ -80,22 +86,23 @@ VIR_LOG_INIT("storage.storage_util");
  * Perform the O(1) btrfs clone operation, if possible.
  * Upon success, return 0.  Otherwise, return -1 and set errno.
  */
-#if HAVE_LINUX_BTRFS_H
+#ifdef REFLINK_IOC_CLONE
 static inline int
-btrfsCloneFile(int dest_fd, int src_fd)
+reflinkCloneFile(int dest_fd, int src_fd)
 {
-    return ioctl(dest_fd, BTRFS_IOC_CLONE, src_fd);
+    return ioctl(dest_fd, REFLINK_IOC_CLONE, src_fd);
 }
 #else
 static inline int
-btrfsCloneFile(int dest_fd ATTRIBUTE_UNUSED,
-               int src_fd ATTRIBUTE_UNUSED)
+reflinkCloneFile(int dest_fd ATTRIBUTE_UNUSED,
+                 int src_fd ATTRIBUTE_UNUSED)
 {
     errno = ENOTSUP;
     return -1;
 }
 #endif
 
+
 static int ATTRIBUTE_NONNULL(2)
 virStorageBackendCopyToFD(virStorageVolDefPtr vol,
                           virStorageVolDefPtr inputvol,
@@ -142,7 +149,7 @@ virStorageBackendCopyToFD(virStorageVolDefPtr vol,
     }
 
     if (reflink_copy) {
-        if (btrfsCloneFile(fd, inputfd) < 0) {
+        if (reflinkCloneFile(fd, inputfd) < 0) {
             ret = -errno;
             virReportSystemError(errno,
                                  _("failed to clone files from '%s'"),