[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v4 17/21] atapi: Account for failed and invalid oper
From: |
Alberto Garcia |
Subject: |
[Qemu-block] [PATCH v4 17/21] atapi: Account for failed and invalid operations |
Date: |
Wed, 28 Oct 2015 17:33:14 +0200 |
Signed-off-by: Alberto Garcia <address@hidden>
---
hw/ide/atapi.c | 31 +++++++++++++++++++------------
1 file changed, 19 insertions(+), 12 deletions(-)
diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c
index 747f466..cf0b78e 100644
--- a/hw/ide/atapi.c
+++ b/hw/ide/atapi.c
@@ -108,27 +108,30 @@ static void cd_data_to_raw(uint8_t *buf, int lba)
static int cd_read_sector(IDEState *s, int lba, uint8_t *buf, int sector_size)
{
int ret;
+ block_acct_start(blk_get_stats(s->blk), &s->acct,
+ 4 * BDRV_SECTOR_SIZE, BLOCK_ACCT_READ);
switch(sector_size) {
case 2048:
- block_acct_start(blk_get_stats(s->blk), &s->acct,
- 4 * BDRV_SECTOR_SIZE, BLOCK_ACCT_READ);
ret = blk_read(s->blk, (int64_t)lba << 2, buf, 4);
- block_acct_done(blk_get_stats(s->blk), &s->acct);
break;
case 2352:
- block_acct_start(blk_get_stats(s->blk), &s->acct,
- 4 * BDRV_SECTOR_SIZE, BLOCK_ACCT_READ);
ret = blk_read(s->blk, (int64_t)lba << 2, buf + 16, 4);
- block_acct_done(blk_get_stats(s->blk), &s->acct);
- if (ret < 0)
- return ret;
- cd_data_to_raw(buf, lba);
+ if (ret >= 0) {
+ cd_data_to_raw(buf, lba);
+ }
break;
default:
- ret = -EIO;
- break;
+ block_acct_invalid(blk_get_stats(s->blk), BLOCK_ACCT_READ);
+ return -EIO;
}
+
+ if (ret < 0) {
+ block_acct_failed(blk_get_stats(s->blk), &s->acct);
+ } else {
+ block_acct_done(blk_get_stats(s->blk), &s->acct);
+ }
+
return ret;
}
@@ -357,7 +360,11 @@ static void ide_atapi_cmd_read_dma_cb(void *opaque, int
ret)
return;
eot:
- block_acct_done(blk_get_stats(s->blk), &s->acct);
+ if (ret < 0) {
+ block_acct_failed(blk_get_stats(s->blk), &s->acct);
+ } else {
+ block_acct_done(blk_get_stats(s->blk), &s->acct);
+ }
ide_set_inactive(s, false);
}
--
2.6.1
- [Qemu-block] [PATCH v4 16/21] xen_disk: Account for failed and invalid operations, (continued)
- [Qemu-block] [PATCH v4 16/21] xen_disk: Account for failed and invalid operations, Alberto Garcia, 2015/10/28
- [Qemu-block] [PATCH v4 11/21] qemu-io: Account for failed, invalid and flush operations, Alberto Garcia, 2015/10/28
- [Qemu-block] [PATCH v4 07/21] block: Allow configuring whether to account failed and invalid ops, Alberto Garcia, 2015/10/28
- [Qemu-block] [PATCH v4 08/21] block: Compute minimum, maximum and average I/O latencies, Alberto Garcia, 2015/10/28
- [Qemu-block] [PATCH v4 21/21] block: Update copyright of the accounting code, Alberto Garcia, 2015/10/28
- [Qemu-block] [PATCH v4 18/21] ide: Account for failed and invalid operations, Alberto Garcia, 2015/10/28
- [Qemu-block] [PATCH v4 19/21] macio: Account for failed operations, Alberto Garcia, 2015/10/28
- [Qemu-block] [PATCH v4 13/21] iotests: Add test for the block device statistics, Alberto Garcia, 2015/10/28
- [Qemu-block] [PATCH v4 15/21] virtio-blk: Account for failed and invalid operations, Alberto Garcia, 2015/10/28
- [Qemu-block] [PATCH v4 20/21] scsi-disk: Account for failed operations, Alberto Garcia, 2015/10/28
- [Qemu-block] [PATCH v4 17/21] atapi: Account for failed and invalid operations,
Alberto Garcia <=
- [Qemu-block] [PATCH v4 12/21] block: Use QEMU_CLOCK_VIRTUAL for the accounting code in qtest mode, Alberto Garcia, 2015/10/28
- [Qemu-block] [PATCH v4 10/21] block: New option to define the intervals for collecting I/O statistics, Alberto Garcia, 2015/10/28
- [Qemu-block] [PATCH v4 14/21] nvme: Account for failed and invalid operations, Alberto Garcia, 2015/10/28