[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 04/13] block: Freeze the backing chain for the du
From: |
Alberto Garcia |
Subject: |
[Qemu-devel] [PATCH v3 04/13] block: Freeze the backing chain for the duration of the stream job |
Date: |
Tue, 12 Mar 2019 18:48:43 +0200 |
Signed-off-by: Alberto Garcia <address@hidden>
---
block/stream.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/block/stream.c b/block/stream.c
index e14579ff80..6253c86fae 100644
--- a/block/stream.c
+++ b/block/stream.c
@@ -35,6 +35,7 @@ typedef struct StreamBlockJob {
BlockdevOnError on_error;
char *backing_file_str;
bool bs_read_only;
+ bool chain_frozen;
} StreamBlockJob;
static int coroutine_fn stream_populate(BlockBackend *blk,
@@ -49,6 +50,16 @@ static int coroutine_fn stream_populate(BlockBackend *blk,
return blk_co_preadv(blk, offset, qiov.size, &qiov, BDRV_REQ_COPY_ON_READ);
}
+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->base);
+ }
+}
+
static int stream_prepare(Job *job)
{
StreamBlockJob *s = container_of(job, StreamBlockJob, common.job);
@@ -58,6 +69,9 @@ static int stream_prepare(Job *job)
Error *local_err = NULL;
int ret = 0;
+ bdrv_unfreeze_backing_chain(bs, base);
+ s->chain_frozen = false;
+
if (bs->backing) {
const char *base_id = NULL, *base_fmt = NULL;
if (base) {
@@ -208,6 +222,7 @@ static const BlockJobDriver stream_job_driver = {
.free = block_job_free,
.run = stream_run,
.prepare = stream_prepare,
+ .abort = stream_abort,
.clean = stream_clean,
.user_resume = block_job_user_resume,
.drain = block_job_drain,
@@ -254,9 +269,15 @@ void stream_start(const char *job_id, BlockDriverState *bs,
&error_abort);
}
+ if (bdrv_freeze_backing_chain(bs, base, errp) < 0) {
+ job_early_fail(&s->common.job);
+ goto fail;
+ }
+
s->base = base;
s->backing_file_str = g_strdup(backing_file_str);
s->bs_read_only = bs_read_only;
+ s->chain_frozen = true;
s->on_error = on_error;
trace_stream_start(bs, base, s);
--
2.11.0
- [Qemu-devel] [PATCH v3 00/13] Add a 'x-blockdev-reopen' QMP command, Alberto Garcia, 2019/03/12
- [Qemu-devel] [PATCH v3 02/13] block: Freeze the backing chain for the duration of the commit job, Alberto Garcia, 2019/03/12
- [Qemu-devel] [PATCH v3 07/13] block: Allow omitting the 'backing' option in certain cases, Alberto Garcia, 2019/03/12
- [Qemu-devel] [PATCH v3 03/13] block: Freeze the backing chain for the duration of the mirror job, Alberto Garcia, 2019/03/12
- [Qemu-devel] [PATCH v3 01/13] block: Allow freezing BdrvChild links, Alberto Garcia, 2019/03/12
- [Qemu-devel] [PATCH v3 05/13] block: Add 'keep_old_opts' parameter to bdrv_reopen_queue(), Alberto Garcia, 2019/03/12
- [Qemu-devel] [PATCH v3 08/13] block: Allow changing the backing file on reopen, Alberto Garcia, 2019/03/12
- [Qemu-devel] [PATCH v3 09/13] block: Add a 'mutable_opts' field to BlockDriver, Alberto Garcia, 2019/03/12
- [Qemu-devel] [PATCH v3 11/13] block: Remove the AioContext parameter from bdrv_reopen_multiple(), Alberto Garcia, 2019/03/12
- [Qemu-devel] [PATCH v3 04/13] block: Freeze the backing chain for the duration of the stream job,
Alberto Garcia <=
- [Qemu-devel] [PATCH v3 13/13] qemu-iotests: Test the x-blockdev-reopen QMP command, Alberto Garcia, 2019/03/12
- [Qemu-devel] [PATCH v3 10/13] block: Add bdrv_reset_options_allowed(), Alberto Garcia, 2019/03/12
- [Qemu-devel] [PATCH v3 06/13] block: Handle child references in bdrv_reopen_queue(), Alberto Garcia, 2019/03/12
- [Qemu-devel] [PATCH v3 12/13] block: Add an 'x-blockdev-reopen' QMP command, Alberto Garcia, 2019/03/12
- Re: [Qemu-devel] [PATCH v3 00/13] Add a 'x-blockdev-reopen' QMP command, Alberto Garcia, 2019/03/12