chiark / gitweb /
qcow2: when dissecting qcow2, use btrfs clone ioctls for reflinking blocks to target
[elogind.git] / src / import / qcow2-util.c
index c84c6aa0d72b20948df62f4c1ec4a38cd1af0235..9b0c23bb1476148af0a5386a0367b2f692bcfb45 100644 (file)
@@ -24,6 +24,7 @@
 #include "util.h"
 #include "sparse-endian.h"
 #include "qcow2-util.h"
 #include "util.h"
 #include "sparse-endian.h"
 #include "qcow2-util.h"
+#include "btrfs-util.h"
 
 #define QCOW2_MAGIC 0x514649fb
 
 
 #define QCOW2_MAGIC 0x514649fb
 
@@ -85,6 +86,11 @@ static int copy_cluster(
                 void *buffer) {
 
         ssize_t l;
                 void *buffer) {
 
         ssize_t l;
+        int r;
+
+        r = btrfs_clone_range(sfd, soffset, dfd, doffset, cluster_size);
+        if (r >= 0)
+                return r;
 
         l = pread(sfd, buffer, cluster_size, soffset);
         if (l < 0)
 
         l = pread(sfd, buffer, cluster_size, soffset);
         if (l < 0)