From nobody Fri Apr 4 06:28:10 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1741442320; cv=none; d=zohomail.com; s=zohoarc; b=f4ATmwqrlXW7meFFBPzn3zQeB++brjkxAW45FewK9KxZ4R3KSylWAbQ9RYK/Nexp3bLpVvSR6RuhdUV5Fpsov2W8+9qQlfsPkTBxmtPMemeAKiKf2x1MfM9OLnGl/81wGN3JWL55+ivTn1Q69jLsXsA6HKo6s8CA0PMfuvLhopo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1741442320; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=gwTZIoIxcOZtk1oGhkded9hRnC1LU+EF+WOzX0EAvi8=; b=QHXkqotEBEF71NWYylrPC/fY5+ziWW7R0JJ1EV8X4q/WF9eYHKFvyeQkQTMaaMaRRor7XcqY65H0aobafMUtyvYhc8GujK2teppBYt2uCTMiwr0y6na78R/7qwj4lJM9zJPp7z8H/QMch7kr1EFFw/XXa95mA3OI0qtYrGUoB+w= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1741442320625310.6840655532802; Sat, 8 Mar 2025 05:58:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tqugK-0004NI-K7; Sat, 08 Mar 2025 08:57:37 -0500 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 1tqrEv-0006sV-2d; Sat, 08 Mar 2025 05:17:05 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tqrEq-000061-UK; Sat, 08 Mar 2025 05:17:04 -0500 Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4Z8zVN0cKrz1f01S; Sat, 8 Mar 2025 18:12:28 +0800 (CST) Received: from kwepemk500007.china.huawei.com (unknown [7.202.194.92]) by mail.maildlp.com (Postfix) with ESMTPS id 1DC911A0171; Sat, 8 Mar 2025 18:16:45 +0800 (CST) Received: from huawei.com (10.246.99.19) by kwepemk500007.china.huawei.com (7.202.194.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Sat, 8 Mar 2025 18:16:43 +0800 To: , , , , , CC: , , , , , , , , , , , Subject: [PATCH 2/2] qapi: Fix qmp_block_set_io_throttle blocked for too long Date: Sat, 8 Mar 2025 18:16:18 +0800 Message-ID: <20250308101618.721954-3-zoudongjie@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20250308101618.721954-1-zoudongjie@huawei.com> References: <20250308101618.721954-1-zoudongjie@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.246.99.19] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemk500007.china.huawei.com (7.202.194.92) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=45.249.212.35; envelope-from=zoudongjie@huawei.com; helo=szxga07-in.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sat, 08 Mar 2025 08:57:14 -0500 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: , Reply-to: zoudongjie From: zoudongjie via Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1741442322291019100 Content-Type: text/plain; charset="utf-8" From: Zhu Yangyang bdrv_drained_begin() is blocked for a long time when network storage is used and the network link has just failed. Therefore, the timeout period is set here. Signed-off-by: Zhu Yangyang --- block/block-backend.c | 14 +++++++++++++- block/qapi-system.c | 7 ++++++- include/system/block-backend-global-state.h | 1 + 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index 9288f7e1c6..409d4559c3 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -2691,20 +2691,32 @@ void blk_set_io_limits(BlockBackend *blk, ThrottleC= onfig *cfg) } =20 void blk_io_limits_disable(BlockBackend *blk) +{ + blk_io_limits_disable_timeout(blk, -1); +} + +int blk_io_limits_disable_timeout(BlockBackend *blk, int64_t timeout_ms) { BlockDriverState *bs =3D blk_bs(blk); ThrottleGroupMember *tgm =3D &blk->public.throttle_group_member; + int ret =3D 0; + assert(tgm->throttle_state); GLOBAL_STATE_CODE(); if (bs) { bdrv_ref(bs); - bdrv_drained_begin(bs); + ret =3D bdrv_drained_begin_timeout(bs, timeout_ms); + if (ret < 0) { + goto out; + } } throttle_group_unregister_tgm(tgm); +out: if (bs) { bdrv_drained_end(bs); bdrv_unref(bs); } + return ret; } =20 /* should be called before blk_set_io_limits if a limit is set */ diff --git a/block/qapi-system.c b/block/qapi-system.c index 54b7409b2b..96fa8e5e51 100644 --- a/block/qapi-system.c +++ b/block/qapi-system.c @@ -39,6 +39,8 @@ #include "system/block-backend.h" #include "system/blockdev.h" =20 +#define QMP_BLOCKING_TIMEOUT 5000 /* ms */ + static BlockBackend *qmp_get_blk(const char *blk_name, const char *qdev_id, Error **errp) { @@ -502,7 +504,10 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, E= rror **errp) blk_set_io_limits(blk, &cfg); } else if (blk_get_public(blk)->throttle_group_member.throttle_state) { /* If all throttling settings are set to 0, disable I/O limits */ - blk_io_limits_disable(blk); + if (blk_io_limits_disable_timeout(blk, QMP_BLOCKING_TIMEOUT) < 0) { + error_setg(errp, "Blk io limits disable timeout"); + return; + } } } =20 diff --git a/include/system/block-backend-global-state.h b/include/system/b= lock-backend-global-state.h index 9cc9b008ec..e55ea9dc64 100644 --- a/include/system/block-backend-global-state.h +++ b/include/system/block-backend-global-state.h @@ -111,6 +111,7 @@ int blk_probe_geometry(BlockBackend *blk, HDGeometry *g= eo); =20 void blk_set_io_limits(BlockBackend *blk, ThrottleConfig *cfg); void blk_io_limits_disable(BlockBackend *blk); +int blk_io_limits_disable_timeout(BlockBackend *blk, int64_t timeout_ms); void blk_io_limits_enable(BlockBackend *blk, const char *group); void blk_io_limits_update_group(BlockBackend *blk, const char *group); void blk_set_force_allow_inactivate(BlockBackend *blk); --=20 2.33.0