From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-devel@nongnu.org, qemu-block@nongnu.org
Cc: eblake@redhat.com, armbru@redhat.com, xiechanglong.d@gmail.com,
wencongyang2@huawei.com, stefanha@redhat.com, jsnow@redhat.com,
famz@redhat.com, jcody@redhat.com, mreitz@redhat.com,
kwolf@redhat.com, vsementsov@virtuozzo.com, den@openvz.org
Subject: [Qemu-devel] [PATCH v3 14/18] block/fleecing-hook: internal api
Date: Mon, 1 Oct 2018 13:29:24 +0300 [thread overview]
Message-ID: <20181001102928.20533-15-vsementsov@virtuozzo.com> (raw)
In-Reply-To: <20181001102928.20533-1-vsementsov@virtuozzo.com>
Add some functions to use fleecing-hook internally from backup job in
further commit.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
include/block/block.h | 9 ++++++++
block/fleecing-hook.c | 51 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 60 insertions(+)
diff --git a/include/block/block.h b/include/block/block.h
index 4edc1e8afa..018751b6ea 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -710,4 +710,13 @@ int coroutine_fn bdrv_co_copy_range(BdrvChild *src, uint64_t src_offset,
BdrvChild *dst, uint64_t dst_offset,
uint64_t bytes, BdrvRequestFlags read_flags,
BdrvRequestFlags write_flags);
+
+
+BlockDriverState *bdrv_fleecing_hook_append(BlockDriverState *source,
+ BlockDriverState *target,
+ const char *copy_bitmap_name,
+ Error **errp);
+void bdrv_fleecing_hook_drop(BlockDriverState *hook);
+uint64_t bdrv_fleecing_hook_progress(BlockDriverState *hook);
+
#endif
diff --git a/block/fleecing-hook.c b/block/fleecing-hook.c
index f4e2f3ce83..1471b985b2 100644
--- a/block/fleecing-hook.c
+++ b/block/fleecing-hook.c
@@ -34,6 +34,8 @@ typedef struct BDRVFleecingHookState {
on guest write. */
BdrvChild *target;
bool cbw_bitmap_created;
+
+ uint64_t bytes_copied;
} BDRVFleecingHookState;
static coroutine_fn int fleecing_hook_co_preadv(
@@ -98,6 +100,7 @@ static coroutine_fn int fleecing_hook_cbw(BlockDriverState *bs, uint64_t offset,
goto finish;
}
+ s->bytes_copied += len;
off += len;
if (off >= end) {
break;
@@ -296,3 +299,51 @@ static void bdrv_fleecing_hook_init(void)
}
block_init(bdrv_fleecing_hook_init);
+
+BlockDriverState *bdrv_fleecing_hook_append(BlockDriverState *source,
+ BlockDriverState *target,
+ const char *copy_bitmap_name,
+ Error **errp)
+{
+ QDict *opts = qdict_new();
+
+ qdict_put_str(opts, "driver", "fleecing-hook");
+ qdict_put_str(opts, "append-to", bdrv_get_node_name(source));
+ qdict_put_str(opts, "target", bdrv_get_node_name(target));
+ if (copy_bitmap_name) {
+ qdict_put_str(opts, "copy-bitmap", copy_bitmap_name);
+ }
+
+ /* set defaults like qmp_blockdev_add */
+ qdict_put_str(opts, BDRV_OPT_CACHE_DIRECT, "off");
+ qdict_put_str(opts, BDRV_OPT_CACHE_NO_FLUSH, "off");
+ qdict_put_str(opts, BDRV_OPT_READ_ONLY, "off");
+
+ return bdrv_open(NULL, NULL, opts, 0, errp);
+}
+
+void bdrv_fleecing_hook_drop(BlockDriverState *hook)
+{
+ AioContext *aio_context = bdrv_get_aio_context(hook);
+
+ aio_context_acquire(aio_context);
+
+ bdrv_drained_begin(hook);
+
+ bdrv_child_try_set_perm(hook->backing, 0, BLK_PERM_ALL, &error_abort);
+ bdrv_replace_node(hook, backing_bs(hook), &error_abort);
+ bdrv_set_backing_hd(hook, NULL, &error_abort);
+
+ bdrv_drained_end(hook);
+
+ bdrv_unref(hook);
+
+ aio_context_release(aio_context);
+}
+
+uint64_t bdrv_fleecing_hook_progress(BlockDriverState *hook)
+{
+ BDRVFleecingHookState *s = hook->opaque;
+
+ return s->bytes_copied;
+}
--
2.18.0
next prev parent reply other threads:[~2018-10-01 10:29 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-01 10:29 [Qemu-devel] [PATCH v3 00/18] fleecing-hook driver for backup Vladimir Sementsov-Ogievskiy
2018-10-01 10:29 ` [Qemu-devel] [PATCH v3 01/18] block/dirty-bitmap: allow set/reset bits in disabled bitmaps Vladimir Sementsov-Ogievskiy
2018-10-03 14:23 ` Eric Blake
2018-10-03 14:50 ` Vladimir Sementsov-Ogievskiy
2018-10-01 10:29 ` [Qemu-devel] [PATCH v3 02/18] block/io: allow BDRV_REQ_SERIALISING for read Vladimir Sementsov-Ogievskiy
2018-10-01 10:29 ` [Qemu-devel] [PATCH v3 03/18] block/backup: simplify backup_incremental_init_copy_bitmap Vladimir Sementsov-Ogievskiy
2018-10-01 10:29 ` [Qemu-devel] [PATCH v3 04/18] block/backup: move from HBitmap to BdrvDirtyBitmap Vladimir Sementsov-Ogievskiy
2018-10-01 10:29 ` [Qemu-devel] [PATCH v3 05/18] util/id: add block-bitmap subsystem Vladimir Sementsov-Ogievskiy
2018-10-01 10:29 ` [Qemu-devel] [PATCH v3 06/18] block/backup: give a name to copy-bitmap Vladimir Sementsov-Ogievskiy
2018-10-01 10:29 ` [Qemu-devel] [PATCH v3 07/18] block/backup: allow use existent copy-bitmap Vladimir Sementsov-Ogievskiy
2018-10-01 10:29 ` [Qemu-devel] [PATCH v3 08/18] block: allow serialized reads to intersect Vladimir Sementsov-Ogievskiy
2018-10-01 10:29 ` [Qemu-devel] [PATCH v3 09/18] block: improve should_update_child Vladimir Sementsov-Ogievskiy
2018-10-01 10:29 ` [Qemu-devel] [PATCH v3 10/18] iotests: handle -f argument correctly for qemu_io_silent Vladimir Sementsov-Ogievskiy
2018-10-01 10:29 ` [Qemu-devel] [PATCH v3 11/18] iotests: allow resume_drive by node name Vladimir Sementsov-Ogievskiy
2018-10-01 10:29 ` [Qemu-devel] [PATCH v3 12/18] iotests: prepare 055 to graph changes during backup job Vladimir Sementsov-Ogievskiy
2018-10-01 10:29 ` [Qemu-devel] [PATCH v3 13/18] block: introduce new filter driver: fleecing-hook Vladimir Sementsov-Ogievskiy
2018-10-04 12:44 ` Kevin Wolf
2018-10-04 13:59 ` Vladimir Sementsov-Ogievskiy
2018-10-04 14:52 ` Kevin Wolf
2018-10-04 21:19 ` Vladimir Sementsov-Ogievskiy
2018-10-05 15:00 ` Vladimir Sementsov-Ogievskiy
2018-10-05 15:52 ` Kevin Wolf
2018-10-05 16:40 ` Vladimir Sementsov-Ogievskiy
2018-10-05 16:47 ` Eric Blake
2018-10-05 18:31 ` Vladimir Sementsov-Ogievskiy
2018-10-01 10:29 ` Vladimir Sementsov-Ogievskiy [this message]
2018-10-04 12:50 ` [Qemu-devel] [PATCH v3 14/18] block/fleecing-hook: internal api Kevin Wolf
2018-10-01 10:29 ` [Qemu-devel] [PATCH v3 15/18] qapi: add x-drop-fleecing qmp command Vladimir Sementsov-Ogievskiy
2018-10-01 10:29 ` [Qemu-devel] [PATCH v3 16/18] iotests: test new fleecing-hook driver in context of 222 iotest Vladimir Sementsov-Ogievskiy
2018-10-01 10:29 ` [Qemu-devel] [PATCH v3 17/18] block/backup: tiny refactor backup_job_create Vladimir Sementsov-Ogievskiy
2018-10-01 10:29 ` [Qemu-devel] [PATCH v3 18/18] block/backup: use fleecing-hook instead of write notifiers Vladimir Sementsov-Ogievskiy
2018-10-03 18:46 ` Vladimir Sementsov-Ogievskiy
2018-10-02 20:19 ` [Qemu-devel] [PATCH v3 00/18] fleecing-hook driver for backup Eric Blake
2018-10-03 9:55 ` Vladimir Sementsov-Ogievskiy
2018-10-03 15:36 ` Vladimir Sementsov-Ogievskiy
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=20181001102928.20533-15-vsementsov@virtuozzo.com \
--to=vsementsov@virtuozzo.com \
--cc=armbru@redhat.com \
--cc=den@openvz.org \
--cc=eblake@redhat.com \
--cc=famz@redhat.com \
--cc=jcody@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=wencongyang2@huawei.com \
--cc=xiechanglong.d@gmail.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.