]> git.proxmox.com Git - pve-qemu-kvm.git/commitdiff
backup: always call dump_cb
authorDietmar Maurer <dietmar@proxmox.com>
Fri, 6 Dec 2013 05:37:00 +0000 (06:37 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 6 Dec 2013 05:37:00 +0000 (06:37 +0100)
And pass job->target. Also use sector addressing instead of cluster numbers.
That way we can use dump_cb to gather statistics, even when we backup
to job->target.

debian/patches/backup-modify-job-api.patch

index bc6c75a84757d62abff48682f24f5b4ac0929526..afeba0a4f67c164864e6e759ecc15f6751a4bd74 100644 (file)
@@ -1,7 +1,7 @@
 Index: new/block/backup.c
 ===================================================================
---- new.orig/block/backup.c    2013-12-02 12:30:23.000000000 +0100
-+++ new/block/backup.c 2013-12-02 12:56:03.000000000 +0100
+--- new.orig/block/backup.c    2013-12-05 08:18:53.000000000 +0100
++++ new/block/backup.c 2013-12-05 13:16:21.000000000 +0100
 @@ -39,6 +39,7 @@
      BlockDriverState *target;
      MirrorSyncMode sync_mode;
@@ -10,28 +10,29 @@ Index: new/block/backup.c
      BlockdevOnError on_source_error;
      BlockdevOnError on_target_error;
      CoRwlock flush_rwlock;
-@@ -137,12 +138,20 @@
+@@ -136,13 +137,21 @@
+             goto out;
          }
  
++        int64_t start_sec = start * BACKUP_SECTORS_PER_CLUSTER;
          if (buffer_is_zero(iov.iov_base, iov.iov_len)) {
 -            ret = bdrv_co_write_zeroes(job->target,
 -                                       start * BACKUP_SECTORS_PER_CLUSTER, n);
 +            if (job->dump_cb) {
-+                ret = job->dump_cb(job->common.opaque, bs, start, NULL);
-+            } else {
-+                ret = bdrv_co_write_zeroes(job->target,
-+                                           start * BACKUP_SECTORS_PER_CLUSTER, n);
++                ret = job->dump_cb(job->common.opaque, job->target, start_sec, n, NULL);
++            }
++            if (job->target) {
++                ret = bdrv_co_write_zeroes(job->target, start_sec, n);
 +            }
          } else {
 -            ret = bdrv_co_writev(job->target,
 -                                 start * BACKUP_SECTORS_PER_CLUSTER, n,
 -                                 &bounce_qiov);
 +            if (job->dump_cb) {
-+                ret = job->dump_cb(job->common.opaque, bs, start, bounce_buffer);
-+            } else {
-+                ret = bdrv_co_writev(job->target,
-+                                     start * BACKUP_SECTORS_PER_CLUSTER, n,
-+                                     &bounce_qiov);
++                ret = job->dump_cb(job->common.opaque, job->target, start_sec, n, bounce_buffer);
++            }
++            if (job->target) {
++                ret = bdrv_co_writev(job->target, start_sec, n, &bounce_qiov);
 +            }
          }
          if (ret < 0) {
@@ -120,8 +121,8 @@ Index: new/block/backup.c
      qemu_coroutine_enter(job->common.co, job);
 Index: new/blockdev.c
 ===================================================================
---- new.orig/blockdev.c        2013-12-02 12:30:23.000000000 +0100
-+++ new/blockdev.c     2013-12-02 12:54:24.000000000 +0100
+--- new.orig/blockdev.c        2013-12-05 08:18:53.000000000 +0100
++++ new/blockdev.c     2013-12-05 13:07:43.000000000 +0100
 @@ -1932,7 +1932,7 @@
      }
  
@@ -133,14 +134,14 @@ Index: new/blockdev.c
          error_propagate(errp, local_err);
 Index: new/include/block/block_int.h
 ===================================================================
---- new.orig/include/block/block_int.h 2013-12-02 12:30:23.000000000 +0100
-+++ new/include/block/block_int.h      2013-12-02 12:52:21.000000000 +0100
+--- new.orig/include/block/block_int.h 2013-12-05 08:18:53.000000000 +0100
++++ new/include/block/block_int.h      2013-12-05 13:16:53.000000000 +0100
 @@ -54,6 +54,9 @@
  #define BLOCK_OPT_LAZY_REFCOUNTS    "lazy_refcounts"
  #define BLOCK_OPT_ADAPTER_TYPE      "adapter_type"
  
 +typedef int BackupDumpFunc(void *opaque, BlockDriverState *bs,
-+                           int64_t cluster_num, unsigned char *buf);
++                           int64_t sector_num, int n_sectors, unsigned char *buf);
 +
  typedef struct BdrvTrackedRequest {
      BlockDriverState *bs;