From nobody Tue Nov 18 07:42:43 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 ARC-Seal: i=1; a=rsa-sha256; t=1608039201; cv=none; d=zohomail.com; s=zohoarc; b=G2DRmrt/roXLMCfw5Pokjm3TH/hQ8o0rnEBvCqqyBt0UB0gwv/rjQzT9yQJVT1CzUfCOBSRFHTVQRI2IcdTz0n32ekOpIn3S88unJkD+fVDwJxj0nT1X9RMH5o1Kwx/IrLsiWpzygIDhZ5jLHA9LXaLLEPYcTWRKry/oVNCD1/U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608039201; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RMTr+QsC5/nflD8X6emyF8GBppB0LUGu1p21x7dLN0g=; b=aVyXqR/aal/9vOjHzP0C6GX9niVLonIC5lW9DqPOcg2YBMdFAyxntPRLOnikMrEGT3xv8j1jJRSQF0YwpRP8BzSPWARvEkWPE/CeXVsysVEkPMrYtG0BVtjwU8dvTsoL5aWJFdL9FaUVSt78bmw0OXYV22m4/BK4K98WcDCVPAA= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1608039200829968.9905601091834; Tue, 15 Dec 2020 05:33:20 -0800 (PST) Received: from localhost ([::1]:42838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kp9Yu-0004ys-2R for importer@patchew.org; Tue, 15 Dec 2020 07:36:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40716) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kp9Tg-0007o1-6z; Tue, 15 Dec 2020 07:30:52 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:2998) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kp9TY-0006w7-Ew; Tue, 15 Dec 2020 07:30:51 -0500 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4CwHdf4QHrzhsSt; Tue, 15 Dec 2020 20:29:58 +0800 (CST) Received: from localhost (10.174.184.155) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.498.0; Tue, 15 Dec 2020 20:30:26 +0800 From: Jiahui Cen To: Subject: [PATCH v4 3/7] block-backend: Add device specific retry callback Date: Tue, 15 Dec 2020 20:30:07 +0800 Message-ID: <20201215123011.4048-4-cenjiahui@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201215123011.4048-1-cenjiahui@huawei.com> References: <20201215123011.4048-1-cenjiahui@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.174.184.155] X-CFilter-Loop: Reflected 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.191; envelope-from=cenjiahui@huawei.com; helo=szxga05-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_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , cenjiahui@huawei.com, zhang.zhanghailiang@huawei.com, qemu-block@nongnu.org, "Michael S. Tsirkin" , Markus Armbruster , Max Reitz , Stefan Hajnoczi , fangying1@huawei.com, John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Add retry_request_cb in BlockDevOps to do device specific retry action. Backend's timer would be registered only when the backend is set 'retry' on errors and the device supports retry action. Signed-off-by: Jiahui Cen Signed-off-by: Ying Fang --- block/block-backend.c | 8 ++++++++ include/sysemu/block-backend.h | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/block/block-backend.c b/block/block-backend.c index fe775ea298..bca7c581ee 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -995,6 +995,14 @@ void blk_set_dev_ops(BlockBackend *blk, const BlockDev= Ops *ops, blk->dev_ops =3D ops; blk->dev_opaque =3D opaque; =20 + if ((blk->on_read_error =3D=3D BLOCKDEV_ON_ERROR_RETRY || + blk->on_write_error =3D=3D BLOCKDEV_ON_ERROR_RETRY) && + ops->retry_request_cb) { + blk->retry_timer =3D aio_timer_new(blk->ctx, QEMU_CLOCK_REALTIME, + SCALE_MS, ops->retry_request_cb, + opaque); + } + /* Are we currently quiesced? Should we enforce this right now? */ if (blk->quiesce_counter && ops->drained_begin) { ops->drained_begin(opaque); diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index 8203d7f6f9..b31144aca9 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -66,6 +66,10 @@ typedef struct BlockDevOps { * Runs when the backend's last drain request ends. */ void (*drained_end)(void *opaque); + /* + * Runs when retrying failed requests. + */ + void (*retry_request_cb)(void *opaque); } BlockDevOps; =20 /* This struct is embedded in (the private) BlockBackend struct and contai= ns --=20 2.28.0