diff options
author | Benoît Canet <benoit.canet@nodalink.com> | 2014-09-05 15:46:18 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2014-09-10 10:41:29 +0200 |
commit | 5366d0c8bc2a8bb7a4e58e75c7e457e86d3d56f6 (patch) | |
tree | c1c927a6277424b5e079ed99b464ca9fbc70ca76 /hw/ide | |
parent | 28298fd3d9df6685c069fa0d03398c8c585a83ea (diff) |
block: Make the block accounting functions operate on BlockAcctStats
This is the next step for decoupling block accounting functions from
BlockDriverState.
In a future commit the BlockAcctStats structure will be moved from
BlockDriverState to the device models structures.
Note that bdrv_get_stats was introduced so device models can retrieve the
BlockAcctStats structure of a BlockDriverState without being aware of it's
layout.
This function should go away when BlockAcctStats will be embedded in the device
models structures.
CC: Kevin Wolf <kwolf@redhat.com>
CC: Stefan Hajnoczi <stefanha@redhat.com>
CC: Keith Busch <keith.busch@intel.com>
CC: Anthony Liguori <aliguori@amazon.com>
CC: "Michael S. Tsirkin" <mst@redhat.com>
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Eric Blake <eblake@redhat.com>
CC: Peter Maydell <peter.maydell@linaro.org>
CC: Michael Tokarev <mjt@tls.msk.ru>
CC: John Snow <jsnow@redhat.com>
CC: Markus Armbruster <armbru@redhat.com>
CC: Alexander Graf <agraf@suse.de>
CC: Max Reitz <mreitz@redhat.com>
Signed-off-by: Benoît Canet <benoit.canet@nodalink.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'hw/ide')
-rw-r--r-- | hw/ide/ahci.c | 3 | ||||
-rw-r--r-- | hw/ide/atapi.c | 18 | ||||
-rw-r--r-- | hw/ide/core.c | 24 | ||||
-rw-r--r-- | hw/ide/macio.c | 19 |
4 files changed, 37 insertions, 27 deletions
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 9f434b1b91..ba69de30e0 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -809,7 +809,8 @@ static void ncq_cb(void *opaque, int ret) DPRINTF(ncq_tfs->drive->port_no, "NCQ transfer tag %d finished\n", ncq_tfs->tag); - bdrv_acct_done(ncq_tfs->drive->port.ifs[0].bs, &ncq_tfs->acct); + block_acct_done(bdrv_get_stats(ncq_tfs->drive->port.ifs[0].bs), + &ncq_tfs->acct); qemu_sglist_destroy(&ncq_tfs->sglist); ncq_tfs->used = 0; } diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c index 4b15af1ac5..6d52cda4cc 100644 --- a/hw/ide/atapi.c +++ b/hw/ide/atapi.c @@ -110,14 +110,16 @@ static int cd_read_sector(IDEState *s, int lba, uint8_t *buf, int sector_size) switch(sector_size) { case 2048: - bdrv_acct_start(s->bs, &s->acct, 4 * BDRV_SECTOR_SIZE, BLOCK_ACCT_READ); + block_acct_start(bdrv_get_stats(s->bs), &s->acct, + 4 * BDRV_SECTOR_SIZE, BLOCK_ACCT_READ); ret = bdrv_read(s->bs, (int64_t)lba << 2, buf, 4); - bdrv_acct_done(s->bs, &s->acct); + block_acct_done(bdrv_get_stats(s->bs), &s->acct); break; case 2352: - bdrv_acct_start(s->bs, &s->acct, 4 * BDRV_SECTOR_SIZE, BLOCK_ACCT_READ); + block_acct_start(bdrv_get_stats(s->bs), &s->acct, + 4 * BDRV_SECTOR_SIZE, BLOCK_ACCT_READ); ret = bdrv_read(s->bs, (int64_t)lba << 2, buf + 16, 4); - bdrv_acct_done(s->bs, &s->acct); + block_acct_done(bdrv_get_stats(s->bs), &s->acct); if (ret < 0) return ret; cd_data_to_raw(buf, lba); @@ -253,7 +255,8 @@ static void ide_atapi_cmd_reply(IDEState *s, int size, int max_size) s->io_buffer_index = 0; if (s->atapi_dma) { - bdrv_acct_start(s->bs, &s->acct, size, BLOCK_ACCT_READ); + block_acct_start(bdrv_get_stats(s->bs), &s->acct, size, + BLOCK_ACCT_READ); s->status = READY_STAT | SEEK_STAT | DRQ_STAT; ide_start_dma(s, ide_atapi_cmd_read_dma_cb); } else { @@ -354,7 +357,7 @@ static void ide_atapi_cmd_read_dma_cb(void *opaque, int ret) return; eot: - bdrv_acct_done(s->bs, &s->acct); + block_acct_done(bdrv_get_stats(s->bs), &s->acct); ide_set_inactive(s, false); } @@ -369,7 +372,8 @@ static void ide_atapi_cmd_read_dma(IDEState *s, int lba, int nb_sectors, s->io_buffer_size = 0; s->cd_sector_size = sector_size; - bdrv_acct_start(s->bs, &s->acct, s->packet_transfer_size, BLOCK_ACCT_READ); + block_acct_start(bdrv_get_stats(s->bs), &s->acct, s->packet_transfer_size, + BLOCK_ACCT_READ); /* XXX: check if BUSY_STAT should be set */ s->status = READY_STAT | SEEK_STAT | DRQ_STAT | BUSY_STAT; diff --git a/hw/ide/core.c b/hw/ide/core.c index 43b4c1bd98..6fba056783 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -568,7 +568,7 @@ static void ide_sector_read_cb(void *opaque, int ret) s->pio_aiocb = NULL; s->status &= ~BUSY_STAT; - bdrv_acct_done(s->bs, &s->acct); + block_acct_done(bdrv_get_stats(s->bs), &s->acct); if (ret != 0) { if (ide_handle_rw_error(s, -ret, IDE_RETRY_PIO | IDE_RETRY_READ)) { @@ -624,7 +624,8 @@ void ide_sector_read(IDEState *s) s->iov.iov_len = n * BDRV_SECTOR_SIZE; qemu_iovec_init_external(&s->qiov, &s->iov, 1); - bdrv_acct_start(s->bs, &s->acct, n * BDRV_SECTOR_SIZE, BLOCK_ACCT_READ); + block_acct_start(bdrv_get_stats(s->bs), &s->acct, + n * BDRV_SECTOR_SIZE, BLOCK_ACCT_READ); s->pio_aiocb = bdrv_aio_readv(s->bs, sector_num, &s->qiov, n, ide_sector_read_cb, s); } @@ -756,7 +757,7 @@ void ide_dma_cb(void *opaque, int ret) eot: if (s->dma_cmd == IDE_DMA_READ || s->dma_cmd == IDE_DMA_WRITE) { - bdrv_acct_done(s->bs, &s->acct); + block_acct_done(bdrv_get_stats(s->bs), &s->acct); } ide_set_inactive(s, stay_active); } @@ -770,12 +771,12 @@ static void ide_sector_start_dma(IDEState *s, enum ide_dma_cmd dma_cmd) switch (dma_cmd) { case IDE_DMA_READ: - bdrv_acct_start(s->bs, &s->acct, s->nsector * BDRV_SECTOR_SIZE, - BLOCK_ACCT_READ); + block_acct_start(bdrv_get_stats(s->bs), &s->acct, + s->nsector * BDRV_SECTOR_SIZE, BLOCK_ACCT_READ); break; case IDE_DMA_WRITE: - bdrv_acct_start(s->bs, &s->acct, s->nsector * BDRV_SECTOR_SIZE, - BLOCK_ACCT_WRITE); + block_acct_start(bdrv_get_stats(s->bs), &s->acct, + s->nsector * BDRV_SECTOR_SIZE, BLOCK_ACCT_WRITE); break; default: break; @@ -802,7 +803,7 @@ static void ide_sector_write_cb(void *opaque, int ret) IDEState *s = opaque; int n; - bdrv_acct_done(s->bs, &s->acct); + block_acct_done(bdrv_get_stats(s->bs), &s->acct); s->pio_aiocb = NULL; s->status &= ~BUSY_STAT; @@ -869,7 +870,8 @@ void ide_sector_write(IDEState *s) s->iov.iov_len = n * BDRV_SECTOR_SIZE; qemu_iovec_init_external(&s->qiov, &s->iov, 1); - bdrv_acct_start(s->bs, &s->acct, n * BDRV_SECTOR_SIZE, BLOCK_ACCT_READ); + block_acct_start(bdrv_get_stats(s->bs), &s->acct, + n * BDRV_SECTOR_SIZE, BLOCK_ACCT_READ); s->pio_aiocb = bdrv_aio_writev(s->bs, sector_num, &s->qiov, n, ide_sector_write_cb, s); } @@ -888,7 +890,7 @@ static void ide_flush_cb(void *opaque, int ret) } if (s->bs) { - bdrv_acct_done(s->bs, &s->acct); + block_acct_done(bdrv_get_stats(s->bs), &s->acct); } s->status = READY_STAT | SEEK_STAT; ide_cmd_done(s); @@ -903,7 +905,7 @@ void ide_flush_cache(IDEState *s) } s->status |= BUSY_STAT; - bdrv_acct_start(s->bs, &s->acct, 0, BLOCK_ACCT_FLUSH); + block_acct_start(bdrv_get_stats(s->bs), &s->acct, 0, BLOCK_ACCT_FLUSH); s->pio_aiocb = bdrv_aio_flush(s->bs, ide_flush_cb, s); } diff --git a/hw/ide/macio.c b/hw/ide/macio.c index 1b653aeeda..cefc85cf12 100644 --- a/hw/ide/macio.c +++ b/hw/ide/macio.c @@ -171,7 +171,7 @@ static void pmac_ide_atapi_transfer_cb(void *opaque, int ret) done: MACIO_DPRINTF("done DMA\n"); - bdrv_acct_done(s->bs, &s->acct); + block_acct_done(bdrv_get_stats(s->bs), &s->acct); io->dma_end(opaque); } @@ -352,7 +352,7 @@ static void pmac_ide_transfer_cb(void *opaque, int ret) done: if (s->dma_cmd == IDE_DMA_READ || s->dma_cmd == IDE_DMA_WRITE) { - bdrv_acct_done(s->bs, &s->acct); + block_acct_done(bdrv_get_stats(s->bs), &s->acct); } io->dma_end(io); } @@ -370,8 +370,8 @@ static void pmac_ide_transfer(DBDMA_io *io) /* Handle non-block ATAPI DMA transfers */ if (s->lba == -1) { s->io_buffer_size = MIN(io->len, s->packet_transfer_size); - bdrv_acct_start(s->bs, &s->acct, s->io_buffer_size, - BLOCK_ACCT_READ); + block_acct_start(bdrv_get_stats(s->bs), &s->acct, s->io_buffer_size, + BLOCK_ACCT_READ); MACIO_DPRINTF("non-block ATAPI DMA transfer size: %d\n", s->io_buffer_size); @@ -382,22 +382,25 @@ static void pmac_ide_transfer(DBDMA_io *io) m->dma_active = false; MACIO_DPRINTF("end of non-block ATAPI DMA transfer\n"); - bdrv_acct_done(s->bs, &s->acct); + block_acct_done(bdrv_get_stats(s->bs), &s->acct); io->dma_end(io); return; } - bdrv_acct_start(s->bs, &s->acct, io->len, BLOCK_ACCT_READ); + block_acct_start(bdrv_get_stats(s->bs), &s->acct, io->len, + BLOCK_ACCT_READ); pmac_ide_atapi_transfer_cb(io, 0); return; } switch (s->dma_cmd) { case IDE_DMA_READ: - bdrv_acct_start(s->bs, &s->acct, io->len, BLOCK_ACCT_READ); + block_acct_start(bdrv_get_stats(s->bs), &s->acct, io->len, + BLOCK_ACCT_READ); break; case IDE_DMA_WRITE: - bdrv_acct_start(s->bs, &s->acct, io->len, BLOCK_ACCT_WRITE); + block_acct_start(bdrv_get_stats(s->bs), &s->acct, io->len, + BLOCK_ACCT_WRITE); break; default: break; |