mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
block: explicit I/O accounting
Decouple the I/O accounting from bdrv_aio_readv/writev/flush and make the hardware models call directly into the accounting helpers. This means: - we do not count internal requests from image formats in addition to guest originating I/O - we do not double count I/O ops if the device model handles it chunk wise - we only account I/O once it actuall is done - can extent I/O accounting to synchronous or coroutine I/O easily - implement I/O latency tracking easily (see the next patch) I've conveted the existing device model callers to the new model, device models that are using synchronous I/O and weren't accounted before haven't been updated yet. Also scsi hasn't been converted to the end-to-end accounting as I want to defer that after the pending scsi layer overhaul. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
2f4b759367
commit
a597e79ce1
12 changed files with 171 additions and 50 deletions
|
@ -79,6 +79,7 @@ struct ioreq {
|
|||
|
||||
struct XenBlkDev *blkdev;
|
||||
QLIST_ENTRY(ioreq) list;
|
||||
BlockAcctCookie acct;
|
||||
};
|
||||
|
||||
struct XenBlkDev {
|
||||
|
@ -401,6 +402,7 @@ static void qemu_aio_complete(void *opaque, int ret)
|
|||
ioreq->status = ioreq->aio_errors ? BLKIF_RSP_ERROR : BLKIF_RSP_OKAY;
|
||||
ioreq_unmap(ioreq);
|
||||
ioreq_finish(ioreq);
|
||||
bdrv_acct_done(ioreq->blkdev->bs, &ioreq->acct);
|
||||
qemu_bh_schedule(ioreq->blkdev->bh);
|
||||
}
|
||||
|
||||
|
@ -419,6 +421,7 @@ static int ioreq_runio_qemu_aio(struct ioreq *ioreq)
|
|||
|
||||
switch (ioreq->req.operation) {
|
||||
case BLKIF_OP_READ:
|
||||
bdrv_acct_start(blkdev->bs, &ioreq->acct, ioreq->v.size, BDRV_ACCT_READ);
|
||||
ioreq->aio_inflight++;
|
||||
bdrv_aio_readv(blkdev->bs, ioreq->start / BLOCK_SIZE,
|
||||
&ioreq->v, ioreq->v.size / BLOCK_SIZE,
|
||||
|
@ -429,6 +432,8 @@ static int ioreq_runio_qemu_aio(struct ioreq *ioreq)
|
|||
if (!ioreq->req.nr_segments) {
|
||||
break;
|
||||
}
|
||||
|
||||
bdrv_acct_start(blkdev->bs, &ioreq->acct, ioreq->v.size, BDRV_ACCT_WRITE);
|
||||
ioreq->aio_inflight++;
|
||||
bdrv_aio_writev(blkdev->bs, ioreq->start / BLOCK_SIZE,
|
||||
&ioreq->v, ioreq->v.size / BLOCK_SIZE,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue