From nobody Tue Nov 18 07:42:40 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=1608036705; cv=none; d=zohomail.com; s=zohoarc; b=RMSiF4FM3VGm/SFVamH/rWZxkszWiWkKqnt0/CoaEY53S86THB6ZZydx3F1n1xQVouGXtx7On6nNfbdie+L4BjP9EsVM8uclegtytv2u7cSGcU2+g3fuelr3WVF/KXcHiHSVmVseBP59rAWLOGTKI952GeYvToTwaqdaP1mJ+SE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608036705; 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=JvG+G0ETf2kzcpDVfLOZoep1tCqyHGnu+Ap2Nuv5+ps=; b=Zw/k/XHFXFqdWSWQZmolnBqirvJeo2eKoTuOTj9EnM+S9Ckv3yuS0G9mds/ukDZKQLO0Qxg1YOrLgWuurAw0/KHrYtmpaeg9Fubel5LRGQFAXVpJZUahJEqq7WxoIKy/bvb7IcKUr+TOBoP+LLcNJeGJ8FDrOB3EKVF8zKFKYdM= 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 1608036705427298.09154217563014; Tue, 15 Dec 2020 04:51:45 -0800 (PST) Received: from localhost ([::1]:34626 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kp9WM-0001Rr-UL for importer@patchew.org; Tue, 15 Dec 2020 07:33:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40704) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kp9Te-0007lc-EA; Tue, 15 Dec 2020 07:30:50 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:2999) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kp9TZ-0006vK-F8; Tue, 15 Dec 2020 07:30:50 -0500 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4CwHdf4lLxzhsTL; 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:28 +0800 From: Jiahui Cen To: Subject: [PATCH v4 7/7] virtio_blk: Add support for retry on errors Date: Tue, 15 Dec 2020 20:30:11 +0800 Message-ID: <20201215123011.4048-8-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" Insert failed requests into device's list for later retry and handle queued requests to implement retry_request_cb. Signed-off-by: Jiahui Cen Signed-off-by: Ying Fang --- hw/block/virtio-blk.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index bac2d6fa2b..cf8b350eaf 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -108,6 +108,10 @@ static int virtio_blk_handle_rw_error(VirtIOBlockReq *= req, int error, block_acct_failed(blk_get_stats(s->blk), &req->acct); } virtio_blk_free_request(req); + } else if (action =3D=3D BLOCK_ERROR_ACTION_RETRY) { + req->mr_next =3D NULL; + req->next =3D s->rq; + s->rq =3D req; } =20 blk_error_action(s->blk, action, is_read, error); @@ -149,6 +153,7 @@ static void virtio_blk_rw_complete(void *opaque, int re= t) } } =20 + blk_error_retry_reset_timeout(s->blk); virtio_blk_req_complete(req, VIRTIO_BLK_S_OK); block_acct_done(blk_get_stats(s->blk), &req->acct); virtio_blk_free_request(req); @@ -828,12 +833,12 @@ static void virtio_blk_handle_output(VirtIODevice *vd= ev, VirtQueue *vq) =20 void virtio_blk_process_queued_requests(VirtIOBlock *s, bool is_bh) { - VirtIOBlockReq *req =3D s->rq; + VirtIOBlockReq *req; MultiReqBuffer mrb =3D {}; =20 - s->rq =3D NULL; - aio_context_acquire(blk_get_aio_context(s->conf.conf.blk)); + req =3D s->rq; + s->rq =3D NULL; while (req) { VirtIOBlockReq *next =3D req->next; if (virtio_blk_handle_request(req, &mrb)) { @@ -1134,8 +1139,16 @@ static void virtio_blk_resize(void *opaque) aio_bh_schedule_oneshot(qemu_get_aio_context(), virtio_resize_cb, vdev= ); } =20 +static void virtio_blk_retry_request(void *opaque) +{ + VirtIOBlock *s =3D VIRTIO_BLK(opaque); + + virtio_blk_process_queued_requests(s, false); +} + static const BlockDevOps virtio_block_ops =3D { .resize_cb =3D virtio_blk_resize, + .retry_request_cb =3D virtio_blk_retry_request, }; =20 static void virtio_blk_device_realize(DeviceState *dev, Error **errp) --=20 2.28.0