[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 13/53] block/stream: add s->target_bs
From: |
Max Reitz |
Subject: |
[PULL 13/53] block/stream: add s->target_bs |
Date: |
Tue, 26 Jan 2021 15:19:36 +0100 |
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Add a direct link to target bs for convenience and to simplify
following commit which will insert COR filter above target bs.
This is a part of original commit written by Andrey.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20201216061703.70908-13-vsementsov@virtuozzo.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
block/stream.c | 23 ++++++++++-------------
1 file changed, 10 insertions(+), 13 deletions(-)
diff --git a/block/stream.c b/block/stream.c
index 045d6bc76b..626dfa2b22 100644
--- a/block/stream.c
+++ b/block/stream.c
@@ -33,6 +33,7 @@ typedef struct StreamBlockJob {
BlockJob common;
BlockDriverState *base_overlay; /* COW overlay (stream from this) */
BlockDriverState *above_base; /* Node directly above the base */
+ BlockDriverState *target_bs;
BlockdevOnError on_error;
char *backing_file_str;
bool bs_read_only;
@@ -53,23 +54,20 @@ static void stream_abort(Job *job)
StreamBlockJob *s = container_of(job, StreamBlockJob, common.job);
if (s->chain_frozen) {
- BlockJob *bjob = &s->common;
- bdrv_unfreeze_backing_chain(blk_bs(bjob->blk), s->above_base);
+ bdrv_unfreeze_backing_chain(s->target_bs, s->above_base);
}
}
static int stream_prepare(Job *job)
{
StreamBlockJob *s = container_of(job, StreamBlockJob, common.job);
- BlockJob *bjob = &s->common;
- BlockDriverState *bs = blk_bs(bjob->blk);
- BlockDriverState *unfiltered_bs = bdrv_skip_filters(bs);
+ BlockDriverState *unfiltered_bs = bdrv_skip_filters(s->target_bs);
BlockDriverState *base = bdrv_filter_or_cow_bs(s->above_base);
BlockDriverState *unfiltered_base = bdrv_skip_filters(base);
Error *local_err = NULL;
int ret = 0;
- bdrv_unfreeze_backing_chain(bs, s->above_base);
+ bdrv_unfreeze_backing_chain(s->target_bs, s->above_base);
s->chain_frozen = false;
if (bdrv_cow_child(unfiltered_bs)) {
@@ -95,13 +93,12 @@ static void stream_clean(Job *job)
{
StreamBlockJob *s = container_of(job, StreamBlockJob, common.job);
BlockJob *bjob = &s->common;
- BlockDriverState *bs = blk_bs(bjob->blk);
/* Reopen the image back in read-only mode if necessary */
if (s->bs_read_only) {
/* Give up write permissions before making it read-only */
blk_set_perm(bjob->blk, 0, BLK_PERM_ALL, &error_abort);
- bdrv_reopen_set_read_only(bs, true, NULL);
+ bdrv_reopen_set_read_only(s->target_bs, true, NULL);
}
g_free(s->backing_file_str);
@@ -111,8 +108,7 @@ static int coroutine_fn stream_run(Job *job, Error **errp)
{
StreamBlockJob *s = container_of(job, StreamBlockJob, common.job);
BlockBackend *blk = s->common.blk;
- BlockDriverState *bs = blk_bs(blk);
- BlockDriverState *unfiltered_bs = bdrv_skip_filters(bs);
+ BlockDriverState *unfiltered_bs = bdrv_skip_filters(s->target_bs);
bool enable_cor = !bdrv_cow_child(s->base_overlay);
int64_t len;
int64_t offset = 0;
@@ -125,7 +121,7 @@ static int coroutine_fn stream_run(Job *job, Error **errp)
return 0;
}
- len = bdrv_getlength(bs);
+ len = bdrv_getlength(s->target_bs);
if (len < 0) {
return len;
}
@@ -137,7 +133,7 @@ static int coroutine_fn stream_run(Job *job, Error **errp)
* account.
*/
if (enable_cor) {
- bdrv_enable_copy_on_read(bs);
+ bdrv_enable_copy_on_read(s->target_bs);
}
for ( ; offset < len; offset += n) {
@@ -199,7 +195,7 @@ static int coroutine_fn stream_run(Job *job, Error **errp)
}
if (enable_cor) {
- bdrv_disable_copy_on_read(bs);
+ bdrv_disable_copy_on_read(s->target_bs);
}
/* Do not remove the backing file if an error was there but ignored. */
@@ -314,6 +310,7 @@ void stream_start(const char *job_id, BlockDriverState *bs,
s->base_overlay = base_overlay;
s->above_base = above_base;
s->backing_file_str = g_strdup(backing_file_str);
+ s->target_bs = bs;
s->bs_read_only = bs_read_only;
s->chain_frozen = true;
--
2.29.2
- [PULL 04/53] copy-on-read: add filter drop function, (continued)
- [PULL 04/53] copy-on-read: add filter drop function, Max Reitz, 2021/01/26
- [PULL 05/53] qapi: add filter-node-name to block-stream, Max Reitz, 2021/01/26
- [PULL 07/53] iotests: add #310 to test bottom node in COR driver, Max Reitz, 2021/01/26
- [PULL 06/53] qapi: copy-on-read filter: add 'bottom' option, Max Reitz, 2021/01/26
- [PULL 08/53] block: include supported_read_flags into BDS structure, Max Reitz, 2021/01/26
- [PULL 11/53] qapi: block-stream: add "bottom" argument, Max Reitz, 2021/01/26
- [PULL 16/53] iotests/297: Rewrite in Python and extend reach, Max Reitz, 2021/01/26
- [PULL 17/53] iotests: Move try_remove to iotests.py, Max Reitz, 2021/01/26
- [PULL 14/53] block: apply COR-filter to block-stream jobs, Max Reitz, 2021/01/26
- [PULL 10/53] stream: rework backing-file changing, Max Reitz, 2021/01/26
- [PULL 13/53] block/stream: add s->target_bs,
Max Reitz <=
- [PULL 12/53] iotests: 30: prepare to COR filter insertion by stream job, Max Reitz, 2021/01/26
- [PULL 09/53] copy-on-read: skip non-guest reads if no copy needed, Max Reitz, 2021/01/26
- [PULL 20/53] iotests/129: Use throttle node, Max Reitz, 2021/01/26
- [PULL 22/53] iotests/129: Limit mirror job's buffer size, Max Reitz, 2021/01/26
- [PULL 15/53] iotests.py: Assume a couple of variables as given, Max Reitz, 2021/01/26
- [PULL 18/53] iotests/129: Remove test images in tearDown(), Max Reitz, 2021/01/26
- [PULL 19/53] iotests/129: Do not check @busy, Max Reitz, 2021/01/26
- [PULL 25/53] coroutine-sigaltstack: Add SIGUSR2 mutex, Max Reitz, 2021/01/26
- [PULL 27/53] block/block-copy: More explicit call_state, Max Reitz, 2021/01/26
- [PULL 23/53] iotests/129: Clean up pylint and mypy complaints, Max Reitz, 2021/01/26