[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 17/28] block: Freeze the backing chain for the durati
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 17/28] block: Freeze the backing chain for the duration of the commit job |
Date: |
Tue, 12 Mar 2019 18:30:14 +0100 |
From: Alberto Garcia <address@hidden>
Signed-off-by: Alberto Garcia <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/commit.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/block/commit.c b/block/commit.c
index 3b46ca7f97..ba60fef58a 100644
--- a/block/commit.c
+++ b/block/commit.c
@@ -39,6 +39,7 @@ typedef struct CommitBlockJob {
BlockDriverState *base_bs;
BlockdevOnError on_error;
bool base_read_only;
+ bool chain_frozen;
char *backing_file_str;
} CommitBlockJob;
@@ -68,6 +69,9 @@ static int commit_prepare(Job *job)
{
CommitBlockJob *s = container_of(job, CommitBlockJob, common.job);
+ bdrv_unfreeze_backing_chain(s->commit_top_bs, s->base_bs);
+ s->chain_frozen = false;
+
/* Remove base node parent that still uses BLK_PERM_WRITE/RESIZE before
* the normal backing chain can be restored. */
blk_unref(s->base);
@@ -84,6 +88,10 @@ static void commit_abort(Job *job)
CommitBlockJob *s = container_of(job, CommitBlockJob, common.job);
BlockDriverState *top_bs = blk_bs(s->top);
+ if (s->chain_frozen) {
+ bdrv_unfreeze_backing_chain(s->commit_top_bs, s->base_bs);
+ }
+
/* Make sure commit_top_bs and top stay around until bdrv_replace_node() */
bdrv_ref(top_bs);
bdrv_ref(s->commit_top_bs);
@@ -330,6 +338,11 @@ void commit_start(const char *job_id, BlockDriverState *bs,
}
}
+ if (bdrv_freeze_backing_chain(commit_top_bs, base, errp) < 0) {
+ goto fail;
+ }
+ s->chain_frozen = true;
+
ret = block_job_add_bdrv(&s->common, "base", base, 0, BLK_PERM_ALL, errp);
if (ret < 0) {
goto fail;
@@ -362,6 +375,9 @@ void commit_start(const char *job_id, BlockDriverState *bs,
return;
fail:
+ if (s->chain_frozen) {
+ bdrv_unfreeze_backing_chain(commit_top_bs, base);
+ }
if (s->base) {
blk_unref(s->base);
}
--
2.20.1
- [Qemu-devel] [PULL 06/28] qemu-iotests: commit to backing file with auto-read-only, (continued)
- [Qemu-devel] [PULL 06/28] qemu-iotests: commit to backing file with auto-read-only, Kevin Wolf, 2019/03/12
- [Qemu-devel] [PULL 07/28] block: Avoid useless local_err, Kevin Wolf, 2019/03/12
- [Qemu-devel] [PULL 11/28] file-posix: Store BDRVRawState.reopen_state during reopen, Kevin Wolf, 2019/03/12
- [Qemu-devel] [PULL 10/28] file-posix: Factor out raw_reconfigure_getfd(), Kevin Wolf, 2019/03/12
- [Qemu-devel] [PULL 09/28] file-posix: Fix bdrv_open_flags() for snapshot=on, Kevin Wolf, 2019/03/12
- [Qemu-devel] [PULL 12/28] file-posix: Lock new fd in raw_reopen_prepare(), Kevin Wolf, 2019/03/12
- [Qemu-devel] [PULL 15/28] nvme: fix write zeroes offset and count, Kevin Wolf, 2019/03/12
- [Qemu-devel] [PULL 13/28] file-posix: Prepare permission code for fd switching, Kevin Wolf, 2019/03/12
- [Qemu-devel] [PULL 08/28] block: Make permission changes in reopen less wrong, Kevin Wolf, 2019/03/12
- [Qemu-devel] [PULL 14/28] file-posix: Make auto-read-only dynamic, Kevin Wolf, 2019/03/12
- [Qemu-devel] [PULL 17/28] block: Freeze the backing chain for the duration of the commit job,
Kevin Wolf <=
- [Qemu-devel] [PULL 16/28] block: Allow freezing BdrvChild links, Kevin Wolf, 2019/03/12
- [Qemu-devel] [PULL 19/28] block: Freeze the backing chain for the duration of the stream job, Kevin Wolf, 2019/03/12
- [Qemu-devel] [PULL 18/28] block: Freeze the backing chain for the duration of the mirror job, Kevin Wolf, 2019/03/12
- [Qemu-devel] [PULL 20/28] block: Add 'keep_old_opts' parameter to bdrv_reopen_queue(), Kevin Wolf, 2019/03/12
- [Qemu-devel] [PULL 22/28] block: Allow omitting the 'backing' option in certain cases, Kevin Wolf, 2019/03/12
- [Qemu-devel] [PULL 24/28] block: Add a 'mutable_opts' field to BlockDriver, Kevin Wolf, 2019/03/12
- [Qemu-devel] [PULL 25/28] block: Add bdrv_reset_options_allowed(), Kevin Wolf, 2019/03/12
- [Qemu-devel] [PULL 26/28] block: Remove the AioContext parameter from bdrv_reopen_multiple(), Kevin Wolf, 2019/03/12
- [Qemu-devel] [PULL 23/28] block: Allow changing the backing file on reopen, Kevin Wolf, 2019/03/12
- [Qemu-devel] [PULL 21/28] block: Handle child references in bdrv_reopen_queue(), Kevin Wolf, 2019/03/12