From nobody Sat May 3 10:50:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513956086556800.3865205898177; Fri, 22 Dec 2017 07:21:26 -0800 (PST) Received: from localhost ([::1]:54364 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1eSP8F-0006qb-2S for importer@patchew.org; Fri, 22 Dec 2017 10:21:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56714) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6B-0005Ft-1Q for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP69-0001pV-UB for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:18:58 -0500 Received: from mx1.redhat.com ([209.132.183.28]:26756) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP64-0001iP-UU; Fri, 22 Dec 2017 10:18:53 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E93A580476; Fri, 22 Dec 2017 15:18:51 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-107.ams2.redhat.com [10.36.117.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id CC6DE60C80; Fri, 22 Dec 2017 15:18:50 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Fri, 22 Dec 2017 16:18:12 +0100 Message-Id: <20171222151846.28110-2-kwolf@redhat.com> In-Reply-To: <20171222151846.28110-1-kwolf@redhat.com> References: <20171222151846.28110-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 22 Dec 2017 15:18:51 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 01/35] block: Formats don't need CONSISTENT_READ with NO_IO X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Commit 1f4ad7d fixed 'qemu-img info' for raw images that are currently in use as a mirror target. It is not enough for image formats, though, as these still unconditionally request BLK_PERM_CONSISTENT_READ. As this permission is geared towards whether the guest-visible data is consistent, and has no impact on whether the metadata is sane, and 'qemu-img info' does not read guest-visible data (except for the raw format), it makes sense to not require BLK_PERM_CONSISTENT_READ if there is not going to be any guest I/O performed, regardless of image format. Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- block.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index 1c37ce4554..db0be7ef36 100644 --- a/block.c +++ b/block.c @@ -1924,6 +1924,8 @@ void bdrv_format_default_perms(BlockDriverState *bs, = BdrvChild *c, assert(role =3D=3D &child_backing || role =3D=3D &child_file); =20 if (!backing) { + int flags =3D bdrv_reopen_get_flags(reopen_queue, bs); + /* Apart from the modifications below, the same permissions are * forwarded and left alone as for filters */ bdrv_filter_default_perms(bs, c, role, reopen_queue, perm, shared, @@ -1936,7 +1938,9 @@ void bdrv_format_default_perms(BlockDriverState *bs, = BdrvChild *c, =20 /* bs->file always needs to be consistent because of the metadata.= We * can never allow other users to resize or write to it. */ - perm |=3D BLK_PERM_CONSISTENT_READ; + if (!(flags & BDRV_O_NO_IO)) { + perm |=3D BLK_PERM_CONSISTENT_READ; + } shared &=3D ~(BLK_PERM_WRITE | BLK_PERM_RESIZE); } else { /* We want consistent read from backing files if the parent needs = it. --=20 2.13.6 From nobody Sat May 3 10:50:33 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513956086494216.7914028146372; Fri, 22 Dec 2017 07:21:26 -0800 (PST) Received: from localhost ([::1]:54365 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1eSP8K-0006wB-LK for importer@patchew.org; Fri, 22 Dec 2017 10:21:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56706) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6A-0005Fd-Q3 for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:18:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP69-0001pA-Pr for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:18:58 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46734) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP66-0001kK-R7; Fri, 22 Dec 2017 10:18:54 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CF0FFC0586A2; Fri, 22 Dec 2017 15:18:53 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-107.ams2.redhat.com [10.36.117.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id AF7EC60C80; Fri, 22 Dec 2017 15:18:52 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Fri, 22 Dec 2017 16:18:13 +0100 Message-Id: <20171222151846.28110-3-kwolf@redhat.com> In-Reply-To: <20171222151846.28110-1-kwolf@redhat.com> References: <20171222151846.28110-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 22 Dec 2017 15:18:53 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 02/35] iotests: fix 197 for vpc X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: John Snow <jsnow@redhat.com> VPC has some difficulty creating geometries of particular size. However, we can indeed force it to use a literal one, so let's do that for the sake of test 197, which is testing some specific offsets. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Luk=C3=A1=C5=A1 Doktor <ldoktor@redhat.com> --- tests/qemu-iotests/197 | 4 ++++ tests/qemu-iotests/common.filter | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/qemu-iotests/197 b/tests/qemu-iotests/197 index 887eb4f496..5e869fe2b7 100755 --- a/tests/qemu-iotests/197 +++ b/tests/qemu-iotests/197 @@ -60,6 +60,10 @@ echo '=3D=3D=3D Copy-on-read =3D=3D=3D' echo =20 # Prep the images +# VPC rounds image sizes to a specific geometry, force a specific size. +if [ "$IMGFMT" =3D "vpc" ]; then + IMGOPTS=3D$(_optstr_add "$IMGOPTS" "force_size") +fi _make_test_img 4G $QEMU_IO -c "write -P 55 3G 1k" "$TEST_IMG" | _filter_qemu_io IMGPROTO=3Dfile IMGFMT=3Dqcow2 IMGOPTS=3D TEST_IMG_FILE=3D"$TEST_WRAP" \ diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.f= ilter index d9237799e9..f08248bfd9 100644 --- a/tests/qemu-iotests/common.filter +++ b/tests/qemu-iotests/common.filter @@ -134,7 +134,8 @@ _filter_img_create() -e "s# log_size=3D[0-9]\\+##g" \ -e "s# refcount_bits=3D[0-9]\\+##g" \ -e "s# key-secret=3D[a-zA-Z0-9]\\+##g" \ - -e "s# iter-time=3D[0-9]\\+##g" + -e "s# iter-time=3D[0-9]\\+##g" \ + -e "s# force_size=3D\\(on\\|off\\)##g" } =20 _filter_img_info() --=20 2.13.6 From nobody Sat May 3 10:50:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513956269596128.3848103459717; Fri, 22 Dec 2017 07:24:29 -0800 (PST) Received: from localhost ([::1]:54393 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1eSPBL-00014U-Av for importer@patchew.org; Fri, 22 Dec 2017 10:24:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56796) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6D-0005Il-K1 for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6C-0001ti-ET for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54226) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP69-0001oD-ID; Fri, 22 Dec 2017 10:18:57 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BD4DE6016F; Fri, 22 Dec 2017 15:18:56 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-107.ams2.redhat.com [10.36.117.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2CB1160C80; Fri, 22 Dec 2017 15:18:54 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Fri, 22 Dec 2017 16:18:14 +0100 Message-Id: <20171222151846.28110-4-kwolf@redhat.com> In-Reply-To: <20171222151846.28110-1-kwolf@redhat.com> References: <20171222151846.28110-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 22 Dec 2017 15:18:56 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 03/35] block: Make bdrv_drain_invoke() recursive X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This change separates bdrv_drain_invoke(), which calls the BlockDriver drain callbacks, from bdrv_drain_recurse(). Instead, the function performs its own recursion now. One reason for this is that bdrv_drain_recurse() can be called multiple times by bdrv_drain_all_begin(), but the callbacks may only be called once. The separation is necessary to fix this bug. The other reason is that we intend to go to a model where we call all driver callbacks first, and only then start polling. This is not fully achieved yet with this patch, as bdrv_drain_invoke() contains a BDRV_POLL_WHILE() loop for the block driver callbacks, which can still call callbacks for any unrelated event. It's a step in this direction anyway. Cc: qemu-stable@nongnu.org Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> --- block/io.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/block/io.c b/block/io.c index 6773926fc1..096468b761 100644 --- a/block/io.c +++ b/block/io.c @@ -175,8 +175,10 @@ static void coroutine_fn bdrv_drain_invoke_entry(void = *opaque) bdrv_wakeup(bs); } =20 +/* Recursively call BlockDriver.bdrv_co_drain_begin/end callbacks */ static void bdrv_drain_invoke(BlockDriverState *bs, bool begin) { + BdrvChild *child, *tmp; BdrvCoDrainData data =3D { .bs =3D bs, .done =3D false, .begin =3D beg= in}; =20 if (!bs->drv || (begin && !bs->drv->bdrv_co_drain_begin) || @@ -187,6 +189,10 @@ static void bdrv_drain_invoke(BlockDriverState *bs, bo= ol begin) data.co =3D qemu_coroutine_create(bdrv_drain_invoke_entry, &data); bdrv_coroutine_enter(bs, data.co); BDRV_POLL_WHILE(bs, !data.done); + + QLIST_FOREACH_SAFE(child, &bs->children, next, tmp) { + bdrv_drain_invoke(child->bs, begin); + } } =20 static bool bdrv_drain_recurse(BlockDriverState *bs, bool begin) @@ -194,9 +200,6 @@ static bool bdrv_drain_recurse(BlockDriverState *bs, bo= ol begin) BdrvChild *child, *tmp; bool waited; =20 - /* Ensure any pending metadata writes are submitted to bs->file. */ - bdrv_drain_invoke(bs, begin); - /* Wait for drained requests to finish */ waited =3D BDRV_POLL_WHILE(bs, atomic_read(&bs->in_flight) > 0); =20 @@ -279,6 +282,7 @@ void bdrv_drained_begin(BlockDriverState *bs) bdrv_parent_drained_begin(bs); } =20 + bdrv_drain_invoke(bs, true); bdrv_drain_recurse(bs, true); } =20 @@ -294,6 +298,7 @@ void bdrv_drained_end(BlockDriverState *bs) } =20 bdrv_parent_drained_end(bs); + bdrv_drain_invoke(bs, false); bdrv_drain_recurse(bs, false); aio_enable_external(bdrv_get_aio_context(bs)); } @@ -372,6 +377,8 @@ void bdrv_drain_all_begin(void) aio_context_acquire(aio_context); for (bs =3D bdrv_first(&it); bs; bs =3D bdrv_next(&it)) { if (aio_context =3D=3D bdrv_get_aio_context(bs)) { + /* FIXME Calling this multiple times is wrong */ + bdrv_drain_invoke(bs, true); waited |=3D bdrv_drain_recurse(bs, true); } } @@ -393,6 +400,7 @@ void bdrv_drain_all_end(void) aio_context_acquire(aio_context); aio_enable_external(aio_context); bdrv_parent_drained_end(bs); + bdrv_drain_invoke(bs, false); bdrv_drain_recurse(bs, false); aio_context_release(aio_context); } --=20 2.13.6 From nobody Sat May 3 10:50:33 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513956274516252.30492511665852; Fri, 22 Dec 2017 07:24:34 -0800 (PST) Received: from localhost ([::1]:54394 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1eSPBO-00017A-BA for importer@patchew.org; Fri, 22 Dec 2017 10:24:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56822) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6E-0005JS-56 for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6D-0001vY-AX for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54230) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6B-0001q0-0J; Fri, 22 Dec 2017 10:18:59 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3A5C260161; Fri, 22 Dec 2017 15:18:58 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-107.ams2.redhat.com [10.36.117.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1BC2151DF4; Fri, 22 Dec 2017 15:18:56 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Fri, 22 Dec 2017 16:18:15 +0100 Message-Id: <20171222151846.28110-5-kwolf@redhat.com> In-Reply-To: <20171222151846.28110-1-kwolf@redhat.com> References: <20171222151846.28110-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 22 Dec 2017 15:18:58 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 04/35] block: Call .drain_begin only once in bdrv_drain_all_begin() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" bdrv_drain_all_begin() used to call the .bdrv_co_drain_begin() driver callback inside its polling loop. This means that how many times it got called for each node depended on long it had to poll the event loop. This is obviously not right and results in nodes that stay drained even after bdrv_drain_all_end(), which calls .bdrv_co_drain_begin() once per node. Fix bdrv_drain_all_begin() to call the callback only once, too. Cc: qemu-stable@nongnu.org Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> --- block/io.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/block/io.c b/block/io.c index 096468b761..603f5b059e 100644 --- a/block/io.c +++ b/block/io.c @@ -355,6 +355,7 @@ void bdrv_drain_all_begin(void) aio_context_acquire(aio_context); bdrv_parent_drained_begin(bs); aio_disable_external(aio_context); + bdrv_drain_invoke(bs, true); aio_context_release(aio_context); =20 if (!g_slist_find(aio_ctxs, aio_context)) { @@ -377,8 +378,6 @@ void bdrv_drain_all_begin(void) aio_context_acquire(aio_context); for (bs =3D bdrv_first(&it); bs; bs =3D bdrv_next(&it)) { if (aio_context =3D=3D bdrv_get_aio_context(bs)) { - /* FIXME Calling this multiple times is wrong */ - bdrv_drain_invoke(bs, true); waited |=3D bdrv_drain_recurse(bs, true); } } --=20 2.13.6 From nobody Sat May 3 10:50:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513956473248562.7055253555217; Fri, 22 Dec 2017 07:27:53 -0800 (PST) Received: from localhost ([::1]:54426 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1eSPEi-00049f-4V for importer@patchew.org; Fri, 22 Dec 2017 10:27:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56926) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6J-0005PF-Ue for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6I-000235-Cr for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:07 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54250) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6C-0001sn-F9; Fri, 22 Dec 2017 10:19:00 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AC87860161; Fri, 22 Dec 2017 15:18:59 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-107.ams2.redhat.com [10.36.117.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E00F60C80; Fri, 22 Dec 2017 15:18:58 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Fri, 22 Dec 2017 16:18:16 +0100 Message-Id: <20171222151846.28110-6-kwolf@redhat.com> In-Reply-To: <20171222151846.28110-1-kwolf@redhat.com> References: <20171222151846.28110-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 22 Dec 2017 15:18:59 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 05/35] test-bdrv-drain: Test BlockDriver callbacks for drain X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This adds a test case that the BlockDriver callbacks for drain are called in bdrv_drained_all_begin/end(), and that both of them are called exactly once. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> --- tests/test-bdrv-drain.c | 137 ++++++++++++++++++++++++++++++++++++++++++++= ++++ tests/Makefile.include | 2 + 2 files changed, 139 insertions(+) create mode 100644 tests/test-bdrv-drain.c diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c new file mode 100644 index 0000000000..0e567e34ba --- /dev/null +++ b/tests/test-bdrv-drain.c @@ -0,0 +1,137 @@ +/* + * Block node draining tests + * + * Copyright (c) 2017 Kevin Wolf <kwolf@redhat.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#include "qemu/osdep.h" +#include "block/block.h" +#include "sysemu/block-backend.h" +#include "qapi/error.h" + +typedef struct BDRVTestState { + int drain_count; +} BDRVTestState; + +static void coroutine_fn bdrv_test_co_drain_begin(BlockDriverState *bs) +{ + BDRVTestState *s =3D bs->opaque; + s->drain_count++; +} + +static void coroutine_fn bdrv_test_co_drain_end(BlockDriverState *bs) +{ + BDRVTestState *s =3D bs->opaque; + s->drain_count--; +} + +static void bdrv_test_close(BlockDriverState *bs) +{ + BDRVTestState *s =3D bs->opaque; + g_assert_cmpint(s->drain_count, >, 0); +} + +static int coroutine_fn bdrv_test_co_preadv(BlockDriverState *bs, + uint64_t offset, uint64_t byte= s, + QEMUIOVector *qiov, int flags) +{ + /* We want this request to stay until the polling loop in drain waits = for + * it to complete. We need to sleep a while as bdrv_drain_invoke() com= es + * first and polls its result, too, but it shouldn't accidentally comp= lete + * this request yet. */ + qemu_co_sleep_ns(QEMU_CLOCK_REALTIME, 100000); + + return 0; +} + +static BlockDriver bdrv_test =3D { + .format_name =3D "test", + .instance_size =3D sizeof(BDRVTestState), + + .bdrv_close =3D bdrv_test_close, + .bdrv_co_preadv =3D bdrv_test_co_preadv, + + .bdrv_co_drain_begin =3D bdrv_test_co_drain_begin, + .bdrv_co_drain_end =3D bdrv_test_co_drain_end, +}; + +static void aio_ret_cb(void *opaque, int ret) +{ + int *aio_ret =3D opaque; + *aio_ret =3D ret; +} + +static void test_drv_cb_drain_all(void) +{ + BlockBackend *blk; + BlockDriverState *bs; + BDRVTestState *s; + BlockAIOCB *acb; + int aio_ret; + + QEMUIOVector qiov; + struct iovec iov =3D { + .iov_base =3D NULL, + .iov_len =3D 0, + }; + qemu_iovec_init_external(&qiov, &iov, 1); + + blk =3D blk_new(BLK_PERM_ALL, BLK_PERM_ALL); + bs =3D bdrv_new_open_driver(&bdrv_test, "test-node", BDRV_O_RDWR, + &error_abort); + s =3D bs->opaque; + blk_insert_bs(blk, bs, &error_abort); + + /* Simple bdrv_drain_all_begin/end pair, check that CBs are called */ + g_assert_cmpint(s->drain_count, =3D=3D, 0); + bdrv_drain_all_begin(); + g_assert_cmpint(s->drain_count, =3D=3D, 1); + bdrv_drain_all_end(); + g_assert_cmpint(s->drain_count, =3D=3D, 0); + + /* Now do the same while a request is pending */ + aio_ret =3D -EINPROGRESS; + acb =3D blk_aio_preadv(blk, 0, &qiov, 0, aio_ret_cb, &aio_ret); + g_assert(acb !=3D NULL); + g_assert_cmpint(aio_ret, =3D=3D, -EINPROGRESS); + + g_assert_cmpint(s->drain_count, =3D=3D, 0); + bdrv_drain_all_begin(); + g_assert_cmpint(aio_ret, =3D=3D, 0); + g_assert_cmpint(s->drain_count, =3D=3D, 1); + bdrv_drain_all_end(); + g_assert_cmpint(s->drain_count, =3D=3D, 0); + + bdrv_unref(bs); + blk_unref(blk); +} + +int main(int argc, char **argv) +{ + bdrv_init(); + qemu_init_main_loop(&error_abort); + + g_test_init(&argc, &argv, NULL); + + g_test_add_func("/bdrv-drain/driver-cb/drain_all", test_drv_cb_drain_a= ll); + + return g_test_run(); +} diff --git a/tests/Makefile.include b/tests/Makefile.include index 77f8183117..39a4b5359d 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -80,6 +80,7 @@ gcov-files-test-thread-pool-y =3D thread-pool.c gcov-files-test-hbitmap-y =3D util/hbitmap.c check-unit-y +=3D tests/test-hbitmap$(EXESUF) gcov-files-test-hbitmap-y =3D blockjob.c +check-unit-y +=3D tests/test-bdrv-drain$(EXESUF) check-unit-y +=3D tests/test-blockjob$(EXESUF) check-unit-y +=3D tests/test-blockjob-txn$(EXESUF) check-unit-y +=3D tests/test-x86-cpuid$(EXESUF) @@ -595,6 +596,7 @@ tests/test-coroutine$(EXESUF): tests/test-coroutine.o $= (test-block-obj-y) tests/test-aio$(EXESUF): tests/test-aio.o $(test-block-obj-y) tests/test-aio-multithread$(EXESUF): tests/test-aio-multithread.o $(test-b= lock-obj-y) tests/test-throttle$(EXESUF): tests/test-throttle.o $(test-block-obj-y) +tests/test-bdrv-drain$(EXESUF): tests/test-bdrv-drain.o $(test-block-obj-y= ) $(test-util-obj-y) tests/test-blockjob$(EXESUF): tests/test-blockjob.o $(test-block-obj-y) $(= test-util-obj-y) tests/test-blockjob-txn$(EXESUF): tests/test-blockjob-txn.o $(test-block-o= bj-y) $(test-util-obj-y) tests/test-thread-pool$(EXESUF): tests/test-thread-pool.o $(test-block-obj= -y) --=20 2.13.6 From nobody Sat May 3 10:50:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513956449353562.5849020494571; Fri, 22 Dec 2017 07:27:29 -0800 (PST) Received: from localhost ([::1]:54419 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1eSPE2-0003X4-4G for importer@patchew.org; Fri, 22 Dec 2017 10:27:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56946) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6K-0005Pz-Ga for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6J-00025G-Dt for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40632) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6D-0001vk-Vv; Fri, 22 Dec 2017 10:19:02 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 27EBD2C9711; Fri, 22 Dec 2017 15:19:01 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-107.ams2.redhat.com [10.36.117.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0AFF160C80; Fri, 22 Dec 2017 15:18:59 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Fri, 22 Dec 2017 16:18:17 +0100 Message-Id: <20171222151846.28110-7-kwolf@redhat.com> In-Reply-To: <20171222151846.28110-1-kwolf@redhat.com> References: <20171222151846.28110-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 22 Dec 2017 15:19:01 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 06/35] block: bdrv_drain_recurse(): Remove unused begin parameter X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Now that the bdrv_drain_invoke() calls are pulled up to the callers of bdrv_drain_recurse(), the 'begin' parameter isn't needed any more. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> --- block/io.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/block/io.c b/block/io.c index 603f5b059e..390d463c71 100644 --- a/block/io.c +++ b/block/io.c @@ -195,7 +195,7 @@ static void bdrv_drain_invoke(BlockDriverState *bs, boo= l begin) } } =20 -static bool bdrv_drain_recurse(BlockDriverState *bs, bool begin) +static bool bdrv_drain_recurse(BlockDriverState *bs) { BdrvChild *child, *tmp; bool waited; @@ -218,7 +218,7 @@ static bool bdrv_drain_recurse(BlockDriverState *bs, bo= ol begin) */ bdrv_ref(bs); } - waited |=3D bdrv_drain_recurse(bs, begin); + waited |=3D bdrv_drain_recurse(bs); if (in_main_loop) { bdrv_unref(bs); } @@ -283,7 +283,7 @@ void bdrv_drained_begin(BlockDriverState *bs) } =20 bdrv_drain_invoke(bs, true); - bdrv_drain_recurse(bs, true); + bdrv_drain_recurse(bs); } =20 void bdrv_drained_end(BlockDriverState *bs) @@ -299,7 +299,7 @@ void bdrv_drained_end(BlockDriverState *bs) =20 bdrv_parent_drained_end(bs); bdrv_drain_invoke(bs, false); - bdrv_drain_recurse(bs, false); + bdrv_drain_recurse(bs); aio_enable_external(bdrv_get_aio_context(bs)); } =20 @@ -378,7 +378,7 @@ void bdrv_drain_all_begin(void) aio_context_acquire(aio_context); for (bs =3D bdrv_first(&it); bs; bs =3D bdrv_next(&it)) { if (aio_context =3D=3D bdrv_get_aio_context(bs)) { - waited |=3D bdrv_drain_recurse(bs, true); + waited |=3D bdrv_drain_recurse(bs); } } aio_context_release(aio_context); @@ -400,7 +400,7 @@ void bdrv_drain_all_end(void) aio_enable_external(aio_context); bdrv_parent_drained_end(bs); bdrv_drain_invoke(bs, false); - bdrv_drain_recurse(bs, false); + bdrv_drain_recurse(bs); aio_context_release(aio_context); } =20 --=20 2.13.6 From nobody Sat May 3 10:50:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513956091961511.32760260988573; Fri, 22 Dec 2017 07:21:31 -0800 (PST) Received: from localhost ([::1]:54367 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1eSP8Z-0007Ao-Ha for importer@patchew.org; Fri, 22 Dec 2017 10:21:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56942) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6K-0005Pg-BT for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6J-00025L-GA for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46780) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6F-0001xO-EL; Fri, 22 Dec 2017 10:19:03 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 97706C0733FB; Fri, 22 Dec 2017 15:19:02 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-107.ams2.redhat.com [10.36.117.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 79FB460C80; Fri, 22 Dec 2017 15:19:01 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Fri, 22 Dec 2017 16:18:18 +0100 Message-Id: <20171222151846.28110-8-kwolf@redhat.com> In-Reply-To: <20171222151846.28110-1-kwolf@redhat.com> References: <20171222151846.28110-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 22 Dec 2017 15:19:02 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 07/35] block: Don't wait for requests in bdrv_drain*_end() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The device is drained, so there is no point in waiting for requests at the end of the drained section. Remove the bdrv_drain_recurse() calls there. The bdrv_drain_recurse() calls were introduced in commit 481cad48e5e in order to call the .bdrv_co_drain_end() driver callback. This is now done by a separate bdrv_drain_invoke() call. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> --- block/io.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/block/io.c b/block/io.c index 390d463c71..5fdb92a15e 100644 --- a/block/io.c +++ b/block/io.c @@ -299,7 +299,6 @@ void bdrv_drained_end(BlockDriverState *bs) =20 bdrv_parent_drained_end(bs); bdrv_drain_invoke(bs, false); - bdrv_drain_recurse(bs); aio_enable_external(bdrv_get_aio_context(bs)); } =20 @@ -400,7 +399,6 @@ void bdrv_drain_all_end(void) aio_enable_external(aio_context); bdrv_parent_drained_end(bs); bdrv_drain_invoke(bs, false); - bdrv_drain_recurse(bs); aio_context_release(aio_context); } =20 --=20 2.13.6 From nobody Sat May 3 10:50:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513956264477403.0819721295584; Fri, 22 Dec 2017 07:24:24 -0800 (PST) Received: from localhost ([::1]:54392 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1eSPBL-00014Q-87 for importer@patchew.org; Fri, 22 Dec 2017 10:24:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56947) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6K-0005Q2-Gl for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6J-00025Q-HT for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45416) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6G-0001z3-TH; Fri, 22 Dec 2017 10:19:05 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 167CA80469; Fri, 22 Dec 2017 15:19:04 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-107.ams2.redhat.com [10.36.117.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id EA63960C80; Fri, 22 Dec 2017 15:19:02 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Fri, 22 Dec 2017 16:18:19 +0100 Message-Id: <20171222151846.28110-9-kwolf@redhat.com> In-Reply-To: <20171222151846.28110-1-kwolf@redhat.com> References: <20171222151846.28110-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 22 Dec 2017 15:19:04 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 08/35] block: Unify order in drain functions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Drain requests are propagated to child nodes, parent nodes and directly to the AioContext. The order in which this happened was different between all combinations of drain/drain_all and begin/end. The correct order is to keep children only drained when their parents are also drained. This means that at the start of a drained section, the AioContext needs to be drained first, the parents second and only then the children. The correct order for the end of a drained section is the opposite. This patch changes the three other functions to follow the example of bdrv_drained_begin(), which is the only one that got it right. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> --- block/io.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/block/io.c b/block/io.c index 5fdb92a15e..1e92d2e5b2 100644 --- a/block/io.c +++ b/block/io.c @@ -277,6 +277,7 @@ void bdrv_drained_begin(BlockDriverState *bs) return; } =20 + /* Stop things in parent-to-child order */ if (atomic_fetch_inc(&bs->quiesce_counter) =3D=3D 0) { aio_disable_external(bdrv_get_aio_context(bs)); bdrv_parent_drained_begin(bs); @@ -297,8 +298,9 @@ void bdrv_drained_end(BlockDriverState *bs) return; } =20 - bdrv_parent_drained_end(bs); + /* Re-enable things in child-to-parent order */ bdrv_drain_invoke(bs, false); + bdrv_parent_drained_end(bs); aio_enable_external(bdrv_get_aio_context(bs)); } =20 @@ -351,9 +353,10 @@ void bdrv_drain_all_begin(void) for (bs =3D bdrv_first(&it); bs; bs =3D bdrv_next(&it)) { AioContext *aio_context =3D bdrv_get_aio_context(bs); =20 + /* Stop things in parent-to-child order */ aio_context_acquire(aio_context); - bdrv_parent_drained_begin(bs); aio_disable_external(aio_context); + bdrv_parent_drained_begin(bs); bdrv_drain_invoke(bs, true); aio_context_release(aio_context); =20 @@ -395,10 +398,11 @@ void bdrv_drain_all_end(void) for (bs =3D bdrv_first(&it); bs; bs =3D bdrv_next(&it)) { AioContext *aio_context =3D bdrv_get_aio_context(bs); =20 + /* Re-enable things in child-to-parent order */ aio_context_acquire(aio_context); - aio_enable_external(aio_context); - bdrv_parent_drained_end(bs); bdrv_drain_invoke(bs, false); + bdrv_parent_drained_end(bs); + aio_enable_external(aio_context); aio_context_release(aio_context); } =20 --=20 2.13.6 From nobody Sat May 3 10:50:33 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513956444345939.715139165692; Fri, 22 Dec 2017 07:27:24 -0800 (PST) Received: from localhost ([::1]:54420 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1eSPE4-0003Zh-SZ for importer@patchew.org; Fri, 22 Dec 2017 10:27:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57018) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6O-0005V0-E7 for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6K-00026t-Hk for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:12 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60072) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6I-00021Y-Cg; Fri, 22 Dec 2017 10:19:06 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9630A25C38; Fri, 22 Dec 2017 15:19:05 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-107.ams2.redhat.com [10.36.117.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 67AB360C80; Fri, 22 Dec 2017 15:19:04 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Fri, 22 Dec 2017 16:18:20 +0100 Message-Id: <20171222151846.28110-10-kwolf@redhat.com> In-Reply-To: <20171222151846.28110-1-kwolf@redhat.com> References: <20171222151846.28110-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 22 Dec 2017 15:19:05 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 09/35] block: Don't acquire AioContext in hmp_qemu_io() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Commit 15afd94a047 added code to acquire and release the AioContext in qemuio_command(). This means that the lock is taken twice now in the call path from hmp_qemu_io(). This causes BDRV_POLL_WHILE() to hang for any requests issued to nodes in a non-mainloop AioContext. Dropping the first locking from hmp_qemu_io() fixes the problem. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> --- hmp.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/hmp.c b/hmp.c index 35a7041824..2d72f94193 100644 --- a/hmp.c +++ b/hmp.c @@ -2318,7 +2318,6 @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict) { BlockBackend *blk; BlockBackend *local_blk =3D NULL; - AioContext *aio_context; const char* device =3D qdict_get_str(qdict, "device"); const char* command =3D qdict_get_str(qdict, "command"); Error *err =3D NULL; @@ -2338,9 +2337,6 @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict) } } =20 - aio_context =3D blk_get_aio_context(blk); - aio_context_acquire(aio_context); - /* * Notably absent: Proper permission management. This is sad, but it s= eems * almost impossible to achieve without changing the semantics and the= reby @@ -2368,8 +2364,6 @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict) */ qemuio_command(blk, command); =20 - aio_context_release(aio_context); - fail: blk_unref(local_blk); hmp_handle_error(mon, &err); --=20 2.13.6 From nobody Sat May 3 10:50:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513956602364923.8597806861592; Fri, 22 Dec 2017 07:30:02 -0800 (PST) Received: from localhost ([::1]:54447 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1eSPGp-00062t-At for importer@patchew.org; Fri, 22 Dec 2017 10:29:59 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57005) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6N-0005UR-Sy for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6M-00028w-Jd for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:11 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46826) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6J-00024z-Pc; Fri, 22 Dec 2017 10:19:07 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 11AE2C07DEBE; Fri, 22 Dec 2017 15:19:07 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-107.ams2.redhat.com [10.36.117.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id E8BB160CA9; Fri, 22 Dec 2017 15:19:05 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Fri, 22 Dec 2017 16:18:21 +0100 Message-Id: <20171222151846.28110-11-kwolf@redhat.com> In-Reply-To: <20171222151846.28110-1-kwolf@redhat.com> References: <20171222151846.28110-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 22 Dec 2017 15:19:07 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 10/35] qcow2: get rid of qcow2_backing_read1 routine X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Edgar Kaziakhmedov <edgar.kaziakhmedov@virtuozzo.com> Since bdrv_co_preadv does all neccessary checks including reading after the end of the backing file, avoid duplication of verification before bdrv_co_preadv call. Signed-off-by: Edgar Kaziakhmedov <edgar.kaziakhmedov@virtuozzo.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- block/qcow2.h | 3 --- block/qcow2.c | 51 ++++++++------------------------------------------- 2 files changed, 8 insertions(+), 46 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index 6f0ff15dd0..46c8cf44ec 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -528,9 +528,6 @@ uint32_t offset_to_reftable_index(BDRVQcow2State *s, ui= nt64_t offset) } =20 /* qcow2.c functions */ -int qcow2_backing_read1(BlockDriverState *bs, QEMUIOVector *qiov, - int64_t sector_num, int nb_sectors); - int64_t qcow2_refcount_metadata_size(int64_t clusters, size_t cluster_size, int refcount_order, bool generous_inc= rease, uint64_t *refblock_count); diff --git a/block/qcow2.c b/block/qcow2.c index 1914a940e5..4348b2c0c5 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1672,34 +1672,12 @@ static int64_t coroutine_fn qcow2_co_get_block_stat= us(BlockDriverState *bs, return status; } =20 -/* handle reading after the end of the backing file */ -int qcow2_backing_read1(BlockDriverState *bs, QEMUIOVector *qiov, - int64_t offset, int bytes) -{ - uint64_t bs_size =3D bs->total_sectors * BDRV_SECTOR_SIZE; - int n1; - - if ((offset + bytes) <=3D bs_size) { - return bytes; - } - - if (offset >=3D bs_size) { - n1 =3D 0; - } else { - n1 =3D bs_size - offset; - } - - qemu_iovec_memset(qiov, n1, 0, bytes - n1); - - return n1; -} - static coroutine_fn int qcow2_co_preadv(BlockDriverState *bs, uint64_t off= set, uint64_t bytes, QEMUIOVector *qiov, int flags) { BDRVQcow2State *s =3D bs->opaque; - int offset_in_cluster, n1; + int offset_in_cluster; int ret; unsigned int cur_bytes; /* number of bytes in current iteration */ uint64_t cluster_offset =3D 0; @@ -1734,26 +1712,13 @@ static coroutine_fn int qcow2_co_preadv(BlockDriver= State *bs, uint64_t offset, case QCOW2_CLUSTER_UNALLOCATED: =20 if (bs->backing) { - /* read from the base image */ - n1 =3D qcow2_backing_read1(bs->backing->bs, &hd_qiov, - offset, cur_bytes); - if (n1 > 0) { - QEMUIOVector local_qiov; - - qemu_iovec_init(&local_qiov, hd_qiov.niov); - qemu_iovec_concat(&local_qiov, &hd_qiov, 0, n1); - - BLKDBG_EVENT(bs->file, BLKDBG_READ_BACKING_AIO); - qemu_co_mutex_unlock(&s->lock); - ret =3D bdrv_co_preadv(bs->backing, offset, n1, - &local_qiov, 0); - qemu_co_mutex_lock(&s->lock); - - qemu_iovec_destroy(&local_qiov); - - if (ret < 0) { - goto fail; - } + BLKDBG_EVENT(bs->file, BLKDBG_READ_BACKING_AIO); + qemu_co_mutex_unlock(&s->lock); + ret =3D bdrv_co_preadv(bs->backing, offset, cur_bytes, + &hd_qiov, 0); + qemu_co_mutex_lock(&s->lock); + if (ret < 0) { + goto fail; } } else { /* Note: in this case, no need to wait */ --=20 2.13.6 From nobody Sat May 3 10:50:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513956646714260.63771700801055; Fri, 22 Dec 2017 07:30:46 -0800 (PST) Received: from localhost ([::1]:54450 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1eSPHV-0006eC-JT for importer@patchew.org; Fri, 22 Dec 2017 10:30:41 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57101) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6W-0005eD-2E for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6S-0002GP-7V for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46840) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6M-00028h-RT; Fri, 22 Dec 2017 10:19:10 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0BB2BC0733FB; Fri, 22 Dec 2017 15:19:10 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-107.ams2.redhat.com [10.36.117.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6406F60C80; Fri, 22 Dec 2017 15:19:07 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Fri, 22 Dec 2017 16:18:22 +0100 Message-Id: <20171222151846.28110-12-kwolf@redhat.com> In-Reply-To: <20171222151846.28110-1-kwolf@redhat.com> References: <20171222151846.28110-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 22 Dec 2017 15:19:10 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 11/35] block: Document that x-blockdev-change breaks quorum children list X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Removing a quorum child node with x-blockdev-change results in a quorum driver state that cannot be recreated with create options because it would require a list with gaps. This causes trouble in at least .bdrv_refresh_filename(). Document this problem so that we won't accidentally mark the command stable without having addressed it. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Alberto Garcia <berto@igalia.com> --- qapi/block-core.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qapi/block-core.json b/qapi/block-core.json index a8cdbc300b..e94a6881b2 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -3918,6 +3918,10 @@ # does not support all kinds of operations, all kinds of children, nor # all block drivers. # +# FIXME Removing children from a quorum node means introducing gaps in the +# child indices. This cannot be represented in the 'children' list of +# BlockdevOptionsQuorum, as returned by .bdrv_refresh_filename(). +# # Warning: The data in a new quorum child MUST be consistent with that of # the rest of the array. # --=20 2.13.6 From nobody Sat May 3 10:50:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513956350954576.1601894923597; Fri, 22 Dec 2017 07:25:50 -0800 (PST) Received: from localhost ([::1]:54404 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1eSPCj-0002Gx-Hm for importer@patchew.org; Fri, 22 Dec 2017 10:25:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57214) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6b-0005jF-PN for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6X-0002Mi-Sl for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55718) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6P-0002CI-St; Fri, 22 Dec 2017 10:19:14 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1E650C05972A; Fri, 22 Dec 2017 15:19:13 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-107.ams2.redhat.com [10.36.117.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5EA4060C80; Fri, 22 Dec 2017 15:19:10 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Fri, 22 Dec 2017 16:18:23 +0100 Message-Id: <20171222151846.28110-13-kwolf@redhat.com> In-Reply-To: <20171222151846.28110-1-kwolf@redhat.com> References: <20171222151846.28110-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 22 Dec 2017 15:19:13 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 12/35] nvme: Add tracing X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Doug Gale <doug16k@gmail.com> Add trace output for commands, errors, and undefined behavior. Add guest error log output for undefined behavior. Report invalid undefined accesses to MMIO. Annotate unlikely error checks with unlikely. Signed-off-by: Doug Gale <doug16k@gmail.com> Reviewed-by: Philippe Mathieu-Daud=C3=A9 <f4bug@amsat.org> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- hw/block/nvme.c | 349 ++++++++++++++++++++++++++++++++++++++++++----= ---- hw/block/trace-events | 93 ++++++++++++++ 2 files changed, 390 insertions(+), 52 deletions(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index e529e88e4e..1ac356d3a5 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -34,8 +34,17 @@ #include "qapi/visitor.h" #include "sysemu/block-backend.h" =20 +#include "qemu/log.h" +#include "trace.h" #include "nvme.h" =20 +#define NVME_GUEST_ERR(trace, fmt, ...) \ + do { \ + (trace_##trace)(__VA_ARGS__); \ + qemu_log_mask(LOG_GUEST_ERROR, #trace \ + " in %s: " fmt "\n", __func__, ## __VA_ARGS__); \ + } while (0) + static void nvme_process_sq(void *opaque); =20 static void nvme_addr_read(NvmeCtrl *n, hwaddr addr, void *buf, int size) @@ -86,10 +95,14 @@ static void nvme_isr_notify(NvmeCtrl *n, NvmeCQueue *cq) { if (cq->irq_enabled) { if (msix_enabled(&(n->parent_obj))) { + trace_nvme_irq_msix(cq->vector); msix_notify(&(n->parent_obj), cq->vector); } else { + trace_nvme_irq_pin(); pci_irq_pulse(&n->parent_obj); } + } else { + trace_nvme_irq_masked(); } } =20 @@ -100,7 +113,8 @@ static uint16_t nvme_map_prp(QEMUSGList *qsg, QEMUIOVec= tor *iov, uint64_t prp1, trans_len =3D MIN(len, trans_len); int num_prps =3D (len >> n->page_bits) + 1; =20 - if (!prp1) { + if (unlikely(!prp1)) { + trace_nvme_err_invalid_prp(); return NVME_INVALID_FIELD | NVME_DNR; } else if (n->cmbsz && prp1 >=3D n->ctrl_mem.addr && prp1 < n->ctrl_mem.addr + int128_get64(n->ctrl_mem.size)) { @@ -113,7 +127,8 @@ static uint16_t nvme_map_prp(QEMUSGList *qsg, QEMUIOVec= tor *iov, uint64_t prp1, } len -=3D trans_len; if (len) { - if (!prp2) { + if (unlikely(!prp2)) { + trace_nvme_err_invalid_prp2_missing(); goto unmap; } if (len > n->page_size) { @@ -128,7 +143,8 @@ static uint16_t nvme_map_prp(QEMUSGList *qsg, QEMUIOVec= tor *iov, uint64_t prp1, uint64_t prp_ent =3D le64_to_cpu(prp_list[i]); =20 if (i =3D=3D n->max_prp_ents - 1 && len > n->page_size) { - if (!prp_ent || prp_ent & (n->page_size - 1)) { + if (unlikely(!prp_ent || prp_ent & (n->page_size - 1))= ) { + trace_nvme_err_invalid_prplist_ent(prp_ent); goto unmap; } =20 @@ -140,7 +156,8 @@ static uint16_t nvme_map_prp(QEMUSGList *qsg, QEMUIOVec= tor *iov, uint64_t prp1, prp_ent =3D le64_to_cpu(prp_list[i]); } =20 - if (!prp_ent || prp_ent & (n->page_size - 1)) { + if (unlikely(!prp_ent || prp_ent & (n->page_size - 1))) { + trace_nvme_err_invalid_prplist_ent(prp_ent); goto unmap; } =20 @@ -154,7 +171,8 @@ static uint16_t nvme_map_prp(QEMUSGList *qsg, QEMUIOVec= tor *iov, uint64_t prp1, i++; } } else { - if (prp2 & (n->page_size - 1)) { + if (unlikely(prp2 & (n->page_size - 1))) { + trace_nvme_err_invalid_prp2_align(prp2); goto unmap; } if (qsg->nsg) { @@ -178,16 +196,20 @@ static uint16_t nvme_dma_read_prp(NvmeCtrl *n, uint8_= t *ptr, uint32_t len, QEMUIOVector iov; uint16_t status =3D NVME_SUCCESS; =20 + trace_nvme_dma_read(prp1, prp2); + if (nvme_map_prp(&qsg, &iov, prp1, prp2, len, n)) { return NVME_INVALID_FIELD | NVME_DNR; } if (qsg.nsg > 0) { - if (dma_buf_read(ptr, len, &qsg)) { + if (unlikely(dma_buf_read(ptr, len, &qsg))) { + trace_nvme_err_invalid_dma(); status =3D NVME_INVALID_FIELD | NVME_DNR; } qemu_sglist_destroy(&qsg); } else { - if (qemu_iovec_to_buf(&iov, 0, ptr, len) !=3D len) { + if (unlikely(qemu_iovec_to_buf(&iov, 0, ptr, len) !=3D len)) { + trace_nvme_err_invalid_dma(); status =3D NVME_INVALID_FIELD | NVME_DNR; } qemu_iovec_destroy(&iov); @@ -273,7 +295,8 @@ static uint16_t nvme_write_zeros(NvmeCtrl *n, NvmeNames= pace *ns, NvmeCmd *cmd, uint64_t aio_slba =3D slba << (data_shift - BDRV_SECTOR_BITS); uint32_t aio_nlb =3D nlb << (data_shift - BDRV_SECTOR_BITS); =20 - if (slba + nlb > ns->id_ns.nsze) { + if (unlikely(slba + nlb > ns->id_ns.nsze)) { + trace_nvme_err_invalid_lba_range(slba, nlb, ns->id_ns.nsze); return NVME_LBA_RANGE | NVME_DNR; } =20 @@ -301,8 +324,11 @@ static uint16_t nvme_rw(NvmeCtrl *n, NvmeNamespace *ns= , NvmeCmd *cmd, int is_write =3D rw->opcode =3D=3D NVME_CMD_WRITE ? 1 : 0; enum BlockAcctType acct =3D is_write ? BLOCK_ACCT_WRITE : BLOCK_ACCT_R= EAD; =20 - if ((slba + nlb) > ns->id_ns.nsze) { + trace_nvme_rw(is_write ? "write" : "read", nlb, data_size, slba); + + if (unlikely((slba + nlb) > ns->id_ns.nsze)) { block_acct_invalid(blk_get_stats(n->conf.blk), acct); + trace_nvme_err_invalid_lba_range(slba, nlb, ns->id_ns.nsze); return NVME_LBA_RANGE | NVME_DNR; } =20 @@ -336,7 +362,8 @@ static uint16_t nvme_io_cmd(NvmeCtrl *n, NvmeCmd *cmd, = NvmeRequest *req) NvmeNamespace *ns; uint32_t nsid =3D le32_to_cpu(cmd->nsid); =20 - if (nsid =3D=3D 0 || nsid > n->num_namespaces) { + if (unlikely(nsid =3D=3D 0 || nsid > n->num_namespaces)) { + trace_nvme_err_invalid_ns(nsid, n->num_namespaces); return NVME_INVALID_NSID | NVME_DNR; } =20 @@ -350,6 +377,7 @@ static uint16_t nvme_io_cmd(NvmeCtrl *n, NvmeCmd *cmd, = NvmeRequest *req) case NVME_CMD_READ: return nvme_rw(n, ns, cmd, req); default: + trace_nvme_err_invalid_opc(cmd->opcode); return NVME_INVALID_OPCODE | NVME_DNR; } } @@ -373,10 +401,13 @@ static uint16_t nvme_del_sq(NvmeCtrl *n, NvmeCmd *cmd) NvmeCQueue *cq; uint16_t qid =3D le16_to_cpu(c->qid); =20 - if (!qid || nvme_check_sqid(n, qid)) { + if (unlikely(!qid || nvme_check_sqid(n, qid))) { + trace_nvme_err_invalid_del_sq(qid); return NVME_INVALID_QID | NVME_DNR; } =20 + trace_nvme_del_sq(qid); + sq =3D n->sq[qid]; while (!QTAILQ_EMPTY(&sq->out_req_list)) { req =3D QTAILQ_FIRST(&sq->out_req_list); @@ -439,19 +470,26 @@ static uint16_t nvme_create_sq(NvmeCtrl *n, NvmeCmd *= cmd) uint16_t qflags =3D le16_to_cpu(c->sq_flags); uint64_t prp1 =3D le64_to_cpu(c->prp1); =20 - if (!cqid || nvme_check_cqid(n, cqid)) { + trace_nvme_create_sq(prp1, sqid, cqid, qsize, qflags); + + if (unlikely(!cqid || nvme_check_cqid(n, cqid))) { + trace_nvme_err_invalid_create_sq_cqid(cqid); return NVME_INVALID_CQID | NVME_DNR; } - if (!sqid || !nvme_check_sqid(n, sqid)) { + if (unlikely(!sqid || !nvme_check_sqid(n, sqid))) { + trace_nvme_err_invalid_create_sq_sqid(sqid); return NVME_INVALID_QID | NVME_DNR; } - if (!qsize || qsize > NVME_CAP_MQES(n->bar.cap)) { + if (unlikely(!qsize || qsize > NVME_CAP_MQES(n->bar.cap))) { + trace_nvme_err_invalid_create_sq_size(qsize); return NVME_MAX_QSIZE_EXCEEDED | NVME_DNR; } - if (!prp1 || prp1 & (n->page_size - 1)) { + if (unlikely(!prp1 || prp1 & (n->page_size - 1))) { + trace_nvme_err_invalid_create_sq_addr(prp1); return NVME_INVALID_FIELD | NVME_DNR; } - if (!(NVME_SQ_FLAGS_PC(qflags))) { + if (unlikely(!(NVME_SQ_FLAGS_PC(qflags)))) { + trace_nvme_err_invalid_create_sq_qflags(NVME_SQ_FLAGS_PC(qflags)); return NVME_INVALID_FIELD | NVME_DNR; } sq =3D g_malloc0(sizeof(*sq)); @@ -476,14 +514,17 @@ static uint16_t nvme_del_cq(NvmeCtrl *n, NvmeCmd *cmd) NvmeCQueue *cq; uint16_t qid =3D le16_to_cpu(c->qid); =20 - if (!qid || nvme_check_cqid(n, qid)) { + if (unlikely(!qid || nvme_check_cqid(n, qid))) { + trace_nvme_err_invalid_del_cq_cqid(qid); return NVME_INVALID_CQID | NVME_DNR; } =20 cq =3D n->cq[qid]; - if (!QTAILQ_EMPTY(&cq->sq_list)) { + if (unlikely(!QTAILQ_EMPTY(&cq->sq_list))) { + trace_nvme_err_invalid_del_cq_notempty(qid); return NVME_INVALID_QUEUE_DEL; } + trace_nvme_del_cq(qid); nvme_free_cq(cq, n); return NVME_SUCCESS; } @@ -516,19 +557,27 @@ static uint16_t nvme_create_cq(NvmeCtrl *n, NvmeCmd *= cmd) uint16_t qflags =3D le16_to_cpu(c->cq_flags); uint64_t prp1 =3D le64_to_cpu(c->prp1); =20 - if (!cqid || !nvme_check_cqid(n, cqid)) { + trace_nvme_create_cq(prp1, cqid, vector, qsize, qflags, + NVME_CQ_FLAGS_IEN(qflags) !=3D 0); + + if (unlikely(!cqid || !nvme_check_cqid(n, cqid))) { + trace_nvme_err_invalid_create_cq_cqid(cqid); return NVME_INVALID_CQID | NVME_DNR; } - if (!qsize || qsize > NVME_CAP_MQES(n->bar.cap)) { + if (unlikely(!qsize || qsize > NVME_CAP_MQES(n->bar.cap))) { + trace_nvme_err_invalid_create_cq_size(qsize); return NVME_MAX_QSIZE_EXCEEDED | NVME_DNR; } - if (!prp1) { + if (unlikely(!prp1)) { + trace_nvme_err_invalid_create_cq_addr(prp1); return NVME_INVALID_FIELD | NVME_DNR; } - if (vector > n->num_queues) { + if (unlikely(vector > n->num_queues)) { + trace_nvme_err_invalid_create_cq_vector(vector); return NVME_INVALID_IRQ_VECTOR | NVME_DNR; } - if (!(NVME_CQ_FLAGS_PC(qflags))) { + if (unlikely(!(NVME_CQ_FLAGS_PC(qflags)))) { + trace_nvme_err_invalid_create_cq_qflags(NVME_CQ_FLAGS_PC(qflags)); return NVME_INVALID_FIELD | NVME_DNR; } =20 @@ -543,6 +592,8 @@ static uint16_t nvme_identify_ctrl(NvmeCtrl *n, NvmeIde= ntify *c) uint64_t prp1 =3D le64_to_cpu(c->prp1); uint64_t prp2 =3D le64_to_cpu(c->prp2); =20 + trace_nvme_identify_ctrl(); + return nvme_dma_read_prp(n, (uint8_t *)&n->id_ctrl, sizeof(n->id_ctrl), prp1, prp2); } @@ -554,11 +605,15 @@ static uint16_t nvme_identify_ns(NvmeCtrl *n, NvmeIde= ntify *c) uint64_t prp1 =3D le64_to_cpu(c->prp1); uint64_t prp2 =3D le64_to_cpu(c->prp2); =20 - if (nsid =3D=3D 0 || nsid > n->num_namespaces) { + trace_nvme_identify_ns(nsid); + + if (unlikely(nsid =3D=3D 0 || nsid > n->num_namespaces)) { + trace_nvme_err_invalid_ns(nsid, n->num_namespaces); return NVME_INVALID_NSID | NVME_DNR; } =20 ns =3D &n->namespaces[nsid - 1]; + return nvme_dma_read_prp(n, (uint8_t *)&ns->id_ns, sizeof(ns->id_ns), prp1, prp2); } @@ -573,6 +628,8 @@ static uint16_t nvme_identify_nslist(NvmeCtrl *n, NvmeI= dentify *c) uint16_t ret; int i, j =3D 0; =20 + trace_nvme_identify_nslist(min_nsid); + list =3D g_malloc0(data_len); for (i =3D 0; i < n->num_namespaces; i++) { if (i < min_nsid) { @@ -601,6 +658,7 @@ static uint16_t nvme_identify(NvmeCtrl *n, NvmeCmd *cmd) case 0x02: return nvme_identify_nslist(n, c); default: + trace_nvme_err_invalid_identify_cns(le32_to_cpu(c->cns)); return NVME_INVALID_FIELD | NVME_DNR; } } @@ -613,11 +671,14 @@ static uint16_t nvme_get_feature(NvmeCtrl *n, NvmeCmd= *cmd, NvmeRequest *req) switch (dw10) { case NVME_VOLATILE_WRITE_CACHE: result =3D blk_enable_write_cache(n->conf.blk); + trace_nvme_getfeat_vwcache(result ? "enabled" : "disabled"); break; case NVME_NUMBER_OF_QUEUES: result =3D cpu_to_le32((n->num_queues - 2) | ((n->num_queues - 2) = << 16)); + trace_nvme_getfeat_numq(result); break; default: + trace_nvme_err_invalid_getfeat(dw10); return NVME_INVALID_FIELD | NVME_DNR; } =20 @@ -635,10 +696,14 @@ static uint16_t nvme_set_feature(NvmeCtrl *n, NvmeCmd= *cmd, NvmeRequest *req) blk_set_enable_write_cache(n->conf.blk, dw11 & 1); break; case NVME_NUMBER_OF_QUEUES: + trace_nvme_setfeat_numq((dw11 & 0xFFFF) + 1, + ((dw11 >> 16) & 0xFFFF) + 1, + n->num_queues - 1, n->num_queues - 1); req->cqe.result =3D cpu_to_le32((n->num_queues - 2) | ((n->num_queues - 2) << 16)); break; default: + trace_nvme_err_invalid_setfeat(dw10); return NVME_INVALID_FIELD | NVME_DNR; } return NVME_SUCCESS; @@ -662,6 +727,7 @@ static uint16_t nvme_admin_cmd(NvmeCtrl *n, NvmeCmd *cm= d, NvmeRequest *req) case NVME_ADM_CMD_GET_FEATURES: return nvme_get_feature(n, cmd, req); default: + trace_nvme_err_invalid_admin_opc(cmd->opcode); return NVME_INVALID_OPCODE | NVME_DNR; } } @@ -721,15 +787,78 @@ static int nvme_start_ctrl(NvmeCtrl *n) uint32_t page_bits =3D NVME_CC_MPS(n->bar.cc) + 12; uint32_t page_size =3D 1 << page_bits; =20 - if (n->cq[0] || n->sq[0] || !n->bar.asq || !n->bar.acq || - n->bar.asq & (page_size - 1) || n->bar.acq & (page_size - 1) || - NVME_CC_MPS(n->bar.cc) < NVME_CAP_MPSMIN(n->bar.cap) || - NVME_CC_MPS(n->bar.cc) > NVME_CAP_MPSMAX(n->bar.cap) || - NVME_CC_IOCQES(n->bar.cc) < NVME_CTRL_CQES_MIN(n->id_ctrl.cqes= ) || - NVME_CC_IOCQES(n->bar.cc) > NVME_CTRL_CQES_MAX(n->id_ctrl.cqes= ) || - NVME_CC_IOSQES(n->bar.cc) < NVME_CTRL_SQES_MIN(n->id_ctrl.sqes= ) || - NVME_CC_IOSQES(n->bar.cc) > NVME_CTRL_SQES_MAX(n->id_ctrl.sqes= ) || - !NVME_AQA_ASQS(n->bar.aqa) || !NVME_AQA_ACQS(n->bar.aqa)) { + if (unlikely(n->cq[0])) { + trace_nvme_err_startfail_cq(); + return -1; + } + if (unlikely(n->sq[0])) { + trace_nvme_err_startfail_sq(); + return -1; + } + if (unlikely(!n->bar.asq)) { + trace_nvme_err_startfail_nbarasq(); + return -1; + } + if (unlikely(!n->bar.acq)) { + trace_nvme_err_startfail_nbaracq(); + return -1; + } + if (unlikely(n->bar.asq & (page_size - 1))) { + trace_nvme_err_startfail_asq_misaligned(n->bar.asq); + return -1; + } + if (unlikely(n->bar.acq & (page_size - 1))) { + trace_nvme_err_startfail_acq_misaligned(n->bar.acq); + return -1; + } + if (unlikely(NVME_CC_MPS(n->bar.cc) < + NVME_CAP_MPSMIN(n->bar.cap))) { + trace_nvme_err_startfail_page_too_small( + NVME_CC_MPS(n->bar.cc), + NVME_CAP_MPSMIN(n->bar.cap)); + return -1; + } + if (unlikely(NVME_CC_MPS(n->bar.cc) > + NVME_CAP_MPSMAX(n->bar.cap))) { + trace_nvme_err_startfail_page_too_large( + NVME_CC_MPS(n->bar.cc), + NVME_CAP_MPSMAX(n->bar.cap)); + return -1; + } + if (unlikely(NVME_CC_IOCQES(n->bar.cc) < + NVME_CTRL_CQES_MIN(n->id_ctrl.cqes))) { + trace_nvme_err_startfail_cqent_too_small( + NVME_CC_IOCQES(n->bar.cc), + NVME_CTRL_CQES_MIN(n->bar.cap)); + return -1; + } + if (unlikely(NVME_CC_IOCQES(n->bar.cc) > + NVME_CTRL_CQES_MAX(n->id_ctrl.cqes))) { + trace_nvme_err_startfail_cqent_too_large( + NVME_CC_IOCQES(n->bar.cc), + NVME_CTRL_CQES_MAX(n->bar.cap)); + return -1; + } + if (unlikely(NVME_CC_IOSQES(n->bar.cc) < + NVME_CTRL_SQES_MIN(n->id_ctrl.sqes))) { + trace_nvme_err_startfail_sqent_too_small( + NVME_CC_IOSQES(n->bar.cc), + NVME_CTRL_SQES_MIN(n->bar.cap)); + return -1; + } + if (unlikely(NVME_CC_IOSQES(n->bar.cc) > + NVME_CTRL_SQES_MAX(n->id_ctrl.sqes))) { + trace_nvme_err_startfail_sqent_too_large( + NVME_CC_IOSQES(n->bar.cc), + NVME_CTRL_SQES_MAX(n->bar.cap)); + return -1; + } + if (unlikely(!NVME_AQA_ASQS(n->bar.aqa))) { + trace_nvme_err_startfail_asqent_sz_zero(); + return -1; + } + if (unlikely(!NVME_AQA_ACQS(n->bar.aqa))) { + trace_nvme_err_startfail_acqent_sz_zero(); return -1; } =20 @@ -749,16 +878,48 @@ static int nvme_start_ctrl(NvmeCtrl *n) static void nvme_write_bar(NvmeCtrl *n, hwaddr offset, uint64_t data, unsigned size) { + if (unlikely(offset & (sizeof(uint32_t) - 1))) { + NVME_GUEST_ERR(nvme_ub_mmiowr_misaligned32, + "MMIO write not 32-bit aligned," + " offset=3D0x%"PRIx64"", offset); + /* should be ignored, fall through for now */ + } + + if (unlikely(size < sizeof(uint32_t))) { + NVME_GUEST_ERR(nvme_ub_mmiowr_toosmall, + "MMIO write smaller than 32-bits," + " offset=3D0x%"PRIx64", size=3D%u", + offset, size); + /* should be ignored, fall through for now */ + } + switch (offset) { - case 0xc: + case 0xc: /* INTMS */ + if (unlikely(msix_enabled(&(n->parent_obj)))) { + NVME_GUEST_ERR(nvme_ub_mmiowr_intmask_with_msix, + "undefined access to interrupt mask set" + " when MSI-X is enabled"); + /* should be ignored, fall through for now */ + } n->bar.intms |=3D data & 0xffffffff; n->bar.intmc =3D n->bar.intms; + trace_nvme_mmio_intm_set(data & 0xffffffff, + n->bar.intmc); break; - case 0x10: + case 0x10: /* INTMC */ + if (unlikely(msix_enabled(&(n->parent_obj)))) { + NVME_GUEST_ERR(nvme_ub_mmiowr_intmask_with_msix, + "undefined access to interrupt mask clr" + " when MSI-X is enabled"); + /* should be ignored, fall through for now */ + } n->bar.intms &=3D ~(data & 0xffffffff); n->bar.intmc =3D n->bar.intms; + trace_nvme_mmio_intm_clr(data & 0xffffffff, + n->bar.intmc); break; - case 0x14: + case 0x14: /* CC */ + trace_nvme_mmio_cfg(data & 0xffffffff); /* Windows first sends data, then sends enable bit */ if (!NVME_CC_EN(data) && !NVME_CC_EN(n->bar.cc) && !NVME_CC_SHN(data) && !NVME_CC_SHN(n->bar.cc)) @@ -768,40 +929,82 @@ static void nvme_write_bar(NvmeCtrl *n, hwaddr offset= , uint64_t data, =20 if (NVME_CC_EN(data) && !NVME_CC_EN(n->bar.cc)) { n->bar.cc =3D data; - if (nvme_start_ctrl(n)) { + if (unlikely(nvme_start_ctrl(n))) { + trace_nvme_err_startfail(); n->bar.csts =3D NVME_CSTS_FAILED; } else { + trace_nvme_mmio_start_success(); n->bar.csts =3D NVME_CSTS_READY; } } else if (!NVME_CC_EN(data) && NVME_CC_EN(n->bar.cc)) { + trace_nvme_mmio_stopped(); nvme_clear_ctrl(n); n->bar.csts &=3D ~NVME_CSTS_READY; } if (NVME_CC_SHN(data) && !(NVME_CC_SHN(n->bar.cc))) { - nvme_clear_ctrl(n); - n->bar.cc =3D data; - n->bar.csts |=3D NVME_CSTS_SHST_COMPLETE; + trace_nvme_mmio_shutdown_set(); + nvme_clear_ctrl(n); + n->bar.cc =3D data; + n->bar.csts |=3D NVME_CSTS_SHST_COMPLETE; } else if (!NVME_CC_SHN(data) && NVME_CC_SHN(n->bar.cc)) { - n->bar.csts &=3D ~NVME_CSTS_SHST_COMPLETE; - n->bar.cc =3D data; + trace_nvme_mmio_shutdown_cleared(); + n->bar.csts &=3D ~NVME_CSTS_SHST_COMPLETE; + n->bar.cc =3D data; + } + break; + case 0x1C: /* CSTS */ + if (data & (1 << 4)) { + NVME_GUEST_ERR(nvme_ub_mmiowr_ssreset_w1c_unsupported, + "attempted to W1C CSTS.NSSRO" + " but CAP.NSSRS is zero (not supported)"); + } else if (data !=3D 0) { + NVME_GUEST_ERR(nvme_ub_mmiowr_ro_csts, + "attempted to set a read only bit" + " of controller status"); + } + break; + case 0x20: /* NSSR */ + if (data =3D=3D 0x4E564D65) { + trace_nvme_ub_mmiowr_ssreset_unsupported(); + } else { + /* The spec says that writes of other values have no effect */ + return; } break; - case 0x24: + case 0x24: /* AQA */ n->bar.aqa =3D data & 0xffffffff; + trace_nvme_mmio_aqattr(data & 0xffffffff); break; - case 0x28: + case 0x28: /* ASQ */ n->bar.asq =3D data; + trace_nvme_mmio_asqaddr(data); break; - case 0x2c: + case 0x2c: /* ASQ hi */ n->bar.asq |=3D data << 32; + trace_nvme_mmio_asqaddr_hi(data, n->bar.asq); break; - case 0x30: + case 0x30: /* ACQ */ + trace_nvme_mmio_acqaddr(data); n->bar.acq =3D data; break; - case 0x34: + case 0x34: /* ACQ hi */ n->bar.acq |=3D data << 32; + trace_nvme_mmio_acqaddr_hi(data, n->bar.acq); break; + case 0x38: /* CMBLOC */ + NVME_GUEST_ERR(nvme_ub_mmiowr_cmbloc_reserved, + "invalid write to reserved CMBLOC" + " when CMBSZ is zero, ignored"); + return; + case 0x3C: /* CMBSZ */ + NVME_GUEST_ERR(nvme_ub_mmiowr_cmbsz_readonly, + "invalid write to read only CMBSZ, ignored"); + return; default: + NVME_GUEST_ERR(nvme_ub_mmiowr_invalid, + "invalid MMIO write," + " offset=3D0x%"PRIx64", data=3D%"PRIx64"", + offset, data); break; } } @@ -812,9 +1015,26 @@ static uint64_t nvme_mmio_read(void *opaque, hwaddr a= ddr, unsigned size) uint8_t *ptr =3D (uint8_t *)&n->bar; uint64_t val =3D 0; =20 + if (unlikely(addr & (sizeof(uint32_t) - 1))) { + NVME_GUEST_ERR(nvme_ub_mmiord_misaligned32, + "MMIO read not 32-bit aligned," + " offset=3D0x%"PRIx64"", addr); + /* should RAZ, fall through for now */ + } else if (unlikely(size < sizeof(uint32_t))) { + NVME_GUEST_ERR(nvme_ub_mmiord_toosmall, + "MMIO read smaller than 32-bits," + " offset=3D0x%"PRIx64"", addr); + /* should RAZ, fall through for now */ + } + if (addr < sizeof(n->bar)) { memcpy(&val, ptr + addr, size); + } else { + NVME_GUEST_ERR(nvme_ub_mmiord_invalid_ofs, + "MMIO read beyond last register," + " offset=3D0x%"PRIx64", returning 0", addr); } + return val; } =20 @@ -822,22 +1042,36 @@ static void nvme_process_db(NvmeCtrl *n, hwaddr addr= , int val) { uint32_t qid; =20 - if (addr & ((1 << 2) - 1)) { + if (unlikely(addr & ((1 << 2) - 1))) { + NVME_GUEST_ERR(nvme_ub_db_wr_misaligned, + "doorbell write not 32-bit aligned," + " offset=3D0x%"PRIx64", ignoring", addr); return; } =20 if (((addr - 0x1000) >> 2) & 1) { + /* Completion queue doorbell write */ + uint16_t new_head =3D val & 0xffff; int start_sqs; NvmeCQueue *cq; =20 qid =3D (addr - (0x1000 + (1 << 2))) >> 3; - if (nvme_check_cqid(n, qid)) { + if (unlikely(nvme_check_cqid(n, qid))) { + NVME_GUEST_ERR(nvme_ub_db_wr_invalid_cq, + "completion queue doorbell write" + " for nonexistent queue," + " sqid=3D%"PRIu32", ignoring", qid); return; } =20 cq =3D n->cq[qid]; - if (new_head >=3D cq->size) { + if (unlikely(new_head >=3D cq->size)) { + NVME_GUEST_ERR(nvme_ub_db_wr_invalid_cqhead, + "completion queue doorbell write value" + " beyond queue size, sqid=3D%"PRIu32"," + " new_head=3D%"PRIu16", ignoring", + qid, new_head); return; } =20 @@ -855,16 +1089,27 @@ static void nvme_process_db(NvmeCtrl *n, hwaddr addr= , int val) nvme_isr_notify(n, cq); } } else { + /* Submission queue doorbell write */ + uint16_t new_tail =3D val & 0xffff; NvmeSQueue *sq; =20 qid =3D (addr - 0x1000) >> 3; - if (nvme_check_sqid(n, qid)) { + if (unlikely(nvme_check_sqid(n, qid))) { + NVME_GUEST_ERR(nvme_ub_db_wr_invalid_sq, + "submission queue doorbell write" + " for nonexistent queue," + " sqid=3D%"PRIu32", ignoring", qid); return; } =20 sq =3D n->sq[qid]; - if (new_tail >=3D sq->size) { + if (unlikely(new_tail >=3D sq->size)) { + NVME_GUEST_ERR(nvme_ub_db_wr_invalid_sqtail, + "submission queue doorbell write value" + " beyond queue size, sqid=3D%"PRIu32"," + " new_tail=3D%"PRIu16", ignoring", + qid, new_tail); return; } =20 diff --git a/hw/block/trace-events b/hw/block/trace-events index 962a3bfa24..5acd495207 100644 --- a/hw/block/trace-events +++ b/hw/block/trace-events @@ -11,6 +11,99 @@ virtio_blk_submit_multireq(void *vdev, void *mrb, int st= art, int num_reqs, uint6 hd_geometry_lchs_guess(void *blk, int cyls, int heads, int secs) "blk %p L= CHS %d %d %d" hd_geometry_guess(void *blk, uint32_t cyls, uint32_t heads, uint32_t secs,= int trans) "blk %p CHS %u %u %u trans %d" =20 +# hw/block/nvme.c +# nvme traces for successful events +nvme_irq_msix(uint32_t vector) "raising MSI-X IRQ vector %u" +nvme_irq_pin(void) "pulsing IRQ pin" +nvme_irq_masked(void) "IRQ is masked" +nvme_dma_read(uint64_t prp1, uint64_t prp2) "DMA read, prp1=3D0x%"PRIx64" = prp2=3D0x%"PRIx64"" +nvme_rw(char const *verb, uint32_t blk_count, uint64_t byte_count, uint64_= t lba) "%s %"PRIu32" blocks (%"PRIu64" bytes) from LBA %"PRIu64"" +nvme_create_sq(uint64_t addr, uint16_t sqid, uint16_t cqid, uint16_t qsize= , uint16_t qflags) "create submission queue, addr=3D0x%"PRIx64", sqid=3D%"P= RIu16", cqid=3D%"PRIu16", qsize=3D%"PRIu16", qflags=3D%"PRIu16"" +nvme_create_cq(uint64_t addr, uint16_t cqid, uint16_t vector, uint16_t siz= e, uint16_t qflags, int ien) "create completion queue, addr=3D0x%"PRIx64", = cqid=3D%"PRIu16", vector=3D%"PRIu16", qsize=3D%"PRIu16", qflags=3D%"PRIu16"= , ien=3D%d" +nvme_del_sq(uint16_t qid) "deleting submission queue sqid=3D%"PRIu16"" +nvme_del_cq(uint16_t cqid) "deleted completion queue, sqid=3D%"PRIu16"" +nvme_identify_ctrl(void) "identify controller" +nvme_identify_ns(uint16_t ns) "identify namespace, nsid=3D%"PRIu16"" +nvme_identify_nslist(uint16_t ns) "identify namespace list, nsid=3D%"PRIu1= 6"" +nvme_getfeat_vwcache(char const* result) "get feature volatile write cache= , result=3D%s" +nvme_getfeat_numq(int result) "get feature number of queues, result=3D%d" +nvme_setfeat_numq(int reqcq, int reqsq, int gotcq, int gotsq) "requested c= q_count=3D%d sq_count=3D%d, responding with cq_count=3D%d sq_count=3D%d" +nvme_mmio_intm_set(uint64_t data, uint64_t new_mask) "wrote MMIO, interrup= t mask set, data=3D0x%"PRIx64", new_mask=3D0x%"PRIx64"" +nvme_mmio_intm_clr(uint64_t data, uint64_t new_mask) "wrote MMIO, interrup= t mask clr, data=3D0x%"PRIx64", new_mask=3D0x%"PRIx64"" +nvme_mmio_cfg(uint64_t data) "wrote MMIO, config controller config=3D0x%"P= RIx64"" +nvme_mmio_aqattr(uint64_t data) "wrote MMIO, admin queue attributes=3D0x%"= PRIx64"" +nvme_mmio_asqaddr(uint64_t data) "wrote MMIO, admin submission queue addre= ss=3D0x%"PRIx64"" +nvme_mmio_acqaddr(uint64_t data) "wrote MMIO, admin completion queue addre= ss=3D0x%"PRIx64"" +nvme_mmio_asqaddr_hi(uint64_t data, uint64_t new_addr) "wrote MMIO, admin = submission queue high half=3D0x%"PRIx64", new_address=3D0x%"PRIx64"" +nvme_mmio_acqaddr_hi(uint64_t data, uint64_t new_addr) "wrote MMIO, admin = completion queue high half=3D0x%"PRIx64", new_address=3D0x%"PRIx64"" +nvme_mmio_start_success(void) "setting controller enable bit succeeded" +nvme_mmio_stopped(void) "cleared controller enable bit" +nvme_mmio_shutdown_set(void) "shutdown bit set" +nvme_mmio_shutdown_cleared(void) "shutdown bit cleared" + +# nvme traces for error conditions +nvme_err_invalid_dma(void) "PRP/SGL is too small for transfer size" +nvme_err_invalid_prplist_ent(uint64_t prplist) "PRP list entry is null or = not page aligned: 0x%"PRIx64"" +nvme_err_invalid_prp2_align(uint64_t prp2) "PRP2 is not page aligned: 0x%"= PRIx64"" +nvme_err_invalid_prp2_missing(void) "PRP2 is null and more data to be tran= sferred" +nvme_err_invalid_field(void) "invalid field" +nvme_err_invalid_prp(void) "invalid PRP" +nvme_err_invalid_sgl(void) "invalid SGL" +nvme_err_invalid_ns(uint32_t ns, uint32_t limit) "invalid namespace %u not= within 1-%u" +nvme_err_invalid_opc(uint8_t opc) "invalid opcode 0x%"PRIx8"" +nvme_err_invalid_admin_opc(uint8_t opc) "invalid admin opcode 0x%"PRIx8"" +nvme_err_invalid_lba_range(uint64_t start, uint64_t len, uint64_t limit) "= Invalid LBA start=3D%"PRIu64" len=3D%"PRIu64" limit=3D%"PRIu64"" +nvme_err_invalid_del_sq(uint16_t qid) "invalid submission queue deletion, = sid=3D%"PRIu16"" +nvme_err_invalid_create_sq_cqid(uint16_t cqid) "failed creating submission= queue, invalid cqid=3D%"PRIu16"" +nvme_err_invalid_create_sq_sqid(uint16_t sqid) "failed creating submission= queue, invalid sqid=3D%"PRIu16"" +nvme_err_invalid_create_sq_size(uint16_t qsize) "failed creating submissio= n queue, invalid qsize=3D%"PRIu16"" +nvme_err_invalid_create_sq_addr(uint64_t addr) "failed creating submission= queue, addr=3D0x%"PRIx64"" +nvme_err_invalid_create_sq_qflags(uint16_t qflags) "failed creating submis= sion queue, qflags=3D%"PRIu16"" +nvme_err_invalid_del_cq_cqid(uint16_t cqid) "failed deleting completion qu= eue, cqid=3D%"PRIu16"" +nvme_err_invalid_del_cq_notempty(uint16_t cqid) "failed deleting completio= n queue, it is not empty, cqid=3D%"PRIu16"" +nvme_err_invalid_create_cq_cqid(uint16_t cqid) "failed creating completion= queue, cqid=3D%"PRIu16"" +nvme_err_invalid_create_cq_size(uint16_t size) "failed creating completion= queue, size=3D%"PRIu16"" +nvme_err_invalid_create_cq_addr(uint64_t addr) "failed creating completion= queue, addr=3D0x%"PRIx64"" +nvme_err_invalid_create_cq_vector(uint16_t vector) "failed creating comple= tion queue, vector=3D%"PRIu16"" +nvme_err_invalid_create_cq_qflags(uint16_t qflags) "failed creating comple= tion queue, qflags=3D%"PRIu16"" +nvme_err_invalid_identify_cns(uint16_t cns) "identify, invalid cns=3D0x%"P= RIx16"" +nvme_err_invalid_getfeat(int dw10) "invalid get features, dw10=3D0x%"PRIx3= 2"" +nvme_err_invalid_setfeat(uint32_t dw10) "invalid set features, dw10=3D0x%"= PRIx32"" +nvme_err_startfail_cq(void) "nvme_start_ctrl failed because there are non-= admin completion queues" +nvme_err_startfail_sq(void) "nvme_start_ctrl failed because there are non-= admin submission queues" +nvme_err_startfail_nbarasq(void) "nvme_start_ctrl failed because the admin= submission queue address is null" +nvme_err_startfail_nbaracq(void) "nvme_start_ctrl failed because the admin= completion queue address is null" +nvme_err_startfail_asq_misaligned(uint64_t addr) "nvme_start_ctrl failed b= ecause the admin submission queue address is misaligned: 0x%"PRIx64"" +nvme_err_startfail_acq_misaligned(uint64_t addr) "nvme_start_ctrl failed b= ecause the admin completion queue address is misaligned: 0x%"PRIx64"" +nvme_err_startfail_page_too_small(uint8_t log2ps, uint8_t maxlog2ps) "nvme= _start_ctrl failed because the page size is too small: log2size=3D%u, min= =3D%u" +nvme_err_startfail_page_too_large(uint8_t log2ps, uint8_t maxlog2ps) "nvme= _start_ctrl failed because the page size is too large: log2size=3D%u, max= =3D%u" +nvme_err_startfail_cqent_too_small(uint8_t log2ps, uint8_t maxlog2ps) "nvm= e_start_ctrl failed because the completion queue entry size is too small: l= og2size=3D%u, min=3D%u" +nvme_err_startfail_cqent_too_large(uint8_t log2ps, uint8_t maxlog2ps) "nvm= e_start_ctrl failed because the completion queue entry size is too large: l= og2size=3D%u, max=3D%u" +nvme_err_startfail_sqent_too_small(uint8_t log2ps, uint8_t maxlog2ps) "nvm= e_start_ctrl failed because the submission queue entry size is too small: l= og2size=3D%u, min=3D%u" +nvme_err_startfail_sqent_too_large(uint8_t log2ps, uint8_t maxlog2ps) "nvm= e_start_ctrl failed because the submission queue entry size is too large: l= og2size=3D%u, max=3D%u" +nvme_err_startfail_asqent_sz_zero(void) "nvme_start_ctrl failed because th= e admin submission queue size is zero" +nvme_err_startfail_acqent_sz_zero(void) "nvme_start_ctrl failed because th= e admin completion queue size is zero" +nvme_err_startfail(void) "setting controller enable bit failed" + +# Traces for undefined behavior +nvme_ub_mmiowr_misaligned32(uint64_t offset) "MMIO write not 32-bit aligne= d, offset=3D0x%"PRIx64"" +nvme_ub_mmiowr_toosmall(uint64_t offset, unsigned size) "MMIO write smalle= r than 32 bits, offset=3D0x%"PRIx64", size=3D%u" +nvme_ub_mmiowr_intmask_with_msix(void) "undefined access to interrupt mask= set when MSI-X is enabled" +nvme_ub_mmiowr_ro_csts(void) "attempted to set a read only bit of controll= er status" +nvme_ub_mmiowr_ssreset_w1c_unsupported(void) "attempted to W1C CSTS.NSSRO = but CAP.NSSRS is zero (not supported)" +nvme_ub_mmiowr_ssreset_unsupported(void) "attempted NVM subsystem reset bu= t CAP.NSSRS is zero (not supported)" +nvme_ub_mmiowr_cmbloc_reserved(void) "invalid write to reserved CMBLOC whe= n CMBSZ is zero, ignored" +nvme_ub_mmiowr_cmbsz_readonly(void) "invalid write to read only CMBSZ, ign= ored" +nvme_ub_mmiowr_invalid(uint64_t offset, uint64_t data) "invalid MMIO write= , offset=3D0x%"PRIx64", data=3D0x%"PRIx64"" +nvme_ub_mmiord_misaligned32(uint64_t offset) "MMIO read not 32-bit aligned= , offset=3D0x%"PRIx64"" +nvme_ub_mmiord_toosmall(uint64_t offset) "MMIO read smaller than 32-bits, = offset=3D0x%"PRIx64"" +nvme_ub_mmiord_invalid_ofs(uint64_t offset) "MMIO read beyond last registe= r, offset=3D0x%"PRIx64", returning 0" +nvme_ub_db_wr_misaligned(uint64_t offset) "doorbell write not 32-bit align= ed, offset=3D0x%"PRIx64", ignoring" +nvme_ub_db_wr_invalid_cq(uint32_t qid) "completion queue doorbell write fo= r nonexistent queue, cqid=3D%"PRIu32", ignoring" +nvme_ub_db_wr_invalid_cqhead(uint32_t qid, uint16_t new_head) "completion = queue doorbell write value beyond queue size, cqid=3D%"PRIu32", new_head=3D= %"PRIu16", ignoring" +nvme_ub_db_wr_invalid_sq(uint32_t qid) "submission queue doorbell write fo= r nonexistent queue, sqid=3D%"PRIu32", ignoring" +nvme_ub_db_wr_invalid_sqtail(uint32_t qid, uint16_t new_tail) "submission = queue doorbell write value beyond queue size, sqid=3D%"PRIu32", new_head=3D= %"PRIu16", ignoring" + # hw/block/xen_disk.c xen_disk_alloc(char *name) "%s" xen_disk_init(char *name) "%s" --=20 2.13.6 From nobody Sat May 3 10:50:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513956600743508.9193119920376; Fri, 22 Dec 2017 07:30:00 -0800 (PST) Received: from localhost ([::1]:54446 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1eSPGf-0005tR-En for importer@patchew.org; Fri, 22 Dec 2017 10:29:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57088) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6V-0005cx-6V for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6U-0002Io-B6 for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:19 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46878) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6S-0002Fh-1L; Fri, 22 Dec 2017 10:19:16 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 44502C04B928; Fri, 22 Dec 2017 15:19:15 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-107.ams2.redhat.com [10.36.117.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 71A5060C80; Fri, 22 Dec 2017 15:19:13 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Fri, 22 Dec 2017 16:18:24 +0100 Message-Id: <20171222151846.28110-14-kwolf@redhat.com> In-Reply-To: <20171222151846.28110-1-kwolf@redhat.com> References: <20171222151846.28110-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 22 Dec 2017 15:19:15 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 13/35] block: Open backing image in force share mode for size probe X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Fam Zheng <famz@redhat.com> Management tools create overlays of running guests with qemu-img: $ qemu-img create -b /image/in/use.qcow2 -f qcow2 /overlay/image.qcow2 but this doesn't work anymore due to image locking: qemu-img: /overlay/image.qcow2: Failed to get shared "write" lock Is another process using the image? Could not open backing image to determine size. Use the force share option to allow this use case again. Cc: qemu-stable@nongnu.org Signed-off-by: Fam Zheng <famz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- block.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index db0be7ef36..dd90dca896 100644 --- a/block.c +++ b/block.c @@ -4605,10 +4605,11 @@ void bdrv_img_create(const char *filename, const ch= ar *fmt, back_flags =3D flags; back_flags &=3D ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKIN= G); =20 + backing_options =3D qdict_new(); if (backing_fmt) { - backing_options =3D qdict_new(); qdict_put_str(backing_options, "driver", backing_fmt); } + qdict_put_bool(backing_options, BDRV_OPT_FORCE_SHARE, true); =20 bs =3D bdrv_open(full_backing, NULL, backing_options, back_flags, &local_err); --=20 2.13.6 From nobody Sat May 3 10:50:33 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513956771129517.5223012318672; Fri, 22 Dec 2017 07:32:51 -0800 (PST) Received: from localhost ([::1]:54469 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1eSPJU-0008Lm-Qg for importer@patchew.org; Fri, 22 Dec 2017 10:32:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57118) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6W-0005ez-OI for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6V-0002L7-Tg for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41828) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6T-0002HP-HV; Fri, 22 Dec 2017 10:19:17 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B479E85A02; Fri, 22 Dec 2017 15:19:16 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-107.ams2.redhat.com [10.36.117.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 963165CC02; Fri, 22 Dec 2017 15:19:15 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Fri, 22 Dec 2017 16:18:25 +0100 Message-Id: <20171222151846.28110-15-kwolf@redhat.com> In-Reply-To: <20171222151846.28110-1-kwolf@redhat.com> References: <20171222151846.28110-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 22 Dec 2017 15:19:16 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 14/35] block: Remove the obsolete -drive boot=on|off parameter X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Thomas Huth <thuth@redhat.com> It's not working anymore since QEMU v1.3.0 - time to remove it now. Signed-off-by: Thomas Huth <thuth@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- blockdev.c | 11 ----------- qemu-doc.texi | 6 ------ 2 files changed, 17 deletions(-) diff --git a/blockdev.c b/blockdev.c index 9c3a430cfb..29d569a24e 100644 --- a/blockdev.c +++ b/blockdev.c @@ -735,10 +735,6 @@ QemuOptsList qemu_legacy_drive_opts =3D { .type =3D QEMU_OPT_STRING, .help =3D "chs translation (auto, lba, none)", },{ - .name =3D "boot", - .type =3D QEMU_OPT_BOOL, - .help =3D "(deprecated, ignored)", - },{ .name =3D "addr", .type =3D QEMU_OPT_STRING, .help =3D "pci address (virtio only)", @@ -873,13 +869,6 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfac= eType block_default_type) goto fail; } =20 - /* Deprecated option boot=3D[on|off] */ - if (qemu_opt_get(legacy_opts, "boot") !=3D NULL) { - fprintf(stderr, "qemu-kvm: boot=3Don|off is deprecated and will be= " - "ignored. Future versions will reject this parameter. Plea= se " - "update your scripts.\n"); - } - /* Other deprecated options */ if (!qtest_enabled()) { for (i =3D 0; i < ARRAY_SIZE(deprecated); i++) { diff --git a/qemu-doc.texi b/qemu-doc.texi index 90bea7331d..ed55bd477d 100644 --- a/qemu-doc.texi +++ b/qemu-doc.texi @@ -2589,12 +2589,6 @@ deprecated. =20 @section System emulator command line arguments =20 -@subsection -drive boot=3Don|off (since 1.3.0) - -The ``boot=3Don|off'' option to the ``-drive'' argument is -ignored. Applications should use the ``bootindex=3DN'' parameter -to set an absolute ordering between devices instead. - @subsection -tdf (since 1.3.0) =20 The ``-tdf'' argument is ignored. The behaviour implemented --=20 2.13.6 From nobody Sat May 3 10:50:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513956815821144.49546669589324; Fri, 22 Dec 2017 07:33:35 -0800 (PST) Received: from localhost ([::1]:54472 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1eSPK4-0000Sc-HD for importer@patchew.org; Fri, 22 Dec 2017 10:33:20 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57217) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6b-0005jI-PS for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6Y-0002NH-FI for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45558) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6U-0002It-Vn; Fri, 22 Dec 2017 10:19:19 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2E5FE80469; Fri, 22 Dec 2017 15:19:18 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-107.ams2.redhat.com [10.36.117.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 10EC651DF2; Fri, 22 Dec 2017 15:19:16 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Fri, 22 Dec 2017 16:18:26 +0100 Message-Id: <20171222151846.28110-16-kwolf@redhat.com> In-Reply-To: <20171222151846.28110-1-kwolf@redhat.com> References: <20171222151846.28110-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 22 Dec 2017 15:19:18 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 15/35] block: Remove the deprecated -hdachs option X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Thomas Huth <thuth@redhat.com> It's been marked as deprecated since QEMU v2.10.0, and so far nobody complained that we should keep it, so let's remove this legacy option now to simplify the code quite a bit. Signed-off-by: Thomas Huth <thuth@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- vl.c | 86 ++---------------------------------------------------= ---- qemu-doc.texi | 8 ------ qemu-options.hx | 19 ++----------- 3 files changed, 4 insertions(+), 109 deletions(-) diff --git a/vl.c b/vl.c index d3a5c5d021..444b7507da 100644 --- a/vl.c +++ b/vl.c @@ -3052,9 +3052,8 @@ int main(int argc, char **argv, char **envp) const char *boot_order =3D NULL; const char *boot_once =3D NULL; DisplayState *ds; - int cyls, heads, secs, translation; QemuOpts *opts, *machine_opts; - QemuOpts *hda_opts =3D NULL, *icount_opts =3D NULL, *accel_opts =3D NU= LL; + QemuOpts *icount_opts =3D NULL, *accel_opts =3D NULL; QemuOptsList *olist; int optind; const char *optarg; @@ -3146,8 +3145,6 @@ int main(int argc, char **argv, char **envp) =20 cpu_model =3D NULL; snapshot =3D 0; - cyls =3D heads =3D secs =3D 0; - translation =3D BIOS_ATA_TRANSLATION_AUTO; =20 nb_nics =3D 0; =20 @@ -3186,7 +3183,7 @@ int main(int argc, char **argv, char **envp) if (optind >=3D argc) break; if (argv[optind][0] !=3D '-') { - hda_opts =3D drive_add(IF_DEFAULT, 0, argv[optind++], HD_OPTS); + drive_add(IF_DEFAULT, 0, argv[optind++], HD_OPTS); } else { const QEMUOption *popt; =20 @@ -3206,21 +3203,6 @@ int main(int argc, char **argv, char **envp) cpu_model =3D optarg; break; case QEMU_OPTION_hda: - { - char buf[256]; - if (cyls =3D=3D 0) - snprintf(buf, sizeof(buf), "%s", HD_OPTS); - else - snprintf(buf, sizeof(buf), - "%s,cyls=3D%d,heads=3D%d,secs=3D%d%s", - HD_OPTS , cyls, heads, secs, - translation =3D=3D BIOS_ATA_TRANSLATION_L= BA ? - ",trans=3Dlba" : - translation =3D=3D BIOS_ATA_TRANSLATION_N= ONE ? - ",trans=3Dnone" : ""); - drive_add(IF_DEFAULT, 0, optarg, buf); - break; - } case QEMU_OPTION_hdb: case QEMU_OPTION_hdc: case QEMU_OPTION_hdd: @@ -3271,70 +3253,6 @@ int main(int argc, char **argv, char **envp) case QEMU_OPTION_snapshot: snapshot =3D 1; break; - case QEMU_OPTION_hdachs: - { - const char *p; - p =3D optarg; - cyls =3D strtol(p, (char **)&p, 0); - if (cyls < 1 || cyls > 16383) - goto chs_fail; - if (*p !=3D ',') - goto chs_fail; - p++; - heads =3D strtol(p, (char **)&p, 0); - if (heads < 1 || heads > 16) - goto chs_fail; - if (*p !=3D ',') - goto chs_fail; - p++; - secs =3D strtol(p, (char **)&p, 0); - if (secs < 1 || secs > 63) - goto chs_fail; - if (*p =3D=3D ',') { - p++; - if (!strcmp(p, "large")) { - translation =3D BIOS_ATA_TRANSLATION_LARGE; - } else if (!strcmp(p, "rechs")) { - translation =3D BIOS_ATA_TRANSLATION_RECHS; - } else if (!strcmp(p, "none")) { - translation =3D BIOS_ATA_TRANSLATION_NONE; - } else if (!strcmp(p, "lba")) { - translation =3D BIOS_ATA_TRANSLATION_LBA; - } else if (!strcmp(p, "auto")) { - translation =3D BIOS_ATA_TRANSLATION_AUTO; - } else { - goto chs_fail; - } - } else if (*p !=3D '\0') { - chs_fail: - error_report("invalid physical CHS format"); - exit(1); - } - if (hda_opts !=3D NULL) { - qemu_opt_set_number(hda_opts, "cyls", cyls, - &error_abort); - qemu_opt_set_number(hda_opts, "heads", heads, - &error_abort); - qemu_opt_set_number(hda_opts, "secs", secs, - &error_abort); - if (translation =3D=3D BIOS_ATA_TRANSLATION_LARGE)= { - qemu_opt_set(hda_opts, "trans", "large", - &error_abort); - } else if (translation =3D=3D BIOS_ATA_TRANSLATION= _RECHS) { - qemu_opt_set(hda_opts, "trans", "rechs", - &error_abort); - } else if (translation =3D=3D BIOS_ATA_TRANSLATION= _LBA) { - qemu_opt_set(hda_opts, "trans", "lba", - &error_abort); - } else if (translation =3D=3D BIOS_ATA_TRANSLATION= _NONE) { - qemu_opt_set(hda_opts, "trans", "none", - &error_abort); - } - } - } - error_report("'-hdachs' is deprecated, please use '-device" - " ide-hd,cyls=3Dc,heads=3Dh,secs=3Ds,...' ins= tead"); - break; case QEMU_OPTION_numa: opts =3D qemu_opts_parse_noisily(qemu_find_opts("numa"), optarg, true); diff --git a/qemu-doc.texi b/qemu-doc.texi index ed55bd477d..96fda9c56e 100644 --- a/qemu-doc.texi +++ b/qemu-doc.texi @@ -2686,14 +2686,6 @@ The ``--net dump'' argument is now replaced with the ``-object filter-dump'' argument which works in combination with the modern ``-netdev`` backends instead. =20 -@subsection -hdachs (since 2.10.0) - -The ``-hdachs'' argument is now a synonym for setting -the ``cyls'', ``heads'', ``secs'', and ``trans'' properties -on the ``ide-hd'' device using the ``-device'' argument. -The new syntax allows different settings to be provided -per disk. - @subsection -usbdevice (since 2.10.0) =20 The ``-usbdevice DEV'' argument is now a synonym for setting diff --git a/qemu-options.hx b/qemu-options.hx index 94647e21e3..2d39ba0b6d 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -846,8 +846,8 @@ of available connectors of a given interface type. @item media=3D@var{media} This option defines the type of the media: disk or cdrom. @item cyls=3D@var{c},heads=3D@var{h},secs=3D@var{s}[,trans=3D@var{t}] -These options have the same definition as they have in @option{-hdachs}. -These parameters are deprecated, use the corresponding parameters +Force disk physical geometry and the optional BIOS translation (trans=3Dno= ne or +lba). These parameters are deprecated, use the corresponding parameters of @code{-device} instead. @item snapshot=3D@var{snapshot} @var{snapshot} is "on" or "off" and controls snapshot mode for the given d= rive @@ -1027,21 +1027,6 @@ the raw disk image you use is not written back. You = can however force the write back by pressing @key{C-a s} (@pxref{disk_images}). ETEXI =20 -DEF("hdachs", HAS_ARG, QEMU_OPTION_hdachs, \ - "-hdachs c,h,s[,t]\n" \ - " force hard disk 0 physical geometry and the optional = BIOS\n" \ - " translation (t=3Dnone or lba) (usually QEMU can guess= them)\n", - QEMU_ARCH_ALL) -STEXI -@item -hdachs @var{c},@var{h},@var{s},[,@var{t}] -@findex -hdachs -Force hard disk 0 physical geometry (1 <=3D @var{c} <=3D 16383, 1 <=3D -@var{h} <=3D 16, 1 <=3D @var{s} <=3D 63) and optionally force the BIOS -translation mode (@var{t}=3Dnone, lba or auto). Usually QEMU can guess -all those parameters. This option is deprecated, please use -@code{-device ide-hd,cyls=3Dc,heads=3Dh,secs=3Ds,...} instead. -ETEXI - DEF("fsdev", HAS_ARG, QEMU_OPTION_fsdev, "-fsdev fsdriver,id=3Did[,path=3Dpath,][security_model=3D{mapped-xattr= |mapped-file|passthrough|none}]\n" " [,writeout=3Dimmediate][,readonly][,socket=3Dsocket|sock_fd=3Dsock_f= d][,fmode=3Dfmode][,dmode=3Ddmode]\n" --=20 2.13.6 From nobody Sat May 3 10:50:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151395687344938.88092228389041; Fri, 22 Dec 2017 07:34:33 -0800 (PST) Received: from localhost ([::1]:54499 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1eSPL9-0001Py-LC for importer@patchew.org; Fri, 22 Dec 2017 10:34:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57322) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6k-0005ne-Nj for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6f-0002UI-MW for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34886) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6W-0002Kx-ED; Fri, 22 Dec 2017 10:19:20 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9CFAF6911; Fri, 22 Dec 2017 15:19:19 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-107.ams2.redhat.com [10.36.117.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8059D60C80; Fri, 22 Dec 2017 15:19:18 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Fri, 22 Dec 2017 16:18:27 +0100 Message-Id: <20171222151846.28110-17-kwolf@redhat.com> In-Reply-To: <20171222151846.28110-1-kwolf@redhat.com> References: <20171222151846.28110-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 22 Dec 2017 15:19:19 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 16/35] block: Mention -drive cyls/heads/secs/trans/serial/addr in deprecation chapter X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Thomas Huth <thuth@redhat.com> Looks like we forgot to announce the deprecation of these options in the corresponding chapter of the qemu-doc text, so let's do that now. Signed-off-by: Thomas Huth <thuth@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- qemu-doc.texi | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/qemu-doc.texi b/qemu-doc.texi index 96fda9c56e..2cc741e77e 100644 --- a/qemu-doc.texi +++ b/qemu-doc.texi @@ -2680,6 +2680,21 @@ longer be directly supported in QEMU. The ``-drive if=3Dscsi'' argument is replaced by the the ``-device BUS-TYPE'' argument combined with ``-drive if=3Dnone''. =20 +@subsection -drive cyls=3D...,heads=3D...,secs=3D...,trans=3D... (since 2.= 10.0) + +The drive geometry arguments are replaced by the the geometry arguments +that can be specified with the ``-device'' parameter. + +@subsection -drive serial=3D... (since 2.10.0) + +The drive serial argument is replaced by the the serial argument +that can be specified with the ``-device'' parameter. + +@subsection -drive addr=3D... (since 2.10.0) + +The drive addr argument is replaced by the the addr argument +that can be specified with the ``-device'' parameter. + @subsection -net dump (since 2.10.0) =20 The ``--net dump'' argument is now replaced with the --=20 2.13.6 From nobody Sat May 3 10:50:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513956973987123.92757909567047; Fri, 22 Dec 2017 07:36:13 -0800 (PST) Received: from localhost ([::1]:54513 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1eSPMj-0002m2-Sf for importer@patchew.org; Fri, 22 Dec 2017 10:36:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57324) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6l-0005nz-3B for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6g-0002Uw-4k for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54376) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6X-0002MD-Rw; Fri, 22 Dec 2017 10:19:21 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 19BE32BA6; Fri, 22 Dec 2017 15:19:21 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-107.ams2.redhat.com [10.36.117.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF8DD60C80; Fri, 22 Dec 2017 15:19:19 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Fri, 22 Dec 2017 16:18:28 +0100 Message-Id: <20171222151846.28110-18-kwolf@redhat.com> In-Reply-To: <20171222151846.28110-1-kwolf@redhat.com> References: <20171222151846.28110-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 22 Dec 2017 15:19:21 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 17/35] block: Remove unused bdrv_requests_pending X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Fam Zheng <famz@redhat.com> Signed-off-by: Fam Zheng <famz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- include/block/block_int.h | 1 - block/io.c | 18 ------------------ 2 files changed, 19 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index a5482775ec..e107163594 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -1045,7 +1045,6 @@ bool blk_dev_is_tray_open(BlockBackend *blk); bool blk_dev_is_medium_locked(BlockBackend *blk); =20 void bdrv_set_dirty(BlockDriverState *bs, int64_t offset, int64_t bytes); -bool bdrv_requests_pending(BlockDriverState *bs); =20 void bdrv_clear_dirty_bitmap(BdrvDirtyBitmap *bitmap, HBitmap **out); void bdrv_undo_clear_dirty_bitmap(BdrvDirtyBitmap *bitmap, HBitmap *in); diff --git a/block/io.c b/block/io.c index 1e92d2e5b2..cf780c3cb0 100644 --- a/block/io.c +++ b/block/io.c @@ -134,24 +134,6 @@ void bdrv_disable_copy_on_read(BlockDriverState *bs) assert(old >=3D 1); } =20 -/* Check if any requests are in-flight (including throttled requests) */ -bool bdrv_requests_pending(BlockDriverState *bs) -{ - BdrvChild *child; - - if (atomic_read(&bs->in_flight)) { - return true; - } - - QLIST_FOREACH(child, &bs->children, next) { - if (bdrv_requests_pending(child->bs)) { - return true; - } - } - - return false; -} - typedef struct { Coroutine *co; BlockDriverState *bs; --=20 2.13.6 From nobody Sat May 3 10:50:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513956986968132.79936882089362; Fri, 22 Dec 2017 07:36:26 -0800 (PST) Received: from localhost ([::1]:54514 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1eSPMy-0002vv-TV for importer@patchew.org; Fri, 22 Dec 2017 10:36:20 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57323) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6l-0005ny-2x for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6g-0002V3-5n for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60188) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6Z-0002Nb-Bm; Fri, 22 Dec 2017 10:19:23 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 89720356C4; Fri, 22 Dec 2017 15:19:22 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-107.ams2.redhat.com [10.36.117.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B67A5CC02; Fri, 22 Dec 2017 15:19:21 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Fri, 22 Dec 2017 16:18:29 +0100 Message-Id: <20171222151846.28110-19-kwolf@redhat.com> In-Reply-To: <20171222151846.28110-1-kwolf@redhat.com> References: <20171222151846.28110-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 22 Dec 2017 15:19:22 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 18/35] block: Assert drain_all is only called from main AioContext X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> --- block/io.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/block/io.c b/block/io.c index cf780c3cb0..b94740b8ff 100644 --- a/block/io.c +++ b/block/io.c @@ -330,6 +330,12 @@ void bdrv_drain_all_begin(void) BdrvNextIterator it; GSList *aio_ctxs =3D NULL, *ctx; =20 + /* BDRV_POLL_WHILE() for a node can only be called from its own I/O th= read + * or the main loop AioContext. We potentially use BDRV_POLL_WHILE() on + * nodes in several different AioContexts, so make sure we're in the m= ain + * context. */ + assert(qemu_get_current_aio_context() =3D=3D qemu_get_aio_context()); + block_job_pause_all(); =20 for (bs =3D bdrv_first(&it); bs; bs =3D bdrv_next(&it)) { --=20 2.13.6 From nobody Sat May 3 10:50:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513957177342620.9806301527981; Fri, 22 Dec 2017 07:39:37 -0800 (PST) Received: from localhost ([::1]:54554 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1eSPPt-0005nN-4C for importer@patchew.org; Fri, 22 Dec 2017 10:39:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57325) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6l-0005o1-3g for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6g-0002Uk-1h for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:4937) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6a-0002Po-QD; Fri, 22 Dec 2017 10:19:24 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 09EA76911; Fri, 22 Dec 2017 15:19:24 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-107.ams2.redhat.com [10.36.117.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC34F51DF0; Fri, 22 Dec 2017 15:19:22 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Fri, 22 Dec 2017 16:18:30 +0100 Message-Id: <20171222151846.28110-20-kwolf@redhat.com> In-Reply-To: <20171222151846.28110-1-kwolf@redhat.com> References: <20171222151846.28110-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 22 Dec 2017 15:19:24 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 19/35] block: Make bdrv_drain() driver callbacks non-recursive X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" bdrv_drained_begin() doesn't increase bs->quiesce_counter recursively and also doesn't notify other parent nodes of children, which both means that the child nodes are not actually drained, and bdrv_drained_begin() is providing useful functionality only on a single node. To keep things consistent, we also shouldn't call the block driver callbacks recursively. A proper recursive drain version that provides an actually working drained section for child nodes will be introduced later. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> --- block/io.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/block/io.c b/block/io.c index b94740b8ff..91a52e2d82 100644 --- a/block/io.c +++ b/block/io.c @@ -158,7 +158,7 @@ static void coroutine_fn bdrv_drain_invoke_entry(void *= opaque) } =20 /* Recursively call BlockDriver.bdrv_co_drain_begin/end callbacks */ -static void bdrv_drain_invoke(BlockDriverState *bs, bool begin) +static void bdrv_drain_invoke(BlockDriverState *bs, bool begin, bool recur= sive) { BdrvChild *child, *tmp; BdrvCoDrainData data =3D { .bs =3D bs, .done =3D false, .begin =3D beg= in}; @@ -172,8 +172,10 @@ static void bdrv_drain_invoke(BlockDriverState *bs, bo= ol begin) bdrv_coroutine_enter(bs, data.co); BDRV_POLL_WHILE(bs, !data.done); =20 - QLIST_FOREACH_SAFE(child, &bs->children, next, tmp) { - bdrv_drain_invoke(child->bs, begin); + if (recursive) { + QLIST_FOREACH_SAFE(child, &bs->children, next, tmp) { + bdrv_drain_invoke(child->bs, begin, true); + } } } =20 @@ -265,7 +267,7 @@ void bdrv_drained_begin(BlockDriverState *bs) bdrv_parent_drained_begin(bs); } =20 - bdrv_drain_invoke(bs, true); + bdrv_drain_invoke(bs, true, false); bdrv_drain_recurse(bs); } =20 @@ -281,7 +283,7 @@ void bdrv_drained_end(BlockDriverState *bs) } =20 /* Re-enable things in child-to-parent order */ - bdrv_drain_invoke(bs, false); + bdrv_drain_invoke(bs, false, false); bdrv_parent_drained_end(bs); aio_enable_external(bdrv_get_aio_context(bs)); } @@ -345,7 +347,7 @@ void bdrv_drain_all_begin(void) aio_context_acquire(aio_context); aio_disable_external(aio_context); bdrv_parent_drained_begin(bs); - bdrv_drain_invoke(bs, true); + bdrv_drain_invoke(bs, true, true); aio_context_release(aio_context); =20 if (!g_slist_find(aio_ctxs, aio_context)) { @@ -388,7 +390,7 @@ void bdrv_drain_all_end(void) =20 /* Re-enable things in child-to-parent order */ aio_context_acquire(aio_context); - bdrv_drain_invoke(bs, false); + bdrv_drain_invoke(bs, false, true); bdrv_parent_drained_end(bs); aio_enable_external(aio_context); aio_context_release(aio_context); --=20 2.13.6 From nobody Sat May 3 10:50:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513957052722632.5569772016954; Fri, 22 Dec 2017 07:37:32 -0800 (PST) Received: from localhost ([::1]:54522 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1eSPO3-0003vW-Ju for importer@patchew.org; Fri, 22 Dec 2017 10:37:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57327) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6l-0005oU-Df for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6g-0002Ur-4l for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41878) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6d-0002Rw-B9; Fri, 22 Dec 2017 10:19:27 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8AA3F806B5; Fri, 22 Dec 2017 15:19:26 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-107.ams2.redhat.com [10.36.117.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5953A60CA9; Fri, 22 Dec 2017 15:19:24 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Fri, 22 Dec 2017 16:18:31 +0100 Message-Id: <20171222151846.28110-21-kwolf@redhat.com> In-Reply-To: <20171222151846.28110-1-kwolf@redhat.com> References: <20171222151846.28110-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 22 Dec 2017 15:19:26 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 20/35] test-bdrv-drain: Test callback for bdrv_drain X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The existing test is for bdrv_drain_all_begin/end() only. Generalise the test case so that it can be run for the other variants as well. At the moment this is only bdrv_drain_begin/end(), but in a while, we'll add another one. Also, add a backing file to the test node to test whether the operations work recursively. Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- tests/test-bdrv-drain.c | 69 ++++++++++++++++++++++++++++++++++++++++++++-= ---- 1 file changed, 62 insertions(+), 7 deletions(-) diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c index 0e567e34ba..3a3eef0f87 100644 --- a/tests/test-bdrv-drain.c +++ b/tests/test-bdrv-drain.c @@ -71,6 +71,8 @@ static BlockDriver bdrv_test =3D { =20 .bdrv_co_drain_begin =3D bdrv_test_co_drain_begin, .bdrv_co_drain_end =3D bdrv_test_co_drain_end, + + .bdrv_child_perm =3D bdrv_format_default_perms, }; =20 static void aio_ret_cb(void *opaque, int ret) @@ -79,11 +81,34 @@ static void aio_ret_cb(void *opaque, int ret) *aio_ret =3D ret; } =20 -static void test_drv_cb_drain_all(void) +enum drain_type { + BDRV_DRAIN_ALL, + BDRV_DRAIN, +}; + +static void do_drain_begin(enum drain_type drain_type, BlockDriverState *b= s) +{ + switch (drain_type) { + case BDRV_DRAIN_ALL: bdrv_drain_all_begin(); break; + case BDRV_DRAIN: bdrv_drained_begin(bs); break; + default: g_assert_not_reached(); + } +} + +static void do_drain_end(enum drain_type drain_type, BlockDriverState *bs) +{ + switch (drain_type) { + case BDRV_DRAIN_ALL: bdrv_drain_all_end(); break; + case BDRV_DRAIN: bdrv_drained_end(bs); break; + default: g_assert_not_reached(); + } +} + +static void test_drv_cb_common(enum drain_type drain_type, bool recursive) { BlockBackend *blk; - BlockDriverState *bs; - BDRVTestState *s; + BlockDriverState *bs, *backing; + BDRVTestState *s, *backing_s; BlockAIOCB *acb; int aio_ret; =20 @@ -100,12 +125,23 @@ static void test_drv_cb_drain_all(void) s =3D bs->opaque; blk_insert_bs(blk, bs, &error_abort); =20 + backing =3D bdrv_new_open_driver(&bdrv_test, "backing", 0, &error_abor= t); + backing_s =3D backing->opaque; + bdrv_set_backing_hd(bs, backing, &error_abort); + /* Simple bdrv_drain_all_begin/end pair, check that CBs are called */ g_assert_cmpint(s->drain_count, =3D=3D, 0); - bdrv_drain_all_begin(); + g_assert_cmpint(backing_s->drain_count, =3D=3D, 0); + + do_drain_begin(drain_type, bs); + g_assert_cmpint(s->drain_count, =3D=3D, 1); - bdrv_drain_all_end(); + g_assert_cmpint(backing_s->drain_count, =3D=3D, !!recursive); + + do_drain_end(drain_type, bs); + g_assert_cmpint(s->drain_count, =3D=3D, 0); + g_assert_cmpint(backing_s->drain_count, =3D=3D, 0); =20 /* Now do the same while a request is pending */ aio_ret =3D -EINPROGRESS; @@ -114,16 +150,34 @@ static void test_drv_cb_drain_all(void) g_assert_cmpint(aio_ret, =3D=3D, -EINPROGRESS); =20 g_assert_cmpint(s->drain_count, =3D=3D, 0); - bdrv_drain_all_begin(); + g_assert_cmpint(backing_s->drain_count, =3D=3D, 0); + + do_drain_begin(drain_type, bs); + g_assert_cmpint(aio_ret, =3D=3D, 0); g_assert_cmpint(s->drain_count, =3D=3D, 1); - bdrv_drain_all_end(); + g_assert_cmpint(backing_s->drain_count, =3D=3D, !!recursive); + + do_drain_end(drain_type, bs); + g_assert_cmpint(s->drain_count, =3D=3D, 0); + g_assert_cmpint(backing_s->drain_count, =3D=3D, 0); =20 + bdrv_unref(backing); bdrv_unref(bs); blk_unref(blk); } =20 +static void test_drv_cb_drain_all(void) +{ + test_drv_cb_common(BDRV_DRAIN_ALL, true); +} + +static void test_drv_cb_drain(void) +{ + test_drv_cb_common(BDRV_DRAIN, false); +} + int main(int argc, char **argv) { bdrv_init(); @@ -132,6 +186,7 @@ int main(int argc, char **argv) g_test_init(&argc, &argv, NULL); =20 g_test_add_func("/bdrv-drain/driver-cb/drain_all", test_drv_cb_drain_a= ll); + g_test_add_func("/bdrv-drain/driver-cb/drain", test_drv_cb_drain); =20 return g_test_run(); } --=20 2.13.6 From nobody Sat May 3 10:50:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513957354244307.7331937810284; Fri, 22 Dec 2017 07:42:34 -0800 (PST) Received: from localhost ([::1]:54597 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1eSPSu-00008C-3R for importer@patchew.org; Fri, 22 Dec 2017 10:42:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57436) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6p-0005wA-Hw for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6o-0002b5-C9 for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51018) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6e-0002TO-UO; Fri, 22 Dec 2017 10:19:29 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1698430A066; Fri, 22 Dec 2017 15:19:28 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-107.ams2.redhat.com [10.36.117.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id DCAC951DED; Fri, 22 Dec 2017 15:19:26 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Fri, 22 Dec 2017 16:18:32 +0100 Message-Id: <20171222151846.28110-22-kwolf@redhat.com> In-Reply-To: <20171222151846.28110-1-kwolf@redhat.com> References: <20171222151846.28110-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 22 Dec 2017 15:19:28 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 21/35] test-bdrv-drain: Test bs->quiesce_counter X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This is currently only working correctly for bdrv_drain(), not for bdrv_drain_all(). Leave a comment for the drain_all case, we'll address it later. Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- tests/test-bdrv-drain.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c index 3a3eef0f87..323cb0b961 100644 --- a/tests/test-bdrv-drain.c +++ b/tests/test-bdrv-drain.c @@ -178,6 +178,48 @@ static void test_drv_cb_drain(void) test_drv_cb_common(BDRV_DRAIN, false); } =20 +static void test_quiesce_common(enum drain_type drain_type, bool recursive) +{ + BlockBackend *blk; + BlockDriverState *bs, *backing; + + blk =3D blk_new(BLK_PERM_ALL, BLK_PERM_ALL); + bs =3D bdrv_new_open_driver(&bdrv_test, "test-node", BDRV_O_RDWR, + &error_abort); + blk_insert_bs(blk, bs, &error_abort); + + backing =3D bdrv_new_open_driver(&bdrv_test, "backing", 0, &error_abor= t); + bdrv_set_backing_hd(bs, backing, &error_abort); + + g_assert_cmpint(bs->quiesce_counter, =3D=3D, 0); + g_assert_cmpint(backing->quiesce_counter, =3D=3D, 0); + + do_drain_begin(drain_type, bs); + + g_assert_cmpint(bs->quiesce_counter, =3D=3D, 1); + g_assert_cmpint(backing->quiesce_counter, =3D=3D, !!recursive); + + do_drain_end(drain_type, bs); + + g_assert_cmpint(bs->quiesce_counter, =3D=3D, 0); + g_assert_cmpint(backing->quiesce_counter, =3D=3D, 0); + + bdrv_unref(backing); + bdrv_unref(bs); + blk_unref(blk); +} + +static void test_quiesce_drain_all(void) +{ + // XXX drain_all doesn't quiesce + //test_quiesce_common(BDRV_DRAIN_ALL, true); +} + +static void test_quiesce_drain(void) +{ + test_quiesce_common(BDRV_DRAIN, false); +} + int main(int argc, char **argv) { bdrv_init(); @@ -188,5 +230,8 @@ int main(int argc, char **argv) g_test_add_func("/bdrv-drain/driver-cb/drain_all", test_drv_cb_drain_a= ll); g_test_add_func("/bdrv-drain/driver-cb/drain", test_drv_cb_drain); =20 + g_test_add_func("/bdrv-drain/quiesce/drain_all", test_quiesce_drain_al= l); + g_test_add_func("/bdrv-drain/quiesce/drain", test_quiesce_drain); + return g_test_run(); } --=20 2.13.6 From nobody Sat May 3 10:50:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513957240379673.2482918167095; Fri, 22 Dec 2017 07:40:40 -0800 (PST) Received: from localhost ([::1]:54566 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1eSPQv-0006ed-7T for importer@patchew.org; Fri, 22 Dec 2017 10:40:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57473) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6q-0005xm-Jh for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6p-0002cV-MP for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40816) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6k-0002Ud-Sb; Fri, 22 Dec 2017 10:19:34 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BD31713AAB; Fri, 22 Dec 2017 15:19:29 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-107.ams2.redhat.com [10.36.117.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 69E8260CA9; Fri, 22 Dec 2017 15:19:28 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Fri, 22 Dec 2017 16:18:33 +0100 Message-Id: <20171222151846.28110-23-kwolf@redhat.com> In-Reply-To: <20171222151846.28110-1-kwolf@redhat.com> References: <20171222151846.28110-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 22 Dec 2017 15:19:29 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 22/35] blockjob: Pause job on draining any job BDS X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Block jobs already paused themselves when their main BlockBackend entered a drained section. This is not good enough: We also want to pause a block job and may not submit new requests if, for example, the mirror target node should be drained. This implements .drained_begin/end callbacks in child_job in order to consider all block nodes related to the job, and removes the BlockBackend callbacks which are unnecessary now because the root of the job main BlockBackend is always referenced with a child_job, too. Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- blockjob.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/blockjob.c b/blockjob.c index 6173e4728c..f5cea84e73 100644 --- a/blockjob.c +++ b/blockjob.c @@ -234,26 +234,23 @@ static char *child_job_get_parent_desc(BdrvChild *c) job->id); } =20 -static const BdrvChildRole child_job =3D { - .get_parent_desc =3D child_job_get_parent_desc, - .stay_at_node =3D true, -}; - -static void block_job_drained_begin(void *opaque) +static void child_job_drained_begin(BdrvChild *c) { - BlockJob *job =3D opaque; + BlockJob *job =3D c->opaque; block_job_pause(job); } =20 -static void block_job_drained_end(void *opaque) +static void child_job_drained_end(BdrvChild *c) { - BlockJob *job =3D opaque; + BlockJob *job =3D c->opaque; block_job_resume(job); } =20 -static const BlockDevOps block_job_dev_ops =3D { - .drained_begin =3D block_job_drained_begin, - .drained_end =3D block_job_drained_end, +static const BdrvChildRole child_job =3D { + .get_parent_desc =3D child_job_get_parent_desc, + .drained_begin =3D child_job_drained_begin, + .drained_end =3D child_job_drained_end, + .stay_at_node =3D true, }; =20 void block_job_remove_all_bdrv(BlockJob *job) @@ -715,7 +712,6 @@ void *block_job_create(const char *job_id, const BlockJ= obDriver *driver, block_job_add_bdrv(job, "main node", bs, 0, BLK_PERM_ALL, &error_abort= ); bs->job =3D job; =20 - blk_set_dev_ops(blk, &block_job_dev_ops, job); bdrv_op_unblock(bs, BLOCK_OP_TYPE_DATAPLANE, job->blocker); =20 QLIST_INSERT_HEAD(&block_jobs, job, job_list); --=20 2.13.6 From nobody Sat May 3 10:50:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513957511216380.8453813795927; Fri, 22 Dec 2017 07:45:11 -0800 (PST) Received: from localhost ([::1]:54773 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1eSPVN-0002jb-Q8 for importer@patchew.org; Fri, 22 Dec 2017 10:45:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57489) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6r-0005yd-4i for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6p-0002cq-V2 for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45652) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6m-0002Wy-19; Fri, 22 Dec 2017 10:19:36 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4AC5180476; Fri, 22 Dec 2017 15:19:33 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-107.ams2.redhat.com [10.36.117.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1CB5651DED; Fri, 22 Dec 2017 15:19:29 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Fri, 22 Dec 2017 16:18:34 +0100 Message-Id: <20171222151846.28110-24-kwolf@redhat.com> In-Reply-To: <20171222151846.28110-1-kwolf@redhat.com> References: <20171222151846.28110-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 22 Dec 2017 15:19:33 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 23/35] test-bdrv-drain: Test drain vs. block jobs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Block jobs must be paused if any of the involved nodes are drained. Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- tests/test-bdrv-drain.c | 121 ++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 121 insertions(+) diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c index 323cb0b961..9783768a20 100644 --- a/tests/test-bdrv-drain.c +++ b/tests/test-bdrv-drain.c @@ -24,6 +24,7 @@ =20 #include "qemu/osdep.h" #include "block/block.h" +#include "block/blockjob_int.h" #include "sysemu/block-backend.h" #include "qapi/error.h" =20 @@ -220,6 +221,123 @@ static void test_quiesce_drain(void) test_quiesce_common(BDRV_DRAIN, false); } =20 + +typedef struct TestBlockJob { + BlockJob common; + bool should_complete; +} TestBlockJob; + +static void test_job_completed(BlockJob *job, void *opaque) +{ + block_job_completed(job, 0); +} + +static void coroutine_fn test_job_start(void *opaque) +{ + TestBlockJob *s =3D opaque; + + while (!s->should_complete) { + block_job_sleep_ns(&s->common, 100000); + } + + block_job_defer_to_main_loop(&s->common, test_job_completed, NULL); +} + +static void test_job_complete(BlockJob *job, Error **errp) +{ + TestBlockJob *s =3D container_of(job, TestBlockJob, common); + s->should_complete =3D true; +} + +BlockJobDriver test_job_driver =3D { + .instance_size =3D sizeof(TestBlockJob), + .start =3D test_job_start, + .complete =3D test_job_complete, +}; + +static void test_blockjob_common(enum drain_type drain_type) +{ + BlockBackend *blk_src, *blk_target; + BlockDriverState *src, *target; + BlockJob *job; + int ret; + + src =3D bdrv_new_open_driver(&bdrv_test, "source", BDRV_O_RDWR, + &error_abort); + blk_src =3D blk_new(BLK_PERM_ALL, BLK_PERM_ALL); + blk_insert_bs(blk_src, src, &error_abort); + + target =3D bdrv_new_open_driver(&bdrv_test, "target", BDRV_O_RDWR, + &error_abort); + blk_target =3D blk_new(BLK_PERM_ALL, BLK_PERM_ALL); + blk_insert_bs(blk_target, target, &error_abort); + + job =3D block_job_create("job0", &test_job_driver, src, 0, BLK_PERM_AL= L, 0, + 0, NULL, NULL, &error_abort); + block_job_add_bdrv(job, "target", target, 0, BLK_PERM_ALL, &error_abor= t); + block_job_start(job); + + g_assert_cmpint(job->pause_count, =3D=3D, 0); + g_assert_false(job->paused); + g_assert_false(job->busy); /* We're in block_job_sleep_ns() */ + + do_drain_begin(drain_type, src); + + if (drain_type =3D=3D BDRV_DRAIN_ALL) { + /* bdrv_drain_all() drains both src and target, and involves an + * additional block_job_pause_all() */ + g_assert_cmpint(job->pause_count, =3D=3D, 3); + } else { + g_assert_cmpint(job->pause_count, =3D=3D, 1); + } + /* XXX We don't wait until the job is actually paused. Is this okay? */ + /* g_assert_true(job->paused); */ + g_assert_false(job->busy); /* The job is paused */ + + do_drain_end(drain_type, src); + + g_assert_cmpint(job->pause_count, =3D=3D, 0); + g_assert_false(job->paused); + g_assert_false(job->busy); /* We're in block_job_sleep_ns() */ + + do_drain_begin(drain_type, target); + + if (drain_type =3D=3D BDRV_DRAIN_ALL) { + /* bdrv_drain_all() drains both src and target, and involves an + * additional block_job_pause_all() */ + g_assert_cmpint(job->pause_count, =3D=3D, 3); + } else { + g_assert_cmpint(job->pause_count, =3D=3D, 1); + } + /* XXX We don't wait until the job is actually paused. Is this okay? */ + /* g_assert_true(job->paused); */ + g_assert_false(job->busy); /* The job is paused */ + + do_drain_end(drain_type, target); + + g_assert_cmpint(job->pause_count, =3D=3D, 0); + g_assert_false(job->paused); + g_assert_false(job->busy); /* We're in block_job_sleep_ns() */ + + ret =3D block_job_complete_sync(job, &error_abort); + g_assert_cmpint(ret, =3D=3D, 0); + + blk_unref(blk_src); + blk_unref(blk_target); + bdrv_unref(src); + bdrv_unref(target); +} + +static void test_blockjob_drain_all(void) +{ + test_blockjob_common(BDRV_DRAIN_ALL); +} + +static void test_blockjob_drain(void) +{ + test_blockjob_common(BDRV_DRAIN); +} + int main(int argc, char **argv) { bdrv_init(); @@ -233,5 +351,8 @@ int main(int argc, char **argv) g_test_add_func("/bdrv-drain/quiesce/drain_all", test_quiesce_drain_al= l); g_test_add_func("/bdrv-drain/quiesce/drain", test_quiesce_drain); =20 + g_test_add_func("/bdrv-drain/blockjob/drain_all", test_blockjob_drain_= all); + g_test_add_func("/bdrv-drain/blockjob/drain", test_blockjob_drain); + return g_test_run(); } --=20 2.13.6 From nobody Sat May 3 10:50:33 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513957177252451.2237605386505; Fri, 22 Dec 2017 07:39:37 -0800 (PST) Received: from localhost ([::1]:54555 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1eSPQ1-0005wN-1j for importer@patchew.org; Fri, 22 Dec 2017 10:39:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57458) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6q-0005x0-5Q for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6p-0002c8-C6 for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54444) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6l-0002Y3-Kx; Fri, 22 Dec 2017 10:19:35 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C003C81DFF; Fri, 22 Dec 2017 15:19:34 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-107.ams2.redhat.com [10.36.117.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C80A60CA9; Fri, 22 Dec 2017 15:19:33 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Fri, 22 Dec 2017 16:18:35 +0100 Message-Id: <20171222151846.28110-25-kwolf@redhat.com> In-Reply-To: <20171222151846.28110-1-kwolf@redhat.com> References: <20171222151846.28110-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 22 Dec 2017 15:19:34 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 24/35] block: Don't block_job_pause_all() in bdrv_drain_all() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Block jobs are already paused using the BdrvChildRole drain callbacks, so we don't need an additional block_job_pause_all() call. Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- block/io.c | 4 ---- tests/test-bdrv-drain.c | 10 ++++------ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/block/io.c b/block/io.c index 91a52e2d82..74d2e5278e 100644 --- a/block/io.c +++ b/block/io.c @@ -338,8 +338,6 @@ void bdrv_drain_all_begin(void) * context. */ assert(qemu_get_current_aio_context() =3D=3D qemu_get_aio_context()); =20 - block_job_pause_all(); - for (bs =3D bdrv_first(&it); bs; bs =3D bdrv_next(&it)) { AioContext *aio_context =3D bdrv_get_aio_context(bs); =20 @@ -395,8 +393,6 @@ void bdrv_drain_all_end(void) aio_enable_external(aio_context); aio_context_release(aio_context); } - - block_job_resume_all(); } =20 void bdrv_drain_all(void) diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c index 9783768a20..6da66ae841 100644 --- a/tests/test-bdrv-drain.c +++ b/tests/test-bdrv-drain.c @@ -284,9 +284,8 @@ static void test_blockjob_common(enum drain_type drain_= type) do_drain_begin(drain_type, src); =20 if (drain_type =3D=3D BDRV_DRAIN_ALL) { - /* bdrv_drain_all() drains both src and target, and involves an - * additional block_job_pause_all() */ - g_assert_cmpint(job->pause_count, =3D=3D, 3); + /* bdrv_drain_all() drains both src and target */ + g_assert_cmpint(job->pause_count, =3D=3D, 2); } else { g_assert_cmpint(job->pause_count, =3D=3D, 1); } @@ -303,9 +302,8 @@ static void test_blockjob_common(enum drain_type drain_= type) do_drain_begin(drain_type, target); =20 if (drain_type =3D=3D BDRV_DRAIN_ALL) { - /* bdrv_drain_all() drains both src and target, and involves an - * additional block_job_pause_all() */ - g_assert_cmpint(job->pause_count, =3D=3D, 3); + /* bdrv_drain_all() drains both src and target */ + g_assert_cmpint(job->pause_count, =3D=3D, 2); } else { g_assert_cmpint(job->pause_count, =3D=3D, 1); } --=20 2.13.6 From nobody Sat May 3 10:50:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513957347597617.7024034149645; Fri, 22 Dec 2017 07:42:27 -0800 (PST) Received: from localhost ([::1]:54596 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1eSPSo-0008Tj-DZ for importer@patchew.org; Fri, 22 Dec 2017 10:42:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57466) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6q-0005xP-E5 for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6p-0002cQ-Lq for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34992) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6n-0002ZR-0S; Fri, 22 Dec 2017 10:19:37 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3A9C75D685; Fri, 22 Dec 2017 15:19:36 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-107.ams2.redhat.com [10.36.117.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B6FB51DED; Fri, 22 Dec 2017 15:19:34 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Fri, 22 Dec 2017 16:18:36 +0100 Message-Id: <20171222151846.28110-26-kwolf@redhat.com> In-Reply-To: <20171222151846.28110-1-kwolf@redhat.com> References: <20171222151846.28110-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 22 Dec 2017 15:19:36 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 25/35] block: Nested drain_end must still call callbacks X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" bdrv_do_drained_begin() restricts the call of parent callbacks and aio_disable_external() to the outermost drain section, but the block driver callbacks are always called. bdrv_do_drained_end() must match this behaviour, otherwise nodes stay drained even if begin/end calls were balanced. Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- block/io.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/block/io.c b/block/io.c index 74d2e5278e..6038a16c58 100644 --- a/block/io.c +++ b/block/io.c @@ -273,19 +273,21 @@ void bdrv_drained_begin(BlockDriverState *bs) =20 void bdrv_drained_end(BlockDriverState *bs) { + int old_quiesce_counter; + if (qemu_in_coroutine()) { bdrv_co_yield_to_drain(bs, false); return; } assert(bs->quiesce_counter > 0); - if (atomic_fetch_dec(&bs->quiesce_counter) > 1) { - return; - } + old_quiesce_counter =3D atomic_fetch_dec(&bs->quiesce_counter); =20 /* Re-enable things in child-to-parent order */ bdrv_drain_invoke(bs, false, false); - bdrv_parent_drained_end(bs); - aio_enable_external(bdrv_get_aio_context(bs)); + if (old_quiesce_counter =3D=3D 1) { + bdrv_parent_drained_end(bs); + aio_enable_external(bdrv_get_aio_context(bs)); + } } =20 /* --=20 2.13.6 From nobody Sat May 3 10:50:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513957507427937.5322999765342; Fri, 22 Dec 2017 07:45:07 -0800 (PST) Received: from localhost ([::1]:54776 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1eSPVP-0002lG-Aj for importer@patchew.org; Fri, 22 Dec 2017 10:45:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57510) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6s-00060D-57 for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6r-0002e4-3x for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55854) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6o-0002af-Gu; Fri, 22 Dec 2017 10:19:38 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AA39DC0050CB; Fri, 22 Dec 2017 15:19:37 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-107.ams2.redhat.com [10.36.117.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D3A351DED; Fri, 22 Dec 2017 15:19:36 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Fri, 22 Dec 2017 16:18:37 +0100 Message-Id: <20171222151846.28110-27-kwolf@redhat.com> In-Reply-To: <20171222151846.28110-1-kwolf@redhat.com> References: <20171222151846.28110-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 22 Dec 2017 15:19:37 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 26/35] test-bdrv-drain: Test nested drain sections X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- tests/test-bdrv-drain.c | 57 +++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 57 insertions(+) diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c index 6da66ae841..9098b77ab4 100644 --- a/tests/test-bdrv-drain.c +++ b/tests/test-bdrv-drain.c @@ -85,6 +85,7 @@ static void aio_ret_cb(void *opaque, int ret) enum drain_type { BDRV_DRAIN_ALL, BDRV_DRAIN, + DRAIN_TYPE_MAX, }; =20 static void do_drain_begin(enum drain_type drain_type, BlockDriverState *b= s) @@ -221,6 +222,60 @@ static void test_quiesce_drain(void) test_quiesce_common(BDRV_DRAIN, false); } =20 +static void test_nested(void) +{ + BlockBackend *blk; + BlockDriverState *bs, *backing; + BDRVTestState *s, *backing_s; + enum drain_type outer, inner; + + blk =3D blk_new(BLK_PERM_ALL, BLK_PERM_ALL); + bs =3D bdrv_new_open_driver(&bdrv_test, "test-node", BDRV_O_RDWR, + &error_abort); + s =3D bs->opaque; + blk_insert_bs(blk, bs, &error_abort); + + backing =3D bdrv_new_open_driver(&bdrv_test, "backing", 0, &error_abor= t); + backing_s =3D backing->opaque; + bdrv_set_backing_hd(bs, backing, &error_abort); + + for (outer =3D 0; outer < DRAIN_TYPE_MAX; outer++) { + for (inner =3D 0; inner < DRAIN_TYPE_MAX; inner++) { + /* XXX bdrv_drain_all() doesn't increase the quiesce_counter */ + int bs_quiesce =3D (outer !=3D BDRV_DRAIN_ALL) + + (inner !=3D BDRV_DRAIN_ALL); + int backing_quiesce =3D 0; + int backing_cb_cnt =3D (outer !=3D BDRV_DRAIN) + + (inner !=3D BDRV_DRAIN); + + g_assert_cmpint(bs->quiesce_counter, =3D=3D, 0); + g_assert_cmpint(backing->quiesce_counter, =3D=3D, 0); + g_assert_cmpint(s->drain_count, =3D=3D, 0); + g_assert_cmpint(backing_s->drain_count, =3D=3D, 0); + + do_drain_begin(outer, bs); + do_drain_begin(inner, bs); + + g_assert_cmpint(bs->quiesce_counter, =3D=3D, bs_quiesce); + g_assert_cmpint(backing->quiesce_counter, =3D=3D, backing_quie= sce); + g_assert_cmpint(s->drain_count, =3D=3D, 2); + g_assert_cmpint(backing_s->drain_count, =3D=3D, backing_cb_cnt= ); + + do_drain_end(inner, bs); + do_drain_end(outer, bs); + + g_assert_cmpint(bs->quiesce_counter, =3D=3D, 0); + g_assert_cmpint(backing->quiesce_counter, =3D=3D, 0); + g_assert_cmpint(s->drain_count, =3D=3D, 0); + g_assert_cmpint(backing_s->drain_count, =3D=3D, 0); + } + } + + bdrv_unref(backing); + bdrv_unref(bs); + blk_unref(blk); +} + =20 typedef struct TestBlockJob { BlockJob common; @@ -349,6 +404,8 @@ int main(int argc, char **argv) g_test_add_func("/bdrv-drain/quiesce/drain_all", test_quiesce_drain_al= l); g_test_add_func("/bdrv-drain/quiesce/drain", test_quiesce_drain); =20 + g_test_add_func("/bdrv-drain/nested", test_nested); + g_test_add_func("/bdrv-drain/blockjob/drain_all", test_blockjob_drain_= all); g_test_add_func("/bdrv-drain/blockjob/drain", test_blockjob_drain); =20 --=20 2.13.6 From nobody Sat May 3 10:50:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513957660560145.34963810263775; Fri, 22 Dec 2017 07:47:40 -0800 (PST) Received: from localhost ([::1]:54863 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1eSPXl-0004nA-As for importer@patchew.org; Fri, 22 Dec 2017 10:47:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57604) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6y-00064q-TC for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6v-0002jL-PE for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51054) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6q-0002cF-2C; Fri, 22 Dec 2017 10:19:40 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 472E230A085; Fri, 22 Dec 2017 15:19:39 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-107.ams2.redhat.com [10.36.117.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 08D6351DF6; Fri, 22 Dec 2017 15:19:37 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Fri, 22 Dec 2017 16:18:38 +0100 Message-Id: <20171222151846.28110-28-kwolf@redhat.com> In-Reply-To: <20171222151846.28110-1-kwolf@redhat.com> References: <20171222151846.28110-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 22 Dec 2017 15:19:39 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 27/35] block: Don't notify parents in drain call chain X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This is in preparation for subtree drains, i.e. drained sections that affect not only a single node, but recursively all child nodes, too. Calling the parent callbacks for drain is pointless when we just came from that parent node recursively and leads to multiple increases of bs->quiesce_counter in a single drain call. Don't do it. In order for this to work correctly, the parent callback must be called for every bdrv_drain_begin/end() call, not only for the outermost one: If we have a node N with two parents A and B, recursive draining of A should cause the quiesce_counter of B to increase because its child N is drained independently of B. If now B is recursively drained, too, A must increase its quiesce_counter because N is drained independently of A only now, even if N is going from quiesce_counter 1 to 2. Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- include/block/block.h | 4 ++-- block.c | 13 +++++++++---- block/io.c | 47 ++++++++++++++++++++++++++++++++++------------- 3 files changed, 45 insertions(+), 19 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index c05cac57e5..60c5d11029 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -585,7 +585,7 @@ void bdrv_io_unplug(BlockDriverState *bs); * Begin a quiesced section of all users of @bs. This is part of * bdrv_drained_begin. */ -void bdrv_parent_drained_begin(BlockDriverState *bs); +void bdrv_parent_drained_begin(BlockDriverState *bs, BdrvChild *ignore); =20 /** * bdrv_parent_drained_end: @@ -593,7 +593,7 @@ void bdrv_parent_drained_begin(BlockDriverState *bs); * End a quiesced section of all users of @bs. This is part of * bdrv_drained_end. */ -void bdrv_parent_drained_end(BlockDriverState *bs); +void bdrv_parent_drained_end(BlockDriverState *bs, BdrvChild *ignore); =20 /** * bdrv_drained_begin: diff --git a/block.c b/block.c index dd90dca896..6c247167b8 100644 --- a/block.c +++ b/block.c @@ -1972,13 +1972,16 @@ static void bdrv_replace_child_noperm(BdrvChild *ch= ild, BlockDriverState *new_bs) { BlockDriverState *old_bs =3D child->bs; + int i; =20 if (old_bs && new_bs) { assert(bdrv_get_aio_context(old_bs) =3D=3D bdrv_get_aio_context(ne= w_bs)); } if (old_bs) { if (old_bs->quiesce_counter && child->role->drained_end) { - child->role->drained_end(child); + for (i =3D 0; i < old_bs->quiesce_counter; i++) { + child->role->drained_end(child); + } } if (child->role->detach) { child->role->detach(child); @@ -1991,7 +1994,9 @@ static void bdrv_replace_child_noperm(BdrvChild *chil= d, if (new_bs) { QLIST_INSERT_HEAD(&new_bs->parents, child, next_parent); if (new_bs->quiesce_counter && child->role->drained_begin) { - child->role->drained_begin(child); + for (i =3D 0; i < new_bs->quiesce_counter; i++) { + child->role->drained_begin(child); + } } =20 if (child->role->attach) { @@ -4759,7 +4764,7 @@ void bdrv_set_aio_context(BlockDriverState *bs, AioCo= ntext *new_context) AioContext *ctx =3D bdrv_get_aio_context(bs); =20 aio_disable_external(ctx); - bdrv_parent_drained_begin(bs); + bdrv_parent_drained_begin(bs, NULL); bdrv_drain(bs); /* ensure there are no in-flight requests */ =20 while (aio_poll(ctx, false)) { @@ -4773,7 +4778,7 @@ void bdrv_set_aio_context(BlockDriverState *bs, AioCo= ntext *new_context) */ aio_context_acquire(new_context); bdrv_attach_aio_context(bs, new_context); - bdrv_parent_drained_end(bs); + bdrv_parent_drained_end(bs, NULL); aio_enable_external(ctx); aio_context_release(new_context); } diff --git a/block/io.c b/block/io.c index 6038a16c58..09de0a9070 100644 --- a/block/io.c +++ b/block/io.c @@ -40,22 +40,28 @@ static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int bytes, BdrvRequestFlags flags); =20 -void bdrv_parent_drained_begin(BlockDriverState *bs) +void bdrv_parent_drained_begin(BlockDriverState *bs, BdrvChild *ignore) { BdrvChild *c, *next; =20 QLIST_FOREACH_SAFE(c, &bs->parents, next_parent, next) { + if (c =3D=3D ignore) { + continue; + } if (c->role->drained_begin) { c->role->drained_begin(c); } } } =20 -void bdrv_parent_drained_end(BlockDriverState *bs) +void bdrv_parent_drained_end(BlockDriverState *bs, BdrvChild *ignore) { BdrvChild *c, *next; =20 QLIST_FOREACH_SAFE(c, &bs->parents, next_parent, next) { + if (c =3D=3D ignore) { + continue; + } if (c->role->drained_end) { c->role->drained_end(c); } @@ -139,6 +145,7 @@ typedef struct { BlockDriverState *bs; bool done; bool begin; + BdrvChild *parent; } BdrvCoDrainData; =20 static void coroutine_fn bdrv_drain_invoke_entry(void *opaque) @@ -211,6 +218,9 @@ static bool bdrv_drain_recurse(BlockDriverState *bs) return waited; } =20 +static void bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent); +static void bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent); + static void bdrv_co_drain_bh_cb(void *opaque) { BdrvCoDrainData *data =3D opaque; @@ -219,9 +229,9 @@ static void bdrv_co_drain_bh_cb(void *opaque) =20 bdrv_dec_in_flight(bs); if (data->begin) { - bdrv_drained_begin(bs); + bdrv_do_drained_begin(bs, data->parent); } else { - bdrv_drained_end(bs); + bdrv_do_drained_end(bs, data->parent); } =20 data->done =3D true; @@ -229,7 +239,7 @@ static void bdrv_co_drain_bh_cb(void *opaque) } =20 static void coroutine_fn bdrv_co_yield_to_drain(BlockDriverState *bs, - bool begin) + bool begin, BdrvChild *par= ent) { BdrvCoDrainData data; =20 @@ -243,6 +253,7 @@ static void coroutine_fn bdrv_co_yield_to_drain(BlockDr= iverState *bs, .bs =3D bs, .done =3D false, .begin =3D begin, + .parent =3D parent, }; bdrv_inc_in_flight(bs); aio_bh_schedule_oneshot(bdrv_get_aio_context(bs), @@ -254,29 +265,34 @@ static void coroutine_fn bdrv_co_yield_to_drain(Block= DriverState *bs, assert(data.done); } =20 -void bdrv_drained_begin(BlockDriverState *bs) +static void bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent) { if (qemu_in_coroutine()) { - bdrv_co_yield_to_drain(bs, true); + bdrv_co_yield_to_drain(bs, true, parent); return; } =20 /* Stop things in parent-to-child order */ if (atomic_fetch_inc(&bs->quiesce_counter) =3D=3D 0) { aio_disable_external(bdrv_get_aio_context(bs)); - bdrv_parent_drained_begin(bs); } =20 + bdrv_parent_drained_begin(bs, parent); bdrv_drain_invoke(bs, true, false); bdrv_drain_recurse(bs); } =20 -void bdrv_drained_end(BlockDriverState *bs) +void bdrv_drained_begin(BlockDriverState *bs) +{ + bdrv_do_drained_begin(bs, NULL); +} + +static void bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent) { int old_quiesce_counter; =20 if (qemu_in_coroutine()) { - bdrv_co_yield_to_drain(bs, false); + bdrv_co_yield_to_drain(bs, false, parent); return; } assert(bs->quiesce_counter > 0); @@ -284,12 +300,17 @@ void bdrv_drained_end(BlockDriverState *bs) =20 /* Re-enable things in child-to-parent order */ bdrv_drain_invoke(bs, false, false); + bdrv_parent_drained_end(bs, parent); if (old_quiesce_counter =3D=3D 1) { - bdrv_parent_drained_end(bs); aio_enable_external(bdrv_get_aio_context(bs)); } } =20 +void bdrv_drained_end(BlockDriverState *bs) +{ + bdrv_do_drained_end(bs, NULL); +} + /* * Wait for pending requests to complete on a single BlockDriverState subt= ree, * and suspend block driver's internal I/O until next request arrives. @@ -346,7 +367,7 @@ void bdrv_drain_all_begin(void) /* Stop things in parent-to-child order */ aio_context_acquire(aio_context); aio_disable_external(aio_context); - bdrv_parent_drained_begin(bs); + bdrv_parent_drained_begin(bs, NULL); bdrv_drain_invoke(bs, true, true); aio_context_release(aio_context); =20 @@ -391,7 +412,7 @@ void bdrv_drain_all_end(void) /* Re-enable things in child-to-parent order */ aio_context_acquire(aio_context); bdrv_drain_invoke(bs, false, true); - bdrv_parent_drained_end(bs); + bdrv_parent_drained_end(bs, NULL); aio_enable_external(aio_context); aio_context_release(aio_context); } --=20 2.13.6 From nobody Sat May 3 10:50:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513957423457184.48654147361322; Fri, 22 Dec 2017 07:43:43 -0800 (PST) Received: from localhost ([::1]:54672 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1eSPU2-0001Ey-9Q for importer@patchew.org; Fri, 22 Dec 2017 10:43:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57625) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP70-000664-66 for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6y-0002nd-Up for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35032) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6s-0002fr-Vn; Fri, 22 Dec 2017 10:19:43 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 309C91A406F; Fri, 22 Dec 2017 15:19:42 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-107.ams2.redhat.com [10.36.117.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9A2F960CA9; Fri, 22 Dec 2017 15:19:39 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Fri, 22 Dec 2017 16:18:39 +0100 Message-Id: <20171222151846.28110-29-kwolf@redhat.com> In-Reply-To: <20171222151846.28110-1-kwolf@redhat.com> References: <20171222151846.28110-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 22 Dec 2017 15:19:42 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 28/35] block: Add bdrv_subtree_drained_begin/end() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" bdrv_drained_begin() waits for the completion of requests in the whole subtree, but it only actually keeps its immediate bs parameter quiesced until bdrv_drained_end(). Add a version that keeps the whole subtree drained. As of this commit, graph changes cannot be allowed during a subtree drained section, but this will be fixed soon. Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- include/block/block.h | 13 +++++++++++++ block/io.c | 54 ++++++++++++++++++++++++++++++++++++++++-------= ---- 2 files changed, 56 insertions(+), 11 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index 60c5d11029..de9c5a2b9b 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -608,12 +608,25 @@ void bdrv_parent_drained_end(BlockDriverState *bs, Bd= rvChild *ignore); void bdrv_drained_begin(BlockDriverState *bs); =20 /** + * Like bdrv_drained_begin, but recursively begins a quiesced section for + * exclusive access to all child nodes as well. + * + * Graph changes are not allowed during a subtree drain section. + */ +void bdrv_subtree_drained_begin(BlockDriverState *bs); + +/** * bdrv_drained_end: * * End a quiescent section started by bdrv_drained_begin(). */ void bdrv_drained_end(BlockDriverState *bs); =20 +/** + * End a quiescent section started by bdrv_subtree_drained_begin(). + */ +void bdrv_subtree_drained_end(BlockDriverState *bs); + void bdrv_add_child(BlockDriverState *parent, BlockDriverState *child, Error **errp); void bdrv_del_child(BlockDriverState *parent, BdrvChild *child, Error **er= rp); diff --git a/block/io.c b/block/io.c index 09de0a9070..6befef166d 100644 --- a/block/io.c +++ b/block/io.c @@ -145,6 +145,7 @@ typedef struct { BlockDriverState *bs; bool done; bool begin; + bool recursive; BdrvChild *parent; } BdrvCoDrainData; =20 @@ -218,8 +219,10 @@ static bool bdrv_drain_recurse(BlockDriverState *bs) return waited; } =20 -static void bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent); -static void bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent); +static void bdrv_do_drained_begin(BlockDriverState *bs, bool recursive, + BdrvChild *parent); +static void bdrv_do_drained_end(BlockDriverState *bs, bool recursive, + BdrvChild *parent); =20 static void bdrv_co_drain_bh_cb(void *opaque) { @@ -229,9 +232,9 @@ static void bdrv_co_drain_bh_cb(void *opaque) =20 bdrv_dec_in_flight(bs); if (data->begin) { - bdrv_do_drained_begin(bs, data->parent); + bdrv_do_drained_begin(bs, data->recursive, data->parent); } else { - bdrv_do_drained_end(bs, data->parent); + bdrv_do_drained_end(bs, data->recursive, data->parent); } =20 data->done =3D true; @@ -239,7 +242,8 @@ static void bdrv_co_drain_bh_cb(void *opaque) } =20 static void coroutine_fn bdrv_co_yield_to_drain(BlockDriverState *bs, - bool begin, BdrvChild *par= ent) + bool begin, bool recursive, + BdrvChild *parent) { BdrvCoDrainData data; =20 @@ -253,6 +257,7 @@ static void coroutine_fn bdrv_co_yield_to_drain(BlockDr= iverState *bs, .bs =3D bs, .done =3D false, .begin =3D begin, + .recursive =3D recursive, .parent =3D parent, }; bdrv_inc_in_flight(bs); @@ -265,10 +270,13 @@ static void coroutine_fn bdrv_co_yield_to_drain(Block= DriverState *bs, assert(data.done); } =20 -static void bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent) +static void bdrv_do_drained_begin(BlockDriverState *bs, bool recursive, + BdrvChild *parent) { + BdrvChild *child, *next; + if (qemu_in_coroutine()) { - bdrv_co_yield_to_drain(bs, true, parent); + bdrv_co_yield_to_drain(bs, true, recursive, parent); return; } =20 @@ -280,19 +288,32 @@ static void bdrv_do_drained_begin(BlockDriverState *b= s, BdrvChild *parent) bdrv_parent_drained_begin(bs, parent); bdrv_drain_invoke(bs, true, false); bdrv_drain_recurse(bs); + + if (recursive) { + QLIST_FOREACH_SAFE(child, &bs->children, next, next) { + bdrv_do_drained_begin(child->bs, true, child); + } + } } =20 void bdrv_drained_begin(BlockDriverState *bs) { - bdrv_do_drained_begin(bs, NULL); + bdrv_do_drained_begin(bs, false, NULL); +} + +void bdrv_subtree_drained_begin(BlockDriverState *bs) +{ + bdrv_do_drained_begin(bs, true, NULL); } =20 -static void bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent) +static void bdrv_do_drained_end(BlockDriverState *bs, bool recursive, + BdrvChild *parent) { + BdrvChild *child, *next; int old_quiesce_counter; =20 if (qemu_in_coroutine()) { - bdrv_co_yield_to_drain(bs, false, parent); + bdrv_co_yield_to_drain(bs, false, recursive, parent); return; } assert(bs->quiesce_counter > 0); @@ -304,11 +325,22 @@ static void bdrv_do_drained_end(BlockDriverState *bs,= BdrvChild *parent) if (old_quiesce_counter =3D=3D 1) { aio_enable_external(bdrv_get_aio_context(bs)); } + + if (recursive) { + QLIST_FOREACH_SAFE(child, &bs->children, next, next) { + bdrv_do_drained_end(child->bs, true, child); + } + } } =20 void bdrv_drained_end(BlockDriverState *bs) { - bdrv_do_drained_end(bs, NULL); + bdrv_do_drained_end(bs, false, NULL); +} + +void bdrv_subtree_drained_end(BlockDriverState *bs) +{ + bdrv_do_drained_end(bs, true, NULL); } =20 /* --=20 2.13.6 From nobody Sat May 3 10:50:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513957814842982.407478176324; Fri, 22 Dec 2017 07:50:14 -0800 (PST) Received: from localhost ([::1]:54923 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1eSPaL-0006kL-Kc for importer@patchew.org; Fri, 22 Dec 2017 10:50:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57681) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP72-0006CL-Mx for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP71-0002ps-Ku for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54476) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6u-0002hS-IM; Fri, 22 Dec 2017 10:19:44 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B9EB179704; Fri, 22 Dec 2017 15:19:43 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-107.ams2.redhat.com [10.36.117.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 840D051DED; Fri, 22 Dec 2017 15:19:42 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Fri, 22 Dec 2017 16:18:40 +0100 Message-Id: <20171222151846.28110-30-kwolf@redhat.com> In-Reply-To: <20171222151846.28110-1-kwolf@redhat.com> References: <20171222151846.28110-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 22 Dec 2017 15:19:43 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 29/35] test-bdrv-drain: Tests for bdrv_subtree_drain X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add a subtree drain version to the existing test cases. Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- tests/test-bdrv-drain.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c index 9098b77ab4..f363d51b34 100644 --- a/tests/test-bdrv-drain.c +++ b/tests/test-bdrv-drain.c @@ -85,6 +85,7 @@ static void aio_ret_cb(void *opaque, int ret) enum drain_type { BDRV_DRAIN_ALL, BDRV_DRAIN, + BDRV_SUBTREE_DRAIN, DRAIN_TYPE_MAX, }; =20 @@ -93,6 +94,7 @@ static void do_drain_begin(enum drain_type drain_type, Bl= ockDriverState *bs) switch (drain_type) { case BDRV_DRAIN_ALL: bdrv_drain_all_begin(); break; case BDRV_DRAIN: bdrv_drained_begin(bs); break; + case BDRV_SUBTREE_DRAIN: bdrv_subtree_drained_begin(bs); break; default: g_assert_not_reached(); } } @@ -102,6 +104,7 @@ static void do_drain_end(enum drain_type drain_type, Bl= ockDriverState *bs) switch (drain_type) { case BDRV_DRAIN_ALL: bdrv_drain_all_end(); break; case BDRV_DRAIN: bdrv_drained_end(bs); break; + case BDRV_SUBTREE_DRAIN: bdrv_subtree_drained_end(bs); break; default: g_assert_not_reached(); } } @@ -180,6 +183,11 @@ static void test_drv_cb_drain(void) test_drv_cb_common(BDRV_DRAIN, false); } =20 +static void test_drv_cb_drain_subtree(void) +{ + test_drv_cb_common(BDRV_SUBTREE_DRAIN, true); +} + static void test_quiesce_common(enum drain_type drain_type, bool recursive) { BlockBackend *blk; @@ -222,6 +230,11 @@ static void test_quiesce_drain(void) test_quiesce_common(BDRV_DRAIN, false); } =20 +static void test_quiesce_drain_subtree(void) +{ + test_quiesce_common(BDRV_SUBTREE_DRAIN, true); +} + static void test_nested(void) { BlockBackend *blk; @@ -244,7 +257,8 @@ static void test_nested(void) /* XXX bdrv_drain_all() doesn't increase the quiesce_counter */ int bs_quiesce =3D (outer !=3D BDRV_DRAIN_ALL) + (inner !=3D BDRV_DRAIN_ALL); - int backing_quiesce =3D 0; + int backing_quiesce =3D (outer =3D=3D BDRV_SUBTREE_DRAIN) + + (inner =3D=3D BDRV_SUBTREE_DRAIN); int backing_cb_cnt =3D (outer !=3D BDRV_DRAIN) + (inner !=3D BDRV_DRAIN); =20 @@ -391,6 +405,11 @@ static void test_blockjob_drain(void) test_blockjob_common(BDRV_DRAIN); } =20 +static void test_blockjob_drain_subtree(void) +{ + test_blockjob_common(BDRV_SUBTREE_DRAIN); +} + int main(int argc, char **argv) { bdrv_init(); @@ -400,14 +419,20 @@ int main(int argc, char **argv) =20 g_test_add_func("/bdrv-drain/driver-cb/drain_all", test_drv_cb_drain_a= ll); g_test_add_func("/bdrv-drain/driver-cb/drain", test_drv_cb_drain); + g_test_add_func("/bdrv-drain/driver-cb/drain_subtree", + test_drv_cb_drain_subtree); =20 g_test_add_func("/bdrv-drain/quiesce/drain_all", test_quiesce_drain_al= l); g_test_add_func("/bdrv-drain/quiesce/drain", test_quiesce_drain); + g_test_add_func("/bdrv-drain/quiesce/drain_subtree", + test_quiesce_drain_subtree); =20 g_test_add_func("/bdrv-drain/nested", test_nested); =20 g_test_add_func("/bdrv-drain/blockjob/drain_all", test_blockjob_drain_= all); g_test_add_func("/bdrv-drain/blockjob/drain", test_blockjob_drain); + g_test_add_func("/bdrv-drain/blockjob/drain_subtree", + test_blockjob_drain_subtree); =20 return g_test_run(); } --=20 2.13.6 From nobody Sat May 3 10:50:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513957661456204.17715453954486; Fri, 22 Dec 2017 07:47:41 -0800 (PST) Received: from localhost ([::1]:54864 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1eSPXq-0004qm-GB for importer@patchew.org; Fri, 22 Dec 2017 10:47:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57651) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP71-0006AH-Jw for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP70-0002ot-CD for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45722) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6w-0002ix-2A; Fri, 22 Dec 2017 10:19:46 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 47BA080476; Fri, 22 Dec 2017 15:19:45 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-107.ams2.redhat.com [10.36.117.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 18A4160CA9; Fri, 22 Dec 2017 15:19:43 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Fri, 22 Dec 2017 16:18:41 +0100 Message-Id: <20171222151846.28110-31-kwolf@redhat.com> In-Reply-To: <20171222151846.28110-1-kwolf@redhat.com> References: <20171222151846.28110-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 22 Dec 2017 15:19:45 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 30/35] test-bdrv-drain: Test behaviour in coroutine context X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If bdrv_do_drained_begin/end() are called in coroutine context, they first use a BH to get out of the coroutine context. Call some existing tests again from a coroutine to cover this code path. Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- tests/test-bdrv-drain.c | 59 +++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 59 insertions(+) diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c index f363d51b34..354c6151a0 100644 --- a/tests/test-bdrv-drain.c +++ b/tests/test-bdrv-drain.c @@ -82,6 +82,34 @@ static void aio_ret_cb(void *opaque, int ret) *aio_ret =3D ret; } =20 +typedef struct CallInCoroutineData { + void (*entry)(void); + bool done; +} CallInCoroutineData; + +static coroutine_fn void call_in_coroutine_entry(void *opaque) +{ + CallInCoroutineData *data =3D opaque; + + data->entry(); + data->done =3D true; +} + +static void call_in_coroutine(void (*entry)(void)) +{ + Coroutine *co; + CallInCoroutineData data =3D { + .entry =3D entry, + .done =3D false, + }; + + co =3D qemu_coroutine_create(call_in_coroutine_entry, &data); + qemu_coroutine_enter(co); + while (!data.done) { + aio_poll(qemu_get_aio_context(), true); + } +} + enum drain_type { BDRV_DRAIN_ALL, BDRV_DRAIN, @@ -188,6 +216,16 @@ static void test_drv_cb_drain_subtree(void) test_drv_cb_common(BDRV_SUBTREE_DRAIN, true); } =20 +static void test_drv_cb_co_drain(void) +{ + call_in_coroutine(test_drv_cb_drain); +} + +static void test_drv_cb_co_drain_subtree(void) +{ + call_in_coroutine(test_drv_cb_drain_subtree); +} + static void test_quiesce_common(enum drain_type drain_type, bool recursive) { BlockBackend *blk; @@ -235,6 +273,16 @@ static void test_quiesce_drain_subtree(void) test_quiesce_common(BDRV_SUBTREE_DRAIN, true); } =20 +static void test_quiesce_co_drain(void) +{ + call_in_coroutine(test_quiesce_drain); +} + +static void test_quiesce_co_drain_subtree(void) +{ + call_in_coroutine(test_quiesce_drain_subtree); +} + static void test_nested(void) { BlockBackend *blk; @@ -422,11 +470,22 @@ int main(int argc, char **argv) g_test_add_func("/bdrv-drain/driver-cb/drain_subtree", test_drv_cb_drain_subtree); =20 + // XXX bdrv_drain_all() doesn't work in coroutine context + g_test_add_func("/bdrv-drain/driver-cb/co/drain", test_drv_cb_co_drain= ); + g_test_add_func("/bdrv-drain/driver-cb/co/drain_subtree", + test_drv_cb_co_drain_subtree); + + g_test_add_func("/bdrv-drain/quiesce/drain_all", test_quiesce_drain_al= l); g_test_add_func("/bdrv-drain/quiesce/drain", test_quiesce_drain); g_test_add_func("/bdrv-drain/quiesce/drain_subtree", test_quiesce_drain_subtree); =20 + // XXX bdrv_drain_all() doesn't work in coroutine context + g_test_add_func("/bdrv-drain/quiesce/co/drain", test_quiesce_co_drain); + g_test_add_func("/bdrv-drain/quiesce/co/drain_subtree", + test_quiesce_co_drain_subtree); + g_test_add_func("/bdrv-drain/nested", test_nested); =20 g_test_add_func("/bdrv-drain/blockjob/drain_all", test_blockjob_drain_= all); --=20 2.13.6 From nobody Sat May 3 10:50:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513957989401314.54606451416043; Fri, 22 Dec 2017 07:53:09 -0800 (PST) Received: from localhost ([::1]:55075 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1eSPd4-0000j5-3N for importer@patchew.org; Fri, 22 Dec 2017 10:52:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57690) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP73-0006Cj-1W for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP71-0002qL-US for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60334) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP6z-0002nP-By; Fri, 22 Dec 2017 10:19:49 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 96E5F356DB; Fri, 22 Dec 2017 15:19:48 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-107.ams2.redhat.com [10.36.117.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9AD7460C80; Fri, 22 Dec 2017 15:19:45 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Fri, 22 Dec 2017 16:18:42 +0100 Message-Id: <20171222151846.28110-32-kwolf@redhat.com> In-Reply-To: <20171222151846.28110-1-kwolf@redhat.com> References: <20171222151846.28110-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 22 Dec 2017 15:19:48 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 31/35] test-bdrv-drain: Recursive draining with multiple parents X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Test that drain sections are correctly propagated through the graph. Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- tests/test-bdrv-drain.c | 74 +++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 74 insertions(+) diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c index 354c6151a0..690b585b4d 100644 --- a/tests/test-bdrv-drain.c +++ b/tests/test-bdrv-drain.c @@ -338,6 +338,79 @@ static void test_nested(void) blk_unref(blk); } =20 +static void test_multiparent(void) +{ + BlockBackend *blk_a, *blk_b; + BlockDriverState *bs_a, *bs_b, *backing; + BDRVTestState *a_s, *b_s, *backing_s; + + blk_a =3D blk_new(BLK_PERM_ALL, BLK_PERM_ALL); + bs_a =3D bdrv_new_open_driver(&bdrv_test, "test-node-a", BDRV_O_RDWR, + &error_abort); + a_s =3D bs_a->opaque; + blk_insert_bs(blk_a, bs_a, &error_abort); + + blk_b =3D blk_new(BLK_PERM_ALL, BLK_PERM_ALL); + bs_b =3D bdrv_new_open_driver(&bdrv_test, "test-node-b", BDRV_O_RDWR, + &error_abort); + b_s =3D bs_b->opaque; + blk_insert_bs(blk_b, bs_b, &error_abort); + + backing =3D bdrv_new_open_driver(&bdrv_test, "backing", 0, &error_abor= t); + backing_s =3D backing->opaque; + bdrv_set_backing_hd(bs_a, backing, &error_abort); + bdrv_set_backing_hd(bs_b, backing, &error_abort); + + g_assert_cmpint(bs_a->quiesce_counter, =3D=3D, 0); + g_assert_cmpint(bs_b->quiesce_counter, =3D=3D, 0); + g_assert_cmpint(backing->quiesce_counter, =3D=3D, 0); + g_assert_cmpint(a_s->drain_count, =3D=3D, 0); + g_assert_cmpint(b_s->drain_count, =3D=3D, 0); + g_assert_cmpint(backing_s->drain_count, =3D=3D, 0); + + do_drain_begin(BDRV_SUBTREE_DRAIN, bs_a); + + g_assert_cmpint(bs_a->quiesce_counter, =3D=3D, 1); + g_assert_cmpint(bs_b->quiesce_counter, =3D=3D, 1); + g_assert_cmpint(backing->quiesce_counter, =3D=3D, 1); + g_assert_cmpint(a_s->drain_count, =3D=3D, 1); + g_assert_cmpint(b_s->drain_count, =3D=3D, 1); + g_assert_cmpint(backing_s->drain_count, =3D=3D, 1); + + do_drain_begin(BDRV_SUBTREE_DRAIN, bs_b); + + g_assert_cmpint(bs_a->quiesce_counter, =3D=3D, 2); + g_assert_cmpint(bs_b->quiesce_counter, =3D=3D, 2); + g_assert_cmpint(backing->quiesce_counter, =3D=3D, 2); + g_assert_cmpint(a_s->drain_count, =3D=3D, 2); + g_assert_cmpint(b_s->drain_count, =3D=3D, 2); + g_assert_cmpint(backing_s->drain_count, =3D=3D, 2); + + do_drain_end(BDRV_SUBTREE_DRAIN, bs_b); + + g_assert_cmpint(bs_a->quiesce_counter, =3D=3D, 1); + g_assert_cmpint(bs_b->quiesce_counter, =3D=3D, 1); + g_assert_cmpint(backing->quiesce_counter, =3D=3D, 1); + g_assert_cmpint(a_s->drain_count, =3D=3D, 1); + g_assert_cmpint(b_s->drain_count, =3D=3D, 1); + g_assert_cmpint(backing_s->drain_count, =3D=3D, 1); + + do_drain_end(BDRV_SUBTREE_DRAIN, bs_a); + + g_assert_cmpint(bs_a->quiesce_counter, =3D=3D, 0); + g_assert_cmpint(bs_b->quiesce_counter, =3D=3D, 0); + g_assert_cmpint(backing->quiesce_counter, =3D=3D, 0); + g_assert_cmpint(a_s->drain_count, =3D=3D, 0); + g_assert_cmpint(b_s->drain_count, =3D=3D, 0); + g_assert_cmpint(backing_s->drain_count, =3D=3D, 0); + + bdrv_unref(backing); + bdrv_unref(bs_a); + bdrv_unref(bs_b); + blk_unref(blk_a); + blk_unref(blk_b); +} + =20 typedef struct TestBlockJob { BlockJob common; @@ -487,6 +560,7 @@ int main(int argc, char **argv) test_quiesce_co_drain_subtree); =20 g_test_add_func("/bdrv-drain/nested", test_nested); + g_test_add_func("/bdrv-drain/multiparent", test_multiparent); =20 g_test_add_func("/bdrv-drain/blockjob/drain_all", test_blockjob_drain_= all); g_test_add_func("/bdrv-drain/blockjob/drain", test_blockjob_drain); --=20 2.13.6 From nobody Sat May 3 10:50:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513958140782687.9629235547716; Fri, 22 Dec 2017 07:55:40 -0800 (PST) Received: from localhost ([::1]:55288 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1eSPfZ-0002xF-Q4 for importer@patchew.org; Fri, 22 Dec 2017 10:55:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57786) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP7A-0006L8-HY for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:20:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP79-0002vp-4P for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:20:00 -0500 Received: from mx1.redhat.com ([209.132.183.28]:61727) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP70-0002oo-Us; Fri, 22 Dec 2017 10:19:51 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 22016690B; Fri, 22 Dec 2017 15:19:50 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-107.ams2.redhat.com [10.36.117.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id E776560CA9; Fri, 22 Dec 2017 15:19:48 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Fri, 22 Dec 2017 16:18:43 +0100 Message-Id: <20171222151846.28110-33-kwolf@redhat.com> In-Reply-To: <20171222151846.28110-1-kwolf@redhat.com> References: <20171222151846.28110-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 22 Dec 2017 15:19:50 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 32/35] block: Allow graph changes in subtree drained section X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We need to remember how many of the drain sections in which a node is were recursive (i.e. subtree drain rather than node drain), so that they can be correctly applied when children are added or removed during the drained section. With this change, it is safe to modify the graph even inside a bdrv_subtree_drained_begin/end() section. Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- include/block/block.h | 2 -- include/block/block_int.h | 5 +++++ block.c | 32 +++++++++++++++++++++++++++++--- block/io.c | 28 ++++++++++++++++++++++++---- 4 files changed, 58 insertions(+), 9 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index de9c5a2b9b..9b12774ddf 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -610,8 +610,6 @@ void bdrv_drained_begin(BlockDriverState *bs); /** * Like bdrv_drained_begin, but recursively begins a quiesced section for * exclusive access to all child nodes as well. - * - * Graph changes are not allowed during a subtree drain section. */ void bdrv_subtree_drained_begin(BlockDriverState *bs); =20 diff --git a/include/block/block_int.h b/include/block/block_int.h index e107163594..29cafa4236 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -717,6 +717,8 @@ struct BlockDriverState { =20 /* Accessed with atomic ops. */ int quiesce_counter; + int recursive_quiesce_counter; + unsigned int write_gen; /* Current data generation */ =20 /* Protected by reqs_lock. */ @@ -768,6 +770,9 @@ int coroutine_fn bdrv_co_pwritev(BdrvChild *child, int64_t offset, unsigned int bytes, QEMUIOVector *qiov, BdrvRequestFlags flags); =20 +void bdrv_apply_subtree_drain(BdrvChild *child, BlockDriverState *new_pare= nt); +void bdrv_unapply_subtree_drain(BdrvChild *child, BlockDriverState *old_pa= rent); + int get_tmp_filename(char *filename, int size); BlockDriver *bdrv_probe_all(const uint8_t *buf, int buf_size, const char *filename); diff --git a/block.c b/block.c index 6c247167b8..8b46ba21b1 100644 --- a/block.c +++ b/block.c @@ -822,6 +822,18 @@ static void bdrv_child_cb_drained_end(BdrvChild *child) bdrv_drained_end(bs); } =20 +static void bdrv_child_cb_attach(BdrvChild *child) +{ + BlockDriverState *bs =3D child->opaque; + bdrv_apply_subtree_drain(child, bs); +} + +static void bdrv_child_cb_detach(BdrvChild *child) +{ + BlockDriverState *bs =3D child->opaque; + bdrv_unapply_subtree_drain(child, bs); +} + static int bdrv_child_cb_inactivate(BdrvChild *child) { BlockDriverState *bs =3D child->opaque; @@ -889,6 +901,8 @@ const BdrvChildRole child_file =3D { .inherit_options =3D bdrv_inherited_options, .drained_begin =3D bdrv_child_cb_drained_begin, .drained_end =3D bdrv_child_cb_drained_end, + .attach =3D bdrv_child_cb_attach, + .detach =3D bdrv_child_cb_detach, .inactivate =3D bdrv_child_cb_inactivate, }; =20 @@ -911,6 +925,8 @@ const BdrvChildRole child_format =3D { .inherit_options =3D bdrv_inherited_fmt_options, .drained_begin =3D bdrv_child_cb_drained_begin, .drained_end =3D bdrv_child_cb_drained_end, + .attach =3D bdrv_child_cb_attach, + .detach =3D bdrv_child_cb_detach, .inactivate =3D bdrv_child_cb_inactivate, }; =20 @@ -953,6 +969,8 @@ static void bdrv_backing_attach(BdrvChild *c) parent->backing_blocker); bdrv_op_unblock(backing_hd, BLOCK_OP_TYPE_BACKUP_TARGET, parent->backing_blocker); + + bdrv_child_cb_attach(c); } =20 static void bdrv_backing_detach(BdrvChild *c) @@ -963,6 +981,8 @@ static void bdrv_backing_detach(BdrvChild *c) bdrv_op_unblock_all(c->bs, parent->backing_blocker); error_free(parent->backing_blocker); parent->backing_blocker =3D NULL; + + bdrv_child_cb_detach(c); } =20 /* @@ -1978,14 +1998,17 @@ static void bdrv_replace_child_noperm(BdrvChild *ch= ild, assert(bdrv_get_aio_context(old_bs) =3D=3D bdrv_get_aio_context(ne= w_bs)); } if (old_bs) { + /* Detach first so that the recursive drain sections coming from @= child + * are already gone and we only end the drain sections that came f= rom + * elsewhere. */ + if (child->role->detach) { + child->role->detach(child); + } if (old_bs->quiesce_counter && child->role->drained_end) { for (i =3D 0; i < old_bs->quiesce_counter; i++) { child->role->drained_end(child); } } - if (child->role->detach) { - child->role->detach(child); - } QLIST_REMOVE(child, next_parent); } =20 @@ -1999,6 +2022,9 @@ static void bdrv_replace_child_noperm(BdrvChild *chil= d, } } =20 + /* Attach only after starting new drained sections, so that recurs= ive + * drain sections coming from @child don't get an extra .drained_b= egin + * callback. */ if (child->role->attach) { child->role->attach(child); } diff --git a/block/io.c b/block/io.c index 6befef166d..7ea402352e 100644 --- a/block/io.c +++ b/block/io.c @@ -270,8 +270,8 @@ static void coroutine_fn bdrv_co_yield_to_drain(BlockDr= iverState *bs, assert(data.done); } =20 -static void bdrv_do_drained_begin(BlockDriverState *bs, bool recursive, - BdrvChild *parent) +void bdrv_do_drained_begin(BlockDriverState *bs, bool recursive, + BdrvChild *parent) { BdrvChild *child, *next; =20 @@ -290,6 +290,7 @@ static void bdrv_do_drained_begin(BlockDriverState *bs,= bool recursive, bdrv_drain_recurse(bs); =20 if (recursive) { + bs->recursive_quiesce_counter++; QLIST_FOREACH_SAFE(child, &bs->children, next, next) { bdrv_do_drained_begin(child->bs, true, child); } @@ -306,8 +307,8 @@ void bdrv_subtree_drained_begin(BlockDriverState *bs) bdrv_do_drained_begin(bs, true, NULL); } =20 -static void bdrv_do_drained_end(BlockDriverState *bs, bool recursive, - BdrvChild *parent) +void bdrv_do_drained_end(BlockDriverState *bs, bool recursive, + BdrvChild *parent) { BdrvChild *child, *next; int old_quiesce_counter; @@ -327,6 +328,7 @@ static void bdrv_do_drained_end(BlockDriverState *bs, b= ool recursive, } =20 if (recursive) { + bs->recursive_quiesce_counter--; QLIST_FOREACH_SAFE(child, &bs->children, next, next) { bdrv_do_drained_end(child->bs, true, child); } @@ -343,6 +345,24 @@ void bdrv_subtree_drained_end(BlockDriverState *bs) bdrv_do_drained_end(bs, true, NULL); } =20 +void bdrv_apply_subtree_drain(BdrvChild *child, BlockDriverState *new_pare= nt) +{ + int i; + + for (i =3D 0; i < new_parent->recursive_quiesce_counter; i++) { + bdrv_do_drained_begin(child->bs, true, child); + } +} + +void bdrv_unapply_subtree_drain(BdrvChild *child, BlockDriverState *old_pa= rent) +{ + int i; + + for (i =3D 0; i < old_parent->recursive_quiesce_counter; i++) { + bdrv_do_drained_end(child->bs, true, child); + } +} + /* * Wait for pending requests to complete on a single BlockDriverState subt= ree, * and suspend block driver's internal I/O until next request arrives. --=20 2.13.6 From nobody Sat May 3 10:50:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513957828957573.695023582259; Fri, 22 Dec 2017 07:50:28 -0800 (PST) Received: from localhost ([::1]:54926 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1eSPaY-0006tQ-Rd for importer@patchew.org; Fri, 22 Dec 2017 10:50:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57763) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP79-0006K7-Mz for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:20:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP78-0002vK-HW for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:19:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35092) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP72-0002qY-Qg; Fri, 22 Dec 2017 10:19:53 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 02AEE6916; Fri, 22 Dec 2017 15:19:52 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-107.ams2.redhat.com [10.36.117.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 752FC60C80; Fri, 22 Dec 2017 15:19:50 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Fri, 22 Dec 2017 16:18:44 +0100 Message-Id: <20171222151846.28110-34-kwolf@redhat.com> In-Reply-To: <20171222151846.28110-1-kwolf@redhat.com> References: <20171222151846.28110-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 22 Dec 2017 15:19:52 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 33/35] test-bdrv-drain: Test graph changes in drained section X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- tests/test-bdrv-drain.c | 80 +++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 80 insertions(+) diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c index 690b585b4d..d760e2b243 100644 --- a/tests/test-bdrv-drain.c +++ b/tests/test-bdrv-drain.c @@ -411,6 +411,85 @@ static void test_multiparent(void) blk_unref(blk_b); } =20 +static void test_graph_change(void) +{ + BlockBackend *blk_a, *blk_b; + BlockDriverState *bs_a, *bs_b, *backing; + BDRVTestState *a_s, *b_s, *backing_s; + + blk_a =3D blk_new(BLK_PERM_ALL, BLK_PERM_ALL); + bs_a =3D bdrv_new_open_driver(&bdrv_test, "test-node-a", BDRV_O_RDWR, + &error_abort); + a_s =3D bs_a->opaque; + blk_insert_bs(blk_a, bs_a, &error_abort); + + blk_b =3D blk_new(BLK_PERM_ALL, BLK_PERM_ALL); + bs_b =3D bdrv_new_open_driver(&bdrv_test, "test-node-b", BDRV_O_RDWR, + &error_abort); + b_s =3D bs_b->opaque; + blk_insert_bs(blk_b, bs_b, &error_abort); + + backing =3D bdrv_new_open_driver(&bdrv_test, "backing", 0, &error_abor= t); + backing_s =3D backing->opaque; + bdrv_set_backing_hd(bs_a, backing, &error_abort); + + g_assert_cmpint(bs_a->quiesce_counter, =3D=3D, 0); + g_assert_cmpint(bs_b->quiesce_counter, =3D=3D, 0); + g_assert_cmpint(backing->quiesce_counter, =3D=3D, 0); + g_assert_cmpint(a_s->drain_count, =3D=3D, 0); + g_assert_cmpint(b_s->drain_count, =3D=3D, 0); + g_assert_cmpint(backing_s->drain_count, =3D=3D, 0); + + do_drain_begin(BDRV_SUBTREE_DRAIN, bs_a); + do_drain_begin(BDRV_SUBTREE_DRAIN, bs_a); + do_drain_begin(BDRV_SUBTREE_DRAIN, bs_a); + do_drain_begin(BDRV_SUBTREE_DRAIN, bs_b); + do_drain_begin(BDRV_SUBTREE_DRAIN, bs_b); + + bdrv_set_backing_hd(bs_b, backing, &error_abort); + g_assert_cmpint(bs_a->quiesce_counter, =3D=3D, 5); + g_assert_cmpint(bs_b->quiesce_counter, =3D=3D, 5); + g_assert_cmpint(backing->quiesce_counter, =3D=3D, 5); + g_assert_cmpint(a_s->drain_count, =3D=3D, 5); + g_assert_cmpint(b_s->drain_count, =3D=3D, 5); + g_assert_cmpint(backing_s->drain_count, =3D=3D, 5); + + bdrv_set_backing_hd(bs_b, NULL, &error_abort); + g_assert_cmpint(bs_a->quiesce_counter, =3D=3D, 3); + g_assert_cmpint(bs_b->quiesce_counter, =3D=3D, 2); + g_assert_cmpint(backing->quiesce_counter, =3D=3D, 3); + g_assert_cmpint(a_s->drain_count, =3D=3D, 3); + g_assert_cmpint(b_s->drain_count, =3D=3D, 2); + g_assert_cmpint(backing_s->drain_count, =3D=3D, 3); + + bdrv_set_backing_hd(bs_b, backing, &error_abort); + g_assert_cmpint(bs_a->quiesce_counter, =3D=3D, 5); + g_assert_cmpint(bs_b->quiesce_counter, =3D=3D, 5); + g_assert_cmpint(backing->quiesce_counter, =3D=3D, 5); + g_assert_cmpint(a_s->drain_count, =3D=3D, 5); + g_assert_cmpint(b_s->drain_count, =3D=3D, 5); + g_assert_cmpint(backing_s->drain_count, =3D=3D, 5); + + do_drain_end(BDRV_SUBTREE_DRAIN, bs_b); + do_drain_end(BDRV_SUBTREE_DRAIN, bs_b); + do_drain_end(BDRV_SUBTREE_DRAIN, bs_a); + do_drain_end(BDRV_SUBTREE_DRAIN, bs_a); + do_drain_end(BDRV_SUBTREE_DRAIN, bs_a); + + g_assert_cmpint(bs_a->quiesce_counter, =3D=3D, 0); + g_assert_cmpint(bs_b->quiesce_counter, =3D=3D, 0); + g_assert_cmpint(backing->quiesce_counter, =3D=3D, 0); + g_assert_cmpint(a_s->drain_count, =3D=3D, 0); + g_assert_cmpint(b_s->drain_count, =3D=3D, 0); + g_assert_cmpint(backing_s->drain_count, =3D=3D, 0); + + bdrv_unref(backing); + bdrv_unref(bs_a); + bdrv_unref(bs_b); + blk_unref(blk_a); + blk_unref(blk_b); +} + =20 typedef struct TestBlockJob { BlockJob common; @@ -561,6 +640,7 @@ int main(int argc, char **argv) =20 g_test_add_func("/bdrv-drain/nested", test_nested); g_test_add_func("/bdrv-drain/multiparent", test_multiparent); + g_test_add_func("/bdrv-drain/graph-change", test_graph_change); =20 g_test_add_func("/bdrv-drain/blockjob/drain_all", test_blockjob_drain_= all); g_test_add_func("/bdrv-drain/blockjob/drain", test_blockjob_drain); --=20 2.13.6 From nobody Sat May 3 10:50:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513956739634675.3187952774904; Fri, 22 Dec 2017 07:32:19 -0800 (PST) Received: from localhost ([::1]:54466 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1eSPJ0-0007wr-CE for importer@patchew.org; Fri, 22 Dec 2017 10:32:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57812) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP7B-0006MN-PP for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:20:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP7A-0002xR-U6 for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:20:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51144) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP74-0002ru-6U; Fri, 22 Dec 2017 10:19:54 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6EBA830A085; Fri, 22 Dec 2017 15:19:53 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-107.ams2.redhat.com [10.36.117.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5276660C80; Fri, 22 Dec 2017 15:19:52 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Fri, 22 Dec 2017 16:18:45 +0100 Message-Id: <20171222151846.28110-35-kwolf@redhat.com> In-Reply-To: <20171222151846.28110-1-kwolf@redhat.com> References: <20171222151846.28110-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 22 Dec 2017 15:19:53 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 34/35] commit: Simplify reopen of base X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Since commit bde70715, base is the only node that is reopened in commit_start(). This means that the code, which still involves an explicit BlockReopenQueue, can now be simplified by using bdrv_reopen(). Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> --- block/commit.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/block/commit.c b/block/commit.c index c5327551ce..bb6c904704 100644 --- a/block/commit.c +++ b/block/commit.c @@ -277,7 +277,6 @@ void commit_start(const char *job_id, BlockDriverState = *bs, const char *filter_node_name, Error **errp) { CommitBlockJob *s; - BlockReopenQueue *reopen_queue =3D NULL; int orig_base_flags; BlockDriverState *iter; BlockDriverState *commit_top_bs =3D NULL; @@ -299,12 +298,7 @@ void commit_start(const char *job_id, BlockDriverState= *bs, /* convert base to r/w, if necessary */ orig_base_flags =3D bdrv_get_flags(base); if (!(orig_base_flags & BDRV_O_RDWR)) { - reopen_queue =3D bdrv_reopen_queue(reopen_queue, base, NULL, - orig_base_flags | BDRV_O_RDWR); - } - - if (reopen_queue) { - bdrv_reopen_multiple(bdrv_get_aio_context(bs), reopen_queue, &loca= l_err); + bdrv_reopen(base, orig_base_flags | BDRV_O_RDWR, &local_err); if (local_err !=3D NULL) { error_propagate(errp, local_err); goto fail; --=20 2.13.6 From nobody Sat May 3 10:50:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513956573536890.9257459011243; Fri, 22 Dec 2017 07:29:33 -0800 (PST) Received: from localhost ([::1]:54445 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1eSPGF-0005XM-7Z for importer@patchew.org; Fri, 22 Dec 2017 10:29:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57799) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP7B-0006Lo-7H for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:20:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP7A-0002we-1i for qemu-devel@nongnu.org; Fri, 22 Dec 2017 10:20:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45754) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <kwolf@redhat.com>) id 1eSP77-0002u3-A1; Fri, 22 Dec 2017 10:19:57 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 80FF380469; Fri, 22 Dec 2017 15:19:56 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-107.ams2.redhat.com [10.36.117.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id C299760C80; Fri, 22 Dec 2017 15:19:53 +0000 (UTC) From: Kevin Wolf <kwolf@redhat.com> To: qemu-block@nongnu.org Date: Fri, 22 Dec 2017 16:18:46 +0100 Message-Id: <20171222151846.28110-36-kwolf@redhat.com> In-Reply-To: <20171222151846.28110-1-kwolf@redhat.com> References: <20171222151846.28110-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 22 Dec 2017 15:19:56 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 35/35] block: Keep nodes drained between reopen_queue/multiple X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The bdrv_reopen*() implementation doesn't like it if the graph is changed between queuing nodes for reopen and actually reopening them (one of the reasons is that queuing can be recursive). So instead of draining the device only in bdrv_reopen_multiple(), require that callers already drained all affected nodes, and assert this in bdrv_reopen_queue(). Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> --- block.c | 23 ++++++++++++++++------- block/replication.c | 6 ++++++ qemu-io-cmds.c | 3 +++ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/block.c b/block.c index 8b46ba21b1..a8da4f2b25 100644 --- a/block.c +++ b/block.c @@ -2766,6 +2766,7 @@ BlockDriverState *bdrv_open(const char *filename, con= st char *reference, * returns a pointer to bs_queue, which is either the newly allocated * bs_queue, or the existing bs_queue being used. * + * bs must be drained between bdrv_reopen_queue() and bdrv_reopen_multiple= (). */ static BlockReopenQueue *bdrv_reopen_queue_child(BlockReopenQueue *bs_queu= e, BlockDriverState *bs, @@ -2781,6 +2782,11 @@ static BlockReopenQueue *bdrv_reopen_queue_child(Blo= ckReopenQueue *bs_queue, BdrvChild *child; QDict *old_options, *explicit_options; =20 + /* Make sure that the caller remembered to use a drained section. This= is + * important to avoid graph changes between the recursive queuing here= and + * bdrv_reopen_multiple(). */ + assert(bs->quiesce_counter > 0); + if (bs_queue =3D=3D NULL) { bs_queue =3D g_new0(BlockReopenQueue, 1); QSIMPLEQ_INIT(bs_queue); @@ -2905,6 +2911,8 @@ BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue = *bs_queue, * If all devices prepare successfully, then the changes are committed * to all devices. * + * All affected nodes must be drained between bdrv_reopen_queue() and + * bdrv_reopen_multiple(). */ int bdrv_reopen_multiple(AioContext *ctx, BlockReopenQueue *bs_queue, Erro= r **errp) { @@ -2914,11 +2922,8 @@ int bdrv_reopen_multiple(AioContext *ctx, BlockReope= nQueue *bs_queue, Error **er =20 assert(bs_queue !=3D NULL); =20 - aio_context_release(ctx); - bdrv_drain_all_begin(); - aio_context_acquire(ctx); - QSIMPLEQ_FOREACH(bs_entry, bs_queue, entry) { + assert(bs_entry->state.bs->quiesce_counter > 0); if (bdrv_reopen_prepare(&bs_entry->state, bs_queue, &local_err)) { error_propagate(errp, local_err); goto cleanup; @@ -2947,8 +2952,6 @@ cleanup: } g_free(bs_queue); =20 - bdrv_drain_all_end(); - return ret; } =20 @@ -2958,12 +2961,18 @@ int bdrv_reopen(BlockDriverState *bs, int bdrv_flag= s, Error **errp) { int ret =3D -1; Error *local_err =3D NULL; - BlockReopenQueue *queue =3D bdrv_reopen_queue(NULL, bs, NULL, bdrv_fla= gs); + BlockReopenQueue *queue; =20 + bdrv_subtree_drained_begin(bs); + + queue =3D bdrv_reopen_queue(NULL, bs, NULL, bdrv_flags); ret =3D bdrv_reopen_multiple(bdrv_get_aio_context(bs), queue, &local_e= rr); if (local_err !=3D NULL) { error_propagate(errp, local_err); } + + bdrv_subtree_drained_end(bs); + return ret; } =20 diff --git a/block/replication.c b/block/replication.c index e41e293d2b..b1ea3caa4b 100644 --- a/block/replication.c +++ b/block/replication.c @@ -394,6 +394,9 @@ static void reopen_backing_file(BlockDriverState *bs, b= ool writable, new_secondary_flags =3D s->orig_secondary_flags; } =20 + bdrv_subtree_drained_begin(s->hidden_disk->bs); + bdrv_subtree_drained_begin(s->secondary_disk->bs); + if (orig_hidden_flags !=3D new_hidden_flags) { reopen_queue =3D bdrv_reopen_queue(reopen_queue, s->hidden_disk->b= s, NULL, new_hidden_flags); @@ -409,6 +412,9 @@ static void reopen_backing_file(BlockDriverState *bs, b= ool writable, reopen_queue, &local_err); error_propagate(errp, local_err); } + + bdrv_subtree_drained_end(s->hidden_disk->bs); + bdrv_subtree_drained_end(s->secondary_disk->bs); } =20 static void backup_job_cleanup(BlockDriverState *bs) diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index de8e3de726..a6a70fc3dc 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -2013,8 +2013,11 @@ static int reopen_f(BlockBackend *blk, int argc, cha= r **argv) opts =3D qopts ? qemu_opts_to_qdict(qopts, NULL) : NULL; qemu_opts_reset(&reopen_opts); =20 + bdrv_subtree_drained_begin(bs); brq =3D bdrv_reopen_queue(NULL, bs, opts, flags); bdrv_reopen_multiple(bdrv_get_aio_context(bs), brq, &local_err); + bdrv_subtree_drained_end(bs); + if (local_err) { error_report_err(local_err); } else { --=20 2.13.6