Skip to contentSkip to conversation

qapi: add interface for setting backup cow buffer size

PATCH In review Liang Li 1 participant 1 message Apr 28, 2019 Block layer

lore
Share & tools
lore

Liang Li

author
#0 lore raw

PATCH 2/2 qapi: add interface for setting backup cow buffer size

Cc John Snow <[email protected]>
Cc Kevin Wolf <[email protected]>
Cc Max Reitz <[email protected]>
Cc Wen Congyang <[email protected]>
Cc Xie Changlong <[email protected]>
Cc Markus Armbruster <[email protected]>
Cc Eric Blake <[email protected]>
Cc Fam Zheng <[email protected]>
---
 block/backup.c            | 3 ++-
 block/replication.c       | 2 +-
 blockdev.c                | 5 +++++
 include/block/block_int.h | 2 ++
 qapi/block-core.json      | 5 +++++
 5 files changed, 15 insertions(+), 2 deletions(-)
block/backup.c +2 -1
index d436f9e4ee..9a04003968 100644
@@ -652,6 +652,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
                   BlockDriverState *target, int64_t speed,
                   MirrorSyncMode sync_mode, BdrvDirtyBitmap *sync_bitmap,
                   bool compress,
+                  int buf_size,
                   BlockdevOnError on_source_error,
                   BlockdevOnError on_target_error,
                   int creation_flags,
@@ -748,7 +749,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
     job->sync_bitmap = sync_mode == MIRROR_SYNC_MODE_INCREMENTAL ?
                        sync_bitmap : NULL;
     job->compress = compress;
-    job->cow_buf_size = 0;
+    job->cow_buf_size = buf_size;
 
     /* Detect image-fleecing (and similar) schemes */
     job->serialize_target_writes = bdrv_chain_contains(target, bs);
block/replication.c +1 -1
index 3d4dedddfc..5ec6911355 100644
@@ -540,7 +540,7 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode,
         bdrv_op_unblock(top_bs, BLOCK_OP_TYPE_DATAPLANE, s->blocker);
 
         job = backup_job_create(NULL, s->secondary_disk->bs, s->hidden_disk->bs,
-                                0, MIRROR_SYNC_MODE_NONE, NULL, false,
+                                0, MIRROR_SYNC_MODE_NONE, NULL, false, 0,
                                 BLOCKDEV_ON_ERROR_REPORT,
                                 BLOCKDEV_ON_ERROR_REPORT, JOB_INTERNAL,
                                 backup_job_completed, bs, NULL, &local_err);
blockdev.c +5 -0
index 79fbac8450..15d96fe25c 100644
@@ -3449,6 +3449,9 @@ static BlockJob *do_drive_backup(DriveBackup *backup, JobTxn *txn,
     if (!backup->has_compress) {
         backup->compress = false;
     }
+    if (!backup->has_buffer) {
+        backup->buffer = 0;
+    }
 
     bs = qmp_get_root_bs(backup->device, errp);
     if (!bs) {
@@ -3550,6 +3553,7 @@ static BlockJob *do_drive_backup(DriveBackup *backup, JobTxn *txn,
 
     job = backup_job_create(backup->job_id, bs, target_bs, backup->speed,
                             backup->sync, bmap, backup->compress,
+                            backup->buffer,
                             backup->on_source_error, backup->on_target_error,
                             job_flags, NULL, NULL, txn, &local_err);
     bdrv_unref(target_bs);
@@ -3660,6 +3664,7 @@ BlockJob *do_blockdev_backup(BlockdevBackup *backup, JobTxn *txn,
     }
     job = backup_job_create(backup->job_id, bs, target_bs, backup->speed,
                             backup->sync, bmap, backup->compress,
+                            backup->buffer,
                             backup->on_source_error, backup->on_target_error,
                             job_flags, NULL, NULL, txn, &local_err);
     if (local_err != NULL) {
include/block/block_int.h +2 -0
index 01e855a066..17c7f26b84 100644
@@ -1137,6 +1137,7 @@ void mirror_start(const char *job_id, BlockDriverState *bs,
  * @speed: The maximum speed, in bytes per second, or 0 for unlimited.
  * @sync_mode: What parts of the disk image should be copied to the destination.
  * @sync_bitmap: The dirty bitmap if sync_mode is MIRROR_SYNC_MODE_INCREMENTAL.
+ * @buffer: Size of buffer used to save data for delayed writing.
  * @on_source_error: The action to take upon error reading from the source.
  * @on_target_error: The action to take upon error writing to the target.
  * @creation_flags: Flags that control the behavior of the Job lifetime.
@@ -1153,6 +1154,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
                             MirrorSyncMode sync_mode,
                             BdrvDirtyBitmap *sync_bitmap,
                             bool compress,
+                            int buffer,
                             BlockdevOnError on_source_error,
                             BlockdevOnError on_target_error,
                             int creation_flags,
qapi/block-core.json +5 -0
index 7ccbfff9d0..726c04c02a 100644
@@ -1377,6 +1377,7 @@
             '*format': 'str', 'sync': 'MirrorSyncMode',
             '*mode': 'NewImageMode', '*speed': 'int',
             '*bitmap': 'str', '*compress': 'bool',
+            '*buffer': 'int',
             '*on-source-error': 'BlockdevOnError',
             '*on-target-error': 'BlockdevOnError',
             '*auto-finalize': 'bool', '*auto-dismiss': 'bool' } }
@@ -1405,6 +1406,9 @@
 # @compress: true to compress data, if the target format supports it.
 #            (default: false) (since 2.8)
 #
+# @buffer: the maximum size of buffer used to save data for delayed writing.
+#            (default: 0) (since 4.1)
+#
 # @on-source-error: the action to take on an error on the source,
 #                   default 'report'.  'stop' and 'enospc' can only be used
 #                   if the block device supports io-status (see BlockInfo).
@@ -1436,6 +1440,7 @@
   'data': { '*job-id': 'str', 'device': 'str', 'target': 'str',
             'sync': 'MirrorSyncMode', '*speed': 'int',
             '*bitmap': 'str', '*compress': 'bool',
+            '*buffer': 'int',
             '*on-source-error': 'BlockdevOnError',
             '*on-target-error': 'BlockdevOnError',
             '*auto-finalize': 'bool', '*auto-dismiss': 'bool' } }
Signature · 1 line
2.14.1