From: Kevin Wolf <kwolf@redhat.com>
To: Zhi Yong Wu <zwu.kernel@gmail.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 02/10] block: add .bdrv_co_is_allocated()
Date: Mon, 14 Nov 2011 09:50:32 +0100 [thread overview]
Message-ID: <4EC0D658.90305@redhat.com> (raw)
In-Reply-To: <CAEH94LjSnvq1i-9rJTeTYsQXtdNPXXT3ES1g8pDkkSTxAW4d6A@mail.gmail.com>
Am 14.11.2011 04:04, schrieb Zhi Yong Wu:
> On Sat, Nov 12, 2011 at 12:47 AM, Stefan Hajnoczi
> <stefanha@linux.vnet.ibm.com> wrote:
>> This patch adds the .bdrv_co_is_allocated() interface which is identical
>> to .bdrv_is_allocated() but runs in coroutine context. Running in
>> coroutine context implies that other coroutines might be performing I/O
>> at the same time. Therefore it must be safe to run while the following
>> BlockDriver functions are in-flight:
>>
>> .bdrv_co_readv()
>> .bdrv_co_writev()
>> .bdrv_co_flush()
>> .bdrv_co_is_allocated()
>>
>> The new .bdrv_co_is_allocated() interface is useful because it can be
>> used when a VM is running, whereas .bdrv_is_allocated() is a synchronous
>> interface that does not cope with parallel requests.
>>
>> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
>> ---
>> block.c | 37 +++++++++++++++++++++++++++++++++++++
>> block_int.h | 2 ++
>> 2 files changed, 39 insertions(+), 0 deletions(-)
>>
>> diff --git a/block.c b/block.c
>> index e6ac6d3..f8705b7 100644
>> --- a/block.c
>> +++ b/block.c
>> @@ -1771,6 +1771,26 @@ int bdrv_has_zero_init(BlockDriverState *bs)
>> return 1;
>> }
>>
>> +typedef struct BdrvCoIsAllocatedData {
>> + BlockDriverState *bs;
>> + int64_t sector_num;
>> + int nb_sectors;
>> + int *pnum;
>> + int ret;
>> + bool done;
>> +} BdrvCoIsAllocatedData;
>> +
>> +/* Coroutine wrapper for bdrv_is_allocated() */
>> +static void coroutine_fn bdrv_is_allocated_co_entry(void *opaque)
>> +{
>> + BdrvCoIsAllocatedData *data = opaque;
>> + BlockDriverState *bs = data->bs;
>> +
>> + data->ret = bs->drv->bdrv_co_is_allocated(bs, data->sector_num,
>> + data->nb_sectors, data->pnum);
>> + data->done = true;
>> +}
>> +
>> /*
>> * Returns true iff the specified sector is present in the disk image. Drivers
>> * not implementing the functionality are assumed to not support backing files,
>> @@ -1786,6 +1806,23 @@ int bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors,
>> int *pnum)
>> {
>> int64_t n;
>> + if (bs->drv->bdrv_co_is_allocated) {
>> + Coroutine *co;
>> + BdrvCoIsAllocatedData data = {
>> + .bs = bs,
>> + .sector_num = sector_num,
>> + .nb_sectors = nb_sectors,
>> + .pnum = pnum,
>> + .done = false,
>> + };
>> +
>> + co = qemu_coroutine_create(bdrv_is_allocated_co_entry);
>> + qemu_coroutine_enter(co, &data);
> Since this main process will stop within qemu_coroutine_enter() until
> bdrv_is_allocated_co_entry() is completed, three lines of condition
> codes below are unnecessary, right?
No, they are needed. We want to wait until the whole operation has
completed, but qemu_coroutine_enter() returns after the first
qemu_coroutine_yield().
Kevin
next prev parent reply other threads:[~2011-11-14 8:47 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-11 16:47 [Qemu-devel] [PATCH 00/10] block: replace .bdrv_is_allocated() with .bdrv_co_is_allocated() Stefan Hajnoczi
2011-11-11 16:47 ` [Qemu-devel] [PATCH 01/10] block: use public bdrv_is_allocated() interface Stefan Hajnoczi
2011-11-11 16:47 ` [Qemu-devel] [PATCH 02/10] block: add .bdrv_co_is_allocated() Stefan Hajnoczi
2011-11-14 3:04 ` Zhi Yong Wu
2011-11-14 7:32 ` Paolo Bonzini
2011-11-14 8:10 ` Zhi Yong Wu
2011-11-14 8:37 ` Paolo Bonzini
2011-11-14 8:53 ` Zhi Yong Wu
2011-11-14 8:50 ` Kevin Wolf [this message]
2011-11-14 8:50 ` Zhi Yong Wu
2011-11-11 16:47 ` [Qemu-devel] [PATCH 03/10] qed: convert to .bdrv_co_is_allocated() Stefan Hajnoczi
2011-11-11 16:47 ` [Qemu-devel] [PATCH 04/10] block: convert qcow2, qcow2, and vmdk " Stefan Hajnoczi
2011-11-11 16:47 ` [Qemu-devel] [PATCH 05/10] vvfat: use public block layer interface Stefan Hajnoczi
2011-11-11 16:59 ` Kevin Wolf
2011-11-14 11:47 ` Stefan Hajnoczi
2011-11-11 16:47 ` [Qemu-devel] [PATCH 06/10] vvfat: convert to .bdrv_co_is_allocated() Stefan Hajnoczi
2011-11-11 16:47 ` [Qemu-devel] [PATCH 07/10] vdi: " Stefan Hajnoczi
2011-11-11 16:47 ` [Qemu-devel] [PATCH 08/10] cow: " Stefan Hajnoczi
2011-11-11 16:47 ` [Qemu-devel] [PATCH 09/10] block: drop .bdrv_is_allocated() interface Stefan Hajnoczi
2011-11-11 16:47 ` [Qemu-devel] [PATCH 10/10] block: add bdrv_co_is_allocated() interface Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4EC0D658.90305@redhat.com \
--to=kwolf@redhat.com \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@linux.vnet.ibm.com \
--cc=zwu.kernel@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.