[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH 08/11] qed: introduce bdrv_qed_init_state
From: |
Paolo Bonzini |
Subject: |
[Qemu-block] [PATCH 08/11] qed: introduce bdrv_qed_init_state |
Date: |
Thu, 29 Jun 2017 15:27:46 +0200 |
This will be used in the next patch, which will call bdrv_qed_do_open
with a CoMutex taken. bdrv_qed_init_state provides a nice place to
initialize it.
Signed-off-by: Paolo Bonzini <address@hidden>
---
RFC->v2: new
block/qed.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/block/qed.c b/block/qed.c
index db390efdbd..8228a50f68 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -363,6 +363,15 @@ static void coroutine_fn
bdrv_qed_co_drain(BlockDriverState *bs)
}
}
+static void bdrv_qed_init_state(BlockDriverState *bs)
+{
+ BDRVQEDState *s = bs->opaque;
+
+ memset(s, 0, sizeof(BDRVQEDState));
+ s->bs = bs;
+ qemu_co_queue_init(&s->allocating_write_reqs);
+}
+
static int bdrv_qed_do_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
@@ -371,9 +380,6 @@ static int bdrv_qed_do_open(BlockDriverState *bs, QDict
*options, int flags,
int64_t file_size;
int ret;
- s->bs = bs;
- qemu_co_queue_init(&s->allocating_write_reqs);
-
ret = bdrv_pread(bs->file, 0, &le_header, sizeof(le_header));
if (ret < 0) {
return ret;
@@ -507,6 +513,7 @@ static int bdrv_qed_open(BlockDriverState *bs, QDict
*options, int flags,
return -EINVAL;
}
+ bdrv_qed_init_state(bs);
return bdrv_qed_do_open(bs, options, flags, errp);
}
@@ -1461,7 +1468,7 @@ static void bdrv_qed_invalidate_cache(BlockDriverState
*bs, Error **errp)
bdrv_qed_close(bs);
- memset(s, 0, sizeof(BDRVQEDState));
+ bdrv_qed_init_state(bs);
ret = bdrv_qed_do_open(bs, NULL, bs->open_flags, &local_err);
if (local_err) {
error_propagate(errp, local_err);
--
2.13.0
- [Qemu-block] [PATCH v2 00/11] Block layer thread-safety, part 2, Paolo Bonzini, 2017/06/29
- [Qemu-block] [PATCH 01/11] qcow2: call CoQueue APIs under CoMutex, Paolo Bonzini, 2017/06/29
- [Qemu-block] [PATCH 03/11] vdi: make it thread-safe, Paolo Bonzini, 2017/06/29
- [Qemu-block] [PATCH 06/11] qed: move tail of qed_aio_write_main to qed_aio_write_{cow, alloc}, Paolo Bonzini, 2017/06/29
- [Qemu-block] [PATCH 02/11] coroutine-lock: add qemu_co_rwlock_downgrade and qemu_co_rwlock_upgrade, Paolo Bonzini, 2017/06/29
- [Qemu-block] [PATCH 04/11] vpc: make it thread-safe, Paolo Bonzini, 2017/06/29
- [Qemu-block] [PATCH 08/11] qed: introduce bdrv_qed_init_state,
Paolo Bonzini <=
- [Qemu-block] [PATCH 05/11] vvfat: make it thread-safe, Paolo Bonzini, 2017/06/29
- [Qemu-block] [PATCH 10/11] sheepdog: add queue_lock, Paolo Bonzini, 2017/06/29
- [Qemu-block] [PATCH 11/11] ssh: support I/O from any AioContext, Paolo Bonzini, 2017/06/29
- [Qemu-block] [PATCH 07/11] block: invoke .bdrv_drain callback in coroutine context and from AioContext, Paolo Bonzini, 2017/06/29
- [Qemu-block] [PATCH 09/11] qed: protect table cache with CoMutex, Paolo Bonzini, 2017/06/29