From patchwork Tue Apr 9 14:59:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabiano Rosas X-Patchwork-Id: 13622825 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7B1ADC67861 for ; Tue, 9 Apr 2024 15:00:10 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ruCwf-0001iT-GU; Tue, 09 Apr 2024 10:59:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ruCwd-0001hg-R9; Tue, 09 Apr 2024 10:59:31 -0400 Received: from smtp-out1.suse.de ([195.135.223.130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruCwc-0005st-9b; Tue, 09 Apr 2024 10:59:31 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id E2E8333A56; Tue, 9 Apr 2024 14:59:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712674768; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P4t2aH2iKWUlJYkBhU1yzSeFXAMp0nqmYIhFgYQ3imc=; b=noxhu/+NEKPkMkQ1zqTzNs0UPPkkqJbjV5moEbWjH2koe0fG64deFF8Kh0OCCptB+MM5j0 UQtR1cRShzbvOUyzDyU8hUJXPrSPN6KIl8Il+IRa2dzMU6Nj2EVN1q7WMPeCTixPv2y6ge juIzMOJlYHceEtfcQ4YNmhhI0eiV6s4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712674768; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P4t2aH2iKWUlJYkBhU1yzSeFXAMp0nqmYIhFgYQ3imc=; b=4NM3xVWjUB+VSGOs0s5GB7yOKluIbgPzKQb74o4Sa85qbmmNIUNIs5DP65jzjpfjZN5DT4 D5cKStuo7JX9MUCA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=qdALqJ3f; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=gPciXh25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712674767; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P4t2aH2iKWUlJYkBhU1yzSeFXAMp0nqmYIhFgYQ3imc=; b=qdALqJ3fnBb53dIUsGHsXXbPMkVMUIlWCeP5zAzGQMsuVElaBy33SY1tELquGvdtPu8ngV C5vk6TrqwOz9t9dbCLs2AoIq9uwWDMeSVHWkymK94OQk5Sp7X7OsYgvWbcLI9geumRKqQL +Tfr87AL47FG+BixzNtnwRfL9chYaz0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712674767; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P4t2aH2iKWUlJYkBhU1yzSeFXAMp0nqmYIhFgYQ3imc=; b=gPciXh25fLSCCOcfTtYuR/UBvVNA5gg4WsOmOL7aA/rvsT/1mTbck5CxMZSwgCWCFabwfx UB48R8FYMjZVwVBQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 4039413313; Tue, 9 Apr 2024 14:59:24 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id EHc6AsxXFWZGOAAAD6G6ig (envelope-from ); Tue, 09 Apr 2024 14:59:24 +0000 From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Kevin Wolf , Hanna Reitz , Markus Armbruster , =?utf-8?q?Jo=C3=A3o_Silva?= , Lin Ma , Claudio Fontana , Dario Faggioli , Eric Blake , Stefan Hajnoczi , Paolo Bonzini , John Snow , Cleber Rosa Subject: [PATCH v3 01/11] block: Allow the wrapper script to see functions declared in qapi.h Date: Tue, 9 Apr 2024 11:59:07 -0300 Message-Id: <20240409145917.6780-2-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240409145917.6780-1-farosas@suse.de> References: <20240409145917.6780-1-farosas@suse.de> MIME-Version: 1.0 X-Spamd-Result: default: False [-4.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; DWL_DNSWL_LOW(-1.00)[suse.de:dkim]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_TWELVE(0.00)[14]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Action: no action X-Rspamd-Queue-Id: E2E8333A56 X-Rspamd-Server: rspamd1.dmz-prg2.suse.org Received-SPF: pass client-ip=195.135.223.130; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org The following patches will add co_wrapper annotations to functions declared in qapi.h. Add that header to the set of files used by block-coroutine-wrapper.py. Reviewed-by: Hanna Czenczek Signed-off-by: Fabiano Rosas --- block/meson.build | 1 + scripts/block-coroutine-wrapper.py | 1 + 2 files changed, 2 insertions(+) diff --git a/block/meson.build b/block/meson.build index e1f03fd773..8fe684d301 100644 --- a/block/meson.build +++ b/block/meson.build @@ -154,6 +154,7 @@ block_gen_c = custom_target('block-gen.c', '../include/block/dirty-bitmap.h', '../include/block/block_int-io.h', '../include/block/block-global-state.h', + '../include/block/qapi.h', '../include/sysemu/block-backend-global-state.h', '../include/sysemu/block-backend-io.h', 'coroutines.h' diff --git a/scripts/block-coroutine-wrapper.py b/scripts/block-coroutine-wrapper.py index dbbde99e39..067b203801 100644 --- a/scripts/block-coroutine-wrapper.py +++ b/scripts/block-coroutine-wrapper.py @@ -44,6 +44,7 @@ def gen_header(): #include "block/block-gen.h" #include "block/block_int.h" #include "block/dirty-bitmap.h" +#include "block/qapi.h" """ From patchwork Tue Apr 9 14:59:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabiano Rosas X-Patchwork-Id: 13622826 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B1950CD1284 for ; Tue, 9 Apr 2024 15:00:11 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ruCwo-0001oO-TJ; Tue, 09 Apr 2024 10:59:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ruCwg-0001kR-Rw; Tue, 09 Apr 2024 10:59:35 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruCwf-0005u6-8u; Tue, 09 Apr 2024 10:59:34 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 8D60B20A6A; Tue, 9 Apr 2024 14:59:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712674771; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZgR+jiIhx54qTUTAC4AMtnTlIllhTJDE02frQu2rkuE=; b=o2T3Ngz+Y6st5BRE+Y3QEbgPS2yCV0HBaZJUnS9YezVnVmeYRYOwxZqQmkl1xnUSDtmJwY HSMUGJgDr7T5q6pOCgBttF+Ecvi3wcA9W+ZyzvGxwAjqf9GeaB9V/Htpc00tkxVUCFxhZW teHMqfxEOlv6oAU1pyDe4wBGvWocigE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712674771; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZgR+jiIhx54qTUTAC4AMtnTlIllhTJDE02frQu2rkuE=; b=ojhFCI4SQGmN3XS8z5Tzw77qJ9mvQABlr0hzPmvQ4usclCuDB5T2/5fUWAhK/BRKees2EM deC4mfawjv4ogeCw== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=o2T3Ngz+; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=ojhFCI4S DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712674771; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZgR+jiIhx54qTUTAC4AMtnTlIllhTJDE02frQu2rkuE=; b=o2T3Ngz+Y6st5BRE+Y3QEbgPS2yCV0HBaZJUnS9YezVnVmeYRYOwxZqQmkl1xnUSDtmJwY HSMUGJgDr7T5q6pOCgBttF+Ecvi3wcA9W+ZyzvGxwAjqf9GeaB9V/Htpc00tkxVUCFxhZW teHMqfxEOlv6oAU1pyDe4wBGvWocigE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712674771; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZgR+jiIhx54qTUTAC4AMtnTlIllhTJDE02frQu2rkuE=; b=ojhFCI4SQGmN3XS8z5Tzw77qJ9mvQABlr0hzPmvQ4usclCuDB5T2/5fUWAhK/BRKees2EM deC4mfawjv4ogeCw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 607E413313; Tue, 9 Apr 2024 14:59:28 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id GN3dCdBXFWZGOAAAD6G6ig (envelope-from ); Tue, 09 Apr 2024 14:59:28 +0000 From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Kevin Wolf , Hanna Reitz , Markus Armbruster , =?utf-8?q?Jo=C3=A3o_Silva?= , Lin Ma , Claudio Fontana , Dario Faggioli , Eric Blake , Stefan Hajnoczi , Paolo Bonzini Subject: [PATCH v3 02/11] block: Temporarily mark bdrv_co_get_allocated_file_size as mixed Date: Tue, 9 Apr 2024 11:59:08 -0300 Message-Id: <20240409145917.6780-3-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240409145917.6780-1-farosas@suse.de> References: <20240409145917.6780-1-farosas@suse.de> MIME-Version: 1.0 X-Spamd-Result: default: False [-4.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; DWL_DNSWL_LOW(-1.00)[suse.de:dkim]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCPT_COUNT_TWELVE(0.00)[12]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; R_RATELIMIT(0.00)[to_ip_from(RL8i9y4krh53rntrk3u7dj74zf)]; RCVD_VIA_SMTP_AUTH(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email] X-Rspamd-Action: no action X-Rspamd-Queue-Id: 8D60B20A6A X-Rspamd-Server: rspamd1.dmz-prg2.suse.org Received-SPF: pass client-ip=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Some callers of this function are about to be converted to run in coroutines, so allow it to be executed both inside and outside a coroutine while we convert all the callers. This will be reverted once all callers of bdrv_do_query_node_info run in a coroutine. Signed-off-by: Fabiano Rosas Reviewed-by: Eric Blake Reviewed-by: Hanna Czenczek --- include/block/block-io.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/block/block-io.h b/include/block/block-io.h index b49e0537dd..349d7760a1 100644 --- a/include/block/block-io.h +++ b/include/block/block-io.h @@ -86,7 +86,7 @@ int64_t co_wrapper_mixed_bdrv_rdlock bdrv_getlength(BlockDriverState *bs); int64_t coroutine_fn GRAPH_RDLOCK bdrv_co_get_allocated_file_size(BlockDriverState *bs); -int64_t co_wrapper_bdrv_rdlock +int64_t co_wrapper_mixed_bdrv_rdlock bdrv_get_allocated_file_size(BlockDriverState *bs); BlockMeasureInfo *bdrv_measure(BlockDriver *drv, QemuOpts *opts, From patchwork Tue Apr 9 14:59:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabiano Rosas X-Patchwork-Id: 13622836 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 26B81CD128A for ; Tue, 9 Apr 2024 15:02:03 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ruCx0-0001tc-6x; Tue, 09 Apr 2024 10:59:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ruCwm-0001oB-Hw; Tue, 09 Apr 2024 10:59:42 -0400 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruCwj-0005ug-KP; Tue, 09 Apr 2024 10:59:38 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 4AC1433A53; Tue, 9 Apr 2024 14:59:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712674775; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HliQrJKBtw9WoMssEwBhMGiZx/IPAwhMPbYu9kACb68=; b=j+4g8CciXzEWx1QdwGgEi+IFgx4LkMHnzXdepD3WlQb6iZeAdRjvNGWOGfG4jDRK4V3rHp QxGBKuugRxhVTTR4GdNWK5u2XwPIWNlSgXAZazlqyoBK9xDnk4Xh8DF8mbKByVz/nZ4DNm q0vyZMLIgjokaLPosi53noZVIlcLJfE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712674775; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HliQrJKBtw9WoMssEwBhMGiZx/IPAwhMPbYu9kACb68=; b=E4RAys7fIAMk7Pc1963jsDQbnxkqIWUjSyosYm7xYK3Xjt1Afgdgfrdt7QcwghGNJSrJyD KfDRA2Cd6iZjLVDw== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712674775; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HliQrJKBtw9WoMssEwBhMGiZx/IPAwhMPbYu9kACb68=; b=j+4g8CciXzEWx1QdwGgEi+IFgx4LkMHnzXdepD3WlQb6iZeAdRjvNGWOGfG4jDRK4V3rHp QxGBKuugRxhVTTR4GdNWK5u2XwPIWNlSgXAZazlqyoBK9xDnk4Xh8DF8mbKByVz/nZ4DNm q0vyZMLIgjokaLPosi53noZVIlcLJfE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712674775; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HliQrJKBtw9WoMssEwBhMGiZx/IPAwhMPbYu9kACb68=; b=E4RAys7fIAMk7Pc1963jsDQbnxkqIWUjSyosYm7xYK3Xjt1Afgdgfrdt7QcwghGNJSrJyD KfDRA2Cd6iZjLVDw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 0A51B13313; Tue, 9 Apr 2024 14:59:31 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id qIiPMNNXFWZGOAAAD6G6ig (envelope-from ); Tue, 09 Apr 2024 14:59:31 +0000 From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Kevin Wolf , Hanna Reitz , Markus Armbruster , =?utf-8?q?Jo=C3=A3o_Silva?= , Lin Ma , Claudio Fontana , Dario Faggioli , Eric Blake , Stefan Hajnoczi , Paolo Bonzini Subject: [PATCH v3 03/11] block: Take the graph lock in bdrv_snapshot_list Date: Tue, 9 Apr 2024 11:59:09 -0300 Message-Id: <20240409145917.6780-4-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240409145917.6780-1-farosas@suse.de> References: <20240409145917.6780-1-farosas@suse.de> MIME-Version: 1.0 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.986]; MIME_GOOD(-0.10)[text/plain]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; RCPT_COUNT_TWELVE(0.00)[12]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email] Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:1; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org This function has up until now always ran in the main loop, outside of a coroutine. We're about to make it run inside a coroutine so start actually taking the graph lock. Signed-off-by: Fabiano Rosas --- block/snapshot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/snapshot.c b/block/snapshot.c index 8242b4abac..3db9536ca2 100644 --- a/block/snapshot.c +++ b/block/snapshot.c @@ -389,7 +389,7 @@ int bdrv_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_info) { GLOBAL_STATE_CODE(); - GRAPH_RDLOCK_GUARD_MAINLOOP(); + GRAPH_RDLOCK_GUARD(); BlockDriver *drv = bs->drv; BlockDriverState *fallback_bs = bdrv_snapshot_fallback(bs); From patchwork Tue Apr 9 14:59:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabiano Rosas X-Patchwork-Id: 13622831 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C9EAAC67861 for ; Tue, 9 Apr 2024 15:01:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ruCx0-0001vc-Hv; Tue, 09 Apr 2024 10:59:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ruCwq-0001pR-ED; Tue, 09 Apr 2024 10:59:44 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruCwo-0005vZ-62; Tue, 09 Apr 2024 10:59:44 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 5278720A77; Tue, 9 Apr 2024 14:59:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712674780; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6eZTojFzlbmM9srO5Hfd2P2mso848RuOOS1Zx/au5io=; b=vSpKTPL/ZU+FKaysuJKxWEeo1YfePCkasWQLAoJG0kRhDyX0fVLNec8KroMS78roBaCoOa tEjW4OiXI4G9hEw+i6teWHZCj3U9GsjdDhDWiIJ3hovZelDFFmNB5H5RfJN4sBUTyR3TCf zpbcYD7gXNAqXbb/0aiJr6GxfXeSLHs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712674780; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6eZTojFzlbmM9srO5Hfd2P2mso848RuOOS1Zx/au5io=; b=41N4Bxa+A6uJxeSAp/IgIMdQUqiJGQm+E3r2B/2jOQ28c7dLsevjTDPW7BMrluCwl3/Tdy 5APYOMJapszzu9Dw== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="vSpKTPL/"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=41N4Bxa+ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712674780; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6eZTojFzlbmM9srO5Hfd2P2mso848RuOOS1Zx/au5io=; b=vSpKTPL/ZU+FKaysuJKxWEeo1YfePCkasWQLAoJG0kRhDyX0fVLNec8KroMS78roBaCoOa tEjW4OiXI4G9hEw+i6teWHZCj3U9GsjdDhDWiIJ3hovZelDFFmNB5H5RfJN4sBUTyR3TCf zpbcYD7gXNAqXbb/0aiJr6GxfXeSLHs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712674780; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6eZTojFzlbmM9srO5Hfd2P2mso848RuOOS1Zx/au5io=; b=41N4Bxa+A6uJxeSAp/IgIMdQUqiJGQm+E3r2B/2jOQ28c7dLsevjTDPW7BMrluCwl3/Tdy 5APYOMJapszzu9Dw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id C4D3D13313; Tue, 9 Apr 2024 14:59:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id UCMfItdXFWZGOAAAD6G6ig (envelope-from ); Tue, 09 Apr 2024 14:59:35 +0000 From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Kevin Wolf , Hanna Reitz , Markus Armbruster , =?utf-8?q?Jo=C3=A3o_Silva?= , Lin Ma , Claudio Fontana , Dario Faggioli , Eric Blake , Stefan Hajnoczi , Paolo Bonzini , John Snow , Vladimir Sementsov-Ogievskiy , Wen Congyang , Xie Changlong , Fam Zheng , Peter Xu Subject: [PATCH v3 04/11] block: Reschedule query-block during qcow2 invalidation Date: Tue, 9 Apr 2024 11:59:10 -0300 Message-Id: <20240409145917.6780-5-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240409145917.6780-1-farosas@suse.de> References: <20240409145917.6780-1-farosas@suse.de> MIME-Version: 1.0 X-Rspamd-Action: no action X-Rspamd-Queue-Id: 5278720A77 X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-2.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; DWL_DNSWL_LOW(-1.00)[suse.de:dkim]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; RCPT_COUNT_TWELVE(0.00)[18]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_CC(0.00)[nongnu.org,redhat.com,suse.de,suse.com,yandex-team.ru,huawei.com,gmail.com,euphon.net]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email,gitlab.com:url]; RCVD_VIA_SMTP_AUTH(0.00)[]; TAGGED_RCPT(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; FREEMAIL_ENVRCPT(0.00)[gmail.com] Received-SPF: pass client-ip=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org There is a small window at the end of block device migration when devices are being re-activated. This includes a resetting of some fields of BDRVQcow2State at qcow2_co_invalidate_cache(). A concurrent QMP query-block command can call qcow2_get_specific_info() during this window and see the cleared values, which leads to an assert: qcow2_get_specific_info: Assertion `false' failed This is the same issue as Gitlab #1933, which has already been resolved[1], but there the fix applied only to non-coroutine commands. Once we move query-block to a coroutine the problem will manifest again. Add an operation blocker to the invalidation function to block the query info path during this window. Instead of failing query-block, which would be disruptive to users, use the blocker to know when to reschedule the coroutine back into the iohandler so it doesn't run while the BDRVQcow2State is inconsistent. To avoid failing query-block when all block operations are blocked, unblock the INFO operation at various places. This preserves the prior situations where query-block used to work. 1 - https://gitlab.com/qemu-project/qemu/-/issues/1933 Signed-off-by: Fabiano Rosas --- block.c | 1 + block/mirror.c | 1 + block/qcow2.c | 20 ++++++++++++++++++++ block/replication.c | 1 + blockjob.c | 1 + include/block/block-common.h | 1 + migration/block.c | 1 + 7 files changed, 26 insertions(+) diff --git a/block.c b/block.c index 468cf5e67d..01478c5471 100644 --- a/block.c +++ b/block.c @@ -1296,6 +1296,7 @@ static void GRAPH_WRLOCK bdrv_backing_attach(BdrvChild *c) parent->backing_blocker); bdrv_op_unblock(backing_hd, BLOCK_OP_TYPE_BACKUP_TARGET, parent->backing_blocker); + bdrv_op_unblock(backing_hd, BLOCK_OP_TYPE_INFO, parent->backing_blocker); } static void bdrv_backing_detach(BdrvChild *c) diff --git a/block/mirror.c b/block/mirror.c index 1bdce3b657..9f952f3fdd 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1191,6 +1191,7 @@ static void mirror_complete(Job *job, Error **errp) error_setg(&s->replace_blocker, "block device is in use by block-job-complete"); bdrv_op_block_all(s->to_replace, s->replace_blocker); + bdrv_op_unblock(s->to_replace, BLOCK_OP_TYPE_INFO, s->replace_blocker); bdrv_ref(s->to_replace); } diff --git a/block/qcow2.c b/block/qcow2.c index 956128b409..b0ec8009e3 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2834,6 +2834,7 @@ qcow2_co_invalidate_cache(BlockDriverState *bs, Error **errp) BdrvChild *data_file; int flags = s->flags; QCryptoBlock *crypto = NULL; + Error *blocker = NULL; QDict *options; int ret; @@ -2845,6 +2846,17 @@ qcow2_co_invalidate_cache(BlockDriverState *bs, Error **errp) crypto = s->crypto; s->crypto = NULL; + /* + * When qcow2_do_open() below reads the qcow header, it yields to + * wait for the I/O which allows a concurrent QMP query-block + * command to be dispatched on the same context before + * BDRVQcow2State has been completely repopulated. Block the + * query-info operation during this window to avoid having + * qcow2_get_specific_info() access bogus values. + */ + error_setg(&blocker, "invalidating cached metadata"); + bdrv_op_block(bs, BLOCK_OP_TYPE_INFO, blocker); + /* * Do not reopen s->data_file (i.e., have qcow2_do_close() not close it, * and then prevent qcow2_do_open() from opening it), because this function @@ -2864,6 +2876,8 @@ qcow2_co_invalidate_cache(BlockDriverState *bs, Error **errp) qemu_co_mutex_lock(&s->lock); ret = qcow2_do_open(bs, options, flags, false, errp); qemu_co_mutex_unlock(&s->lock); + bdrv_op_unblock(bs, BLOCK_OP_TYPE_INFO, blocker); + g_free(blocker); qobject_unref(options); if (ret < 0) { error_prepend(errp, "Could not reopen qcow2 layer: "); @@ -5240,6 +5254,12 @@ qcow2_get_specific_info(BlockDriverState *bs, Error **errp) ImageInfoSpecific *spec_info; QCryptoBlockInfo *encrypt_info = NULL; + if (qemu_in_coroutine() && + bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_INFO, errp)) { + errp = NULL; + aio_co_reschedule_self(iohandler_get_aio_context()); + } + if (s->crypto != NULL) { encrypt_info = qcrypto_block_get_info(s->crypto, errp); if (!encrypt_info) { diff --git a/block/replication.c b/block/replication.c index ca6bd0a720..459d644673 100644 --- a/block/replication.c +++ b/block/replication.c @@ -577,6 +577,7 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode, } bdrv_op_block_all(top_bs, s->blocker); bdrv_op_unblock(top_bs, BLOCK_OP_TYPE_DATAPLANE, s->blocker); + bdrv_op_unblock(top_bs, BLOCK_OP_TYPE_INFO, s->blocker); bdrv_graph_wrunlock(); diff --git a/blockjob.c b/blockjob.c index d5f29e14af..f0df345982 100644 --- a/blockjob.c +++ b/blockjob.c @@ -244,6 +244,7 @@ int block_job_add_bdrv(BlockJob *job, const char *name, BlockDriverState *bs, job->nodes = g_slist_prepend(job->nodes, c); bdrv_op_block_all(bs, job->blocker); + bdrv_op_unblock(bs, BLOCK_OP_TYPE_INFO, job->blocker); return 0; } diff --git a/include/block/block-common.h b/include/block/block-common.h index a846023a09..4458617179 100644 --- a/include/block/block-common.h +++ b/include/block/block-common.h @@ -364,6 +364,7 @@ typedef enum BlockOpType { BLOCK_OP_TYPE_RESIZE, BLOCK_OP_TYPE_STREAM, BLOCK_OP_TYPE_REPLACE, + BLOCK_OP_TYPE_INFO, BLOCK_OP_TYPE_MAX, } BlockOpType; diff --git a/migration/block.c b/migration/block.c index 2b9054889a..3f3bc2748f 100644 --- a/migration/block.c +++ b/migration/block.c @@ -451,6 +451,7 @@ static int init_blk_migration(QEMUFile *f) alloc_aio_bitmap(bmds); error_setg(&bmds->blocker, "block device is in use by migration"); bdrv_op_block_all(bs, bmds->blocker); + bdrv_op_unblock(bs, BLOCK_OP_TYPE_INFO, bmds->blocker); } } From patchwork Tue Apr 9 14:59:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabiano Rosas X-Patchwork-Id: 13622834 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1F3ABCD129C for ; Tue, 9 Apr 2024 15:01:57 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ruCx2-00021U-Nu; Tue, 09 Apr 2024 10:59:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ruCwt-0001rw-5w; Tue, 09 Apr 2024 10:59:52 -0400 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruCwr-0005w0-E3; Tue, 09 Apr 2024 10:59:46 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id F247E33A53; Tue, 9 Apr 2024 14:59:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712674784; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KXN44mQf0i947fYSpOF7uoOsAHoUzjJX+q+hPuynvl0=; b=Op4JUdbzPtgd0mehCws6T22pvJkLVDcPnRJzok0oMBxkbT1K4d3gOav8oAyOqwmnH6tstL 1+cTrqvqVXN/mnDBck2Ge85AQ/WdfYPHyacmXIk1KzC+aLlgrLXHaNgzslXmUFJL042eyX I3mSNkyv+SnZjXvQw5AFPpip6nXxHl4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712674784; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KXN44mQf0i947fYSpOF7uoOsAHoUzjJX+q+hPuynvl0=; b=i2uHJ3Qbir2MhsGAGe98feMVT9ntKEp4kpUYY0gsHqpwqbzYpmJkA0sn6ZJaxXxYGQ9uRb y1ojRRo6CadYFBDg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712674783; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KXN44mQf0i947fYSpOF7uoOsAHoUzjJX+q+hPuynvl0=; b=G8gCe+JBnBPdlViW2DyXUQtRsPOoMTTxOm3W5YKlM8EDFz80zMUJ1/PD3KMomjH9x4Ixf6 wxRm8A94m8ggUsWJjTWYvY3VzhTR+hy6o08suxPrqCJw3FDnOGbgD3HL6my/7cI/Yok4mz seFa2YyBAghAAz8ENMj17xOuQAdJ+7w= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712674783; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KXN44mQf0i947fYSpOF7uoOsAHoUzjJX+q+hPuynvl0=; b=9eHFKBhAmYiJAPeON3aqfv8W5C/RUJEYLgu0Rt0vCjPSnTqu9TpqS9uNWn5QCpkxDvrxct X+1qK1xRdn5d01BQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id C5F5F13313; Tue, 9 Apr 2024 14:59:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id uIXqItxXFWZGOAAAD6G6ig (envelope-from ); Tue, 09 Apr 2024 14:59:40 +0000 From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Kevin Wolf , Hanna Reitz , Markus Armbruster , =?utf-8?q?Jo=C3=A3o_Silva?= , Lin Ma , Claudio Fontana , Dario Faggioli , Eric Blake , Stefan Hajnoczi , Paolo Bonzini Subject: [PATCH v3 05/11] block: Run bdrv_do_query_node_info in a coroutine Date: Tue, 9 Apr 2024 11:59:11 -0300 Message-Id: <20240409145917.6780-6-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240409145917.6780-1-farosas@suse.de> References: <20240409145917.6780-1-farosas@suse.de> MIME-Version: 1.0 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.988]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; RCPT_COUNT_TWELVE(0.00)[12]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; RCVD_TLS_ALL(0.00)[] Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:1; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Move this function into a coroutine so we can convert the whole qmp_query_block command into a coroutine in the next patches. Placing the entire command in a coroutine allow us to yield all the way back to the main loop, releasing the BQL and unblocking the main loop. When the whole conversion is completed, we'll be able to avoid a priority inversion that happens when a QMP command calls a slow (buggy) system call and blocks the vcpu thread from doing mmio due to contention on the BQL. About coroutine safety: Most callees have coroutine versions themselves and thus are safe to call in a coroutine. The remaining ones: - bdrv_refresh_filename, bdrv_get_full_backing_filename: String manipulation, nothing that would be unsafe for use in coroutines; - bdrv_get_format_name: Just accesses a field; - bdrv_get_specific_info, bdrv_query_snapshot_info_list: No locks or anything that would poll or block. (using a mixed wrapper for now, but after all callers are converted, this can become a coroutine exclusively) Signed-off-by: Fabiano Rosas --- - used the coroutine version of the called functions when available --- block/qapi.c | 11 ++++++----- include/block/qapi.h | 8 ++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/block/qapi.c b/block/qapi.c index 2b5793f1d9..26a9510345 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -225,8 +225,9 @@ int bdrv_query_snapshot_info_list(BlockDriverState *bs, * Helper function for other query info functions. Store information about @bs * in @info, setting @errp on error. */ -static void GRAPH_RDLOCK -bdrv_do_query_node_info(BlockDriverState *bs, BlockNodeInfo *info, Error **errp) +void coroutine_fn +bdrv_co_do_query_node_info(BlockDriverState *bs, BlockNodeInfo *info, + Error **errp) { int64_t size; const char *backing_filename; @@ -234,7 +235,7 @@ bdrv_do_query_node_info(BlockDriverState *bs, BlockNodeInfo *info, Error **errp) int ret; Error *err = NULL; - size = bdrv_getlength(bs); + size = bdrv_co_getlength(bs); if (size < 0) { error_setg_errno(errp, -size, "Can't get image size '%s'", bs->exact_filename); @@ -246,13 +247,13 @@ bdrv_do_query_node_info(BlockDriverState *bs, BlockNodeInfo *info, Error **errp) info->filename = g_strdup(bs->filename); info->format = g_strdup(bdrv_get_format_name(bs)); info->virtual_size = size; - info->actual_size = bdrv_get_allocated_file_size(bs); + info->actual_size = bdrv_co_get_allocated_file_size(bs); info->has_actual_size = info->actual_size >= 0; if (bs->encrypted) { info->encrypted = true; info->has_encrypted = true; } - if (bdrv_get_info(bs, &bdi) >= 0) { + if (bdrv_co_get_info(bs, &bdi) >= 0) { if (bdi.cluster_size != 0) { info->cluster_size = bdi.cluster_size; info->has_cluster_size = true; diff --git a/include/block/qapi.h b/include/block/qapi.h index 54c48de26a..234730b3de 100644 --- a/include/block/qapi.h +++ b/include/block/qapi.h @@ -25,6 +25,7 @@ #ifndef BLOCK_QAPI_H #define BLOCK_QAPI_H +#include "block/block-common.h" #include "block/graph-lock.h" #include "block/snapshot.h" #include "qapi/qapi-types-block-core.h" @@ -49,4 +50,11 @@ void bdrv_image_info_specific_dump(ImageInfoSpecific *info_spec, const char *prefix, int indentation); void bdrv_node_info_dump(BlockNodeInfo *info, int indentation, bool protocol); + +void coroutine_fn GRAPH_RDLOCK +bdrv_co_do_query_node_info(BlockDriverState *bs, BlockNodeInfo *info, + Error **errp); +void co_wrapper_bdrv_rdlock +bdrv_do_query_node_info(BlockDriverState *bs, BlockNodeInfo *info, + Error **errp); #endif From patchwork Tue Apr 9 14:59:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabiano Rosas X-Patchwork-Id: 13622832 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8ECC2C67861 for ; Tue, 9 Apr 2024 15:01:31 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ruCx2-00021b-Pu; Tue, 09 Apr 2024 10:59:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ruCww-0001sC-VW; Tue, 09 Apr 2024 10:59:52 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruCwv-0005wf-A1; Tue, 09 Apr 2024 10:59:50 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id AE27220A78; Tue, 9 Apr 2024 14:59:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712674787; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KAYIpAd1qbdyRj+S8CALiYZ5ko2puswcHyLu7YCTDbo=; b=oTsapD+KuXzonp8KzH+4tneOvzh8oh4LNA3+U01KI2TPobeH6DDuXcuVkHD4kdleIKf3+H k1e25QEIO0Cw6lqAAwIeX3PAwk49SB8b1CtBQUmN3EAgsPlgjv/joQlezfbJ4eKiLtsut5 G3ZuePJuRGb8YWu8S08sNTuBg/yBB8k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712674787; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KAYIpAd1qbdyRj+S8CALiYZ5ko2puswcHyLu7YCTDbo=; b=lKhWATIs+hK0g8XYSlkFXwC6xJQt3uxPdB7RxiQM98hOQ66vCPMpQ8++CRcv3eHuY6mtaI FWet+QuSCQhQf4Dg== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712674787; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KAYIpAd1qbdyRj+S8CALiYZ5ko2puswcHyLu7YCTDbo=; b=oTsapD+KuXzonp8KzH+4tneOvzh8oh4LNA3+U01KI2TPobeH6DDuXcuVkHD4kdleIKf3+H k1e25QEIO0Cw6lqAAwIeX3PAwk49SB8b1CtBQUmN3EAgsPlgjv/joQlezfbJ4eKiLtsut5 G3ZuePJuRGb8YWu8S08sNTuBg/yBB8k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712674787; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KAYIpAd1qbdyRj+S8CALiYZ5ko2puswcHyLu7YCTDbo=; b=lKhWATIs+hK0g8XYSlkFXwC6xJQt3uxPdB7RxiQM98hOQ66vCPMpQ8++CRcv3eHuY6mtaI FWet+QuSCQhQf4Dg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 7380113313; Tue, 9 Apr 2024 14:59:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id 8CPYDuBXFWZGOAAAD6G6ig (envelope-from ); Tue, 09 Apr 2024 14:59:44 +0000 From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Kevin Wolf , Hanna Reitz , Markus Armbruster , =?utf-8?q?Jo=C3=A3o_Silva?= , Lin Ma , Claudio Fontana , Dario Faggioli , Eric Blake , Stefan Hajnoczi , Paolo Bonzini Subject: [PATCH v3 06/11] block: Convert bdrv_query_block_graph_info to coroutine Date: Tue, 9 Apr 2024 11:59:12 -0300 Message-Id: <20240409145917.6780-7-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240409145917.6780-1-farosas@suse.de> References: <20240409145917.6780-1-farosas@suse.de> MIME-Version: 1.0 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCPT_COUNT_TWELVE(0.00)[12]; FUZZY_BLOCKED(0.00)[rspamd.com]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCVD_TLS_ALL(0.00)[]; R_RATELIMIT(0.00)[to_ip_from(RL14emxp6ck9fz14jedoy69s36)]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email] Received-SPF: pass client-ip=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org We're converting callers of bdrv_co_get_allocated_file_size() to run in coroutines because that function will be made asynchronous when called (indirectly) from the QMP dispatcher. This function is a candidate because it calls bdrv_do_query_node_info(), which in turn calls bdrv_co_get_allocated_file_size(). All the functions called from bdrv_do_query_node_info() onwards are coroutine-safe, either have a coroutine version themselves[1] or are mostly simple code/string manipulation[2]. 1) bdrv_co_getlength(), bdrv_co_get_allocated_file_size(), bdrv_co_get_info(); 2) bdrv_refresh_filename(), bdrv_get_format_name(), bdrv_get_full_backing_filename(), bdrv_query_snapshot_info_list(), bdrv_get_specific_info(); Signed-off-by: Fabiano Rosas Reviewed-by: Hanna Czenczek --- block/qapi.c | 14 ++++++++------ include/block/qapi.h | 6 +++++- qemu-img.c | 3 --- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/block/qapi.c b/block/qapi.c index 26a9510345..7b1cf48246 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -370,7 +370,7 @@ fail: } /** - * bdrv_query_block_graph_info: + * bdrv_co_query_block_graph_info: * @bs: root node to start from * @p_info: location to store image information * @errp: location to store error information @@ -379,17 +379,19 @@ fail: * * @p_info will be set only on success. On error, store error in @errp. */ -void bdrv_query_block_graph_info(BlockDriverState *bs, - BlockGraphInfo **p_info, - Error **errp) +void coroutine_fn +bdrv_co_query_block_graph_info(BlockDriverState *bs, BlockGraphInfo **p_info, + Error **errp) { ERRP_GUARD(); BlockGraphInfo *info; BlockChildInfoList **children_list_tail; BdrvChild *c; + assert_bdrv_graph_readable(); + info = g_new0(BlockGraphInfo, 1); - bdrv_do_query_node_info(bs, qapi_BlockGraphInfo_base(info), errp); + bdrv_co_do_query_node_info(bs, qapi_BlockGraphInfo_base(info), errp); if (*errp) { goto fail; } @@ -403,7 +405,7 @@ void bdrv_query_block_graph_info(BlockDriverState *bs, QAPI_LIST_APPEND(children_list_tail, c_info); c_info->name = g_strdup(c->name); - bdrv_query_block_graph_info(c->bs, &c_info->info, errp); + bdrv_co_query_block_graph_info(c->bs, &c_info->info, errp); if (*errp) { goto fail; } diff --git a/include/block/qapi.h b/include/block/qapi.h index 234730b3de..76be9cc3e5 100644 --- a/include/block/qapi.h +++ b/include/block/qapi.h @@ -41,7 +41,11 @@ bdrv_query_snapshot_info_list(BlockDriverState *bs, void GRAPH_RDLOCK bdrv_query_image_info(BlockDriverState *bs, ImageInfo **p_info, bool flat, bool skip_implicit_filters, Error **errp); -void GRAPH_RDLOCK + +void coroutine_fn GRAPH_RDLOCK +bdrv_co_query_block_graph_info(BlockDriverState *bs, BlockGraphInfo **p_info, + Error **errp); +void co_wrapper_bdrv_rdlock bdrv_query_block_graph_info(BlockDriverState *bs, BlockGraphInfo **p_info, Error **errp); diff --git a/qemu-img.c b/qemu-img.c index 7668f86769..19db8f18fc 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -2958,10 +2958,7 @@ static BlockGraphInfoList *collect_image_info_list(bool image_opts, * duplicate the backing chain information that we obtain by walking * the chain manually here. */ - bdrv_graph_rdlock_main_loop(); bdrv_query_block_graph_info(bs, &info, &err); - bdrv_graph_rdunlock_main_loop(); - if (err) { error_report_err(err); blk_unref(blk); From patchwork Tue Apr 9 14:59:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabiano Rosas X-Patchwork-Id: 13622829 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 970F6CD1284 for ; Tue, 9 Apr 2024 15:00:49 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ruCx4-00024w-VD; Tue, 09 Apr 2024 10:59:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ruCx0-0001wJ-NC; Tue, 09 Apr 2024 10:59:55 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruCwy-0005xN-UN; Tue, 09 Apr 2024 10:59:54 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 5215E20A78; Tue, 9 Apr 2024 14:59:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712674791; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rNhniJdJtCPE7hwb4rO4kEJtB24O1r0vXiH7WmETWpE=; b=lIdMSM3c+mmoDTn+xSu8jcKmczmSZeSLxCQ+xYKNYdySkzS/AeDRyuSYtMLG3EMAgTdf3X ufjfB54jR5QEfInMJ8AcwVTzCN35f1pmb9Z1NFlbH1Bt4E3EeDOHqDwyrz57gFFMc4ysbY HhPPszYdOT2iB61C/1j2QKDayPC4PEc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712674791; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rNhniJdJtCPE7hwb4rO4kEJtB24O1r0vXiH7WmETWpE=; b=qYkYB80SxapEbC0bWbjrHA83wuDYzOEZNat7mVnuZ23HPETTlvPO366d1Bo4Bp8Dq7TwZ4 Lk3XTFtav3oUHyCA== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=lIdMSM3c; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=qYkYB80S DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712674791; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rNhniJdJtCPE7hwb4rO4kEJtB24O1r0vXiH7WmETWpE=; b=lIdMSM3c+mmoDTn+xSu8jcKmczmSZeSLxCQ+xYKNYdySkzS/AeDRyuSYtMLG3EMAgTdf3X ufjfB54jR5QEfInMJ8AcwVTzCN35f1pmb9Z1NFlbH1Bt4E3EeDOHqDwyrz57gFFMc4ysbY HhPPszYdOT2iB61C/1j2QKDayPC4PEc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712674791; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rNhniJdJtCPE7hwb4rO4kEJtB24O1r0vXiH7WmETWpE=; b=qYkYB80SxapEbC0bWbjrHA83wuDYzOEZNat7mVnuZ23HPETTlvPO366d1Bo4Bp8Dq7TwZ4 Lk3XTFtav3oUHyCA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 20EA013313; Tue, 9 Apr 2024 14:59:47 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id eHRGNuNXFWZGOAAAD6G6ig (envelope-from ); Tue, 09 Apr 2024 14:59:47 +0000 From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Kevin Wolf , Hanna Reitz , Markus Armbruster , =?utf-8?q?Jo=C3=A3o_Silva?= , Lin Ma , Claudio Fontana , Dario Faggioli , Eric Blake , Stefan Hajnoczi , Paolo Bonzini Subject: [PATCH v3 07/11] block: Convert bdrv_query_image_info to coroutine Date: Tue, 9 Apr 2024 11:59:13 -0300 Message-Id: <20240409145917.6780-8-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240409145917.6780-1-farosas@suse.de> References: <20240409145917.6780-1-farosas@suse.de> MIME-Version: 1.0 X-Spamd-Result: default: False [-4.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; DWL_DNSWL_LOW(-1.00)[suse.de:dkim]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCPT_COUNT_TWELVE(0.00)[12]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email]; FROM_EQ_ENVFROM(0.00)[]; R_RATELIMIT(0.00)[to_ip_from(RL8i9y4krh53rntrk3u7dj74zf)]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Action: no action X-Rspamd-Queue-Id: 5215E20A78 X-Rspamd-Server: rspamd1.dmz-prg2.suse.org Received-SPF: pass client-ip=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org This function is a caller of bdrv_do_query_node_info(), which have been converted to a coroutine. Convert this function as well so we're closer from having the whole qmp_query_block as a single coroutine. Also remove the wrapper for bdrv_co_do_query_node_info() now that all its callers are converted. Signed-off-by: Fabiano Rosas --- block/qapi.c | 16 +++++++--------- include/block/qapi.h | 8 ++++---- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/block/qapi.c b/block/qapi.c index 7b1cf48246..5e263960a9 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -304,7 +304,7 @@ bdrv_co_do_query_node_info(BlockDriverState *bs, BlockNodeInfo *info, } /** - * bdrv_query_image_info: + * bdrv_co_query_image_info: * @bs: block node to examine * @p_info: location to store image information * @flat: skip backing node information @@ -325,17 +325,15 @@ bdrv_co_do_query_node_info(BlockDriverState *bs, BlockNodeInfo *info, * * @p_info will be set only on success. On error, store error in @errp. */ -void bdrv_query_image_info(BlockDriverState *bs, - ImageInfo **p_info, - bool flat, - bool skip_implicit_filters, - Error **errp) +void coroutine_fn +bdrv_co_query_image_info(BlockDriverState *bs, ImageInfo **p_info, bool flat, + bool skip_implicit_filters, Error **errp) { ERRP_GUARD(); ImageInfo *info; info = g_new0(ImageInfo, 1); - bdrv_do_query_node_info(bs, qapi_ImageInfo_base(info), errp); + bdrv_co_do_query_node_info(bs, qapi_ImageInfo_base(info), errp); if (*errp) { goto fail; } @@ -353,8 +351,8 @@ void bdrv_query_image_info(BlockDriverState *bs, } if (backing) { - bdrv_query_image_info(backing, &info->backing_image, false, - skip_implicit_filters, errp); + bdrv_co_query_image_info(backing, &info->backing_image, false, + skip_implicit_filters, errp); if (*errp) { goto fail; } diff --git a/include/block/qapi.h b/include/block/qapi.h index 76be9cc3e5..5f7e3a690e 100644 --- a/include/block/qapi.h +++ b/include/block/qapi.h @@ -38,7 +38,10 @@ int GRAPH_RDLOCK bdrv_query_snapshot_info_list(BlockDriverState *bs, SnapshotInfoList **p_list, Error **errp); -void GRAPH_RDLOCK +void coroutine_fn GRAPH_RDLOCK +bdrv_co_query_image_info(BlockDriverState *bs, ImageInfo **p_info, bool flat, + bool skip_implicit_filters, Error **errp); +void co_wrapper_bdrv_rdlock bdrv_query_image_info(BlockDriverState *bs, ImageInfo **p_info, bool flat, bool skip_implicit_filters, Error **errp); @@ -58,7 +61,4 @@ void bdrv_node_info_dump(BlockNodeInfo *info, int indentation, bool protocol); void coroutine_fn GRAPH_RDLOCK bdrv_co_do_query_node_info(BlockDriverState *bs, BlockNodeInfo *info, Error **errp); -void co_wrapper_bdrv_rdlock -bdrv_do_query_node_info(BlockDriverState *bs, BlockNodeInfo *info, - Error **errp); #endif From patchwork Tue Apr 9 14:59:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabiano Rosas X-Patchwork-Id: 13622828 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6BFBFC67861 for ; Tue, 9 Apr 2024 15:00:31 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ruCxA-0002CD-4h; Tue, 09 Apr 2024 11:00:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ruCx7-0002B3-Q8; Tue, 09 Apr 2024 11:00:01 -0400 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruCx5-0005yq-5m; Tue, 09 Apr 2024 11:00:01 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 01CCD33A53; Tue, 9 Apr 2024 14:59:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712674795; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UitpenjgjaZ/EGFw0QIA5tUbLvxpmY7Nii+8cAT9XSc=; b=wvhLbUinMgKSJApHuoaaUreBTbz1Q5i26lB4qm59Xm6XAT9myRI8b3MdfnQb2OoibnLzVq Uk448S3f8MSqj1cUar/yM3NrY1ha5ZqtEs9qTVoIvS35KtOJO/yguUXv7gbzvEWCZ54jLY o2/mUS1Hl9Jmsgs3EyVO6/VKduSjHWI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712674795; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UitpenjgjaZ/EGFw0QIA5tUbLvxpmY7Nii+8cAT9XSc=; b=eIn3Hh1PIxRxg4gCqpGgQWCe1FboOaPaMTnEOwgMYLwVajE3u9U5Z/Et2KJ4Lpi9Sfn4ig RAChL+g+l69QYSDg== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=wvhLbUin; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=eIn3Hh1P DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712674795; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UitpenjgjaZ/EGFw0QIA5tUbLvxpmY7Nii+8cAT9XSc=; b=wvhLbUinMgKSJApHuoaaUreBTbz1Q5i26lB4qm59Xm6XAT9myRI8b3MdfnQb2OoibnLzVq Uk448S3f8MSqj1cUar/yM3NrY1ha5ZqtEs9qTVoIvS35KtOJO/yguUXv7gbzvEWCZ54jLY o2/mUS1Hl9Jmsgs3EyVO6/VKduSjHWI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712674795; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UitpenjgjaZ/EGFw0QIA5tUbLvxpmY7Nii+8cAT9XSc=; b=eIn3Hh1PIxRxg4gCqpGgQWCe1FboOaPaMTnEOwgMYLwVajE3u9U5Z/Et2KJ4Lpi9Sfn4ig RAChL+g+l69QYSDg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id C5F2B13313; Tue, 9 Apr 2024 14:59:51 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id iA2sIudXFWZGOAAAD6G6ig (envelope-from ); Tue, 09 Apr 2024 14:59:51 +0000 From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Kevin Wolf , Hanna Reitz , Markus Armbruster , =?utf-8?q?Jo=C3=A3o_Silva?= , Lin Ma , Claudio Fontana , Dario Faggioli , Eric Blake , Stefan Hajnoczi , Paolo Bonzini Subject: [PATCH v3 08/11] block: Convert bdrv_block_device_info into co_wrapper Date: Tue, 9 Apr 2024 11:59:14 -0300 Message-Id: <20240409145917.6780-9-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240409145917.6780-1-farosas@suse.de> References: <20240409145917.6780-1-farosas@suse.de> MIME-Version: 1.0 X-Rspamd-Action: no action X-Rspamd-Queue-Id: 01CCD33A53 X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; DWL_DNSWL_LOW(-1.00)[suse.de:dkim]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCPT_COUNT_TWELVE(0.00)[12]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email]; FROM_EQ_ENVFROM(0.00)[]; R_RATELIMIT(0.00)[to_ip_from(RL8i9y4krh53rntrk3u7dj74zf)]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DKIM_TRACE(0.00)[suse.de:+] Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:1; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org We're converting callers of bdrv_co_get_allocated_file_size() to run in coroutines because that function will be made asynchronous when called (indirectly) from the QMP dispatcher. This function is a candidate because it calls bdrv_query_image_info() -> bdrv_co_do_query_node_info() -> bdrv_co_get_allocated_file_size(). It is safe to turn this is a coroutine because the code it calls is made up of either simple accessors and string manipulation functions [1] or it has already been determined to be safe [2]. 1) bdrv_refresh_filename(), bdrv_is_read_only(), blk_enable_write_cache(), bdrv_cow_bs(), blk_get_public(), throttle_group_get_name(), bdrv_write_threshold_get(), bdrv_query_dirty_bitmaps(), throttle_group_get_config(), bdrv_filter_or_cow_bs(), bdrv_skip_implicit_filters() 2) bdrv_co_do_query_node_info() (see previous commits); This was the only caller of bdrv_query_image_info(), so we can remove the wrapper for that function now. Signed-off-by: Fabiano Rosas --- - used co_wrapper_bdrv_rdlock instead of co_wrapper --- block/qapi.c | 10 +++++----- include/block/qapi.h | 13 ++++++------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/block/qapi.c b/block/qapi.c index 5e263960a9..9a59e5606f 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -41,10 +41,10 @@ #include "qemu/qemu-print.h" #include "sysemu/block-backend.h" -BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk, - BlockDriverState *bs, - bool flat, - Error **errp) +BlockDeviceInfo *coroutine_fn bdrv_co_block_device_info(BlockBackend *blk, + BlockDriverState *bs, + bool flat, + Error **errp) { ERRP_GUARD(); ImageInfo **p_image_info; @@ -152,7 +152,7 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk, * Skip automatically inserted nodes that the user isn't aware of for * query-block (blk != NULL), but not for query-named-block-nodes */ - bdrv_query_image_info(bs, p_image_info, flat, blk != NULL, errp); + bdrv_co_query_image_info(bs, p_image_info, flat, blk != NULL, errp); if (*errp) { qapi_free_BlockDeviceInfo(info); return NULL; diff --git a/include/block/qapi.h b/include/block/qapi.h index 5f7e3a690e..9f0e957963 100644 --- a/include/block/qapi.h +++ b/include/block/qapi.h @@ -30,10 +30,12 @@ #include "block/snapshot.h" #include "qapi/qapi-types-block-core.h" -BlockDeviceInfo * GRAPH_RDLOCK -bdrv_block_device_info(BlockBackend *blk, BlockDriverState *bs, - bool flat, Error **errp); - +BlockDeviceInfo *coroutine_fn GRAPH_RDLOCK +bdrv_co_block_device_info(BlockBackend *blk, BlockDriverState *bs, bool flat, + Error **errp); +BlockDeviceInfo *co_wrapper_bdrv_rdlock +bdrv_block_device_info(BlockBackend *blk, BlockDriverState *bs, bool flat, + Error **errp); int GRAPH_RDLOCK bdrv_query_snapshot_info_list(BlockDriverState *bs, SnapshotInfoList **p_list, @@ -41,9 +43,6 @@ bdrv_query_snapshot_info_list(BlockDriverState *bs, void coroutine_fn GRAPH_RDLOCK bdrv_co_query_image_info(BlockDriverState *bs, ImageInfo **p_info, bool flat, bool skip_implicit_filters, Error **errp); -void co_wrapper_bdrv_rdlock -bdrv_query_image_info(BlockDriverState *bs, ImageInfo **p_info, bool flat, - bool skip_implicit_filters, Error **errp); void coroutine_fn GRAPH_RDLOCK bdrv_co_query_block_graph_info(BlockDriverState *bs, BlockGraphInfo **p_info, From patchwork Tue Apr 9 14:59:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabiano Rosas X-Patchwork-Id: 13622830 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 358F6C67861 for ; Tue, 9 Apr 2024 15:00:53 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ruCxC-0002FT-Ju; Tue, 09 Apr 2024 11:00:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ruCx8-0002BV-8e; Tue, 09 Apr 2024 11:00:02 -0400 Received: from smtp-out2.suse.de ([2a07:de40:b251:101:10:150:64:2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruCx6-0005zE-BX; Tue, 09 Apr 2024 11:00:01 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id A08BC20A6A; Tue, 9 Apr 2024 14:59:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712674798; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UsAc/pCFXmSQb/9yLrhfsKxho44YarL6SfffbDN0XhA=; b=kXBH8NaN6dm1PnEOYCB0igdHZgZZtJaTSjHY3vpbrn2/2tCxginAik+ISLe02f8bA71u4X ADcmbhy1EN7+4D3JxW8UNdcXUZmI8ntaju+l9HJg9C2I+e6BirPkcZiqLMICmUM5mhamo3 7VrmYIUIJOR1LcV4YxARnJY1IHu4AKA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712674798; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UsAc/pCFXmSQb/9yLrhfsKxho44YarL6SfffbDN0XhA=; b=3mmxl236a9akO4gu/fp0fMPL1OozAkT1m5Qe4B05044Eip8oyLs7EN5LzoqNd1/GuJBtkc wwlTQARyATkBEXDw== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712674798; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UsAc/pCFXmSQb/9yLrhfsKxho44YarL6SfffbDN0XhA=; b=kXBH8NaN6dm1PnEOYCB0igdHZgZZtJaTSjHY3vpbrn2/2tCxginAik+ISLe02f8bA71u4X ADcmbhy1EN7+4D3JxW8UNdcXUZmI8ntaju+l9HJg9C2I+e6BirPkcZiqLMICmUM5mhamo3 7VrmYIUIJOR1LcV4YxARnJY1IHu4AKA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712674798; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UsAc/pCFXmSQb/9yLrhfsKxho44YarL6SfffbDN0XhA=; b=3mmxl236a9akO4gu/fp0fMPL1OozAkT1m5Qe4B05044Eip8oyLs7EN5LzoqNd1/GuJBtkc wwlTQARyATkBEXDw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 72DAF1398D; Tue, 9 Apr 2024 14:59:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id GPylDutXFWZGOAAAD6G6ig (envelope-from ); Tue, 09 Apr 2024 14:59:55 +0000 From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Kevin Wolf , Hanna Reitz , Markus Armbruster , =?utf-8?q?Jo=C3=A3o_Silva?= , Lin Ma , Claudio Fontana , Dario Faggioli , Eric Blake , Stefan Hajnoczi , Paolo Bonzini Subject: [PATCH v3 09/11] block: Don't query all block devices at hmp_nbd_server_start Date: Tue, 9 Apr 2024 11:59:15 -0300 Message-Id: <20240409145917.6780-10-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240409145917.6780-1-farosas@suse.de> References: <20240409145917.6780-1-farosas@suse.de> MIME-Version: 1.0 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[]; RCPT_COUNT_TWELVE(0.00)[12]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; R_RATELIMIT(0.00)[to_ip_from(RL14emxp6ck9fz14jedoy69s36)]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; RCVD_TLS_ALL(0.00)[] Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:2; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org We're currently doing a full query-block just to enumerate the devices for qmp_nbd_server_add and then discarding the BlockInfoList afterwards. Alter hmp_nbd_server_start to instead iterate explicitly over the block_backends list. This allows the removal of the dependency on qmp_query_block from hmp_nbd_server_start. This is desirable because we're about to move qmp_query_block into a coroutine and don't need to change the NBD code at the same time. Add the GRAPH_RDLOCK_GUARD_MAINLOOP macro because bdrv_skip_implicit_filters() needs the graph lock. Signed-off-by: Fabiano Rosas --- - add a comment explaining some checks are done to preserve previous behavior; - we need the strdup when assigning .device to preserve const. Just add a matching g_free(); - about the possible leak at qmp_nbd_server_add() unrelated to this patch, commit 8675cbd68b ("nbd: Utilize QAPI_CLONE for type conversion") mentions that the QAPI visitor will already free arg->name. --- block/monitor/block-hmp-cmds.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c index d954bec6f1..9db587c661 100644 --- a/block/monitor/block-hmp-cmds.c +++ b/block/monitor/block-hmp-cmds.c @@ -387,10 +387,12 @@ void hmp_nbd_server_start(Monitor *mon, const QDict *qdict) bool writable = qdict_get_try_bool(qdict, "writable", false); bool all = qdict_get_try_bool(qdict, "all", false); Error *local_err = NULL; - BlockInfoList *block_list, *info; + BlockBackend *blk; SocketAddress *addr; NbdServerAddOptions export; + GRAPH_RDLOCK_GUARD_MAINLOOP(); + if (writable && !all) { error_setg(&local_err, "-w only valid together with -a"); goto exit; @@ -415,29 +417,43 @@ void hmp_nbd_server_start(Monitor *mon, const QDict *qdict) /* Then try adding all block devices. If one fails, close all and * exit. */ - block_list = qmp_query_block(NULL); + for (blk = blk_all_next(NULL); blk; blk = blk_all_next(blk)) { + BlockDriverState *bs = blk_bs(blk); - for (info = block_list; info; info = info->next) { - if (!info->value->inserted) { + if (!*blk_name(blk)) { + continue; + } + + /* + * Note: historically we used to call qmp_query_block() to get + * the list of block devices. The two 'continue' cases below + * are the same as used by that function and are here to + * preserve behavior. + */ + + if (!blk_get_attached_dev(blk)) { + continue; + } + + bs = bdrv_skip_implicit_filters(bs); + if (!bs || !bs->drv) { continue; } export = (NbdServerAddOptions) { - .device = info->value->device, + .device = g_strdup(blk_name(blk)), .has_writable = true, .writable = writable, }; qmp_nbd_server_add(&export, &local_err); - + g_free(export.device); if (local_err != NULL) { qmp_nbd_server_stop(NULL); break; } } - qapi_free_BlockInfoList(block_list); - exit: hmp_handle_error(mon, local_err); } From patchwork Tue Apr 9 14:59:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabiano Rosas X-Patchwork-Id: 13622835 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8D67ECD128A for ; Tue, 9 Apr 2024 15:01:55 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ruCxd-0002dG-BQ; Tue, 09 Apr 2024 11:00:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ruCxG-0002MO-Vk; Tue, 09 Apr 2024 11:00:11 -0400 Received: from smtp-out1.suse.de ([195.135.223.130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruCxB-000611-D1; Tue, 09 Apr 2024 11:00:10 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 9B4A733A57; Tue, 9 Apr 2024 15:00:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712674802; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8jkd3pQPgVFfA8kxk0mRImtAej1THT0x0NrGWIGh+Qc=; b=l8EDq5+TzzXs+rLpKp6p6nRpjp9zCqCeAjWbGd/DlAquMf3b05kvI//DlSmHnvxIjMZ05T JnMKsv0605iAB9xdy6WQZvZqBVFTijgZDNv0YFUnxGnKJUy7T0D//dDE2FUTYd9T2BKzMr kadkyOMccFO+BjTbfl55iDgYUfm2KAw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712674802; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8jkd3pQPgVFfA8kxk0mRImtAej1THT0x0NrGWIGh+Qc=; b=oavRpblkHuSoyidGSQBEBAcrebB3Yp9v1AmmA+falMC1Fnod9ReR+CJJNaoc7bYhO59Yl/ NbtUnZXDVmjjZFBA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712674802; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8jkd3pQPgVFfA8kxk0mRImtAej1THT0x0NrGWIGh+Qc=; b=l8EDq5+TzzXs+rLpKp6p6nRpjp9zCqCeAjWbGd/DlAquMf3b05kvI//DlSmHnvxIjMZ05T JnMKsv0605iAB9xdy6WQZvZqBVFTijgZDNv0YFUnxGnKJUy7T0D//dDE2FUTYd9T2BKzMr kadkyOMccFO+BjTbfl55iDgYUfm2KAw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712674802; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8jkd3pQPgVFfA8kxk0mRImtAej1THT0x0NrGWIGh+Qc=; b=oavRpblkHuSoyidGSQBEBAcrebB3Yp9v1AmmA+falMC1Fnod9ReR+CJJNaoc7bYhO59Yl/ NbtUnZXDVmjjZFBA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 2BF0C13313; Tue, 9 Apr 2024 14:59:58 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id QGnrOO5XFWZGOAAAD6G6ig (envelope-from ); Tue, 09 Apr 2024 14:59:58 +0000 From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Kevin Wolf , Hanna Reitz , Markus Armbruster , =?utf-8?q?Jo=C3=A3o_Silva?= , Lin Ma , Claudio Fontana , Dario Faggioli , Eric Blake , Stefan Hajnoczi , Paolo Bonzini , "Dr. David Alan Gilbert" Subject: [PATCH v3 10/11] block: Convert qmp_query_block and qmp_query_named_block_nodes to coroutine Date: Tue, 9 Apr 2024 11:59:16 -0300 Message-Id: <20240409145917.6780-11-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240409145917.6780-1-farosas@suse.de> References: <20240409145917.6780-1-farosas@suse.de> MIME-Version: 1.0 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.989]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[]; RCPT_COUNT_TWELVE(0.00)[13]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; R_RATELIMIT(0.00)[to_ip_from(RL14emxp6ck9fz14jedoy69s36)]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.com:email]; RCVD_TLS_ALL(0.00)[] Received-SPF: pass client-ip=195.135.223.130; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Lin Ma Convert the remaining functions to make the QMP commands query-block and query-named-block-nodes run in their entirety in a coroutine. With this, any yield from those commands will return all the way back to the main loop. This releases the BQL and the main loop and avoids having the QMP command block another more important task from running. Both commands need to be converted at once because hmp_info_block calls both and it needs to be moved to a coroutine as well. Now the wrapper for bdrv_co_get_allocated_file_size() can be made not mixed and the wrapper for bdrv_co_block_device_info() can be removed. Signed-off-by: Lin Ma Signed-off-by: Fabiano Rosas --- block.c | 8 ++++---- block/monitor/block-hmp-cmds.c | 2 +- block/qapi.c | 12 ++++++------ blockdev.c | 8 ++++---- hmp-commands-info.hx | 1 + include/block/block-global-state.h | 3 ++- include/block/block-hmp-cmds.h | 2 +- include/block/block-io.h | 2 +- include/block/qapi.h | 3 --- qapi/block-core.json | 5 +++-- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/block.c b/block.c index 01478c5471..cba28f07fc 100644 --- a/block.c +++ b/block.c @@ -6207,18 +6207,18 @@ BlockDriverState *bdrv_find_node(const char *node_name) } /* Put this QMP function here so it can access the static graph_bdrv_states. */ -BlockDeviceInfoList *bdrv_named_nodes_list(bool flat, - Error **errp) +BlockDeviceInfoList *coroutine_fn bdrv_co_named_nodes_list(bool flat, + Error **errp) { BlockDeviceInfoList *list; BlockDriverState *bs; GLOBAL_STATE_CODE(); - GRAPH_RDLOCK_GUARD_MAINLOOP(); + GRAPH_RDLOCK_GUARD(); list = NULL; QTAILQ_FOREACH(bs, &graph_bdrv_states, node_list) { - BlockDeviceInfo *info = bdrv_block_device_info(NULL, bs, flat, errp); + BlockDeviceInfo *info = bdrv_co_block_device_info(NULL, bs, flat, errp); if (!info) { qapi_free_BlockDeviceInfoList(list); return NULL; diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c index 9db587c661..8ceff59688 100644 --- a/block/monitor/block-hmp-cmds.c +++ b/block/monitor/block-hmp-cmds.c @@ -738,7 +738,7 @@ static void print_block_info(Monitor *mon, BlockInfo *info, } } -void hmp_info_block(Monitor *mon, const QDict *qdict) +void coroutine_fn hmp_info_block(Monitor *mon, const QDict *qdict) { BlockInfoList *block_list, *info; BlockDeviceInfoList *blockdev_list, *blockdev; diff --git a/block/qapi.c b/block/qapi.c index 9a59e5606f..c4514295ec 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -418,8 +418,8 @@ fail: } /* @p_info will be set only on success. */ -static void GRAPH_RDLOCK -bdrv_query_info(BlockBackend *blk, BlockInfo **p_info, Error **errp) +static void GRAPH_RDLOCK coroutine_fn +bdrv_co_query_info(BlockBackend *blk, BlockInfo **p_info, Error **errp) { BlockInfo *info = g_malloc0(sizeof(*info)); BlockDriverState *bs = blk_bs(blk); @@ -451,7 +451,7 @@ bdrv_query_info(BlockBackend *blk, BlockInfo **p_info, Error **errp) } if (bs && bs->drv) { - info->inserted = bdrv_block_device_info(blk, bs, false, errp); + info->inserted = bdrv_co_block_device_info(blk, bs, false, errp); if (info->inserted == NULL) { goto err; } @@ -661,13 +661,13 @@ bdrv_query_bds_stats(BlockDriverState *bs, bool blk_level) return s; } -BlockInfoList *qmp_query_block(Error **errp) +BlockInfoList *coroutine_fn qmp_query_block(Error **errp) { BlockInfoList *head = NULL, **p_next = &head; BlockBackend *blk; Error *local_err = NULL; - GRAPH_RDLOCK_GUARD_MAINLOOP(); + GRAPH_RDLOCK_GUARD(); for (blk = blk_all_next(NULL); blk; blk = blk_all_next(blk)) { BlockInfoList *info; @@ -677,7 +677,7 @@ BlockInfoList *qmp_query_block(Error **errp) } info = g_malloc0(sizeof(*info)); - bdrv_query_info(blk, &info->value, &local_err); + bdrv_co_query_info(blk, &info->value, &local_err); if (local_err) { error_propagate(errp, local_err); g_free(info); diff --git a/blockdev.c b/blockdev.c index 057601dcf0..fe3226c8c4 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2744,13 +2744,13 @@ void qmp_drive_backup(DriveBackup *backup, Error **errp) blockdev_do_action(&action, errp); } -BlockDeviceInfoList *qmp_query_named_block_nodes(bool has_flat, - bool flat, - Error **errp) +BlockDeviceInfoList *coroutine_fn qmp_query_named_block_nodes(bool has_flat, + bool flat, + Error **errp) { bool return_flat = has_flat && flat; - return bdrv_named_nodes_list(return_flat, errp); + return bdrv_co_named_nodes_list(return_flat, errp); } XDbgBlockGraph *qmp_x_debug_query_block_graph(Error **errp) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index ad1b1306e3..c0dad1fc86 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -65,6 +65,7 @@ ERST .help = "show info of one block device or all block devices " "(-n: show named nodes; -v: show details)", .cmd = hmp_info_block, + .coroutine = true, }, SRST diff --git a/include/block/block-global-state.h b/include/block/block-global-state.h index bd7cecd1cf..ee87a0c7d9 100644 --- a/include/block/block-global-state.h +++ b/include/block/block-global-state.h @@ -196,7 +196,8 @@ void bdrv_aio_cancel(BlockAIOCB *acb); int bdrv_has_zero_init_1(BlockDriverState *bs); int coroutine_mixed_fn GRAPH_RDLOCK bdrv_has_zero_init(BlockDriverState *bs); BlockDriverState *bdrv_find_node(const char *node_name); -BlockDeviceInfoList *bdrv_named_nodes_list(bool flat, Error **errp); +BlockDeviceInfoList *coroutine_fn bdrv_co_named_nodes_list(bool flat, + Error **errp); XDbgBlockGraph * GRAPH_RDLOCK bdrv_get_xdbg_block_graph(Error **errp); BlockDriverState *bdrv_lookup_bs(const char *device, const char *node_name, diff --git a/include/block/block-hmp-cmds.h b/include/block/block-hmp-cmds.h index 71113cd7ef..6d9152318f 100644 --- a/include/block/block-hmp-cmds.h +++ b/include/block/block-hmp-cmds.h @@ -48,7 +48,7 @@ void hmp_eject(Monitor *mon, const QDict *qdict); void hmp_qemu_io(Monitor *mon, const QDict *qdict); -void hmp_info_block(Monitor *mon, const QDict *qdict); +void coroutine_fn hmp_info_block(Monitor *mon, const QDict *qdict); void hmp_info_blockstats(Monitor *mon, const QDict *qdict); void hmp_info_block_jobs(Monitor *mon, const QDict *qdict); void hmp_info_snapshots(Monitor *mon, const QDict *qdict); diff --git a/include/block/block-io.h b/include/block/block-io.h index 349d7760a1..b49e0537dd 100644 --- a/include/block/block-io.h +++ b/include/block/block-io.h @@ -86,7 +86,7 @@ int64_t co_wrapper_mixed_bdrv_rdlock bdrv_getlength(BlockDriverState *bs); int64_t coroutine_fn GRAPH_RDLOCK bdrv_co_get_allocated_file_size(BlockDriverState *bs); -int64_t co_wrapper_mixed_bdrv_rdlock +int64_t co_wrapper_bdrv_rdlock bdrv_get_allocated_file_size(BlockDriverState *bs); BlockMeasureInfo *bdrv_measure(BlockDriver *drv, QemuOpts *opts, diff --git a/include/block/qapi.h b/include/block/qapi.h index 9f0e957963..9274b76814 100644 --- a/include/block/qapi.h +++ b/include/block/qapi.h @@ -33,9 +33,6 @@ BlockDeviceInfo *coroutine_fn GRAPH_RDLOCK bdrv_co_block_device_info(BlockBackend *blk, BlockDriverState *bs, bool flat, Error **errp); -BlockDeviceInfo *co_wrapper_bdrv_rdlock -bdrv_block_device_info(BlockBackend *blk, BlockDriverState *bs, bool flat, - Error **errp); int GRAPH_RDLOCK bdrv_query_snapshot_info_list(BlockDriverState *bs, SnapshotInfoList **p_list, diff --git a/qapi/block-core.json b/qapi/block-core.json index 746d1694c2..4a0a336431 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -849,7 +849,7 @@ # } ## { 'command': 'query-block', 'returns': ['BlockInfo'], - 'allow-preconfig': true } + 'allow-preconfig': true, 'coroutine': true } ## # @BlockDeviceTimedStats: @@ -1997,7 +1997,8 @@ { 'command': 'query-named-block-nodes', 'returns': [ 'BlockDeviceInfo' ], 'data': { '*flat': 'bool' }, - 'allow-preconfig': true } + 'allow-preconfig': true, + 'coroutine': true} ## # @XDbgBlockGraphNodeType: From patchwork Tue Apr 9 14:59:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Fabiano Rosas X-Patchwork-Id: 13622833 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F3DC0CD129A for ; Tue, 9 Apr 2024 15:01:56 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ruCxe-0002lV-8W; Tue, 09 Apr 2024 11:00:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ruCxI-0002OU-Ob; Tue, 09 Apr 2024 11:00:16 -0400 Received: from smtp-out1.suse.de ([195.135.223.130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruCxD-0006Bk-Uz; Tue, 09 Apr 2024 11:00:11 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 3F07B33A58; Tue, 9 Apr 2024 15:00:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712674806; h=from:from:reply-to: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=PK1BOaSiznR5Y3Tqkn92pIJcwhfufC71cNAlVZbSpgA=; b=H2unQWHkXDZqT18q+YNVpxXjfsj1RiOnqjlqp1rSdV7sYsvE2d2HiVlyP6gG/3ibCwFT4e rPtJaQirrdBMokM9dHpr22f5wDVePpxfIC6Zbn4VUxjXK1MWuWPx9ljMXmY2gih6gDS1Og 45fTAvApYLb4VZNyJbZJupGniP93014= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712674806; h=from:from:reply-to: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=PK1BOaSiznR5Y3Tqkn92pIJcwhfufC71cNAlVZbSpgA=; b=t36fCesvaDe8JTtSXiXKMXCDXMuNNWF6z3ptpFDqdNCCQFdzgJ0P0MnmuSUYJWQhWMR/fa fMAkH9xU9IDWNjBg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712674806; h=from:from:reply-to: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=PK1BOaSiznR5Y3Tqkn92pIJcwhfufC71cNAlVZbSpgA=; b=H2unQWHkXDZqT18q+YNVpxXjfsj1RiOnqjlqp1rSdV7sYsvE2d2HiVlyP6gG/3ibCwFT4e rPtJaQirrdBMokM9dHpr22f5wDVePpxfIC6Zbn4VUxjXK1MWuWPx9ljMXmY2gih6gDS1Og 45fTAvApYLb4VZNyJbZJupGniP93014= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712674806; h=from:from:reply-to: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=PK1BOaSiznR5Y3Tqkn92pIJcwhfufC71cNAlVZbSpgA=; b=t36fCesvaDe8JTtSXiXKMXCDXMuNNWF6z3ptpFDqdNCCQFdzgJ0P0MnmuSUYJWQhWMR/fa fMAkH9xU9IDWNjBg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 0EF0A13313; Tue, 9 Apr 2024 15:00:02 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id CCfqMfJXFWZGOAAAD6G6ig (envelope-from ); Tue, 09 Apr 2024 15:00:02 +0000 From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Kevin Wolf , Hanna Reitz , Markus Armbruster , =?utf-8?q?Jo=C3=A3o_Silva?= , Lin Ma , Claudio Fontana , Dario Faggioli , Eric Blake , Stefan Hajnoczi , Paolo Bonzini Subject: [PATCH v3 11/11] block: Add a thread-pool version of fstat Date: Tue, 9 Apr 2024 11:59:17 -0300 Message-Id: <20240409145917.6780-12-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240409145917.6780-1-farosas@suse.de> References: <20240409145917.6780-1-farosas@suse.de> MIME-Version: 1.0 X-Spamd-Result: default: False [-3.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCPT_COUNT_TWELVE(0.00)[12]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; R_RATELIMIT(0.00)[to_ip_from(RL14emxp6ck9fz14jedoy69s36)]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email] Received-SPF: pass client-ip=195.135.223.130; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: João Silva The fstat call can take a long time to finish when running over NFS. Add a version of it that runs in the thread pool. Adapt one of its users, raw_co_get_allocated_file size to use the new version. That function is called via QMP under the qemu_global_mutex so it has a large chance of blocking VCPU threads in case it takes too long to finish. Reviewed-by: Claudio Fontana Reviewed-by: Hanna Czenczek Signed-off-by: João Silva Signed-off-by: Fabiano Rosas --- block/file-posix.c | 40 +++++++++++++++++++++++++++++++++++++--- include/block/raw-aio.h | 4 +++- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index 35684f7e21..6fbf961244 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -226,6 +226,9 @@ typedef struct RawPosixAIOData { struct { unsigned long op; } zone_mgmt; + struct { + struct stat *st; + } fstat; }; } RawPosixAIOData; @@ -2616,6 +2619,34 @@ static void raw_close(BlockDriverState *bs) } } +static int handle_aiocb_fstat(void *opaque) +{ + RawPosixAIOData *aiocb = opaque; + + if (fstat(aiocb->aio_fildes, aiocb->fstat.st) < 0) { + return -errno; + } + + return 0; +} + +static int coroutine_fn raw_co_fstat(BlockDriverState *bs, struct stat *st) +{ + BDRVRawState *s = bs->opaque; + RawPosixAIOData acb; + + acb = (RawPosixAIOData) { + .bs = bs, + .aio_fildes = s->fd, + .aio_type = QEMU_AIO_FSTAT, + .fstat = { + .st = st, + }, + }; + + return raw_thread_pool_submit(handle_aiocb_fstat, &acb); +} + /** * Truncates the given regular file @fd to @offset and, when growing, fills the * new space according to @prealloc. @@ -2860,11 +2891,14 @@ static int64_t coroutine_fn raw_co_getlength(BlockDriverState *bs) static int64_t coroutine_fn raw_co_get_allocated_file_size(BlockDriverState *bs) { struct stat st; - BDRVRawState *s = bs->opaque; + int ret; - if (fstat(s->fd, &st) < 0) { - return -errno; + ret = raw_co_fstat(bs, &st); + + if (ret) { + return ret; } + return (int64_t)st.st_blocks * 512; } diff --git a/include/block/raw-aio.h b/include/block/raw-aio.h index 20e000b8ef..0c6af8dc32 100644 --- a/include/block/raw-aio.h +++ b/include/block/raw-aio.h @@ -31,6 +31,7 @@ #define QEMU_AIO_ZONE_REPORT 0x0100 #define QEMU_AIO_ZONE_MGMT 0x0200 #define QEMU_AIO_ZONE_APPEND 0x0400 +#define QEMU_AIO_FSTAT 0x0800 #define QEMU_AIO_TYPE_MASK \ (QEMU_AIO_READ | \ QEMU_AIO_WRITE | \ @@ -42,7 +43,8 @@ QEMU_AIO_TRUNCATE | \ QEMU_AIO_ZONE_REPORT | \ QEMU_AIO_ZONE_MGMT | \ - QEMU_AIO_ZONE_APPEND) + QEMU_AIO_ZONE_APPEND | \ + QEMU_AIO_FSTAT) /* AIO flags */ #define QEMU_AIO_MISALIGNED 0x1000