mirror of
https://github.com/clearlinux/kvmtool.git
synced 2026-09-04 20:51:28 +00:00
kvm tools: Cleanup virtio_blk_do_io_request I/O error handling
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>
This commit is contained in:
committed by
Will Deacon
parent
3b96de8f0b
commit
f0952e6471
+7
-8
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user