[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 28/41] block: Use bdrv_reopen_set_read_only() in comm
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 28/41] block: Use bdrv_reopen_set_read_only() in commit_start/complete() |
Date: |
Wed, 12 Dec 2018 14:27:22 +0100 |
From: Alberto Garcia <address@hidden>
This patch replaces the bdrv_reopen() calls that set and remove the
BDRV_O_RDWR flag with the new bdrv_reopen_set_read_only() function.
Signed-off-by: Alberto Garcia <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/commit.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/block/commit.c b/block/commit.c
index a2da5740b0..a53c2d04b0 100644
--- a/block/commit.c
+++ b/block/commit.c
@@ -38,7 +38,7 @@ typedef struct CommitBlockJob {
BlockBackend *base;
BlockDriverState *base_bs;
BlockdevOnError on_error;
- int base_flags;
+ bool base_read_only;
char *backing_file_str;
} CommitBlockJob;
@@ -124,8 +124,8 @@ static void commit_clean(Job *job)
/* restore base open flags here if appropriate (e.g., change the base back
* to r/o). These reopens do not need to be atomic, since we won't abort
* even on failure here */
- if (s->base_flags != bdrv_get_flags(s->base_bs)) {
- bdrv_reopen(s->base_bs, s->base_flags, NULL);
+ if (s->base_read_only) {
+ bdrv_reopen_set_read_only(s->base_bs, true, NULL);
}
g_free(s->backing_file_str);
@@ -264,7 +264,6 @@ void commit_start(const char *job_id, BlockDriverState *bs,
const char *filter_node_name, Error **errp)
{
CommitBlockJob *s;
- int orig_base_flags;
BlockDriverState *iter;
BlockDriverState *commit_top_bs = NULL;
Error *local_err = NULL;
@@ -283,11 +282,9 @@ void commit_start(const char *job_id, BlockDriverState *bs,
}
/* convert base to r/w, if necessary */
- orig_base_flags = bdrv_get_flags(base);
- if (!(orig_base_flags & BDRV_O_RDWR)) {
- bdrv_reopen(base, orig_base_flags | BDRV_O_RDWR, &local_err);
- if (local_err != NULL) {
- error_propagate(errp, local_err);
+ s->base_read_only = bdrv_is_read_only(base);
+ if (s->base_read_only) {
+ if (bdrv_reopen_set_read_only(base, false, errp) != 0) {
goto fail;
}
}
@@ -363,7 +360,6 @@ void commit_start(const char *job_id, BlockDriverState *bs,
goto fail;
}
- s->base_flags = orig_base_flags;
s->backing_file_str = g_strdup(backing_file_str);
s->on_error = on_error;
--
2.19.2
- [Qemu-devel] [PULL 17/41] file-posix: Avoid aio_worker() for QEMU_AIO_COPY_RANGE, (continued)
- [Qemu-devel] [PULL 17/41] file-posix: Avoid aio_worker() for QEMU_AIO_COPY_RANGE, Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 21/41] file-posix: Move read/write operation logic out of aio_worker(), Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 19/41] file-posix: Avoid aio_worker() for QEMU_AIO_DISCARD, Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 20/41] file-posix: Avoid aio_worker() for QEMU_AIO_FLUSH, Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 23/41] file-posix: Remove paio_submit_co(), Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 25/41] file-posix: Avoid aio_worker() for QEMU_AIO_IOCTL, Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 26/41] block: Add bdrv_reopen_set_read_only(), Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 24/41] file-posix: Switch to .bdrv_co_ioctl, Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 22/41] file-posix: Avoid aio_worker() for QEMU_AIO_READ/WRITE, Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 27/41] block: Use bdrv_reopen_set_read_only() in bdrv_backing_update_filename(), Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 28/41] block: Use bdrv_reopen_set_read_only() in commit_start/complete(),
Kevin Wolf <=
- [Qemu-devel] [PULL 29/41] block: Use bdrv_reopen_set_read_only() in bdrv_commit(), Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 30/41] block: Use bdrv_reopen_set_read_only() in stream_start/complete(), Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 31/41] block: Use bdrv_reopen_set_read_only() in qmp_change_backing_file(), Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 32/41] block: Use bdrv_reopen_set_read_only() in external_snapshot_commit(), Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 34/41] block: Drop bdrv_reopen(), Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 33/41] block: Use bdrv_reopen_set_read_only() in the mirror driver, Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 36/41] block: Clean up reopen_backing_file() in block/replication.c, Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 38/41] block: Stop passing flags to bdrv_reopen_queue_child(), Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 39/41] block: Remove assertions from update_flags_from_options(), Kevin Wolf, 2018/12/12
- [Qemu-devel] [PULL 37/41] block: Remove flags parameter from bdrv_reopen_queue(), Kevin Wolf, 2018/12/12