As this triggers vq->error_ctx eventfd, we should be a bit more
careful.
 - do not call this if we get unsupported request, just set the
error via request status
 - move it from vhost_blk_set_status() to vhost_blk_handle_host_kick()
to avoid triggering it twice if on vhost_blk_handle_guest_kick()->
vhost_blk_req_handle()->vhost_blk_set_status() path, as
vhost_blk_handle_guest_kick() will already report it

https://virtuozzo.atlassian.net/browse/VSTOR-134034
Signed-off-by: Andrey Zhadchenko <[email protected]>
---
 drivers/vhost/blk.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/vhost/blk.c b/drivers/vhost/blk.c
index 6a1a2bab3bed8..ef39ab92eee11 100644
--- a/drivers/vhost/blk.c
+++ b/drivers/vhost/blk.c
@@ -141,10 +141,8 @@ static inline int vhost_blk_set_status(struct 
vhost_blk_req *req, u8 status)
 
        iov_iter_init(&iter, ITER_DEST, req->status, ARRAY_SIZE(req->status), 
sizeof(status));
        ret = copy_to_iter(&status, sizeof(status), &iter);
-       if (ret != sizeof(status)) {
-               vhostblk_vq_err(req->blk, &req->blk_vq->vq, "Failed to write 
status\n");
+       if (ret != sizeof(status))
                return -EFAULT;
-       }
 
        return 0;
 }
@@ -490,7 +488,6 @@ static int vhost_blk_req_handle(struct vhost_virtqueue *vq,
                vhost_add_used_and_signal(&blk->dev, vq, head, len);
                break;
        default:
-               vhostblk_vq_err(blk, vq, "Unsupported request type %d\n", 
hdr->type);
                status = VIRTIO_BLK_S_UNSUPP;
                ret = vhost_blk_set_status(req, status);
                if (ret)
@@ -597,7 +594,8 @@ static void vhost_blk_handle_host_kick(struct vhost_work 
*work)
                vhost_blk_req_cleanup(req);
 
                status = req->bio_err == 0 ?  VIRTIO_BLK_S_OK : 
VIRTIO_BLK_S_IOERR;
-               (void) vhost_blk_set_status(req, status);
+               if (vhost_blk_set_status(req, status))
+                       vhostblk_vq_err(blk, vq, "Failed to write status");
 
                vhost_add_used(vq, req->head, req->len);
                added = true;
-- 
2.43.5

_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to