Received: from eggs.gnu.org ([2001:4830:134:3::10]:60940) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ur1uN-0006HI-MC for qemu-devel@nongnu.org; Mon, 24 Jun 2013 04:13:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ur1uK-0004GF-RL for qemu-devel@nongnu.org; Mon, 24 Jun 2013 04:13:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45624) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ur1uK-0004G7-Kw for qemu-devel@nongnu.org; Mon, 24 Jun 2013 04:13:52 -0400 Date: Mon, 24 Jun 2013 10:13:43 +0200 From: Stefan Hajnoczi Message-ID: <20130624081343.GE8700@stefanha-thinkpad.redhat.com> References: <1371752409-16313-1-git-send-email-pl@kamp.de> <1371752409-16313-2-git-send-email-pl@kamp.de> <20130621091842.GB2986@dhcp-200-207.str.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130621091842.GB2986@dhcp-200-207.str.redhat.com> Subject: Re: [Qemu-devel] [PATCH 1/2] iscsi: add support for bdrv_co_is_allocated() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: pbonzini@redhat.com, Peter Lieven , qemu-devel@nongnu.org, ronniesahlberg@gmail.com On Fri, Jun 21, 2013 at 11:18:42AM +0200, Kevin Wolf wrote: > Am 20.06.2013 um 20:20 hat Peter Lieven geschrieben: > > @@ -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? The other option is to avoid synchronization here and instead process bs->tracked_requests so that any in-flight writes count as allocated. Stefan