All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Denis V. Lunev" <den@openvz.org>
To: qemu-devel@nongnu.org
Cc: den@openvz.org, Pavel Butsykin <pbutsykin@virtuozzo.com>,
	Jeff Cody <jcody@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	Eric Blake <eblake@redhat.com>, John Snow <jsnow@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Kevin Wolf <kwolf@redhat.com>
Subject: [Qemu-devel] [PATCH 09/11] blockdev-backup: added support for data compression
Date: Tue, 31 May 2016 12:15:28 +0300	[thread overview]
Message-ID: <1464686130-12265-10-git-send-email-den@openvz.org> (raw)
In-Reply-To: <1464686130-12265-1-git-send-email-den@openvz.org>

From: Pavel Butsykin <pbutsykin@virtuozzo.com>

The idea is simple - backup is "written-once" data. It is written block
by block and it is large enough. It would be nice to save storage
space and compress it.

Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Jeff Cody <jcody@redhat.com>
CC: Markus Armbruster <armbru@redhat.com>
CC: Eric Blake <eblake@redhat.com>
CC: John Snow <jsnow@redhat.com>
CC: Stefan Hajnoczi <stefanha@redhat.com>
CC: Kevin Wolf <kwolf@redhat.com>
---
 blockdev.c           | 10 +++++++++-
 qapi/block-core.json |  4 ++++
 qmp-commands.hx      |  4 +++-
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/blockdev.c b/blockdev.c
index b24f508..e72dddf 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1924,6 +1924,7 @@ typedef struct BlockdevBackupState {
 static void do_blockdev_backup(const char *device, const char *target,
                                enum MirrorSyncMode sync,
                                bool has_speed, int64_t speed,
+                               bool has_compress, bool compress,
                                bool has_on_source_error,
                                BlockdevOnError on_source_error,
                                bool has_on_target_error,
@@ -1971,6 +1972,7 @@ static void blockdev_backup_prepare(BlkActionState *common, Error **errp)
     do_blockdev_backup(backup->device, backup->target,
                        backup->sync,
                        backup->has_speed, backup->speed,
+                       backup->has_compress, backup->compress,
                        backup->has_on_source_error, backup->on_source_error,
                        backup->has_on_target_error, backup->on_target_error,
                        common->block_job_txn, &local_err);
@@ -3337,6 +3339,7 @@ BlockDeviceInfoList *qmp_query_named_block_nodes(Error **errp)
 void do_blockdev_backup(const char *device, const char *target,
                          enum MirrorSyncMode sync,
                          bool has_speed, int64_t speed,
+                         bool has_compress, bool compress,
                          bool has_on_source_error,
                          BlockdevOnError on_source_error,
                          bool has_on_target_error,
@@ -3358,6 +3361,9 @@ void do_blockdev_backup(const char *device, const char *target,
     if (!has_on_target_error) {
         on_target_error = BLOCKDEV_ON_ERROR_REPORT;
     }
+    if (!has_compress) {
+        compress = false;
+    }
 
     blk = blk_by_name(device);
     if (!blk) {
@@ -3387,7 +3393,7 @@ void do_blockdev_backup(const char *device, const char *target,
     target_bs = blk_bs(target_blk);
 
     bdrv_set_aio_context(target_bs, aio_context);
-    backup_start(bs, target_bs, speed, sync, NULL, false, on_source_error,
+    backup_start(bs, target_bs, speed, sync, NULL, compress, on_source_error,
                  on_target_error, block_job_cb, bs, txn, &local_err);
     if (local_err != NULL) {
         error_propagate(errp, local_err);
@@ -3399,6 +3405,7 @@ out:
 void qmp_blockdev_backup(const char *device, const char *target,
                          enum MirrorSyncMode sync,
                          bool has_speed, int64_t speed,
+                         bool has_compress, bool compress,
                          bool has_on_source_error,
                          BlockdevOnError on_source_error,
                          bool has_on_target_error,
@@ -3406,6 +3413,7 @@ void qmp_blockdev_backup(const char *device, const char *target,
                          Error **errp)
 {
     do_blockdev_backup(device, target, sync, has_speed, speed,
+                       has_compress, compress,
                        has_on_source_error, on_source_error,
                        has_on_target_error, on_target_error,
                        NULL, errp);
diff --git a/qapi/block-core.json b/qapi/block-core.json
index e54ceb2..f6a971c 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -926,6 +926,9 @@
 # @speed: #optional the maximum speed, in bytes per second. The default is 0,
 #         for unlimited.
 #
+# @compress: #optional the compression data blocks (if the target format
+#            supports it; default: false).
+#
 # @on-source-error: #optional 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).
@@ -944,6 +947,7 @@
   'data': { 'device': 'str', 'target': 'str',
             'sync': 'MirrorSyncMode',
             '*speed': 'int',
+            '*compress': 'bool',
             '*on-source-error': 'BlockdevOnError',
             '*on-target-error': 'BlockdevOnError' } }
 
diff --git a/qmp-commands.hx b/qmp-commands.hx
index ff927ae..19a0427 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -1242,7 +1242,7 @@ EQMP
 
     {
         .name       = "blockdev-backup",
-        .args_type  = "sync:s,device:B,target:B,speed:i?,"
+        .args_type  = "sync:s,device:B,target:B,speed:i?,compress:b?,"
                       "on-source-error:s?,on-target-error:s?",
         .mhandler.cmd_new = qmp_marshal_blockdev_backup,
     },
@@ -1264,6 +1264,8 @@ Arguments:
           sectors allocated in the topmost image, or "none" to only replicate
           new I/O (MirrorSyncMode).
 - "speed": the maximum speed, in bytes per second (json-int, optional)
+- "compress": the compression data blocks (if the target format supports it).
+              (json-bool, optional, default false)
 - "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.
-- 
2.1.4

  parent reply	other threads:[~2016-05-31  9:16 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-31  9:15 [Qemu-devel] [PATCH v4 00/11] backup compression Denis V. Lunev
2016-05-31  9:15 ` [Qemu-devel] [PATCH 01/11] block: switch blk_write_compressed() to byte-based interface Denis V. Lunev
2016-06-13 13:01   ` Stefan Hajnoczi
2016-06-13 14:23   ` Eric Blake
2016-06-22 12:25     ` Pavel Butsykin
2016-06-28 10:53     ` Kevin Wolf
2016-06-28 11:32       ` Pavel Butsykin
2016-05-31  9:15 ` [Qemu-devel] [PATCH 02/11] block/io: add bdrv_co_write_compressed Denis V. Lunev
2016-06-13 13:18   ` Stefan Hajnoczi
2016-06-13 14:32   ` Eric Blake
2016-06-22 12:26     ` Pavel Butsykin
2016-06-28 11:09   ` Kevin Wolf
2016-06-28 11:35     ` Pavel Butsykin
2016-05-31  9:15 ` [Qemu-devel] [PATCH 03/11] qcow2: add qcow2_co_write_compressed Denis V. Lunev
2016-06-13 13:18   ` Stefan Hajnoczi
2016-06-13 20:14   ` Eric Blake
2016-06-22 12:27     ` Pavel Butsykin
2016-06-28 11:17       ` Kevin Wolf
2016-06-28 11:30   ` Kevin Wolf
2016-06-28 15:06     ` Pavel Butsykin
2016-05-31  9:15 ` [Qemu-devel] [PATCH 04/11] vmdk: add vmdk_co_write_compressed Denis V. Lunev
2016-06-13 13:18   ` Stefan Hajnoczi
2016-05-31  9:15 ` [Qemu-devel] [PATCH 05/11] qcow: add qcow_co_write_compressed Denis V. Lunev
2016-06-13 13:18   ` Stefan Hajnoczi
2016-05-31  9:15 ` [Qemu-devel] [PATCH 06/11] block: remove BlockDriver.bdrv_write_compressed Denis V. Lunev
2016-06-13 13:19   ` Stefan Hajnoczi
2016-05-31  9:15 ` [Qemu-devel] [PATCH 07/11] block: optimization blk_pwrite_compressed() Denis V. Lunev
2016-06-13 13:11   ` Stefan Hajnoczi
2016-06-13 20:16     ` Eric Blake
2016-06-15 10:22       ` Stefan Hajnoczi
2016-06-24 15:42   ` Eric Blake
2016-06-28 11:47   ` Kevin Wolf
2016-06-28 12:32     ` Pavel Butsykin
2016-06-28 13:05       ` Kevin Wolf
2016-05-31  9:15 ` [Qemu-devel] [PATCH 08/11] drive-backup: added support for data compression Denis V. Lunev
2016-06-13 13:19   ` Stefan Hajnoczi
2016-06-13 20:18   ` Eric Blake
2016-06-23  9:15     ` Pavel Butsykin
2016-06-24 15:39       ` Eric Blake
2016-06-24 15:50         ` Pavel Butsykin
2016-05-31  9:15 ` Denis V. Lunev [this message]
2016-06-13 13:19   ` [Qemu-devel] [PATCH 09/11] blockdev-backup: " Stefan Hajnoczi
2016-06-13 20:19   ` Eric Blake
2016-05-31  9:15 ` [Qemu-devel] [PATCH 10/11] qemu-iotests: test backup compression in 055 Denis V. Lunev
2016-06-13 13:17   ` Stefan Hajnoczi
2016-05-31  9:15 ` [Qemu-devel] [PATCH 11/11] qemu-iotests: add vmdk for " Denis V. Lunev
2016-06-13 13:18   ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1464686130-12265-10-git-send-email-den@openvz.org \
    --to=den@openvz.org \
    --cc=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=jcody@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbutsykin@virtuozzo.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.