From nobody Sun Oct 5 19:09:41 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1611196680; cv=none; d=zohomail.com; s=zohoarc; b=TEZTGoAReTOAoGMXyVVfbmEPxnlA8U1uDReW1uRrmSbk2WoYPhKhSYiQcMRbWK9i9XrvD/h8GqIwddpMM/4Zpa0uJUXRqGspVKb6PcyMtN21tF1Bb0jVWHckNUlg9W3mTodAADvc5XKSx1Cp1ux1Txe7rX9cGBGnG/gFrzTuoP0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611196680; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rWsNbfno5eQmALjcQ0NugNktpINR/bP8vlBM0Vwjwe4=; b=cDVrY08VekA5SsU69haO7M5sw0NyFyTchZuzJKGRIEfBztQz0uuFS+cd/fzV3n/FxZlVb+4XCKNSqk1Fj/TDgJfzEpPRMiM/DcXrr3mDueVmC5VEIb/uyKyEsfj/QpoHcklhJ9dTMyrONQEO5xrg1AET5x965x+/mlVyLAXmSnQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1611196680051459.5642033876452; Wed, 20 Jan 2021 18:38:00 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.71861.129036 (Exim 4.92) (envelope-from ) id 1l2Pqc-0000FK-JF; Thu, 21 Jan 2021 02:37:22 +0000 Received: by outflank-mailman (output) from mailman id 71861.129036; Thu, 21 Jan 2021 02:37:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l2Pqc-0000FC-E1; Thu, 21 Jan 2021 02:37:22 +0000 Received: by outflank-mailman (input) for mailman id 71861; Thu, 21 Jan 2021 02:37:21 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l2Pqb-0000F7-IC for xen-devel@lists.xenproject.org; Thu, 21 Jan 2021 02:37:21 +0000 Received: from us-smtp-delivery-124.mimecast.com (unknown [63.128.21.124]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 98fea4ce-4cbe-4294-a99e-d71fe66ba4e9; Thu, 21 Jan 2021 02:37:18 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-366-OmmbbNF5OmWTvn1XXuQuCw-1; Wed, 20 Jan 2021 21:37:16 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D68018030A3; Thu, 21 Jan 2021 02:37:14 +0000 (UTC) Received: from blue.redhat.com (ovpn-113-116.phx2.redhat.com [10.3.113.116]) by smtp.corp.redhat.com (Postfix) with ESMTP id C9A085D764; Thu, 21 Jan 2021 02:37:02 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 98fea4ce-4cbe-4294-a99e-d71fe66ba4e9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611196638; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rWsNbfno5eQmALjcQ0NugNktpINR/bP8vlBM0Vwjwe4=; b=i9aeznTA3v25zkraHXqGWlY1cda4vQQc0qYRjkRLlygXHUwPi0KxIOx5ViOcVd+4b0e5Xh wiDyMKijohNAQhrprsv+nW4/x6aZhfCb9cRSotGvbyH+cT0FsDGADQbWog/ujFWupFdDmU IX/Tycnbl0+UENXD4BIHVqJs2vWiS0g= X-MC-Unique: OmmbbNF5OmWTvn1XXuQuCw-1 From: Eric Blake To: qemu-devel@nongnu.org Cc: Sergio Lopez , Kevin Wolf , Stefan Hajnoczi , Max Reitz , Stefano Stabellini , Anthony Perard , Paul Durrant , Paolo Bonzini , Fam Zheng , "Michael S. Tsirkin" , qemu-block@nongnu.org (open list:virtio-blk), xen-devel@lists.xenproject.org (open list:X86 Xen CPUs) Subject: [PULL 03/13] block: Honor blk_set_aio_context() context requirements Date: Wed, 20 Jan 2021 20:36:47 -0600 Message-Id: <20210121023657.1186241-4-eblake@redhat.com> In-Reply-To: <20210121023657.1186241-1-eblake@redhat.com> References: <20210121023657.1186241-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=eblake@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Sergio Lopez The documentation for bdrv_set_aio_context_ignore() states this: * The caller must own the AioContext lock for the old AioContext of bs, bu= t it * must not own the AioContext lock for new_context (unless new_context is = the * same as the current context of bs). As blk_set_aio_context() makes use of this function, this rule also applies to it. Fix all occurrences where this rule wasn't honored. Suggested-by: Kevin Wolf Signed-off-by: Sergio Lopez Message-Id: <20201214170519.223781-2-slp@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Eric Blake --- hw/block/dataplane/virtio-blk.c | 4 ++++ hw/block/dataplane/xen-block.c | 7 ++++++- hw/scsi/virtio-scsi.c | 6 ++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-bl= k.c index 37499c556482..e9050c8987e7 100644 --- a/hw/block/dataplane/virtio-blk.c +++ b/hw/block/dataplane/virtio-blk.c @@ -172,6 +172,7 @@ int virtio_blk_data_plane_start(VirtIODevice *vdev) VirtIOBlockDataPlane *s =3D vblk->dataplane; BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(vblk))); VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); + AioContext *old_context; unsigned i; unsigned nvqs =3D s->conf->num_queues; Error *local_err =3D NULL; @@ -214,7 +215,10 @@ int virtio_blk_data_plane_start(VirtIODevice *vdev) vblk->dataplane_started =3D true; trace_virtio_blk_data_plane_start(s); + old_context =3D blk_get_aio_context(s->conf->conf.blk); + aio_context_acquire(old_context); r =3D blk_set_aio_context(s->conf->conf.blk, s->ctx, &local_err); + aio_context_release(old_context); if (r < 0) { error_report_err(local_err); goto fail_guest_notifiers; diff --git a/hw/block/dataplane/xen-block.c b/hw/block/dataplane/xen-block.c index 71c337c7b7e7..3675f8deaf9d 100644 --- a/hw/block/dataplane/xen-block.c +++ b/hw/block/dataplane/xen-block.c @@ -725,6 +725,7 @@ void xen_block_dataplane_start(XenBlockDataPlane *datap= lane, { ERRP_GUARD(); XenDevice *xendev =3D dataplane->xendev; + AioContext *old_context; unsigned int ring_size; unsigned int i; @@ -808,10 +809,14 @@ void xen_block_dataplane_start(XenBlockDataPlane *dat= aplane, goto stop; } - aio_context_acquire(dataplane->ctx); + old_context =3D blk_get_aio_context(dataplane->blk); + aio_context_acquire(old_context); /* If other users keep the BlockBackend in the iothread, that's ok */ blk_set_aio_context(dataplane->blk, dataplane->ctx, NULL); + aio_context_release(old_context); + /* Only reason for failure is a NULL channel */ + aio_context_acquire(dataplane->ctx); xen_device_set_event_channel_context(xendev, dataplane->event_channel, dataplane->ctx, &error_abort); aio_context_release(dataplane->ctx); diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index 9690bc63c860..99ff261cead1 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -849,15 +849,17 @@ static void virtio_scsi_hotplug(HotplugHandler *hotpl= ug_dev, DeviceState *dev, VirtIODevice *vdev =3D VIRTIO_DEVICE(hotplug_dev); VirtIOSCSI *s =3D VIRTIO_SCSI(vdev); SCSIDevice *sd =3D SCSI_DEVICE(dev); + AioContext *old_context; int ret; if (s->ctx && !s->dataplane_fenced) { if (blk_op_is_blocked(sd->conf.blk, BLOCK_OP_TYPE_DATAPLANE, errp)= ) { return; } - virtio_scsi_acquire(s); + old_context =3D blk_get_aio_context(sd->conf.blk); + aio_context_acquire(old_context); ret =3D blk_set_aio_context(sd->conf.blk, s->ctx, errp); - virtio_scsi_release(s); + aio_context_release(old_context); if (ret < 0) { return; } --=20 2.30.0