From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>, Fam Zheng <famz@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Max Reitz <mreitz@redhat.com>
Subject: [Qemu-devel] [PATCH 1/3] dataplane: add bdrv_acct_*() accounting
Date: Tue, 10 Jun 2014 09:29:50 +0200 [thread overview]
Message-ID: <1402385392-15035-2-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1402385392-15035-1-git-send-email-stefanha@redhat.com>
bdrv_acct_start() and bdrv_acct_done() must be called in order to update
block device accounting information.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
hw/block/dataplane/virtio-blk.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
index 8ac6049..c5c25cb 100644
--- a/hw/block/dataplane/virtio-blk.c
+++ b/hw/block/dataplane/virtio-blk.c
@@ -32,6 +32,7 @@ typedef struct {
struct iovec bounce_iov; /* used if guest buffers are unaligned */
QEMUIOVector bounce_qiov; /* bounce buffer iovecs */
bool read; /* read or write? */
+ BlockAcctCookie acct; /* block device accounting */
} VirtIOBlockRequest;
struct VirtIOBlockDataPlane {
@@ -103,6 +104,9 @@ static void complete_rdwr(void *opaque, int ret)
*/
vring_push(&req->s->vring, req->elem, len + sizeof(hdr));
notify_guest(req->s);
+ if (likely(ret == 0)) {
+ bdrv_acct_done(req->s->blk->conf.bs, &req->acct);
+ }
g_slice_free(VirtIOBlockRequest, req);
}
@@ -170,9 +174,13 @@ static void do_rdwr_cmd(VirtIOBlockDataPlane *s, bool read,
nb_sectors = qiov->size / BDRV_SECTOR_SIZE;
if (read) {
+ bdrv_acct_start(s->blk->conf.bs, &req->acct,
+ qiov->size, BDRV_ACCT_READ);
bdrv_aio_readv(s->blk->conf.bs, sector_num, qiov, nb_sectors,
complete_rdwr, req);
} else {
+ bdrv_acct_start(s->blk->conf.bs, &req->acct,
+ qiov->size, BDRV_ACCT_WRITE);
bdrv_aio_writev(s->blk->conf.bs, sector_num, qiov, nb_sectors,
complete_rdwr, req);
}
@@ -185,6 +193,7 @@ static void complete_flush(void *opaque, int ret)
if (ret == 0) {
status = VIRTIO_BLK_S_OK;
+ bdrv_acct_done(req->s->blk->conf.bs, &req->acct);
} else {
status = VIRTIO_BLK_S_IOERR;
}
@@ -201,6 +210,7 @@ static void do_flush_cmd(VirtIOBlockDataPlane *s, VirtQueueElement *elem,
req->elem = elem;
req->inhdr = inhdr;
+ bdrv_acct_start(s->blk->conf.bs, &req->acct, 0, BDRV_ACCT_FLUSH);
bdrv_aio_flush(s->blk->conf.bs, complete_flush, req);
}
--
1.9.3
next prev parent reply other threads:[~2014-06-10 8:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-10 7:29 [Qemu-devel] [PATCH 0/3] dataplane: add query-blockstats support Stefan Hajnoczi
2014-06-10 7:29 ` Stefan Hajnoczi [this message]
2014-06-10 7:29 ` [Qemu-devel] [PATCH 2/3] block: make bdrv_query_stats() static Stefan Hajnoczi
2014-06-10 7:29 ` [Qemu-devel] [PATCH 3/3] block: acquire AioContext is qmp_query_blockstats() Stefan Hajnoczi
2014-06-10 9:00 ` [Qemu-devel] [PATCH 0/3] dataplane: add query-blockstats support Paolo Bonzini
2014-06-18 11:10 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1402385392-15035-2-git-send-email-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).