From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:57298) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SSo0c-0000pX-Oh for qemu-devel@nongnu.org; Fri, 11 May 2012 07:27:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SSo0V-0005aG-SS for qemu-devel@nongnu.org; Fri, 11 May 2012 07:27:42 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:44540) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SSo0V-0005Zp-K2 for qemu-devel@nongnu.org; Fri, 11 May 2012 07:27:35 -0400 Received: by pbbro12 with SMTP id ro12so4336788pbb.4 for ; Fri, 11 May 2012 04:27:33 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <4FACF79E.6040100@redhat.com> Date: Fri, 11 May 2012 13:27:26 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1336731722-17743-1-git-send-email-ronniesahlberg@gmail.com> <1336731722-17743-2-git-send-email-ronniesahlberg@gmail.com> In-Reply-To: <1336731722-17743-2-git-send-email-ronniesahlberg@gmail.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] ISCSI: Only set up the read-event if we are actually waiting for data to come back in from the target. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ronnie Sahlberg Cc: kwolf@redhat.com, qemu-devel@nongnu.org Il 11/05/2012 12:22, Ronnie Sahlberg ha scritto: > Signed-off-by: Ronnie Sahlberg > --- > block/iscsi.c | 4 +++- > 1 files changed, 3 insertions(+), 1 deletions(-) > > diff --git a/block/iscsi.c b/block/iscsi.c > index d37c4ee..989b5e9 100644 > --- a/block/iscsi.c > +++ b/block/iscsi.c > @@ -105,7 +105,9 @@ iscsi_set_events(IscsiLun *iscsilun) > { > struct iscsi_context *iscsi = iscsilun->iscsi; > > - qemu_aio_set_fd_handler(iscsi_get_fd(iscsi), iscsi_process_read, > + qemu_aio_set_fd_handler(iscsi_get_fd(iscsi), > + (iscsi_queue_length(iscsi) > 0) > + ? iscsi_process_read : NULL, > (iscsi_which_events(iscsi) & POLLOUT) > ? iscsi_process_write : NULL, > iscsi_process_flush, iscsilun); I wonder if iscsi is also susceptible to the same race condition I saw with NBD, where you can have: 1) select in the iothread exiting and reporting readability 2) the iothread subsequently blocking on the mutex 3) a VCPU thread's qemu_aio_wait() calling iscsi_process_read 4) when the VCPU releases the mutex, the iothread will call iscsi_process_read again. This should be easily reproducible with IDE drives, but the above patch would not fix it. Perhaps it's better to call iscsi_queue_length in iscsi_process_read instead. Paolo