From: Paolo Bonzini <pbonzini@redhat.com>
To: ronnie sahlberg <ronniesahlberg@gmail.com>
Cc: Kevin Wolf <kwolf@redhat.com>, Peter Lieven <pl@kamp.de>,
qemu-devel <qemu-devel@nongnu.org>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 1/2] iscsi: add support for bdrv_co_is_allocated()
Date: Fri, 21 Jun 2013 22:01:08 +0200 [thread overview]
Message-ID: <51C4B104.6060608@redhat.com> (raw)
In-Reply-To: <CAN05THTtcj7JN8POjX_EHc=zs3GGuqRWcku70FM5uRzOaM2xYw@mail.gmail.com>
Il 21/06/2013 18:06, ronnie sahlberg ha scritto:
> Should we really mix co-routines and AIO in the same backend?
>
> Would it not be better to instead add a new bdrb_aio_is_allocaed and
> use non-blocking async calls to libiscsi ?
Certainly, but is_allocated's code is not the tidiest.
I'm going to replace the is_allocated callback with a more generic one
(Peter knows, and Kevin might have suspected it too), and I will do the
cleanups at the time I do that.
Paolo
>
> On Fri, Jun 21, 2013 at 2:18 AM, Kevin Wolf <kwolf@redhat.com> wrote:
>> Am 20.06.2013 um 20:20 hat Peter Lieven geschrieben:
>>> Signed-off-by: Peter Lieven <pl@kamp.de>
>>> ---
>>> block/iscsi.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>> 1 file changed, 57 insertions(+)
>>>
>>> diff --git a/block/iscsi.c b/block/iscsi.c
>>> index 0bbf0b1..e6b966d 100644
>>> --- a/block/iscsi.c
>>> +++ b/block/iscsi.c
>>> @@ -49,6 +49,7 @@ typedef struct IscsiLun {
>>> uint64_t num_blocks;
>>> int events;
>>> QEMUTimer *nop_timer;
>>> + uint8_t lbpme;
>>> } IscsiLun;
>>>
>>> typedef struct IscsiAIOCB {
>>> @@ -800,6 +801,60 @@ iscsi_getlength(BlockDriverState *bs)
>>> return len;
>>> }
>>>
>>> +static int coroutine_fn iscsi_co_is_allocated(BlockDriverState *bs,
>>> + int64_t sector_num,
>>> + int nb_sectors, int *pnum)
>>> +{
>>> + IscsiLun *iscsilun = bs->opaque;
>>> + struct scsi_task *task = NULL;
>>> + struct scsi_get_lba_status *lbas = NULL;
>>> + struct scsi_lba_status_descriptor *lbasd = NULL;
>>> + int ret;
>>> +
>>> + *pnum = nb_sectors;
>>> +
>>> + if (iscsilun->lbpme == 0) {
>>> + return 1;
>>> + }
>>> +
>>> + /* in-flight requests could invalidate the lba status result */
>>> + while (iscsi_process_flush(iscsilun)) {
>>> + qemu_aio_wait();
>>> + }
>>
>> Note that you're blocking here. The preferred way would be something
>> involving a yield from the coroutine and a reenter as soon as all
>> requests are done. Maybe a CoRwLock does what you need?
>>
>>> +
>>> + task = iscsi_get_lba_status_sync(iscsilun->iscsi, iscsilun->lun,
>>> + sector_qemu2lun(sector_num, iscsilun),
>>> + 8+16);
>>
>> Spacing around operators (8 + 16)
>>
>>> +
>>> + if (task == NULL || task->status != SCSI_STATUS_GOOD) {
>>> + scsi_free_scsi_task(task);
>>> + return 1;
>>
>> Error cases should set *pnum = 0 and return 0.
>>
>> Kevin
>
>
next prev parent reply other threads:[~2013-06-21 20:01 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-20 18:20 [Qemu-devel] [PATCH 0/2] iscsi: support for is_allocated and inproved has_zero_init Peter Lieven
2013-06-20 18:20 ` [Qemu-devel] [PATCH 1/2] iscsi: add support for bdrv_co_is_allocated() Peter Lieven
2013-06-21 9:18 ` Kevin Wolf
2013-06-21 9:45 ` Peter Lieven
2013-06-21 11:07 ` Kevin Wolf
2013-06-21 11:42 ` Peter Lieven
2013-06-21 13:14 ` Kevin Wolf
2013-06-21 13:23 ` Peter Lieven
2013-06-21 16:31 ` Paolo Bonzini
2013-06-21 17:06 ` Peter Lieven
2013-06-21 17:13 ` ronnie sahlberg
2013-06-21 17:18 ` Peter Lieven
2013-06-21 16:06 ` ronnie sahlberg
2013-06-21 20:01 ` Paolo Bonzini [this message]
2013-06-24 8:13 ` Stefan Hajnoczi
2013-06-24 13:49 ` Paolo Bonzini
2013-06-24 16:11 ` Peter Lieven
2013-06-20 18:20 ` [Qemu-devel] [PATCH 2/2] iscsi: add intelligent has_zero_init check Peter Lieven
2013-06-21 20:00 ` Paolo Bonzini
2013-06-21 20:25 ` Peter Lieven
-- strict thread matches above, loose matches on Subject: below --
2013-06-20 18:08 [Qemu-devel] [PATCH 0/2] iscsi: support for is_allocated and inproved has_zero_init Peter Lieven
2013-06-20 18:08 ` [Qemu-devel] [PATCH 1/2] iscsi: add support for bdrv_co_is_allocated() Peter Lieven
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=51C4B104.6060608@redhat.com \
--to=pbonzini@redhat.com \
--cc=kwolf@redhat.com \
--cc=pl@kamp.de \
--cc=qemu-devel@nongnu.org \
--cc=ronniesahlberg@gmail.com \
--cc=stefanha@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).