From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57183) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uq4F2-0003o5-If for qemu-devel@nongnu.org; Fri, 21 Jun 2013 12:31:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uq4F1-0002jp-QF for qemu-devel@nongnu.org; Fri, 21 Jun 2013 12:31:16 -0400 Received: from mail-ea0-x22b.google.com ([2a00:1450:4013:c01::22b]:42394) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uq4F1-0002jS-Ks for qemu-devel@nongnu.org; Fri, 21 Jun 2013 12:31:15 -0400 Received: by mail-ea0-f171.google.com with SMTP id m14so4793330eaj.30 for ; Fri, 21 Jun 2013 09:31:14 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <51C47FCD.2030206@redhat.com> Date: Fri, 21 Jun 2013 18:31:09 +0200 From: Paolo Bonzini MIME-Version: 1.0 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> <51C420C4.6040503@kamp.de> <20130621110707.GF2986@dhcp-200-207.str.redhat.com> In-Reply-To: <20130621110707.GF2986@dhcp-200-207.str.redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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: Stefan Hajnoczi , Peter Lieven , qemu-devel@nongnu.org, ronniesahlberg@gmail.com Il 21/06/2013 13:07, Kevin Wolf ha scritto: >>> > > 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? >> > Is there a document how to use it? Or can you help here? > The idea would be to take a read lock while any request is in flight > (i.e. qemu_co_rwlock_rdlock() before it's started and > qemu_co_rwlock_unlock() when it completes), and to take a write lock > (qemu_co_rwlock_wrlock) for the part of iscsi_co_is_allocated() that > requires that no other request runs in parallel. > You can just send the SCSI command asynchronously and wait for the result. There is an example in block/qed.c, the same would apply for iscsi. Paolo