From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37116) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLumF-00019B-W2 for qemu-devel@nongnu.org; Thu, 12 Feb 2015 09:30:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YLumB-0002xN-VQ for qemu-devel@nongnu.org; Thu, 12 Feb 2015 09:29:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33016) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLumB-0002xH-Ng for qemu-devel@nongnu.org; Thu, 12 Feb 2015 09:29:55 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t1CETsC0001794 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 12 Feb 2015 09:29:55 -0500 Message-ID: <54DCB8DE.4090302@redhat.com> Date: Thu, 12 Feb 2015 15:29:50 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1423718462-25566-1-git-send-email-famz@redhat.com> <1423718462-25566-4-git-send-email-famz@redhat.com> In-Reply-To: <1423718462-25566-4-git-send-email-famz@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 3/3] virtio-scsi-dataplane: Use main thread BH to set BDS' aio context List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng , qemu-devel@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com On 12/02/2015 06:21, Fam Zheng wrote: > Before processing a request, virtio-scsi dataplane will check if the > backend runs on the same context with it. If not, it has to be moved, > with bdrv_set_aio_context. > > However this function is unsafe to be called from IOThread outside BQL. > The reason is that it calls bdrv_drain_all(), to acquire and drain all > existing BDS. Therefore there is a deadlock problem. > > Fix it by offloading the bdrv_set_aio_context to main loop thread, > through a BH (#1). This main loop BH will set the context, then notify > the calling thread with another BH (#2). In BH (#2), we can continue the > virtio-scsi request processing. > > A queue is added to VirtIOSCSI for tracking the pending requests, so in > virtio_scsi_dataplane_stop, we have to drain them for migration. > > Signed-off-by: Fam Zheng Could you just do set_aio_context for all devices when starting dataplane? For example with a new scsi_device_set_aio_context function (and a new method in SCSIDeviceClass). Maybe I'm missing the obvious. :) Paolo