]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tools: Cleanup virtio_blk_do_io_request I/O error handling
authorPekka Enberg <penberg@kernel.org>
Fri, 8 Apr 2011 17:18:14 +0000 (20:18 +0300)
committerPekka Enberg <penberg@kernel.org>
Fri, 8 Apr 2011 17:18:14 +0000 (20:18 +0300)
There's no point in keeping track of I/O error count when a simple boolean flag
is all we need.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
tools/kvm/virtio-blk.c

index b61b9d43b04f2ff8b7ba470d9ba467de4e752554..d14a04b4b3c70bd30c9b46c3b2d68280a97e5286 100644 (file)
@@ -105,18 +105,20 @@ static bool virtio_blk_do_io_request(struct kvm *self, struct virt_queue *queue)
        struct virtio_blk_outhdr *req;
        uint32_t block_len, block_cnt;
        uint16_t out, in, head;
-       int err, err_cnt, i;
        uint8_t *status;
+       bool io_error;
        void *block;
+       int err, i;
 
-       head                    = virt_queue__get_iov(queue, iov, &out, &in, self);
+       io_error        = false;
+
+       head            = virt_queue__get_iov(queue, iov, &out, &in, self);
 
        /* head */
        req             = iov[0].iov_base;
 
        /* block */
        block_cnt       = 0;
-       err_cnt         = 0;
 
        for (i = 1; i < out + in - 1; i++) {
                block           = iov[i].iov_base;
@@ -131,19 +133,16 @@ static bool virtio_blk_do_io_request(struct kvm *self, struct virt_queue *queue)
                        break;
                default:
                        warning("request type %d", req->type);
-                       err     = -1;
+                       io_error        = true;
                }
 
-               if (err)
-                       err_cnt++;
-
                req->sector     += block_len >> SECTOR_SHIFT;
                block_cnt       += block_len;
        }
 
        /* status */
        status                  = iov[out + in - 1].iov_base;
-       *status                 = err_cnt ? VIRTIO_BLK_S_IOERR : VIRTIO_BLK_S_OK;
+       *status                 = io_error ? VIRTIO_BLK_S_IOERR : VIRTIO_BLK_S_OK;
 
        virt_queue__set_used_elem(queue, head, block_cnt);