From nobody Mon May 20 00:38:58 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622641706; cv=none; d=zohomail.com; s=zohoarc; b=Ka6fXm/ORYoY+IUaxKk4L1elCur8BIjEThsS1LURkgsm79lzRcskvoFTGu/ZU287yqOa1U5xGZMocBPsGJvMA01NBtN96uwTRpyTMnwI7+/+zTQgBPctijRX0jiL3Fji0M29dzKJoWmNuOlSpUGdAmb7v3/KABUXulIA95zUHU4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622641706; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xG0Z68ORK5zXT+w46I4w/BY01xYr5gUode7xyH2he9Y=; b=Rg6YSxusg9tYFystCxyS2s4dZBmQXe9vZtAWYdTwwQitd34CCwXGoUBPvDXZ2r25ohX5Jx7VIHukdXF4FwqE9k0aoiKJVkkiClytPogzsvU9zevObsKIvIlm+LVCMoQhlAPi90FZsmRLTIVK7IhwO3tgkntVczRjhMvrADx+dVA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622641706533805.0229732055979; Wed, 2 Jun 2021 06:48:26 -0700 (PDT) Received: from localhost ([::1]:43844 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1loREP-0003Xc-3c for importer2@patchew.org; Wed, 02 Jun 2021 09:48:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43572) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRBq-0007ut-T6 for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:45:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:57442) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRBn-0006vD-JB for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:45:45 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-527-vWc6n08KNXePzuUn44RLsA-1; Wed, 02 Jun 2021 09:45:39 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 384C11034B04; Wed, 2 Jun 2021 13:45:36 +0000 (UTC) Received: from merkur.redhat.com (ovpn-114-240.ams2.redhat.com [10.36.114.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 120527596A; Wed, 2 Jun 2021 13:45:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622641542; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xG0Z68ORK5zXT+w46I4w/BY01xYr5gUode7xyH2he9Y=; b=EW5riP8cu+oNlqR0ezcdg5Jz5l8OGkc4t9QL0xnv9mwHJBSPfLjhosvIWF147+9d1IeubX NsBhwTbGVjb2ty79c90jjHSpu0sZf3qLPdpUznpwFnP2U4KLXsGt85ZVZ8oNWOXQogkyG/ I6zuTiEE0gCh7UM19O3tzxOgbHEFr8g= X-MC-Unique: vWc6n08KNXePzuUn44RLsA-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 01/20] block/quorum: Provide .bdrv_co_flush instead of .bdrv_co_flush_to_disk Date: Wed, 2 Jun 2021 15:45:10 +0200 Message-Id: <20210602134529.231756-2-kwolf@redhat.com> In-Reply-To: <20210602134529.231756-1-kwolf@redhat.com> References: <20210602134529.231756-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Lukas Straub The quorum block driver uses a custom flush callback to handle the case when some children return io errors. In that case it still returns success if enough children are healthy. However, it provides it as the .bdrv_co_flush_to_disk callback, not as .bdrv_co_flush. This causes the block layer to do it's own generic flushing for the children instead, which doesn't handle errors properly. Fix this by providing .bdrv_co_flush instead of .bdrv_co_flush_to_disk so the block layer uses the custom flush callback. Signed-off-by: Lukas Straub Reported-by: Minghao Yuan Message-Id: <20210518134214.11ccf05f@gecko.fritz.box> Tested-by: Zhang Chen Signed-off-by: Kevin Wolf --- block/quorum.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/quorum.c b/block/quorum.c index cfc1436abb..f2c0805000 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -1279,7 +1279,7 @@ static BlockDriver bdrv_quorum =3D { .bdrv_dirname =3D quorum_dirname, .bdrv_co_block_status =3D quorum_co_block_status, =20 - .bdrv_co_flush_to_disk =3D quorum_co_flush, + .bdrv_co_flush =3D quorum_co_flush, =20 .bdrv_getlength =3D quorum_getlength, =20 --=20 2.30.2 From nobody Mon May 20 00:38:58 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622641683; cv=none; d=zohomail.com; s=zohoarc; b=XvXSzAHASZora7GTeuM809xS0MnyQPRYDn8OqCnhVklPfIkULnNd2xKV6T74Y2Twvxh+DCl5LH43CU2WKDxhI4nl9BpkE/DtfXaXQOJ5uWfQx4FJ+B4kgbZ73qzU0RGbwxQChMQNukRrEL4cVRM0HPHx1C9doXt2ZElTHFlAoYU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622641683; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aV5Y+AO5qhZqScvILJScJW8VzGXWQYW6qK3ZL2yvZY0=; b=KqxO6IzSAHQEYywVfTz5dIgbT4I4d5l8CGN9ohZ9UQyM2/2rTZElO2oTxcgGtLlInFFTdLbnE9AYjvcE6bRSiYrLdAFBxSVrPArTRQEf1LJEF65AbsZJpFinCKDwrtAbpMN+/kV4+yRcbDTsEuWIxqcmzu63m/Lb+AQ92KRFNVA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622641683277898.716881819007; Wed, 2 Jun 2021 06:48:03 -0700 (PDT) Received: from localhost ([::1]:42504 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1loRE1-0002Zg-4j for importer2@patchew.org; Wed, 02 Jun 2021 09:48:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43634) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRBs-0007zY-9b for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:45:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:56353) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRBq-0006xS-K2 for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:45:47 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-476-HwtnQihgNl6X74NYRzYiow-1; Wed, 02 Jun 2021 09:45:42 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4EBC31009630; Wed, 2 Jun 2021 13:45:37 +0000 (UTC) Received: from merkur.redhat.com (ovpn-114-240.ams2.redhat.com [10.36.114.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 57F408C95E; Wed, 2 Jun 2021 13:45:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622641546; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aV5Y+AO5qhZqScvILJScJW8VzGXWQYW6qK3ZL2yvZY0=; b=ESEogEzj0kmRqKFHQ8G16rnpfqrMwYh1tTP6zs6ZURomDDA62Gt90a2qannrZ0Zf9o2Vb/ LobK9gctt3HNMlMdRj1Pk5jxGC+9BIKjTpKACy6WKL+ZNgGYqb1605sm+yPF9FfqV+P4iF USXBeeV2BwatSHYKSyLCnPs5kdvrxWk= X-MC-Unique: HwtnQihgNl6X74NYRzYiow-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 02/20] qemu-io-cmds: assert that we don't have .perm requested in no-blk case Date: Wed, 2 Jun 2021 15:45:11 +0200 Message-Id: <20210602134529.231756-3-kwolf@redhat.com> In-Reply-To: <20210602134529.231756-1-kwolf@redhat.com> References: <20210602134529.231756-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Coverity thinks blk may be NULL. It's a false-positive, as described in a new comment. Fixes: Coverity CID 1453194 Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20210519090532.3753-1-vsementsov@virtuozzo.com> Signed-off-by: Kevin Wolf --- qemu-io-cmds.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index 998b67186d..e8d862a426 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -92,9 +92,19 @@ static int command(BlockBackend *blk, const cmdinfo_t *c= t, int argc, return -EINVAL; } =20 - /* Request additional permissions if necessary for this command. The c= aller + /* + * Request additional permissions if necessary for this command. The c= aller * is responsible for restoring the original permissions afterwards if= this - * is what it wants. */ + * is what it wants. + * + * Coverity thinks that blk may be NULL in the following if condition.= It's + * not so: in init_check_command() we fail if blk is NULL for command = with + * both CMD_FLAG_GLOBAL and CMD_NOFILE_OK flags unset. And in + * qemuio_add_command() we assert that command with non-zero .perm fie= ld + * doesn't set this flags. So, the following assertion is to silence + * Coverity: + */ + assert(blk || !ct->perm); if (ct->perm && blk_is_available(blk)) { uint64_t orig_perm, orig_shared_perm; blk_get_perm(blk, &orig_perm, &orig_shared_perm); --=20 2.30.2 From nobody Mon May 20 00:38:58 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622641856; cv=none; d=zohomail.com; s=zohoarc; b=d+Wu7uKbbRpfQEDdl3A6oHUI0/q3AtiYfkHeUYrOnv5oucEfZJUqyOfWyNJfPhpVM7TEyyWPtsIs94xwSSaltbQVjcNnc5PvJuq6tcG4VfMRFqkFpONzs6gdZ/vIspTq+4weMqogkdwGo//Z2y6FImJ9yjEwzbQ0R3PWjplqpaQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622641856; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=r2vWyn01OGYWoYZoaDJemE1mxbM2rvuc+eJTVRHdwwI=; b=lFWr/7SfVkpcjpD3jH6OAq/1LOBtyUPA9BPYLONow/29QtNrd22hNkkY0OkGin7fJW05sgfjSxB9+RHZr9gkgI9x8ZmxR/uM/otDsLKib9HwJfiR5Xx6cpVlagH0e1RYD2FF+lWsghWRyvvpO3QkoPbgY/EAzk3fUlnne82pdtk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622641856189139.107190147305; Wed, 2 Jun 2021 06:50:56 -0700 (PDT) Received: from localhost ([::1]:53806 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1loRGY-0001lp-Ur for importer2@patchew.org; Wed, 02 Jun 2021 09:50:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43690) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRBx-0008HX-On for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:45:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30672) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRBv-000701-75 for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:45:53 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-193-QI_6VrE7PIyKVzXe_EannA-1; Wed, 02 Jun 2021 09:45:47 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8803880623D; Wed, 2 Jun 2021 13:45:38 +0000 (UTC) Received: from merkur.redhat.com (ovpn-114-240.ams2.redhat.com [10.36.114.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9112419809; Wed, 2 Jun 2021 13:45:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622641550; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r2vWyn01OGYWoYZoaDJemE1mxbM2rvuc+eJTVRHdwwI=; b=OnyUD7tXQfrC1o3un/CeTovWU+Lb6TrW6qAX6eN0Qhbf8Q4WDeGOny1b2wDnpHdSZrAEzG bTU6wPbFds5qVLvOm6DchATZn3iNP7X3eklr5l47LhTX0/cHvQJ/dBzbnRCHiwvktJ3OXN 4Fd1kWkn9avrQ7mlJWG3fmsRhQADJK8= X-MC-Unique: QI_6VrE7PIyKVzXe_EannA-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 03/20] block/vvfat: child_vvfat_qcow: add .get_parent_aio_context, fix crash Date: Wed, 2 Jun 2021 15:45:12 +0200 Message-Id: <20210602134529.231756-4-kwolf@redhat.com> In-Reply-To: <20210602134529.231756-1-kwolf@redhat.com> References: <20210602134529.231756-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Commit 3ca1f3225727419ba573673b744edac10904276f "block: BdrvChildClass: add .get_parent_aio_context handler" introduced new handler and commit 228ca37e12f97788e05bd0c92f89b3e5e4019607 "block: drop ctx argument from bdrv_root_attach_child" made a generic use of it. But 3ca1f3225727419ba573673b744edac10904276f didn't update child_vvfat_qcow. Fix that. Before that fix the command ./build/qemu-system-x86_64 -usb -device usb-storage,drive=3Dfat16 \ -drive file=3Dfat:rw:fat-type=3D16:"",id=3Dfat16,f= ormat=3Draw,if=3Dnone crashes: 1 bdrv_child_get_parent_aio_context (c=3D0x559d62426d20) at ../block.c:1440 2 bdrv_attach_child_common (child_bs=3D0x559d62468190, child_name=3D0x559d606f9e3d "write-target", child_class=3D0x559d60c58d20 , child_role=3D3, perm=3D3, shared_perm=3D4, opaque=3D0x559d62445690, child=3D0x7ffc74c2acc8, tran=3D0x559d6246ddd0, errp=3D0x7ffc74c2ae60) at ../block.c:2795 3 bdrv_attach_child_noperm (parent_bs=3D0x559d62445690, child_bs=3D0x559d62468190, child_name=3D0x559d606f9e3d "write-target", child_class=3D0x559d60c58d20 , child_role=3D3, child=3D0x7ffc74c2acc8, tran=3D0x559d6246ddd0, errp=3D0x7ffc74c2ae60) = at ../block.c:2855 4 bdrv_attach_child (parent_bs=3D0x559d62445690, child_bs=3D0x559d62468190, child_name=3D0x559d606f9e3d "write-target", child_class=3D0x559d60c58d20 , child_role=3D3, errp=3D0x7ffc74c2ae60) at ../block.c:2953 5 bdrv_open_child (filename=3D0x559d62464b80 "/var/tmp/vl.h3TIS4", options=3D0x559d6246ec20, bdref_key=3D0x559d606f9e3d "write-target", parent=3D0x559d62445690, child_class=3D0x559d60c58d20 , child_role=3D3, allow_none=3Dfalse, errp=3D0x7ffc74c2ae60) at ../block.c:3351 6 enable_write_target (bs=3D0x559d62445690, errp=3D0x7ffc74c2ae60) at ../block/vvfat.c:3176 7 vvfat_open (bs=3D0x559d62445690, options=3D0x559d6244adb0, flags=3D15565= 0, errp=3D0x7ffc74c2ae60) at ../block/vvfat.c:1236 8 bdrv_open_driver (bs=3D0x559d62445690, drv=3D0x559d60d4f7e0 , node_name=3D0x0, options=3D0x559d6244adb0, open_flags=3D155650, errp=3D0x7ffc74c2af70) at ../block.c:1557 9 bdrv_open_common (bs=3D0x559d62445690, file=3D0x0, options=3D0x559d6244adb0, errp=3D0x7ffc74c2af70) at ... (gdb) fr 1 #1 0x0000559d603ea3bf in bdrv_child_get_parent_aio_context (c=3D0x559d62426d20) at ../block.c:1440 1440 return c->klass->get_parent_aio_context(c); (gdb) p c->klass $1 =3D (const BdrvChildClass *) 0x559d60c58d20 (gdb) p c->klass->get_parent_aio_context $2 =3D (AioContext *(*)(BdrvChild *)) 0x0 Fixes: 3ca1f3225727419ba573673b744edac10904276f Fixes: 228ca37e12f97788e05bd0c92f89b3e5e4019607 Reported-by: John Arbuckle Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20210524101257.119377-2-vsementsov@virtuozzo.com> Tested-by: John Arbuckle Signed-off-by: Kevin Wolf --- include/block/block.h | 1 + block.c | 4 ++-- block/vvfat.c | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index 82185965ff..8e707a83b7 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -701,6 +701,7 @@ bool bdrv_child_can_set_aio_context(BdrvChild *c, AioCo= ntext *ctx, bool bdrv_can_set_aio_context(BlockDriverState *bs, AioContext *ctx, GSList **ignore, Error **errp); AioContext *bdrv_child_get_parent_aio_context(BdrvChild *c); +AioContext *child_of_bds_get_parent_aio_context(BdrvChild *c); =20 int bdrv_probe_blocksizes(BlockDriverState *bs, BlockSizes *bsz); int bdrv_probe_geometry(BlockDriverState *bs, HDGeometry *geo); diff --git a/block.c b/block.c index 0dc97281dc..ef13076c4c 100644 --- a/block.c +++ b/block.c @@ -1412,7 +1412,7 @@ static int bdrv_child_cb_update_filename(BdrvChild *c= , BlockDriverState *base, return 0; } =20 -static AioContext *bdrv_child_cb_get_parent_aio_context(BdrvChild *c) +AioContext *child_of_bds_get_parent_aio_context(BdrvChild *c) { BlockDriverState *bs =3D c->opaque; =20 @@ -1432,7 +1432,7 @@ const BdrvChildClass child_of_bds =3D { .can_set_aio_ctx =3D bdrv_child_cb_can_set_aio_ctx, .set_aio_ctx =3D bdrv_child_cb_set_aio_ctx, .update_filename =3D bdrv_child_cb_update_filename, - .get_parent_aio_context =3D bdrv_child_cb_get_parent_aio_context, + .get_parent_aio_context =3D child_of_bds_get_parent_aio_context, }; =20 AioContext *bdrv_child_get_parent_aio_context(BdrvChild *c) diff --git a/block/vvfat.c b/block/vvfat.c index 54807f82ca..07232a7cfc 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -3130,6 +3130,7 @@ static void vvfat_qcow_options(BdrvChildRole role, bo= ol parent_is_format, static const BdrvChildClass child_vvfat_qcow =3D { .parent_is_bds =3D true, .inherit_options =3D vvfat_qcow_options, + .get_parent_aio_context =3D child_of_bds_get_parent_aio_context, }; =20 static int enable_write_target(BlockDriverState *bs, Error **errp) --=20 2.30.2 From nobody Mon May 20 00:38:58 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622641699; cv=none; d=zohomail.com; s=zohoarc; b=KU37SGbPauvjfdxn3Gmn9FHCvDVz2xO37Q29nVU986xaf4SRBsErxaoDgD2iZPqbbQKsAG683jqT884oJUmS6gNgfCA7yw6iVBqxliOnEbTVz6KEzz7J1XeUofHACUfNrDi/SxJbfQw9SFr4WIDhFNfgzP7aWIxQL8vzLF/geCY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622641699; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MgFnAmrETwJamIS0R7FX5BEeNaWuQse4e92a2iXdJRE=; b=GRsM3ckSLofdPEyhPrdqSELsHjtpuZpfIUZEJkS1NBsCrHaqiG7MitYkuvrQjCaxaGCvJhqCeXRIYS/UBSNyxA28GcKRW3ywvCFB+Qc+qOs4D5Z+CUVRb+aLzkrbF83om3UyL1xxOFIzJoQrMRx+poABnQExncLcUVVMEieJLAc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622641699499638.2978335638046; Wed, 2 Jun 2021 06:48:19 -0700 (PDT) Received: from localhost ([::1]:43192 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1loREI-00037W-Bt for importer2@patchew.org; Wed, 02 Jun 2021 09:48:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43704) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRBz-0008Mo-Pd for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:45:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39407) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRBw-00071L-4q for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:45:55 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-498-XNoPrqZaNeO5pYAVCC3Xnw-1; Wed, 02 Jun 2021 09:45:49 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E51011085929; Wed, 2 Jun 2021 13:45:39 +0000 (UTC) Received: from merkur.redhat.com (ovpn-114-240.ams2.redhat.com [10.36.114.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE54419814; Wed, 2 Jun 2021 13:45:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622641551; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MgFnAmrETwJamIS0R7FX5BEeNaWuQse4e92a2iXdJRE=; b=DhVavhEYqyyZ3v3ssloK/QbBpjWLD6mShHCikwKq/N/48Dt+wr1kUwFm2c6HJk0cRXluQJ TX+MH20C+GcOxju8qfV2ft88dm797ZLE/OiPTXnNopAhaJvhzN+I1NY6ZQ0MUrqJo295uX 4eptqO63LQ+fF8WWox88YJchCPqDZbo= X-MC-Unique: XNoPrqZaNeO5pYAVCC3Xnw-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 04/20] block/vvfat: fix vvfat_child_perm crash Date: Wed, 2 Jun 2021 15:45:13 +0200 Message-Id: <20210602134529.231756-5-kwolf@redhat.com> In-Reply-To: <20210602134529.231756-1-kwolf@redhat.com> References: <20210602134529.231756-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy It's wrong to rely on s->qcow in vvfat_child_perm, as on permission update during bdrv_open_child() call this field is not set yet. Still prior to aa5a04c7db27eea6b36de32f241b155f0d9ce34d, it didn't crash, as bdrv_open_child passed NULL as child to bdrv_child_perm(), and NULL was equal to NULL in assertion (still, it was bad guarantee for child being s->qcow, not backing :). Since aa5a04c7db27eea6b36de32f241b155f0d9ce34d "add bdrv_attach_child_noperm" bdrv_refresh_perms called on parent node when attaching child, and new correct child pointer is passed to .bdrv_child_perm. Still, s->qcow is NULL at the moment. Let's rely only on role instead. Without that fix, ./build/qemu-system-x86_64 -usb -device usb-storage,drive=3Dfat16 \ -drive \ file=3Dfat:rw:fat-type=3D16:"",id=3Dfat16,format= =3Draw,if=3Dnone crashes: (gdb) bt 0 raise () at /lib64/libc.so.6 1 abort () at /lib64/libc.so.6 2 _nl_load_domain.cold () at /lib64/libc.so.6 3 annobin_assert.c_end () at /lib64/libc.so.6 4 vvfat_child_perm (bs=3D0x559186f3d690, c=3D0x559186f1ed20, role=3D3, reopen_queue=3D0x0, perm=3D0, shared=3D31, nperm=3D0x7ffe56f28298, nshared=3D0x7ffe56f282a0) at ../block/vvfat.c:3214 5 bdrv_child_perm (bs=3D0x559186f3d690, child_bs=3D0x559186f60190, c=3D0x559186f1ed20, role=3D3, reopen_queue=3D0x0, parent_perm=3D0, parent_shared=3D31, nperm=3D0x7ffe56f28298, nshared=3D0x7ffe56f282a0) at ../block.c:2094 6 bdrv_node_refresh_perm (bs=3D0x559186f3d690, q=3D0x0, tran=3D0x559186f65850, errp=3D0x7ffe56f28530) at ../block.c:2336 7 bdrv_list_refresh_perms (list=3D0x559186db5b90 =3D {...}, q=3D0x0, tran=3D0x559186f65850, errp=3D0x7ffe56f28530) at ../block.c:2358 8 bdrv_refresh_perms (bs=3D0x559186f3d690, errp=3D0x7ffe56f28530) at ../block.c:2419 9 bdrv_attach_child (parent_bs=3D0x559186f3d690, child_bs=3D0x559186f60190, child_name=3D0x559184d83e3d "write-target", child_class=3D0x5591852f3b00 , child_role=3D3, errp=3D0x7ffe56f28530) at ../block.c:2959 10 bdrv_open_child (filename=3D0x559186f5cb80 "/var/tmp/vl.7WYmFU", options=3D0x559186f66c20, bdref_key=3D0x559184d83e3d "write-target", parent=3D0x559186f3d690, child_class=3D0x5591852f3b00 , child_role=3D3, allow_none=3Dfalse, errp=3D0x7ffe56f28530) at ../block.c:3351 11 enable_write_target (bs=3D0x559186f3d690, errp=3D0x7ffe56f28530) at ../block/vvfat.c:3177 12 vvfat_open (bs=3D0x559186f3d690, options=3D0x559186f42db0, flags=3D15565= 0, errp=3D0x7ffe56f28530) at ../block/vvfat.c:1236 13 bdrv_open_driver (bs=3D0x559186f3d690, drv=3D0x5591853d97e0 , node_name=3D0x0, options=3D0x559186f42db0, open_flags=3D155650, errp=3D0x7ffe56f28640) at ../block.c:1557 14 bdrv_open_common (bs=3D0x559186f3d690, file=3D0x0, options=3D0x559186f42db0, errp=3D0x7ffe56f28640) at ../block.c:1833 ... (gdb) fr 4 #4 vvfat_child_perm (bs=3D0x559186f3d690, c=3D0x559186f1ed20, role=3D3, reopen_queue=3D0x0, perm=3D0, shared=3D31, nperm=3D0x7ffe56f28298, nshared=3D0x7ffe56f282a0) at ../block/vvfat.c:3214 3214 assert(c =3D=3D s->qcow || (role & BDRV_CHILD_COW)); (gdb) p role $1 =3D 3 # BDRV_CHILD_DATA | BDRV_CHILD_METADATA (gdb) p *c $2 =3D {bs =3D 0x559186f60190, name =3D 0x559186f669d0 "write-target", kla= ss =3D 0x5591852f3b00 , role =3D 3, opaque =3D 0x559186f3d690, perm =3D 3, shared_perm =3D 4, frozen =3D false, parent_quiesce_counter =3D 0, next =3D {le_next =3D 0x0, le_prev = =3D 0x559186f41818}, next_parent =3D {le_next =3D 0x0, le_prev =3D 0x559186f64320}} (gdb) p s->qcow $3 =3D (BdrvChild *) 0x0 Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20210524101257.119377-3-vsementsov@virtuozzo.com> Tested-by: John Arbuckle Signed-off-by: Kevin Wolf --- block/vvfat.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/block/vvfat.c b/block/vvfat.c index 07232a7cfc..86d99c899c 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -3209,15 +3209,12 @@ static void vvfat_child_perm(BlockDriverState *bs, = BdrvChild *c, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) { - BDRVVVFATState *s =3D bs->opaque; - - assert(c =3D=3D s->qcow || (role & BDRV_CHILD_COW)); - - if (c =3D=3D s->qcow) { + if (role & BDRV_CHILD_DATA) { /* This is a private node, nobody should try to attach to it */ *nperm =3D BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE; *nshared =3D BLK_PERM_WRITE_UNCHANGED; } else { + assert(role & BDRV_CHILD_COW); /* The backing file is there so 'commit' can use it. vvfat doesn't * access it in any way. */ *nperm =3D 0; --=20 2.30.2 From nobody Mon May 20 00:38:58 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622641808; cv=none; d=zohomail.com; s=zohoarc; b=JtLh75r5dDCy5pfKzfR0P+mLATJvfVtnDnBYOfd1+VniYqL00kGYwBd/IubvHcJDXxo7J8kwgOQcPNtc+fHAxPCK7t4N/hb+vRo5FhahzrnT26Y8QPiVBaqaDIpAAkRWe3+njxC5StXKQkP+2dH8dC7fh50uPMBUq/3wVgnFqwk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622641808; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5sxgy2f9jgRD2Mv1VSBDcwJ7Rk3aRVaGUNQXV4vp1aI=; b=l/HjThwG3LySXeruJ84WUewww7Wt4Xk/um7XOviTpnQnLrJWYYqooYCaqFOwuKJe5Y0OW3dH5/uEpsoL2L016FhcmHR6T/AeUrMYr5qZHX3MHphhAedgc8I3QZj+CNWhPw2+AaOvH3Cg5kisIKymRCft/BPkvN0S/M/IPgKkocA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622641808453209.66134547146942; Wed, 2 Jun 2021 06:50:08 -0700 (PDT) Received: from localhost ([::1]:52230 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1loRG3-0000jY-DH for importer2@patchew.org; Wed, 02 Jun 2021 09:50:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43726) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRC4-0000Cu-TY for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:46:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:20058) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRC2-00074V-OH for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:46:00 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-368-BFvowecZNGGDWyI70FnGsA-1; Wed, 02 Jun 2021 09:45:55 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 271E7CC62D; Wed, 2 Jun 2021 13:45:41 +0000 (UTC) Received: from merkur.redhat.com (ovpn-114-240.ams2.redhat.com [10.36.114.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 378E060BD9; Wed, 2 Jun 2021 13:45:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622641557; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5sxgy2f9jgRD2Mv1VSBDcwJ7Rk3aRVaGUNQXV4vp1aI=; b=eeDaB93RrZMwkRZh7Xbu4bdp4ATKGcFhA0haYWrE4sVkeb7Bg2Zhlk7EomKlCDo7xNPkiF iojNucCEM3YeHQXhzzMLj1WaDN8C9mRgIeF6x0GyWxwPp2I19Oh5AH4IiQms4BPZRvysVU Xg0SGpsOsFWsAUoiYVPp8r1emNc7Lj0= X-MC-Unique: BFvowecZNGGDWyI70FnGsA-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 05/20] block: consistently use bdrv_is_read_only() Date: Wed, 2 Jun 2021 15:45:14 +0200 Message-Id: <20210602134529.231756-6-kwolf@redhat.com> In-Reply-To: <20210602134529.231756-1-kwolf@redhat.com> References: <20210602134529.231756-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy It's better to use accessor function instead of bs->read_only directly. In some places use bdrv_is_writable() instead of checking both BDRV_O_RDWR set and BDRV_O_INACTIVE not set. In bdrv_open_common() it's a bit strange to add one more variable, but we are going to drop bs->read_only in the next patch, so new ro local variable substitutes it here. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20210527154056.70294-2-vsementsov@virtuozzo.com> Signed-off-by: Kevin Wolf --- block.c | 11 +++++++---- block/block-backend.c | 2 +- block/commit.c | 2 +- block/io.c | 4 ++-- block/qapi.c | 2 +- block/qcow2-snapshot.c | 2 +- block/qcow2.c | 5 ++--- block/snapshot.c | 2 +- block/vhdx-log.c | 2 +- 9 files changed, 17 insertions(+), 15 deletions(-) diff --git a/block.c b/block.c index ef13076c4c..33e99d0c9e 100644 --- a/block.c +++ b/block.c @@ -1720,6 +1720,7 @@ static int bdrv_open_common(BlockDriverState *bs, Blo= ckBackend *file, QemuOpts *opts; BlockDriver *drv; Error *local_err =3D NULL; + bool ro; =20 assert(bs->file =3D=3D NULL); assert(options !=3D NULL && bs->options !=3D options); @@ -1772,15 +1773,17 @@ static int bdrv_open_common(BlockDriverState *bs, B= lockBackend *file, =20 bs->read_only =3D !(bs->open_flags & BDRV_O_RDWR); =20 - if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv, bs->read_only)) { - if (!bs->read_only && bdrv_is_whitelisted(drv, true)) { + ro =3D bdrv_is_read_only(bs); + + if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv, ro)) { + if (!ro && bdrv_is_whitelisted(drv, true)) { ret =3D bdrv_apply_auto_read_only(bs, NULL, NULL); } else { ret =3D -ENOTSUP; } if (ret < 0) { error_setg(errp, - !bs->read_only && bdrv_is_whitelisted(drv, true) + !ro && bdrv_is_whitelisted(drv, true) ? "Driver '%s' can only be used for read-only devic= es" : "Driver '%s' is not whitelisted", drv->format_name); @@ -1792,7 +1795,7 @@ static int bdrv_open_common(BlockDriverState *bs, Blo= ckBackend *file, assert(qatomic_read(&bs->copy_on_read) =3D=3D 0); =20 if (bs->open_flags & BDRV_O_COPY_ON_READ) { - if (!bs->read_only) { + if (!ro) { bdrv_enable_copy_on_read(bs); } else { error_setg(errp, "Can't use copy-on-read on read-only device"); diff --git a/block/block-backend.c b/block/block-backend.c index de5496af66..21b834e9df 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -2269,7 +2269,7 @@ void blk_update_root_state(BlockBackend *blk) assert(blk->root); =20 blk->root_state.open_flags =3D blk->root->bs->open_flags; - blk->root_state.read_only =3D blk->root->bs->read_only; + blk->root_state.read_only =3D bdrv_is_read_only(blk->root->bs); blk->root_state.detect_zeroes =3D blk->root->bs->detect_zeroes; } =20 diff --git a/block/commit.c b/block/commit.c index b89bb20b75..b7f0c7c061 100644 --- a/block/commit.c +++ b/block/commit.c @@ -453,7 +453,7 @@ int bdrv_commit(BlockDriverState *bs) return -EBUSY; } =20 - ro =3D backing_file_bs->read_only; + ro =3D bdrv_is_read_only(backing_file_bs); =20 if (ro) { if (bdrv_reopen_set_read_only(backing_file_bs, false, NULL)) { diff --git a/block/io.c b/block/io.c index 1e826ba9e8..323854d063 100644 --- a/block/io.c +++ b/block/io.c @@ -1973,7 +1973,7 @@ bdrv_co_write_req_prepare(BdrvChild *child, int64_t o= ffset, int64_t bytes, =20 bdrv_check_request(offset, bytes, &error_abort); =20 - if (bs->read_only) { + if (bdrv_is_read_only(bs)) { return -EPERM; } =20 @@ -3406,7 +3406,7 @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, i= nt64_t offset, bool exact, if (new_bytes) { bdrv_make_request_serialising(&req, 1); } - if (bs->read_only) { + if (bdrv_is_read_only(bs)) { error_setg(errp, "Image is read-only"); ret =3D -EACCES; goto out; diff --git a/block/qapi.c b/block/qapi.c index 943e7b15ad..dc69341bfe 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -59,7 +59,7 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk, =20 info =3D g_malloc0(sizeof(*info)); info->file =3D g_strdup(bs->filename); - info->ro =3D bs->read_only; + info->ro =3D bdrv_is_read_only(bs); info->drv =3D g_strdup(bs->drv->format_name); info->encrypted =3D bs->encrypted; =20 diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c index 2e98c7f4b6..71ddb08c21 100644 --- a/block/qcow2-snapshot.c +++ b/block/qcow2-snapshot.c @@ -1026,7 +1026,7 @@ int qcow2_snapshot_load_tmp(BlockDriverState *bs, int new_l1_bytes; int ret; =20 - assert(bs->read_only); + assert(bdrv_is_read_only(bs)); =20 /* Search the snapshot */ snapshot_index =3D find_snapshot_by_id_and_name(bs, snapshot_id, name); diff --git a/block/qcow2.c b/block/qcow2.c index 39b91ef940..ee4530cdbd 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1723,8 +1723,7 @@ static int coroutine_fn qcow2_do_open(BlockDriverStat= e *bs, QDict *options, =20 /* Clear unknown autoclear feature bits */ update_header |=3D s->autoclear_features & ~QCOW2_AUTOCLEAR_MASK; - update_header =3D - update_header && !bs->read_only && !(flags & BDRV_O_INACTIVE); + update_header =3D update_header && bdrv_is_writable(bs); if (update_header) { s->autoclear_features &=3D QCOW2_AUTOCLEAR_MASK; } @@ -1811,7 +1810,7 @@ static int coroutine_fn qcow2_do_open(BlockDriverStat= e *bs, QDict *options, bs->supported_truncate_flags =3D BDRV_REQ_ZERO_WRITE; =20 /* Repair image if dirty */ - if (!(flags & (BDRV_O_CHECK | BDRV_O_INACTIVE)) && !bs->read_only && + if (!(flags & BDRV_O_CHECK) && bdrv_is_writable(bs) && (s->incompatible_features & QCOW2_INCOMPAT_DIRTY)) { BdrvCheckResult result =3D {0}; =20 diff --git a/block/snapshot.c b/block/snapshot.c index e8ae9a28c1..6702c75e42 100644 --- a/block/snapshot.c +++ b/block/snapshot.c @@ -415,7 +415,7 @@ int bdrv_snapshot_load_tmp(BlockDriverState *bs, error_setg(errp, "snapshot_id and name are both NULL"); return -EINVAL; } - if (!bs->read_only) { + if (!bdrv_is_read_only(bs)) { error_setg(errp, "Device is not readonly"); return -EINVAL; } diff --git a/block/vhdx-log.c b/block/vhdx-log.c index 404fb5f3cb..7672161d95 100644 --- a/block/vhdx-log.c +++ b/block/vhdx-log.c @@ -801,7 +801,7 @@ int vhdx_parse_log(BlockDriverState *bs, BDRVVHDXState = *s, bool *flushed, } =20 if (logs.valid) { - if (bs->read_only) { + if (bdrv_is_read_only(bs)) { bdrv_refresh_filename(bs); ret =3D -EPERM; error_setg(errp, --=20 2.30.2 From nobody Mon May 20 00:38:58 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622641933; cv=none; d=zohomail.com; s=zohoarc; b=HuwGQ/SpMwEQpeJsW43AtI6YxFhzsRsNSzITeEfNzEx7bOEEnd2qcv5kSb+xgOreSuxiFvLAUrKRLtfzkhhPEmAoJCru+iVHVeWupqXiR65EC2RNFhUG85UGLETz6ffzjcHqamkYXPOmAue6ETZuzP+/EsoyCp6225L9deNUnUI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622641933; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uSczhTETjrLOl+SvUO6QOHAEcDO1fonXuQdHChJmCdE=; b=ThSQMxy3MqpRI6CgWgDB7Bx/sz7pxRpVW5w9klaVxbO0mZ6+1JFzC3HvyemutXRIfmuhEbh7b6IgZAHWmGAhy1J1M8S290nGLoZz9sr7eOIf737Tu628t8U7qJdzojjHicMAnsDW/2cgKUlMWYzE0L6BwsKSawxyVqwJzgnvEEA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622641933694208.36927352290627; Wed, 2 Jun 2021 06:52:13 -0700 (PDT) Received: from localhost ([::1]:60826 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1loRI4-0006Ru-PV for importer2@patchew.org; Wed, 02 Jun 2021 09:52:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43742) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRC6-0000LF-Na for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:46:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:43222) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRC4-00076a-TT for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:46:02 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-507-iDwnJmA9M8i6xzWcp8aPvg-1; Wed, 02 Jun 2021 09:45:58 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 622638B95A4; Wed, 2 Jun 2021 13:45:42 +0000 (UTC) Received: from merkur.redhat.com (ovpn-114-240.ams2.redhat.com [10.36.114.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E25160BD9; Wed, 2 Jun 2021 13:45:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622641560; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uSczhTETjrLOl+SvUO6QOHAEcDO1fonXuQdHChJmCdE=; b=FxIFNm6iLudWJUKLyExXHi3tq//FwKjReXj7kwlFdHpt7nIsRPHinPl4IPME8ck606TQ8w tIcYwlyeiAS2KX8QmIefY81Rg86b3U+Tk5fhDctj6PM++QkgPNnUb8i0e0Tmb9YYhQv1VU d+p+3Nl50wEd5zEj0lUUWnPosQAAlHU= X-MC-Unique: iDwnJmA9M8i6xzWcp8aPvg-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 06/20] block: drop BlockDriverState::read_only Date: Wed, 2 Jun 2021 15:45:15 +0200 Message-Id: <20210602134529.231756-7-kwolf@redhat.com> In-Reply-To: <20210602134529.231756-1-kwolf@redhat.com> References: <20210602134529.231756-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy This variable is just a cache for !(bs->open_flags & BDRV_O_RDWR), which we have to synchronize everywhere. Let's just drop it and consistently use bdrv_is_read_only(). Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20210527154056.70294-3-vsementsov@virtuozzo.com> Signed-off-by: Kevin Wolf --- include/block/block_int.h | 1 - block.c | 7 +------ tests/unit/test-block-iothread.c | 6 ------ 3 files changed, 1 insertion(+), 13 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index b2c8b09d0f..09661a134b 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -843,7 +843,6 @@ struct BlockDriverState { * locking needed during I/O... */ int open_flags; /* flags used to open the file, re-used for re-open */ - bool read_only; /* if true, the media is read only */ bool encrypted; /* if true, the media is encrypted */ bool sg; /* if true, the device is a /dev/sg* */ bool probed; /* if true, format was probed rather than specified */ diff --git a/block.c b/block.c index 33e99d0c9e..84cb7212f7 100644 --- a/block.c +++ b/block.c @@ -265,7 +265,7 @@ void bdrv_parse_filename_strip_prefix(const char *filen= ame, const char *prefix, * image is inactivated. */ bool bdrv_is_read_only(BlockDriverState *bs) { - return bs->read_only; + return !(bs->open_flags & BDRV_O_RDWR); } =20 int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only, @@ -317,7 +317,6 @@ int bdrv_apply_auto_read_only(BlockDriverState *bs, con= st char *errmsg, goto fail; } =20 - bs->read_only =3D true; bs->open_flags &=3D ~BDRV_O_RDWR; =20 return 0; @@ -1549,7 +1548,6 @@ static int bdrv_open_driver(BlockDriverState *bs, Blo= ckDriver *drv, } =20 bs->drv =3D drv; - bs->read_only =3D !(bs->open_flags & BDRV_O_RDWR); bs->opaque =3D g_malloc0(drv->instance_size); =20 if (drv->bdrv_file_open) { @@ -1771,8 +1769,6 @@ static int bdrv_open_common(BlockDriverState *bs, Blo= ckBackend *file, trace_bdrv_open_common(bs, filename ?: "", bs->open_flags, drv->format_name); =20 - bs->read_only =3D !(bs->open_flags & BDRV_O_RDWR); - ro =3D bdrv_is_read_only(bs); =20 if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv, ro)) { @@ -4548,7 +4544,6 @@ static void bdrv_reopen_commit(BDRVReopenState *reope= n_state) bs->explicit_options =3D reopen_state->explicit_options; bs->options =3D reopen_state->options; bs->open_flags =3D reopen_state->flags; - bs->read_only =3D !(reopen_state->flags & BDRV_O_RDWR); bs->detect_zeroes =3D reopen_state->detect_zeroes; =20 if (reopen_state->replace_backing_bs) { diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothr= ead.c index 8cf172cb7a..c39e70b2f5 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -194,13 +194,11 @@ static void test_sync_op_truncate(BdrvChild *c) g_assert_cmpint(ret, =3D=3D, -EINVAL); =20 /* Error: Read-only image */ - c->bs->read_only =3D true; c->bs->open_flags &=3D ~BDRV_O_RDWR; =20 ret =3D bdrv_truncate(c, 65536, false, PREALLOC_MODE_OFF, 0, NULL); g_assert_cmpint(ret, =3D=3D, -EACCES); =20 - c->bs->read_only =3D false; c->bs->open_flags |=3D BDRV_O_RDWR; } =20 @@ -236,13 +234,11 @@ static void test_sync_op_flush(BdrvChild *c) g_assert_cmpint(ret, =3D=3D, 0); =20 /* Early success: Read-only image */ - c->bs->read_only =3D true; c->bs->open_flags &=3D ~BDRV_O_RDWR; =20 ret =3D bdrv_flush(c->bs); g_assert_cmpint(ret, =3D=3D, 0); =20 - c->bs->read_only =3D false; c->bs->open_flags |=3D BDRV_O_RDWR; } =20 @@ -256,13 +252,11 @@ static void test_sync_op_blk_flush(BlockBackend *blk) g_assert_cmpint(ret, =3D=3D, 0); =20 /* Early success: Read-only image */ - bs->read_only =3D true; bs->open_flags &=3D ~BDRV_O_RDWR; =20 ret =3D blk_flush(blk); g_assert_cmpint(ret, =3D=3D, 0); =20 - bs->read_only =3D false; bs->open_flags |=3D BDRV_O_RDWR; } =20 --=20 2.30.2 From nobody Mon May 20 00:38:58 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622641970; cv=none; d=zohomail.com; s=zohoarc; b=Bgt0m/aLeeH4KZGuuxBeMtB8ZdUxutYVhvAYfJSnLbsXTrvmlVUCdIU+h2yvZ1E/RoGCIwB4k98a5rX40YGpIaxf+aGbozdZdJJZP6xlDI++n7zYfaMSmEZxxuw/nGdnuLx/kbXLfYSpxKeVVnj7anXNAwR9ZyGspGO/UzRTSLU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622641970; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=f2W5gvsMWQvXwqrXI35bDSg8iBskGbDI3OVULsgLVDk=; b=Dw9lNnyJLgDdjcrNKr8je7u2qhx1LtX5hdoyymrGrH/AiQlfHKARwWBHmobiu78UofmrEJ/dCGimkzgnXda5zTCOEEdYb/VhLVoEW8d74CqYTI+E7Q7lxZJBstVC/EQYif2MItUhyctZ0zg9Hrm4JlxM39hAT2as3B5ShIg94AQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622641970637451.5816411883777; Wed, 2 Jun 2021 06:52:50 -0700 (PDT) Received: from localhost ([::1]:35132 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1loRIf-0008Cl-Qp for importer2@patchew.org; Wed, 02 Jun 2021 09:52:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43898) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRCL-0001Gc-H3 for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:46:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:41299) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRCF-0007DJ-Du for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:46:17 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-592-Wd_h7IKhPjK-HflvLmNKeg-1; Wed, 02 Jun 2021 09:46:07 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 970AE814602; Wed, 2 Jun 2021 13:45:43 +0000 (UTC) Received: from merkur.redhat.com (ovpn-114-240.ams2.redhat.com [10.36.114.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id A422C19814; Wed, 2 Jun 2021 13:45:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622641570; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f2W5gvsMWQvXwqrXI35bDSg8iBskGbDI3OVULsgLVDk=; b=ZyPu9vEfQNxyGU+fCrkhrEglgl8pqlrLBns9BBb+eJgfkCDFv50WmqfaP3rXbb4rtc3lST YinNJW2kE8YmDqpHbRfprbwddZGXfr7TW+dpHmCpcZ6F+AVAs8kjB5fm+ZxZmxbYI+prl6 r5shEpx6OX52k67u7+6qnFfV0dfjEuE= X-MC-Unique: Wd_h7IKhPjK-HflvLmNKeg-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 07/20] block: drop BlockBackendRootState::read_only Date: Wed, 2 Jun 2021 15:45:16 +0200 Message-Id: <20210602134529.231756-8-kwolf@redhat.com> In-Reply-To: <20210602134529.231756-1-kwolf@redhat.com> References: <20210602134529.231756-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Instead of keeping additional boolean field, let's store the information in BDRV_O_RDWR bit of BlockBackendRootState::open_flags. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20210527154056.70294-4-vsementsov@virtuozzo.com> Signed-off-by: Kevin Wolf --- include/block/block_int.h | 1 - block/block-backend.c | 10 ++-------- blockdev.c | 3 +-- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 09661a134b..057d88b1fc 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -1007,7 +1007,6 @@ struct BlockDriverState { =20 struct BlockBackendRootState { int open_flags; - bool read_only; BlockdevDetectZeroesOptions detect_zeroes; }; =20 diff --git a/block/block-backend.c b/block/block-backend.c index 21b834e9df..d1a33a2c8e 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1852,7 +1852,7 @@ bool blk_supports_write_perm(BlockBackend *blk) if (bs) { return !bdrv_is_read_only(bs); } else { - return !blk->root_state.read_only; + return blk->root_state.open_flags & BDRV_O_RDWR; } } =20 @@ -2269,7 +2269,6 @@ void blk_update_root_state(BlockBackend *blk) assert(blk->root); =20 blk->root_state.open_flags =3D blk->root->bs->open_flags; - blk->root_state.read_only =3D bdrv_is_read_only(blk->root->bs); blk->root_state.detect_zeroes =3D blk->root->bs->detect_zeroes; } =20 @@ -2288,12 +2287,7 @@ bool blk_get_detect_zeroes_from_root_state(BlockBack= end *blk) */ int blk_get_open_flags_from_root_state(BlockBackend *blk) { - int bs_flags; - - bs_flags =3D blk->root_state.read_only ? 0 : BDRV_O_RDWR; - bs_flags |=3D blk->root_state.open_flags & ~BDRV_O_RDWR; - - return bs_flags; + return blk->root_state.open_flags; } =20 BlockBackendRootState *blk_get_root_state(BlockBackend *blk) diff --git a/blockdev.c b/blockdev.c index 834c2304a1..f08192deda 100644 --- a/blockdev.c +++ b/blockdev.c @@ -583,8 +583,7 @@ static BlockBackend *blockdev_init(const char *file, QD= ict *bs_opts, =20 blk =3D blk_new(qemu_get_aio_context(), 0, BLK_PERM_ALL); blk_rs =3D blk_get_root_state(blk); - blk_rs->open_flags =3D bdrv_flags; - blk_rs->read_only =3D read_only; + blk_rs->open_flags =3D bdrv_flags | (read_only ? 0 : BDRV_O_RDW= R); blk_rs->detect_zeroes =3D detect_zeroes; =20 qobject_unref(bs_opts); --=20 2.30.2 From nobody Mon May 20 00:38:58 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622641980; cv=none; d=zohomail.com; s=zohoarc; b=n0veFAegk4fu8SpnTqQcf+AG9/lzHrdjFN5UDrl3hsonIThWnljEHJCXkV2zxa/zfo29UU1T2hYFJ1CKFqbVSKiI7M5GQ/tCqCQmV/YEIRg23v33+5xabR4GcwEizV/oRxGsp1UfG2kYHXLQ01p75QYsSkcPZ1Ks6NIvZCUMU44= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622641980; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cX0Q8TeZnbeXMi/emkSacTTXOXKvnm1UoXk1pfoo5kw=; b=mKlMNCrNVlYt1PPrFx4QVUtu0Wf2x2y73g3TlVac9jvgil0+RKQUpr5+8KNZ77y4S+1oujYmCeNdkBI13jqFA7IVV2aU8f+DEk32V7IcnfAcigRrQ2IowGVs+qrZHAiRylzv7yWiN11gkbGoSNeImQy65VLlKEwkMgfh2lO6jwk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622641980662116.18949007398328; Wed, 2 Jun 2021 06:53:00 -0700 (PDT) Received: from localhost ([::1]:36026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1loRIp-0000Ld-QY for importer2@patchew.org; Wed, 02 Jun 2021 09:52:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43874) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRCI-00016L-MB for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:46:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:36541) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRCF-0007E1-RA for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:46:14 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-327-4hTn4ExwMkOWpFl-pgpPHA-1; Wed, 02 Jun 2021 09:46:09 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CDC656D5DA; Wed, 2 Jun 2021 13:45:44 +0000 (UTC) Received: from merkur.redhat.com (ovpn-114-240.ams2.redhat.com [10.36.114.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id DDB1860BD9; Wed, 2 Jun 2021 13:45:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622641571; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cX0Q8TeZnbeXMi/emkSacTTXOXKvnm1UoXk1pfoo5kw=; b=FJtGN3FEnGYL091W+gBCkl1QEKG78dg3cEbW69p+7netspKeSfwASg6H54BBVBhFWWUENr oYUxu8iN3oLoasXYBEvrpAso4QJGDFb6Zp2qzwbadCP21C3PNEJAAYqKW9xcPUZqUI5tT3 4q90LPRoFuoGaHbgYpe+IHdCa+04HL4= X-MC-Unique: 4hTn4ExwMkOWpFl-pgpPHA-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 08/20] block/file-posix: Fix problem with fallocate(PUNCH_HOLE) on GPFS Date: Wed, 2 Jun 2021 15:45:17 +0200 Message-Id: <20210602134529.231756-9-kwolf@redhat.com> In-Reply-To: <20210602134529.231756-1-kwolf@redhat.com> References: <20210602134529.231756-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Thomas Huth A customer reported that running qemu-img convert -t none -O qcow2 -f qcow2 input.qcow2 output.qcow2 fails for them with the following error message when the images are stored on a GPFS file system : qemu-img: error while writing sector 0: Invalid argument After analyzing the strace output, it seems like the problem is in handle_aiocb_write_zeroes(): The call to fallocate(FALLOC_FL_PUNCH_HOLE) returns EINVAL, which can apparently happen if the file system has a different idea of the granularity of the operation. It's arguably a bug in GPFS, since the PUNCH_HOLE mode should not result in EINVAL according to the man-page of fallocate(), but the file system is out there in production and so we have to deal with it. In commit 294682cc3a ("block: workaround for unaligned byte range in fallocate()") we also already applied the a work-around for the same problem to the earlier fallocate(FALLOC_FL_ZERO_RANGE) call, so do it now similar with the PUNCH_HOLE call. But instead of silently catching and returning -ENOTSUP (which causes the caller to fall back to writing zeroes), let's rather inform the user once about the buggy file system and try the other fallback instead. Signed-off-by: Thomas Huth Message-Id: <20210527172020.847617-2-thuth@redhat.com> Signed-off-by: Kevin Wolf --- block/file-posix.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/block/file-posix.c b/block/file-posix.c index 10b71d9a13..6e24083f3f 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -1650,6 +1650,17 @@ static int handle_aiocb_write_zeroes(void *opaque) return ret; } s->has_fallocate =3D false; + } else if (ret =3D=3D -EINVAL) { + /* + * Some file systems like older versions of GPFS do not like u= n- + * aligned byte ranges, and return EINVAL in such a case, thou= gh + * they should not do it according to the man-page of fallocat= e(). + * Warn about the bad filesystem and try the final fallback in= stead. + */ + warn_report_once("Your file system is misbehaving: " + "fallocate(FALLOC_FL_PUNCH_HOLE) returned EIN= VAL. " + "Please report this bug to your file sytem " + "vendor."); } else if (ret !=3D -ENOTSUP) { return ret; } else { --=20 2.30.2 From nobody Mon May 20 00:38:58 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622642227; cv=none; d=zohomail.com; s=zohoarc; b=XpFER9KEA0eUe+OPl64/+l0wsTTQ8cv/WE/10Y50E61lLd5An8liMvVpN+ZQXeN+bKz7FJunFX9124gBJ+TO6NS8YeTD3z0TXZJcEuW1+qZWEPoCdbhWxO3QNK59GAqfWi80oVT6M8WllPWf8ssu+YlnfONEQEWx5y3wDV+vaNI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622642227; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CBaDUKnvJIg91/Bx09z1bIJ+o8IZg/K0bT1Oewi4xNs=; b=ExBOC6C+bJu6XogG+H/keczl/ZF8nCfs4M6hgFy82fHVQtNQ5XFn008QdNEZkFkjWB/CA6uMelT0nnxcBH3KM2NhkTlFL8+qfeYxoZ9Ch2a6JnxXOhlpuingeG6jOFRQ9ZreieAtp6SuPVeIWBEQI79NmEZ2broMETGFuhAhIPo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 162264222773017.01791241033027; Wed, 2 Jun 2021 06:57:07 -0700 (PDT) Received: from localhost ([::1]:49558 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1loRMo-00012n-HN for importer2@patchew.org; Wed, 02 Jun 2021 09:57:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43960) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRCQ-0001YF-4c for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:46:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:38998) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRCN-0007Jo-Gk for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:46:21 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-159-zhEb_yy0MbWh4qiV6aZ7IQ-1; Wed, 02 Jun 2021 09:46:08 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0ED9A1075FEB; Wed, 2 Jun 2021 13:45:46 +0000 (UTC) Received: from merkur.redhat.com (ovpn-114-240.ams2.redhat.com [10.36.114.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F2A319814; Wed, 2 Jun 2021 13:45:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622641578; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CBaDUKnvJIg91/Bx09z1bIJ+o8IZg/K0bT1Oewi4xNs=; b=P/Z/l7s/hbZ2YlBOZhARGgwTd4zYlqeCvbBUVAvJ9yocnBR11hx4BBeqsOXCgJUB3uHDKB RxPDWv8+PpOOSL5SZif7MO2rS5qlWD7ubFERHbzTY9IFvQzQ/N16D8/5rBp0KUmLrGpL6N uDZgRby57WmwBd3Ijr1nnzO2sXdZ9i0= X-MC-Unique: zhEb_yy0MbWh4qiV6aZ7IQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 09/20] block/file-posix: Try other fallbacks after invalid FALLOC_FL_ZERO_RANGE Date: Wed, 2 Jun 2021 15:45:18 +0200 Message-Id: <20210602134529.231756-10-kwolf@redhat.com> In-Reply-To: <20210602134529.231756-1-kwolf@redhat.com> References: <20210602134529.231756-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Thomas Huth If fallocate(... FALLOC_FL_ZERO_RANGE ...) returns EINVAL, it's likely an indication that the file system is buggy and does not implement unaligned accesses right. We still might be lucky with the other fallback fallocate() calls later in this function, though, so we should not return immediately and try the others first. Since FALLOC_FL_ZERO_RANGE could also return EINVAL if the file descriptor is not a regular file, we ignore this filesystem bug silently, without printing an error message for the user. Signed-off-by: Thomas Huth Message-Id: <20210527172020.847617-3-thuth@redhat.com> Signed-off-by: Kevin Wolf --- block/file-posix.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index 6e24083f3f..f37dfc10b3 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -1625,17 +1625,17 @@ static int handle_aiocb_write_zeroes(void *opaque) if (s->has_write_zeroes) { int ret =3D do_fallocate(s->fd, FALLOC_FL_ZERO_RANGE, aiocb->aio_offset, aiocb->aio_nbytes); - if (ret =3D=3D -EINVAL) { - /* - * Allow falling back to pwrite for file systems that - * do not support fallocate() for an unaligned byte range. - */ - return -ENOTSUP; - } - if (ret =3D=3D 0 || ret !=3D -ENOTSUP) { + if (ret =3D=3D -ENOTSUP) { + s->has_write_zeroes =3D false; + } else if (ret =3D=3D 0 || ret !=3D -EINVAL) { return ret; } - s->has_write_zeroes =3D false; + /* + * Note: Some file systems do not like unaligned byte ranges, and + * return EINVAL in such a case, though they should not do it acco= rding + * to the man-page of fallocate(). Thus we simply ignore this retu= rn + * value and try the other fallbacks instead. + */ } #endif =20 --=20 2.30.2 From nobody Mon May 20 00:38:58 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622642077; cv=none; d=zohomail.com; s=zohoarc; b=nrjW+mOSpeyj5IEZeY/vweCkI6uPv+o5WO8HDxab5RL98XWY4bLzJjuw1apNtt1T+vKYYgfMGNE0D89seOtlgqKpMUNmX6Y1b3MYlmjQR6GrKDrE2oZA31ppp4UI/PJIFrJp/nUuBTveRomRPDVL3LnoxrHSvJu/umfoPYmjTkw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622642077; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZiJowF4miaokVojnqvQE1qycemMNmA5ngJhIeWf6azo=; b=mofcQlzQz+cgSws9WB7KDgWuKhXLP+a46BWx/L/O1/1HuS++NZlbhxKgh+QZQLUXEv/Em/E0yFfr2eMpSBp3CxbXZNR5GQzWG0LKzoAwv+r6QA2bcl9GtZDkAFl8lOuGFxf+TjWo5eEEAND3IwESKTw3aOh1wFsjiqXyeN8Ev2g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622642077347588.839293813201; Wed, 2 Jun 2021 06:54:37 -0700 (PDT) Received: from localhost ([::1]:42514 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1loRKO-0004eW-Jw for importer2@patchew.org; Wed, 02 Jun 2021 09:54:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43924) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRCN-0001Pl-St for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:46:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:53174) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRCM-0007JB-9x for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:46:19 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-245-0DUAZCI8O9KsgFp6nKLRLg-1; Wed, 02 Jun 2021 09:46:14 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 436C881F03C; Wed, 2 Jun 2021 13:45:47 +0000 (UTC) Received: from merkur.redhat.com (ovpn-114-240.ams2.redhat.com [10.36.114.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5465D60BD9; Wed, 2 Jun 2021 13:45:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622641577; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZiJowF4miaokVojnqvQE1qycemMNmA5ngJhIeWf6azo=; b=ge7YSrtPJuAq4SVqXk489RfaJv1+IC0T3Qrr/QPFQeaa8vgKEvr/wJPDzsZnqUlI90Eb6f Rv+VA1PPP1o2H5EE2dg43zTim5sgKUKQ2K57CYlwr6uy00gyww0CsSJMBB5ma0aX4LjELo cNQpek/kcYyh216UzrDWFYRs7VcKLmQ= X-MC-Unique: 0DUAZCI8O9KsgFp6nKLRLg-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 10/20] block: document child argument of bdrv_attach_child_common() Date: Wed, 2 Jun 2021 15:45:19 +0200 Message-Id: <20210602134529.231756-11-kwolf@redhat.com> In-Reply-To: <20210602134529.231756-1-kwolf@redhat.com> References: <20210602134529.231756-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy The logic around **child is not obvious: this reference is used not only to return resulting child, but also to rollback NULL value on transaction abort. So, let's add documentation and some assertions. While being here, drop extra declaration of bdrv_attach_child_noperm(). Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20210601075218.79249-2-vsementsov@virtuozzo.com> Signed-off-by: Kevin Wolf --- block.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/block.c b/block.c index 84cb7212f7..c0fd363605 100644 --- a/block.c +++ b/block.c @@ -84,14 +84,6 @@ static BlockDriverState *bdrv_open_inherit(const char *f= ilename, =20 static void bdrv_replace_child_noperm(BdrvChild *child, BlockDriverState *new_bs); -static int bdrv_attach_child_noperm(BlockDriverState *parent_bs, - BlockDriverState *child_bs, - const char *child_name, - const BdrvChildClass *child_class, - BdrvChildRole child_role, - BdrvChild **child, - Transaction *tran, - Error **errp); static void bdrv_remove_filter_or_cow_child(BlockDriverState *bs, Transaction *tran); =20 @@ -2759,6 +2751,12 @@ static TransactionActionDrv bdrv_attach_child_common= _drv =3D { =20 /* * Common part of attaching bdrv child to bs or to blk or to job + * + * Resulting new child is returned through @child. + * At start *@child must be NULL. + * @child is saved to a new entry of @tran, so that *@child could be rever= ted to + * NULL on abort(). So referenced variable must live at least until transa= ction + * end. */ static int bdrv_attach_child_common(BlockDriverState *child_bs, const char *child_name, @@ -2833,6 +2831,10 @@ static int bdrv_attach_child_common(BlockDriverState= *child_bs, return 0; } =20 +/* + * Variable referenced by @child must live at least until transaction end. + * (see bdrv_attach_child_common() doc for details) + */ static int bdrv_attach_child_noperm(BlockDriverState *parent_bs, BlockDriverState *child_bs, const char *child_name, @@ -2915,7 +2917,6 @@ BdrvChild *bdrv_root_attach_child(BlockDriverState *c= hild_bs, child_role, perm, shared_perm, opaque, &child, tran, errp); if (ret < 0) { - assert(child =3D=3D NULL); goto out; } =20 @@ -2923,6 +2924,9 @@ BdrvChild *bdrv_root_attach_child(BlockDriverState *c= hild_bs, =20 out: tran_finalize(tran, ret); + /* child is unset on failure by bdrv_attach_child_common_abort() */ + assert((ret < 0) =3D=3D !child); + bdrv_unref(child_bs); return child; } @@ -2962,6 +2966,8 @@ BdrvChild *bdrv_attach_child(BlockDriverState *parent= _bs, =20 out: tran_finalize(tran, ret); + /* child is unset on failure by bdrv_attach_child_common_abort() */ + assert((ret < 0) =3D=3D !child); =20 bdrv_unref(child_bs); =20 --=20 2.30.2 From nobody Mon May 20 00:38:58 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622642131; cv=none; d=zohomail.com; s=zohoarc; b=knGQS7+lDEieC4H32dgf1XYf429sb3Au1YAw1c4kID3S9UTztC3wHOcUrNZhmvdQ5CRN4UMSVR/WYrBBoBehYKUrzBF5tXUDkjdgE0Bg2ohZ0iBkcjpTr0GINXuQueRdNtwyh2GJrGzZ6AiVgP7NaACnQF9AvIze4o/+pKshoFw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622642131; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Mkpp5OqanXbInZTG+8hUEoObj4JueAq7ykXfwjTDSKo=; b=czscT4mvarHD81qn0yCUW5SC7+RVZQguDCdp5Nh4fWjhv/kNBvHVF7ELwusXop2VtPwz1R25WNxH3PhVa+yePz38pPC2f9a68T5MsiR2WGPG/ElFNX63gV4BQdAZjbgQFxpKZNVHN9kxzcKWMNd/HXINXkU2UszO48P4sj7nlYU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622642131157820.956131189541; Wed, 2 Jun 2021 06:55:31 -0700 (PDT) Received: from localhost ([::1]:45204 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1loRLG-0006Re-5F for importer2@patchew.org; Wed, 02 Jun 2021 09:55:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43950) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRCP-0001WY-Lt for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:46:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:23742) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRCN-0007Jw-TE for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:46:21 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-47-Pbtj5aLYN7-qhE6Xi-QAug-1; Wed, 02 Jun 2021 09:46:17 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7A8A71922965; Wed, 2 Jun 2021 13:45:48 +0000 (UTC) Received: from merkur.redhat.com (ovpn-114-240.ams2.redhat.com [10.36.114.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8BAD360BD9; Wed, 2 Jun 2021 13:45:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622641579; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Mkpp5OqanXbInZTG+8hUEoObj4JueAq7ykXfwjTDSKo=; b=BgUHn22dLnyXBx3JYZxhTG6iWOxrnapPUYx8ykEF4gSTftyErLgqEDfFhmR0obnZ2g0kR7 5P7YqL5M0MkzoHFAI0QXMOslZk02FBMZ1FyHhfxOfGm+BpxRgyYkvNv8drY+x7KizQEpUE 9NZocflQr2ESZwmSY+y0Y9Xp+i5qMvs= X-MC-Unique: Pbtj5aLYN7-qhE6Xi-QAug-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 11/20] block-backend: improve blk_root_get_parent_desc() Date: Wed, 2 Jun 2021 15:45:20 +0200 Message-Id: <20210602134529.231756-12-kwolf@redhat.com> In-Reply-To: <20210602134529.231756-1-kwolf@redhat.com> References: <20210602134529.231756-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy We have different types of parents: block nodes, block backends and jobs. So, it makes sense to specify type together with name. While being here also use g_autofree. iotest 307 output is updated. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Alberto Garcia Message-Id: <20210601075218.79249-3-vsementsov@virtuozzo.com> Signed-off-by: Kevin Wolf --- block/block-backend.c | 9 ++++----- tests/qemu-iotests/307.out | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index d1a33a2c8e..5be32c0c42 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -141,19 +141,18 @@ static void blk_root_set_aio_ctx(BdrvChild *child, Ai= oContext *ctx, static char *blk_root_get_parent_desc(BdrvChild *child) { BlockBackend *blk =3D child->opaque; - char *dev_id; + g_autofree char *dev_id =3D NULL; =20 if (blk->name) { - return g_strdup(blk->name); + return g_strdup_printf("block device '%s'", blk->name); } =20 dev_id =3D blk_get_attached_dev_id(blk); if (*dev_id) { - return dev_id; + return g_strdup_printf("block device '%s'", dev_id); } else { /* TODO Callback into the BB owner for something more detailed */ - g_free(dev_id); - return g_strdup("a block device"); + return g_strdup("an unnamed block device"); } } =20 diff --git a/tests/qemu-iotests/307.out b/tests/qemu-iotests/307.out index daa8ad2da0..66bf2ddb74 100644 --- a/tests/qemu-iotests/307.out +++ b/tests/qemu-iotests/307.out @@ -53,7 +53,7 @@ exports available: 1 =20 =3D=3D=3D Add a writable export =3D=3D=3D {"execute": "block-export-add", "arguments": {"description": "This is the = writable second export", "id": "export1", "name": "export1", "node-name": "= fmt", "type": "nbd", "writable": true, "writethrough": true}} -{"error": {"class": "GenericError", "desc": "Conflicts with use by sda as = 'root', which does not allow 'write' on fmt"}} +{"error": {"class": "GenericError", "desc": "Conflicts with use by block d= evice 'sda' as 'root', which does not allow 'write' on fmt"}} {"execute": "device_del", "arguments": {"id": "sda"}} {"return": {}} {"data": {"device": "sda", "path": "/machine/peripheral/sda"}, "event": "D= EVICE_DELETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} --=20 2.30.2 From nobody Mon May 20 00:38:58 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622642267; cv=none; d=zohomail.com; s=zohoarc; b=DSBvyrzUwClvdIE5jsr/CHkQv6Sxe5iuiIUtOAvpZcZT6gsPRDHT0UMrxBEoUGYQsxHg0klyr1IP3xwsRuZqD0JHy/mSrkyWpsKCrUffKzXm0idHEPHuckZVmE+dBFy32suc6d+u9cXkw5/V078Jso9zsS9KI9Fpu5zuyJeODWI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622642267; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=igWrkTKNYAoinrQsAdI9dJItNXjwsqII+NxMQaz3M/M=; b=IRQ7dTCagC1xSk2OvlLNfisYzvCFDklLwJo3+xYfDaSjh0z9iEsA3jRb04N8eOuWvrWuT928Ng4VYu82cfL1iEIYbf8xOhDHAHiSaA34381arHk+OibWX5FaUHHcxdChNX0g35bIz0FOrjFC7z4WeYXIvO9uYaR+yMfktj/oNdw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622642267131688.9242998918705; Wed, 2 Jun 2021 06:57:47 -0700 (PDT) Received: from localhost ([::1]:51882 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1loRNS-0002bR-Bx for importer2@patchew.org; Wed, 02 Jun 2021 09:57:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44012) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRCU-0001pJ-Go for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:46:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:46718) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRCP-0007L1-Dc for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:46:26 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-570-ywTC6w9tOUaBstOXo9-v6w-1; Wed, 02 Jun 2021 09:46:18 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AE090A0CDD; Wed, 2 Jun 2021 13:45:49 +0000 (UTC) Received: from merkur.redhat.com (ovpn-114-240.ams2.redhat.com [10.36.114.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id C078119CBE; Wed, 2 Jun 2021 13:45:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622641580; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=igWrkTKNYAoinrQsAdI9dJItNXjwsqII+NxMQaz3M/M=; b=SK5VUP/7VVWQLJd19GGtDNTyibNJzfXAt5LHKJqu3rEAjQghqT4B53c1MxCeP31vdynVcl WYCj4Ig1Gu+UwCf39P92zaxxpqPACofmQy5zuNb4yfBTzeKyVPW//BG57GbbYqHfRlaqfT 5NZ0p7fChLPGsvBlrb/Kxv37YhOb4Dg= X-MC-Unique: ywTC6w9tOUaBstOXo9-v6w-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 12/20] block: improve bdrv_child_get_parent_desc() Date: Wed, 2 Jun 2021 15:45:21 +0200 Message-Id: <20210602134529.231756-13-kwolf@redhat.com> In-Reply-To: <20210602134529.231756-1-kwolf@redhat.com> References: <20210602134529.231756-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy We have different types of parents: block nodes, block backends and jobs. So, it makes sense to specify type together with name. Next, this handler us used to compose an error message about permission conflict. And permission conflict occurs in a specific place of block graph. We shouldn't report name of parent device (as it refers another place in block graph), but exactly and only the name of the node. So, use bdrv_get_node_name() directly. iotest 283 output is updated. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Alberto Garcia Message-Id: <20210601075218.79249-4-vsementsov@virtuozzo.com> Signed-off-by: Kevin Wolf --- block.c | 2 +- tests/qemu-iotests/283.out | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/block.c b/block.c index c0fd363605..94cb7b6637 100644 --- a/block.c +++ b/block.c @@ -1149,7 +1149,7 @@ int bdrv_parse_cache_mode(const char *mode, int *flag= s, bool *writethrough) static char *bdrv_child_get_parent_desc(BdrvChild *c) { BlockDriverState *parent =3D c->opaque; - return g_strdup(bdrv_get_device_or_node_name(parent)); + return g_strdup_printf("node '%s'", bdrv_get_node_name(parent)); } =20 static void bdrv_child_cb_drained_begin(BdrvChild *child) diff --git a/tests/qemu-iotests/283.out b/tests/qemu-iotests/283.out index 97e62a4c94..c9397bfc44 100644 --- a/tests/qemu-iotests/283.out +++ b/tests/qemu-iotests/283.out @@ -5,7 +5,7 @@ {"execute": "blockdev-add", "arguments": {"driver": "blkdebug", "image": "= base", "node-name": "other", "take-child-perms": ["write"]}} {"return": {}} {"execute": "blockdev-backup", "arguments": {"device": "source", "sync": "= full", "target": "target"}} -{"error": {"class": "GenericError", "desc": "Cannot append backup-top filt= er: Conflicts with use by source as 'image', which does not allow 'write' o= n base"}} +{"error": {"class": "GenericError", "desc": "Cannot append backup-top filt= er: Conflicts with use by node 'source' as 'image', which does not allow 'w= rite' on base"}} =20 =3D=3D=3D backup-top should be gone after job-finalize =3D=3D=3D =20 --=20 2.30.2 From nobody Mon May 20 00:38:58 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622642370; cv=none; d=zohomail.com; s=zohoarc; b=Mi+qY+474r1PvPgkscnRxoesilid6CLQjbILEBzPA5jzaIy76GkMO3c4afwFWT/LdvLwrFIWTs46537C/CuFmrRZm0uzyPvFJBQzfo4rrltpzYffBT8x4fWaCVlvoXUYinosAlfYCSk0f3cTPRI9rPCtWnIFZ4JZ6JC45faSgEM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622642370; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=X3qJhjfuHd8oHrw6mJz1DwARWVHxy/mLa1EaobjhmGc=; b=JQEUMKIn93FIrpZ9vi69fCQF2Fj9kGPdwSJ028VZ++dAjiDpJ0VnSoiLn0pd+lJVnDs0WhZWxsNa+HbMSCU/UvQomea+tIlKIB91NiOwEAP6DjPOOK6l0ZxtT0bmnIdmbZasiuQ0zIeGNDk6K3kXfJ75JmnyldYOI1/MlDHAxYI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622642370777833.8027950710779; Wed, 2 Jun 2021 06:59:30 -0700 (PDT) Received: from localhost ([::1]:57240 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1loRP8-00069w-4O for importer2@patchew.org; Wed, 02 Jun 2021 09:59:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44074) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRCY-00025X-SP for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:46:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22295) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRCX-0007Qk-2a for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:46:30 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-428-GMM3kFR8MP-XYeCPCFECIw-1; Wed, 02 Jun 2021 09:46:22 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E44A08B7CC6; Wed, 2 Jun 2021 13:45:50 +0000 (UTC) Received: from merkur.redhat.com (ovpn-114-240.ams2.redhat.com [10.36.114.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 005D519CBE; Wed, 2 Jun 2021 13:45:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622641588; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X3qJhjfuHd8oHrw6mJz1DwARWVHxy/mLa1EaobjhmGc=; b=F+EVjoG8JlKslpM9jnCVgeW8ig+3BH+BhGalC4jRUBHfow+qUT4FFECyvV1tnDxX7C0mCR LzqCgf5KRCgeYYYb6107Yyg3oySAYLU8/BFbYZBnn5Lr28ziOWbq8uQAJ/oHh88m50qsen Hi9JA98a5j6+pzR5M+LlURu013wCu6A= X-MC-Unique: GMM3kFR8MP-XYeCPCFECIw-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 13/20] block/vvfat: inherit child_vvfat_qcow from child_of_bds Date: Wed, 2 Jun 2021 15:45:22 +0200 Message-Id: <20210602134529.231756-14-kwolf@redhat.com> In-Reply-To: <20210602134529.231756-1-kwolf@redhat.com> References: <20210602134529.231756-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Recently we've fixed a crash by adding .get_parent_aio_context handler to child_vvfat_qcow. Now we want it to support .get_parent_desc as well. child_vvfat_qcow wants to implement own .inherit_options, it's not bad. But omitting all other handlers is a bad idea. Let's inherit the class from child_of_bds instead, similar to chain_child_class and detach_by_driver_cb_class in test-bdrv-drain.c. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20210601075218.79249-5-vsementsov@virtuozzo.com> Signed-off-by: Kevin Wolf --- block/vvfat.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/block/vvfat.c b/block/vvfat.c index 86d99c899c..ae9d387da7 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -3127,11 +3127,7 @@ static void vvfat_qcow_options(BdrvChildRole role, b= ool parent_is_format, qdict_set_default_str(child_options, BDRV_OPT_CACHE_NO_FLUSH, "on"); } =20 -static const BdrvChildClass child_vvfat_qcow =3D { - .parent_is_bds =3D true, - .inherit_options =3D vvfat_qcow_options, - .get_parent_aio_context =3D child_of_bds_get_parent_aio_context, -}; +static BdrvChildClass child_vvfat_qcow; =20 static int enable_write_target(BlockDriverState *bs, Error **errp) { @@ -3268,6 +3264,8 @@ static BlockDriver bdrv_vvfat =3D { =20 static void bdrv_vvfat_init(void) { + child_vvfat_qcow =3D child_of_bds; + child_vvfat_qcow.inherit_options =3D vvfat_qcow_options; bdrv_register(&bdrv_vvfat); } =20 --=20 2.30.2 From nobody Mon May 20 00:38:58 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622641870; cv=none; d=zohomail.com; s=zohoarc; b=VWh3rL6Jard0oSY/zdcyUQSsIOHQYfXDG4RAUyPnh32tpKk20PAwEYiyjCSVbxImvyPn3vzhf7/xEvKqr2l5C3eZ59qTlPByJrwsv5Xo5TRTS7vxM8pabBbEbNvI3wEcK3gsz0c53yTtcYUatxigK27u91+srzjaPff1eESgmPs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622641870; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eIHfk2PxzIMa8nVXOaUPqutAR2SxBNT6tQV5Eo9WgGo=; b=j0NuKzco2Eu/U4NNFmWOQLuTjDyxe/+23HlsvYj9Yfh/gOPzo5zrLyyXP90hQRpz4ggrrn2RicPZ52skwjF/FWK14/F8r9For5afrK7ajX5r7HVbQ6Udi80GTUeix8eqyGcKQ96aC48jQr8VgYG6tbLbfI8jJF/8730w8RVqTHE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 162264187065871.75468061449294; Wed, 2 Jun 2021 06:51:10 -0700 (PDT) Received: from localhost ([::1]:56676 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1loRH3-0003g0-Kd for importer2@patchew.org; Wed, 02 Jun 2021 09:51:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44108) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRCb-0002G5-JH for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:46:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:47070) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRCX-0007Qw-Fs for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:46:33 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-166-Mw62IVzrOiOZeC2ozl3-Xw-1; Wed, 02 Jun 2021 09:46:24 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 26E8719253F8; Wed, 2 Jun 2021 13:45:52 +0000 (UTC) Received: from merkur.redhat.com (ovpn-114-240.ams2.redhat.com [10.36.114.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 369B860BD9; Wed, 2 Jun 2021 13:45:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622641588; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eIHfk2PxzIMa8nVXOaUPqutAR2SxBNT6tQV5Eo9WgGo=; b=JmFzE5+MPpUW2vYeFrM5Xolc2xHVc77+yHsrhebtFnaBVfTMgKTxnVAYPSZMInTNuJ9FYL D0oQnXDSpTUyOgfDlumXowiTjDRKgJev23DGStHLB0AgmAmncj6fd2ITnAyPvzgal1cGUM D+3Fox4/1I9fLKekBaCXC5NUonL+1Cg= X-MC-Unique: Mw62IVzrOiOZeC2ozl3-Xw-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 14/20] block: simplify bdrv_child_user_desc() Date: Wed, 2 Jun 2021 15:45:23 +0200 Message-Id: <20210602134529.231756-15-kwolf@redhat.com> In-Reply-To: <20210602134529.231756-1-kwolf@redhat.com> References: <20210602134529.231756-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy All child classes have this callback. So, drop unreachable code. Still add an assertion to bdrv_attach_child_common(), to early detect bad classes. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20210601075218.79249-6-vsementsov@virtuozzo.com> Signed-off-by: Kevin Wolf --- block.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/block.c b/block.c index 94cb7b6637..3c0c3964ec 100644 --- a/block.c +++ b/block.c @@ -2026,11 +2026,7 @@ bool bdrv_is_writable(BlockDriverState *bs) =20 static char *bdrv_child_user_desc(BdrvChild *c) { - if (c->klass->get_parent_desc) { - return c->klass->get_parent_desc(c); - } - - return g_strdup("another user"); + return c->klass->get_parent_desc(c); } =20 static bool bdrv_a_allow_b(BdrvChild *a, BdrvChild *b, Error **errp) @@ -2772,6 +2768,7 @@ static int bdrv_attach_child_common(BlockDriverState = *child_bs, =20 assert(child); assert(*child =3D=3D NULL); + assert(child_class->get_parent_desc); =20 new_child =3D g_new(BdrvChild, 1); *new_child =3D (BdrvChild) { --=20 2.30.2 From nobody Mon May 20 00:38:58 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622642123; cv=none; d=zohomail.com; s=zohoarc; b=cvJ12EcICmlkYiw7jUg98Oh3FzLL/rAVayJDtOPV9J5fHCSGLQ7bGWRpPjEyam2KGKde7bN9OjwKlwgLVFmAg+OcdbTEm6RrQ5ADMatFo7cZ2smK5X5tdfhsvqUlBnZ0vIgjykjoxKeEKJFAgbyD0uw84kUG0jKjCj6MDW9MsFU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622642123; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IEKfQV4Gz0VuZbvZsdGb/PaJqLtNx01s9bB3Grc1K18=; b=g0dMS3sSF7n5buJoaO7GKcV56ISsooiILOdwLOeH17D3qulTpfPG9elEp+mPZsbxg7JBxiTB//LMgFra3dWWR/ezPyVDI9uE6bdYnA9I35afhUMgjk2XFKMtLxeGawTmYmjWHKlSPsuGHELQTJ19IL0+sF0u7yYA0KOVeR+6Xg8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622642123541447.08363798525033; Wed, 2 Jun 2021 06:55:23 -0700 (PDT) Received: from localhost ([::1]:44476 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1loRL8-0005xj-QB for importer2@patchew.org; Wed, 02 Jun 2021 09:55:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44158) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRCf-0002Tu-7N for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:46:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:53641) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRCb-0007Sz-3r for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:46:36 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-495-MuBQOlzsMB2ovQhUZHn-LQ-1; Wed, 02 Jun 2021 09:46:29 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 614EB1083844; Wed, 2 Jun 2021 13:45:53 +0000 (UTC) Received: from merkur.redhat.com (ovpn-114-240.ams2.redhat.com [10.36.114.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6CEA42DAD0; Wed, 2 Jun 2021 13:45:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622641592; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IEKfQV4Gz0VuZbvZsdGb/PaJqLtNx01s9bB3Grc1K18=; b=fVRCiEJfTkm2rlkr0dLhshgSTMRSEjo+m5RVMgojQKdfM68QuLoatHydlIIzS9XS4UqsWa PTSt5PQl7LB5H+PmTpyEenbPSbUupSEWCMqPXqb55fGiIKk0I4Tk5H+XNN5Mzx9Og8N4fY G7FEGjriT3npJmxGs081h1gDGizyuVk= X-MC-Unique: MuBQOlzsMB2ovQhUZHn-LQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 15/20] block: improve permission conflict error message Date: Wed, 2 Jun 2021 15:45:24 +0200 Message-Id: <20210602134529.231756-16-kwolf@redhat.com> In-Reply-To: <20210602134529.231756-1-kwolf@redhat.com> References: <20210602134529.231756-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Now permissions are updated as follows: 1. do graph modifications ignoring permissions 2. do permission update (of course, we rollback [1] if [2] fails) So, on stage [2] we can't say which users are "old" and which are "new" and exist only since [1]. And current error message is a bit outdated. Let's improve it, to make everything clean. While being here, add also a comment and some good assertions. iotests 283, 307, qsd-jobs outputs are updated. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20210601075218.79249-7-vsementsov@virtuozzo.com> Signed-off-by: Kevin Wolf --- block.c | 29 ++++++++++++++++++++------- tests/qemu-iotests/283.out | 2 +- tests/qemu-iotests/307.out | 2 +- tests/qemu-iotests/tests/qsd-jobs.out | 2 +- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/block.c b/block.c index 3c0c3964ec..3f456892d0 100644 --- a/block.c +++ b/block.c @@ -2029,20 +2029,35 @@ static char *bdrv_child_user_desc(BdrvChild *c) return c->klass->get_parent_desc(c); } =20 +/* + * Check that @a allows everything that @b needs. @a and @b must reference= same + * child node. + */ static bool bdrv_a_allow_b(BdrvChild *a, BdrvChild *b, Error **errp) { - g_autofree char *user =3D NULL; - g_autofree char *perm_names =3D NULL; + const char *child_bs_name; + g_autofree char *a_user =3D NULL; + g_autofree char *b_user =3D NULL; + g_autofree char *perms =3D NULL; + + assert(a->bs); + assert(a->bs =3D=3D b->bs); =20 if ((b->perm & a->shared_perm) =3D=3D b->perm) { return true; } =20 - perm_names =3D bdrv_perm_names(b->perm & ~a->shared_perm); - user =3D bdrv_child_user_desc(a); - error_setg(errp, "Conflicts with use by %s as '%s', which does not " - "allow '%s' on %s", - user, a->name, perm_names, bdrv_get_node_name(b->bs)); + child_bs_name =3D bdrv_get_node_name(b->bs); + a_user =3D bdrv_child_user_desc(a); + b_user =3D bdrv_child_user_desc(b); + perms =3D bdrv_perm_names(b->perm & ~a->shared_perm); + + error_setg(errp, "Permission conflict on node '%s': permissions '%s' a= re " + "both required by %s (uses node '%s' as '%s' child) and " + "unshared by %s (uses node '%s' as '%s' child).", + child_bs_name, perms, + b_user, child_bs_name, b->name, + a_user, child_bs_name, a->name); =20 return false; } diff --git a/tests/qemu-iotests/283.out b/tests/qemu-iotests/283.out index c9397bfc44..c6e12b15c5 100644 --- a/tests/qemu-iotests/283.out +++ b/tests/qemu-iotests/283.out @@ -5,7 +5,7 @@ {"execute": "blockdev-add", "arguments": {"driver": "blkdebug", "image": "= base", "node-name": "other", "take-child-perms": ["write"]}} {"return": {}} {"execute": "blockdev-backup", "arguments": {"device": "source", "sync": "= full", "target": "target"}} -{"error": {"class": "GenericError", "desc": "Cannot append backup-top filt= er: Conflicts with use by node 'source' as 'image', which does not allow 'w= rite' on base"}} +{"error": {"class": "GenericError", "desc": "Cannot append backup-top filt= er: Permission conflict on node 'base': permissions 'write' are both requir= ed by node 'other' (uses node 'base' as 'image' child) and unshared by node= 'source' (uses node 'base' as 'image' child)."}} =20 =3D=3D=3D backup-top should be gone after job-finalize =3D=3D=3D =20 diff --git a/tests/qemu-iotests/307.out b/tests/qemu-iotests/307.out index 66bf2ddb74..4b0c7e155a 100644 --- a/tests/qemu-iotests/307.out +++ b/tests/qemu-iotests/307.out @@ -53,7 +53,7 @@ exports available: 1 =20 =3D=3D=3D Add a writable export =3D=3D=3D {"execute": "block-export-add", "arguments": {"description": "This is the = writable second export", "id": "export1", "name": "export1", "node-name": "= fmt", "type": "nbd", "writable": true, "writethrough": true}} -{"error": {"class": "GenericError", "desc": "Conflicts with use by block d= evice 'sda' as 'root', which does not allow 'write' on fmt"}} +{"error": {"class": "GenericError", "desc": "Permission conflict on node '= fmt': permissions 'write' are both required by an unnamed block device (use= s node 'fmt' as 'root' child) and unshared by block device 'sda' (uses node= 'fmt' as 'root' child)."}} {"execute": "device_del", "arguments": {"id": "sda"}} {"return": {}} {"data": {"device": "sda", "path": "/machine/peripheral/sda"}, "event": "D= EVICE_DELETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} diff --git a/tests/qemu-iotests/tests/qsd-jobs.out b/tests/qemu-iotests/tes= ts/qsd-jobs.out index 9f52255da8..189423354b 100644 --- a/tests/qemu-iotests/tests/qsd-jobs.out +++ b/tests/qemu-iotests/tests/qsd-jobs.out @@ -16,7 +16,7 @@ QMP_VERSION {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "job0"}} -{"error": {"class": "GenericError", "desc": "Conflicts with use by stream = job 'job0' as 'intermediate node', which does not allow 'write' on fmt_base= "}} +{"error": {"class": "GenericError", "desc": "Permission conflict on node '= fmt_base': permissions 'write' are both required by an unnamed block device= (uses node 'fmt_base' as 'root' child) and unshared by stream job 'job0' (= uses node 'fmt_base' as 'intermediate node' child)."}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_EXPORT_DELETED", "data": {"id": "export1"}} *** done --=20 2.30.2 From nobody Mon May 20 00:38:58 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622642260; cv=none; d=zohomail.com; s=zohoarc; b=CXV450xlifjGEOUnpGQgUgckk87uCa1K+wxMP2M97Q5cNmwbBv5TlbyzFtm3YfOeNvpjXCYgDSwP6ZMtJDfRrKBKb7el/BFyA+1pGf08GGvQjBmhteetdxzR12hXwemBuLNKmPrzk24ySzeqU8P933kDJ5SCbKyr1oknQ4nuMwM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622642260; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xH+zSztoc1mlNU11g0Z4uJrazThA21J7My8TwQ7Tiy4=; b=GrkQWRNxcITJjVawnll8NfACF9drgi0lMb8q12JmOxGhGjoP4sGq3tvEVE0oeRQQpChpLADQluBOvB5/apZanEj2PmEmF77ndI/GTdjjY8Qdbg0AjvDjm26EaXpEh1Cp1zRtkvCYGfgdzCSV8RBJssp87gGaGUibhqdZOjZbsFk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 162264226097761.18993322896574; Wed, 2 Jun 2021 06:57:40 -0700 (PDT) Received: from localhost ([::1]:51216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1loRNM-0002AR-7x for importer2@patchew.org; Wed, 02 Jun 2021 09:57:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44194) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRCg-0002a5-Si for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:46:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:35920) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRCf-0007VY-1Q for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:46:38 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-452-zRDiTk3kM2m-VY2SxoRa4w-1; Wed, 02 Jun 2021 09:46:34 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 959471927831; Wed, 2 Jun 2021 13:45:54 +0000 (UTC) Received: from merkur.redhat.com (ovpn-114-240.ams2.redhat.com [10.36.114.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id A2A512DAD0; Wed, 2 Jun 2021 13:45:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622641596; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xH+zSztoc1mlNU11g0Z4uJrazThA21J7My8TwQ7Tiy4=; b=N6lc+th6B4jt5YFcKnahitpldJxyEFbO2Uv/JKNa2162Wn6+D4mxfkSHp99Fyk5Jh7G2a8 4/RA5bLpIeQ+WdI5DOxIWJyTv0lPMDITrKL5m+PHwLlFTaCqHtkKX8/5O0R1qFn41yNB06 07CmSpFzUVOMfu9xQOHiBfI+6AGKAcM= X-MC-Unique: zRDiTk3kM2m-VY2SxoRa4w-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 16/20] block-backend: add drained_poll Date: Wed, 2 Jun 2021 15:45:25 +0200 Message-Id: <20210602134529.231756-17-kwolf@redhat.com> In-Reply-To: <20210602134529.231756-1-kwolf@redhat.com> References: <20210602134529.231756-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Sergio Lopez Allow block backends to poll their devices/users to check if they have been quiesced when entering a drained section. This will be used in the next patch to wait for the NBD server to be completely quiesced. Suggested-by: Kevin Wolf Reviewed-by: Kevin Wolf Reviewed-by: Eric Blake Signed-off-by: Sergio Lopez Message-Id: <20210602060552.17433-2-slp@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Kevin Wolf --- include/sysemu/block-backend.h | 4 ++++ block/block-backend.c | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index 880e903293..5423e3d9c6 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -66,6 +66,10 @@ typedef struct BlockDevOps { * Runs when the backend's last drain request ends. */ void (*drained_end)(void *opaque); + /* + * Is the device still busy? + */ + bool (*drained_poll)(void *opaque); } BlockDevOps; =20 /* This struct is embedded in (the private) BlockBackend struct and contai= ns diff --git a/block/block-backend.c b/block/block-backend.c index 5be32c0c42..15f1ea4288 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -2386,8 +2386,13 @@ static void blk_root_drained_begin(BdrvChild *child) static bool blk_root_drained_poll(BdrvChild *child) { BlockBackend *blk =3D child->opaque; + bool busy =3D false; assert(blk->quiesce_counter); - return !!blk->in_flight; + + if (blk->dev_ops && blk->dev_ops->drained_poll) { + busy =3D blk->dev_ops->drained_poll(blk->dev_opaque); + } + return busy || !!blk->in_flight; } =20 static void blk_root_drained_end(BdrvChild *child, int *drained_end_counte= r) --=20 2.30.2 From nobody Mon May 20 00:38:58 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622642482; cv=none; d=zohomail.com; s=zohoarc; b=jzbiBHlb2/4pcTErM2JzMKivUswaIiVj6e+Q6S/O62Zu6hS2Hk7CYIyxrkYnVGR1A42CkI6O8Xt4Pcoqv8CWkbkFnTJhN0zE7M+3+uKIDVmHBBUpj5yMGTZbk9X5eXEczP5pCSZ2VOyBKc25XyTjwfc1naFSShF7i/OBVbnCowk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622642482; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kLFHWJbTkHtI9zWWTquem6lLwku6QK5+Q5XDeWp4x3Q=; b=QHRDN1H2Zw49jW+IKruNPZqZdAugNS8eh5uTu7FWx8JJT8MLzGsSGiYOl2IJMvmtPbSnYMy9OhDTv7W0n851H/OHPt8IHV005HgLyTCtPRBBL5FJ2+mz60+jnnvZzLJxWoj7Axj1PCVl9jFxy50/kInDKpWW+f8pDLbE8nGkMI4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16226424823021.5159472981787303; Wed, 2 Jun 2021 07:01:22 -0700 (PDT) Received: from localhost ([::1]:34520 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1loRQv-0001S5-IA for importer2@patchew.org; Wed, 02 Jun 2021 10:01:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44190) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRCg-0002Yn-II for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:46:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:32895) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRCe-0007Uo-7u for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:46:38 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-429-FsgVFW8gMNSAJERj63XaYg-1; Wed, 02 Jun 2021 09:46:33 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D17D191DB7E; Wed, 2 Jun 2021 13:45:55 +0000 (UTC) Received: from merkur.redhat.com (ovpn-114-240.ams2.redhat.com [10.36.114.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC67560BD9; Wed, 2 Jun 2021 13:45:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622641595; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kLFHWJbTkHtI9zWWTquem6lLwku6QK5+Q5XDeWp4x3Q=; b=ZOojZxJjJ2S+ZdsX4XapcjPKvtvwYwwpUz2+7Mc6YGFmNpf1Pz5v3aoDw2WTkSRYn9m0rE aGFLtAjKlgpS+22g8plkdoC6OIuvMZaiZ9tX6HjeRWstlwrZDsQD1R4a2Vr2/tithrWFRu xZ1pssCm4YpoXyir8OwvcvetUOonHPc= X-MC-Unique: FsgVFW8gMNSAJERj63XaYg-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 17/20] nbd/server: Use drained block ops to quiesce the server Date: Wed, 2 Jun 2021 15:45:26 +0200 Message-Id: <20210602134529.231756-18-kwolf@redhat.com> In-Reply-To: <20210602134529.231756-1-kwolf@redhat.com> References: <20210602134529.231756-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Sergio Lopez Before switching between AioContexts we need to make sure that we're fully quiesced ("nb_requests =3D=3D 0" for every client) when entering the drained section. To do this, we set "quiescing =3D true" for every client on ".drained_begin" to prevent new coroutines from being created, and check if "nb_requests =3D=3D 0" on ".drained_poll". Finally, once we're exiting the drained section, on ".drained_end" we set "quiescing =3D false" and call "nbd_client_receive_next_request()" to resume the processing of new requests. With these changes, "blk_aio_attach()" and "blk_aio_detach()" can be reverted to be as simple as they were before f148ae7d36. RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=3D1960137 Suggested-by: Kevin Wolf Signed-off-by: Sergio Lopez Message-Id: <20210602060552.17433-3-slp@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Kevin Wolf --- nbd/server.c | 82 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 61 insertions(+), 21 deletions(-) diff --git a/nbd/server.c b/nbd/server.c index 86a44a9b41..b60ebc3ab6 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -1513,6 +1513,11 @@ static void nbd_request_put(NBDRequestData *req) g_free(req); =20 client->nb_requests--; + + if (client->quiescing && client->nb_requests =3D=3D 0) { + aio_wait_kick(); + } + nbd_client_receive_next_request(client); =20 nbd_client_put(client); @@ -1530,49 +1535,68 @@ static void blk_aio_attached(AioContext *ctx, void = *opaque) QTAILQ_FOREACH(client, &exp->clients, next) { qio_channel_attach_aio_context(client->ioc, ctx); =20 + assert(client->nb_requests =3D=3D 0); assert(client->recv_coroutine =3D=3D NULL); assert(client->send_coroutine =3D=3D NULL); - - if (client->quiescing) { - client->quiescing =3D false; - nbd_client_receive_next_request(client); - } } } =20 -static void nbd_aio_detach_bh(void *opaque) +static void blk_aio_detach(void *opaque) { NBDExport *exp =3D opaque; NBDClient *client; =20 + trace_nbd_blk_aio_detach(exp->name, exp->common.ctx); + QTAILQ_FOREACH(client, &exp->clients, next) { qio_channel_detach_aio_context(client->ioc); + } + + exp->common.ctx =3D NULL; +} + +static void nbd_drained_begin(void *opaque) +{ + NBDExport *exp =3D opaque; + NBDClient *client; + + QTAILQ_FOREACH(client, &exp->clients, next) { client->quiescing =3D true; + } +} =20 - if (client->recv_coroutine) { - if (client->read_yielding) { - qemu_aio_coroutine_enter(exp->common.ctx, - client->recv_coroutine); - } else { - AIO_WAIT_WHILE(exp->common.ctx, client->recv_coroutine != =3D NULL); - } - } +static void nbd_drained_end(void *opaque) +{ + NBDExport *exp =3D opaque; + NBDClient *client; =20 - if (client->send_coroutine) { - AIO_WAIT_WHILE(exp->common.ctx, client->send_coroutine !=3D NU= LL); - } + QTAILQ_FOREACH(client, &exp->clients, next) { + client->quiescing =3D false; + nbd_client_receive_next_request(client); } } =20 -static void blk_aio_detach(void *opaque) +static bool nbd_drained_poll(void *opaque) { NBDExport *exp =3D opaque; + NBDClient *client; =20 - trace_nbd_blk_aio_detach(exp->name, exp->common.ctx); + QTAILQ_FOREACH(client, &exp->clients, next) { + if (client->nb_requests !=3D 0) { + /* + * If there's a coroutine waiting for a request on nbd_read_eo= f() + * enter it here so we don't depend on the client to wake it u= p. + */ + if (client->recv_coroutine !=3D NULL && client->read_yielding)= { + qemu_aio_coroutine_enter(exp->common.ctx, + client->recv_coroutine); + } =20 - aio_wait_bh_oneshot(exp->common.ctx, nbd_aio_detach_bh, exp); + return true; + } + } =20 - exp->common.ctx =3D NULL; + return false; } =20 static void nbd_eject_notifier(Notifier *n, void *data) @@ -1594,6 +1618,12 @@ void nbd_export_set_on_eject_blk(BlockExport *exp, B= lockBackend *blk) blk_add_remove_bs_notifier(blk, &nbd_exp->eject_notifier); } =20 +static const BlockDevOps nbd_block_ops =3D { + .drained_begin =3D nbd_drained_begin, + .drained_end =3D nbd_drained_end, + .drained_poll =3D nbd_drained_poll, +}; + static int nbd_export_create(BlockExport *blk_exp, BlockExportOptions *exp= _args, Error **errp) { @@ -1715,8 +1745,17 @@ static int nbd_export_create(BlockExport *blk_exp, B= lockExportOptions *exp_args, =20 exp->allocation_depth =3D arg->allocation_depth; =20 + /* + * We need to inhibit request queuing in the block layer to ensure we = can + * be properly quiesced when entering a drained section, as our corout= ines + * servicing pending requests might enter blk_pread(). + */ + blk_set_disable_request_queuing(blk, true); + blk_add_aio_context_notifier(blk, blk_aio_attached, blk_aio_detach, ex= p); =20 + blk_set_dev_ops(blk, &nbd_block_ops, exp); + QTAILQ_INSERT_TAIL(&exports, exp, next); =20 return 0; @@ -1788,6 +1827,7 @@ static void nbd_export_delete(BlockExport *blk_exp) } blk_remove_aio_context_notifier(exp->common.blk, blk_aio_attached, blk_aio_detach, exp); + blk_set_disable_request_queuing(exp->common.blk, false); } =20 for (i =3D 0; i < exp->nr_export_bitmaps; i++) { --=20 2.30.2 From nobody Mon May 20 00:38:58 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622642554; cv=none; d=zohomail.com; s=zohoarc; b=S5I1uBsZXw29hntWeyybQ7av2UbWpxAX4OE8wgZXoLEYopSJqPr4304QQANnRrGdj6ksTUVmIk13WU1J1Ol/hBaptHXqKor0Kyt2NZE21Z9vXGWifGwpRSRz7poXLttOVVjFiIPVL91aOyAKKB7/JrqsdjecuXEhpm8FrFATPZg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622642554; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WmHgjGywsXlRg4oiXjxQRdcGAShYrkCY9ygqgXKwCBk=; b=NBbhqfv7IPRkfOTGJC8Jl+Ef6ZGtYVBJkjv2/YfLUl+quKLAxhEHNydXQKLmQ6ofCknlu2Ishz/xQp8/7Wapve0r9aO4Wy0v87B+O7jkf6g9sVjxfsngsFmznETMVftGMXHx8j+En4qpkeDTprRkFYHsfgxEpBuFzKPBgLmh5C0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622642554961769.2070401149779; Wed, 2 Jun 2021 07:02:34 -0700 (PDT) Received: from localhost ([::1]:38686 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1loRS5-0004L1-En for importer2@patchew.org; Wed, 02 Jun 2021 10:02:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44286) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRCn-0002hj-La for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:46:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:20865) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRCj-0007YC-Op for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:46:45 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-552-GuwMJL6WP3WlcEu1UOIITA-1; Wed, 02 Jun 2021 09:46:34 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 103428189E4; Wed, 2 Jun 2021 13:45:57 +0000 (UTC) Received: from merkur.redhat.com (ovpn-114-240.ams2.redhat.com [10.36.114.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2024419814; Wed, 2 Jun 2021 13:45:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622641601; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WmHgjGywsXlRg4oiXjxQRdcGAShYrkCY9ygqgXKwCBk=; b=Q8N7DW4UjRqgAVTncCsW1/8V0EcNFWqCu01zLMeUXsyPhsLIrm19QtXlDKo2FhBAKxbIG5 uAJqnlOsSgsVPM6ueIq6KXZmYvYdow3fbK8FWRF2zMhBAHyUmWqmWkx2Gpe42bqxI0l5IL uE1Q5BiBy4240qU4ziSh1D8tq0M5dvQ= X-MC-Unique: GuwMJL6WP3WlcEu1UOIITA-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 18/20] block-copy: fix block_copy_task_entry() progress update Date: Wed, 2 Jun 2021 15:45:27 +0200 Message-Id: <20210602134529.231756-19-kwolf@redhat.com> In-Reply-To: <20210602134529.231756-1-kwolf@redhat.com> References: <20210602134529.231756-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Don't report successful progress on failure, when call_state->ret is set. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20210528141628.44287-2-vsementsov@virtuozzo.com> Reviewed-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- block/block-copy.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/block/block-copy.c b/block/block-copy.c index c2e5090412..f9e871b64f 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -439,9 +439,11 @@ static coroutine_fn int block_copy_task_entry(AioTask = *task) =20 ret =3D block_copy_do_copy(t->s, t->offset, t->bytes, t->zeroes, &error_is_read); - if (ret < 0 && !t->call_state->ret) { - t->call_state->ret =3D ret; - t->call_state->error_is_read =3D error_is_read; + if (ret < 0) { + if (!t->call_state->ret) { + t->call_state->ret =3D ret; + t->call_state->error_is_read =3D error_is_read; + } } else { progress_work_done(t->s->progress, t->bytes); } --=20 2.30.2 From nobody Mon May 20 00:38:58 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622642489; cv=none; d=zohomail.com; s=zohoarc; b=AN7wxKx2E6JkpUjlT/7pNNoBQyhg0Ue2ZovhgO8yE0P/55n15LyBfJp1lw/POdfcpD8WL5Rim5oHiHtkuEH/RR92usYDIMf/+OZx84oO/TuMleBUOEoSg9OnpNmBAaVTvFL9FUbVp0M/wPJhPobf6VCWolNfmgHROfeUvWZL6U0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622642489; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6cZFslVqg6Ig1nveOg6RxDE4vGb312vYDATw+rpf21Q=; b=Hl/wAIuMMu9Z3Z8qO/UV4VOrstQyOKHwfsVOFO60TkbOjrJS1HUIlD4RITOLAoaC4iuJn969YvbrOuqw4UzaIy7eneljvnrC6sVQC+VLkDKjKMHy2zJ7M+2EE0WVMPEgVvL4vhhWZr/TmJJMCqqEJ6qH8kmL1/vbbALrJyn5ROc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622642489635871.7109110097765; Wed, 2 Jun 2021 07:01:29 -0700 (PDT) Received: from localhost ([::1]:34876 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1loRR2-0001h0-Us for importer2@patchew.org; Wed, 02 Jun 2021 10:01:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44276) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRCm-0002hf-6y for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:46:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:43662) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRCh-0007Wd-7F for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:46:43 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-523-p3dWscg7NFujUOvPrgpfzQ-1; Wed, 02 Jun 2021 09:46:36 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 48B91C84C5; Wed, 2 Jun 2021 13:45:58 +0000 (UTC) Received: from merkur.redhat.com (ovpn-114-240.ams2.redhat.com [10.36.114.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 57B2560BD9; Wed, 2 Jun 2021 13:45:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622641598; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6cZFslVqg6Ig1nveOg6RxDE4vGb312vYDATw+rpf21Q=; b=Ee5undhbitbtfdLEz83xWGoxKPs9ZR/wpqUMEV5FkIkpFhcFGqU8VswFJzIl81P30CLIaa uSulOTSvKphvxn2lrJpx2I0yGo6hiHuWwwfhm9LfVWIB7DxfSsBxK8U4IEY7gwRzHyYrao eed3yFvy66vy4KCICZIAhrq6aFfb1yg= X-MC-Unique: p3dWscg7NFujUOvPrgpfzQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 19/20] block-copy: refactor copy_range handling Date: Wed, 2 Jun 2021 15:45:28 +0200 Message-Id: <20210602134529.231756-20-kwolf@redhat.com> In-Reply-To: <20210602134529.231756-1-kwolf@redhat.com> References: <20210602134529.231756-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Currently we update s->use_copy_range and s->copy_size in block_copy_do_copy(). It's not very good: 1. block_copy_do_copy() is intended to be a simple function, that wraps bdrv_co_ functions for need of block copy. That's why we don't pass BlockCopyTask into it. So, block_copy_do_copy() is bad place for manipulation with generic state of block-copy process 2. We are going to make block-copy thread-safe. So, it's good to move manipulation with state of block-copy to the places where we'll need critical sections anyway, to not introduce extra synchronization primitives in block_copy_do_copy(). Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20210528141628.44287-3-vsementsov@virtuozzo.com> Reviewed-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- block/block-copy.c | 72 +++++++++++++++++++++++++++++++--------------- 1 file changed, 49 insertions(+), 23 deletions(-) diff --git a/block/block-copy.c b/block/block-copy.c index f9e871b64f..5808cfe657 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -65,6 +65,7 @@ typedef struct BlockCopyTask { int64_t offset; int64_t bytes; bool zeroes; + bool copy_range; QLIST_ENTRY(BlockCopyTask) list; CoQueue wait_queue; /* coroutines blocked on this task */ } BlockCopyTask; @@ -183,6 +184,7 @@ static BlockCopyTask *block_copy_task_create(BlockCopyS= tate *s, .call_state =3D call_state, .offset =3D offset, .bytes =3D bytes, + .copy_range =3D s->use_copy_range, }; qemu_co_queue_init(&task->wait_queue); QLIST_INSERT_HEAD(&s->tasks, task, list); @@ -342,11 +344,18 @@ static coroutine_fn int block_copy_task_run(AioTaskPo= ol *pool, * * No sync here: nor bitmap neighter intersecting requests handling, only = copy. * + * @copy_range is an in-out argument: if *copy_range is false, copy_range = is not + * done. If *copy_range is true, copy_range is attempted. If the copy_range + * attempt fails, the function falls back to the usual read+write and + * *copy_range is set to false. *copy_range and zeroes must not be true + * simultaneously. + * * Returns 0 on success. */ static int coroutine_fn block_copy_do_copy(BlockCopyState *s, int64_t offset, int64_t bytes, - bool zeroes, bool *error_is_rea= d) + bool zeroes, bool *copy_range, + bool *error_is_read) { int ret; int64_t nbytes =3D MIN(offset + bytes, s->len) - offset; @@ -359,6 +368,7 @@ static int coroutine_fn block_copy_do_copy(BlockCopySta= te *s, assert(offset + bytes <=3D s->len || offset + bytes =3D=3D QEMU_ALIGN_UP(s->len, s->cluster_size)); assert(nbytes < INT_MAX); + assert(!(*copy_range && zeroes)); =20 if (zeroes) { ret =3D bdrv_co_pwrite_zeroes(s->target, offset, nbytes, s->write_= flags & @@ -370,32 +380,15 @@ static int coroutine_fn block_copy_do_copy(BlockCopyS= tate *s, return ret; } =20 - if (s->use_copy_range) { + if (*copy_range) { ret =3D bdrv_co_copy_range(s->source, offset, s->target, offset, n= bytes, 0, s->write_flags); if (ret < 0) { trace_block_copy_copy_range_fail(s, offset, ret); - s->use_copy_range =3D false; - s->copy_size =3D MAX(s->cluster_size, BLOCK_COPY_MAX_BUFFER); + *copy_range =3D false; /* Fallback to read+write with allocated buffer */ } else { - if (s->use_copy_range) { - /* - * Successful copy-range. Now increase copy_size. copy_ra= nge - * does not respect max_transfer (it's a TODO), so we fact= or - * that in here. - * - * Note: we double-check s->use_copy_range for the case wh= en - * parallel block-copy request unsets it during previous - * bdrv_co_copy_range call. - */ - s->copy_size =3D - MIN(MAX(s->cluster_size, BLOCK_COPY_MAX_COPY_RANGE= ), - QEMU_ALIGN_DOWN(block_copy_max_transfer(s->sou= rce, - s->tar= get), - s->cluster_size)); - } - goto out; + return 0; } } =20 @@ -431,14 +424,44 @@ out: return ret; } =20 +static void block_copy_handle_copy_range_result(BlockCopyState *s, + bool is_success) +{ + if (!s->use_copy_range) { + /* already disabled */ + return; + } + + if (is_success) { + /* + * Successful copy-range. Now increase copy_size. copy_range + * does not respect max_transfer (it's a TODO), so we factor + * that in here. + */ + s->copy_size =3D + MIN(MAX(s->cluster_size, BLOCK_COPY_MAX_COPY_RANGE), + QEMU_ALIGN_DOWN(block_copy_max_transfer(s->source, + s->target), + s->cluster_size)); + } else { + /* Copy-range failed, disable it. */ + s->use_copy_range =3D false; + s->copy_size =3D MAX(s->cluster_size, BLOCK_COPY_MAX_BUFFER); + } +} + static coroutine_fn int block_copy_task_entry(AioTask *task) { BlockCopyTask *t =3D container_of(task, BlockCopyTask, task); bool error_is_read =3D false; + bool copy_range =3D t->copy_range; int ret; =20 ret =3D block_copy_do_copy(t->s, t->offset, t->bytes, t->zeroes, - &error_is_read); + ©_range, &error_is_read); + if (t->copy_range) { + block_copy_handle_copy_range_result(t->s, copy_range); + } if (ret < 0) { if (!t->call_state->ret) { t->call_state->ret =3D ret; @@ -619,7 +642,10 @@ block_copy_dirty_clusters(BlockCopyCallState *call_sta= te) g_free(task); continue; } - task->zeroes =3D ret & BDRV_BLOCK_ZERO; + if (ret & BDRV_BLOCK_ZERO) { + task->zeroes =3D true; + task->copy_range =3D false; + } =20 if (s->speed) { if (!call_state->ignore_ratelimit) { --=20 2.30.2 From nobody Mon May 20 00:38:58 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622642382; cv=none; d=zohomail.com; s=zohoarc; b=HiVqvQmciOjDeCKNww0Y7fmEZWrEmRABMaiabwcBBaW/MfqEz2GVTpwJjgJgllPUW6knbvP+qDqUa9Akxf8DJzx3dmc5oDqKEM7PWRx0gLjzL6LvFS/FFWcAfF0QSbc1bJKWVEBLiYCTO+4QGeuWFiKU6m2oBUkQinibrd5ml2U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622642382; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HXp4xsK2COsg/sk8cOxH3Dv6mSNqqIz2BKhEw9890PI=; b=jWhcu1Rzl7gOhkoTP/GGiVJ0SECtD5RZ29P3kJ6kXgrar9DW9+F0GKr+VXj4MQj2TduKS8h3z8Ad5C6n2tL8k2u03Eqdx9ro0G6h+nwBKuSncZGPUJriYzORC3oOTR65RU4gIJzO7utFSulQ9ro9KmZjbpl+7fwQkmyJARg3gq8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 162264238200337.815891717853106; Wed, 2 Jun 2021 06:59:42 -0700 (PDT) Received: from localhost ([::1]:58346 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1loRPJ-0006ua-Bk for importer2@patchew.org; Wed, 02 Jun 2021 09:59:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44262) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRCl-0002hL-Dn for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:46:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:40767) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loRCj-0007X7-2J for qemu-devel@nongnu.org; Wed, 02 Jun 2021 09:46:43 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-60-8lfCwswKPPOobjzalGIpCg-1; Wed, 02 Jun 2021 09:46:36 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7F5111085137; Wed, 2 Jun 2021 13:45:59 +0000 (UTC) Received: from merkur.redhat.com (ovpn-114-240.ams2.redhat.com [10.36.114.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8DC2F60BD9; Wed, 2 Jun 2021 13:45:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622641599; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HXp4xsK2COsg/sk8cOxH3Dv6mSNqqIz2BKhEw9890PI=; b=Gi/bmFbl/b1xBv7ycLuMLf0Ay1GkdC5BaE/AKxsvHDsG3ztr6Y2NBDwNRFBPyVgcg5xgfr qNS/amqvZqy4niL/VsPDVxLwy8ohfEXqSQV9xVsJgLCnnWhee9EUj5TPKIAXSMkAS1xwYv 84E1sNaay8YBlDgzU2UMLaQEPTRakLs= X-MC-Unique: 8lfCwswKPPOobjzalGIpCg-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 20/20] docs/secure-coding-practices: Describe how to use 'null-co' block driver Date: Wed, 2 Jun 2021 15:45:29 +0200 Message-Id: <20210602134529.231756-21-kwolf@redhat.com> In-Reply-To: <20210602134529.231756-1-kwolf@redhat.com> References: <20210602134529.231756-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Philippe Mathieu-Daud=C3=A9 Document that security reports must use 'null-co,read-zeroes=3Don' because otherwise the memory is left uninitialized (which is an on-purpose performance feature). Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20210601162548.2076631-1-philmd@redhat.com> Signed-off-by: Kevin Wolf --- docs/devel/secure-coding-practices.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/devel/secure-coding-practices.rst b/docs/devel/secure-cod= ing-practices.rst index cbfc8af67e..0454cc527e 100644 --- a/docs/devel/secure-coding-practices.rst +++ b/docs/devel/secure-coding-practices.rst @@ -104,3 +104,12 @@ structures and only process the local copy. This prev= ents time-of-check-to-time-of-use (TOCTOU) race conditions that could cause QEM= U to crash when a vCPU thread modifies guest RAM while device emulation is processing it. + +Use of null-co block drivers +---------------------------- + +The ``null-co`` block driver is designed for performance: its read accesse= s are +not initialized by default. In case this driver has to be used for security +research, it must be used with the ``read-zeroes=3Don`` option which fills= read +buffers with zeroes. Security issues reported with the default +(``read-zeroes=3Doff``) will be discarded. --=20 2.30.2