From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:49755) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gt4Ux-00021L-4a for qemu-devel@nongnu.org; Mon, 11 Feb 2019 00:51:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gt4Uw-0002gs-9d for qemu-devel@nongnu.org; Mon, 11 Feb 2019 00:51:19 -0500 From: Stefan Hajnoczi Date: Mon, 11 Feb 2019 13:50:35 +0800 Message-Id: <20190211055040.13528-5-stefanha@redhat.com> In-Reply-To: <20190211055040.13528-1-stefanha@redhat.com> References: <20190211055040.13528-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 4/9] virtio-blk: add acct_failed param to virtio_blk_handle_rw_error() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Marcel Apfelbaum , Peter Maydell , Thomas Huth , Stefan Hajnoczi , Eduardo Habkost , Laurent Vivier , Max Reitz , "Michael S. Tsirkin" , Paolo Bonzini , qemu-block@nongnu.org, Kevin Wolf , Stefano Garzarella , Pankaj Gupta From: Stefano Garzarella We add acct_failed param in order to use virtio_blk_handle_rw_error() also when is not required to call block_acct_failed(). (eg. a discard operation is failed) Reviewed-by: Michael S. Tsirkin Reviewed-by: Stefan Hajnoczi Signed-off-by: Stefano Garzarella Acked-by: Pankaj Gupta Message-id: 20190208134950.187665-2-sgarzare@redhat.com Signed-off-by: Stefan Hajnoczi --- hw/block/virtio-blk.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 843bb2bec8..c95a6f4c9b 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -61,7 +61,7 @@ static void virtio_blk_req_complete(VirtIOBlockReq *req= , unsigned char status) } =20 static int virtio_blk_handle_rw_error(VirtIOBlockReq *req, int error, - bool is_read) + bool is_read, bool acct_failed) { VirtIOBlock *s =3D req->dev; BlockErrorAction action =3D blk_get_error_action(s->blk, is_read, er= ror); @@ -74,7 +74,9 @@ static int virtio_blk_handle_rw_error(VirtIOBlockReq *r= eq, int error, s->rq =3D req; } else if (action =3D=3D BLOCK_ERROR_ACTION_REPORT) { virtio_blk_req_complete(req, VIRTIO_BLK_S_IOERR); - block_acct_failed(blk_get_stats(s->blk), &req->acct); + if (acct_failed) { + block_acct_failed(blk_get_stats(s->blk), &req->acct); + } virtio_blk_free_request(req); } =20 @@ -112,7 +114,7 @@ static void virtio_blk_rw_complete(void *opaque, int = ret) * the memory until the request is completed (which will * happen on the other side of the migration). */ - if (virtio_blk_handle_rw_error(req, -ret, is_read)) { + if (virtio_blk_handle_rw_error(req, -ret, is_read, true)) { continue; } } @@ -131,7 +133,7 @@ static void virtio_blk_flush_complete(void *opaque, i= nt ret) =20 aio_context_acquire(blk_get_aio_context(s->conf.conf.blk)); if (ret) { - if (virtio_blk_handle_rw_error(req, -ret, 0)) { + if (virtio_blk_handle_rw_error(req, -ret, 0, true)) { goto out; } } --=20 2.20.1