All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiahui Cen <cenjiahui@huawei.com>
To: <qemu-devel@nongnu.org>
Cc: Kevin Wolf <kwolf@redhat.com>,
	cenjiahui@huawei.com, zhang.zhanghailiang@huawei.com,
	qemu-block@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	Max Reitz <mreitz@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	fangying1@huawei.com, John Snow <jsnow@redhat.com>
Subject: [PATCH v5 3/9] block-backend: Add device specific retry callback
Date: Fri, 5 Feb 2021 18:13:09 +0800	[thread overview]
Message-ID: <20210205101315.13042-4-cenjiahui@huawei.com> (raw)
In-Reply-To: <20210205101315.13042-1-cenjiahui@huawei.com>

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 <cenjiahui@huawei.com>
Signed-off-by: Ying Fang <fangying1@huawei.com>
---
 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 3a9d55cbe3..a8bfaf6e4a 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -995,6 +995,14 @@ void blk_set_dev_ops(BlockBackend *blk, const BlockDevOps *ops,
     blk->dev_ops = ops;
     blk->dev_opaque = opaque;
 
+    if ((blk->on_read_error == BLOCKDEV_ON_ERROR_RETRY ||
+         blk->on_write_error == BLOCKDEV_ON_ERROR_RETRY) &&
+        ops->retry_request_cb) {
+        blk->retry_timer = 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 880e903293..d806852db5 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;
 
 /* This struct is embedded in (the private) BlockBackend struct and contains
-- 
2.29.2



  parent reply	other threads:[~2021-02-05 10:24 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-05 10:13 [PATCH v5 0/9] block: Add retry for werror=/rerror= mechanism Jiahui Cen
2021-02-05 10:13 ` [PATCH v5 1/9] qapi/block-core: Add retry option for error action Jiahui Cen
2021-02-22 17:22   ` Stefan Hajnoczi
2021-02-05 10:13 ` [PATCH v5 2/9] block-backend: Introduce retry timer Jiahui Cen
2021-02-05 10:13 ` Jiahui Cen [this message]
2021-02-22 17:24   ` [PATCH v5 3/9] block-backend: Add device specific retry callback Stefan Hajnoczi
2021-02-05 10:13 ` [PATCH v5 4/9] block-backend: Enable retry action on errors Jiahui Cen
2021-02-22 17:12   ` Stefan Hajnoczi
2021-02-05 10:13 ` [PATCH v5 5/9] block-backend: Add timeout support for retry Jiahui Cen
2021-02-05 10:13 ` [PATCH v5 6/9] block: Add error retry param setting Jiahui Cen
2021-02-22 17:16   ` Stefan Hajnoczi
2021-02-05 10:13 ` [PATCH v5 7/9] virtio_blk: Add support for retry on errors Jiahui Cen
2021-02-05 10:13 ` [PATCH v5 8/9] scsi-bus: Refactor the code that retries requests Jiahui Cen
2021-02-05 10:13 ` [PATCH v5 9/9] scsi-disk: Add support for retry on errors Jiahui Cen
2021-02-10  1:22 ` [PATCH v5 0/9] block: Add retry for werror=/rerror= mechanism Jiahui Cen
2021-02-22 11:00   ` Stefan Hajnoczi
2021-02-22 17:25 ` Stefan Hajnoczi
2021-02-23  9:40 ` Stefan Hajnoczi
2021-02-23 10:20   ` Jiahui Cen
2021-02-23 13:41   ` Eric Blake
2021-02-25 17:24     ` Vladimir Sementsov-Ogievskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210205101315.13042-4-cenjiahui@huawei.com \
    --to=cenjiahui@huawei.com \
    --cc=armbru@redhat.com \
    --cc=fangying1@huawei.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=zhang.zhanghailiang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.