diff options
author | Alberto Garcia <berto@igalia.com> | 2015-10-28 17:33:04 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2015-11-12 16:22:45 +0100 |
commit | 362e9299b34b3101aaa20f20363441c9f055fa5e (patch) | |
tree | 7c5da8ee5a70455154db577a42878555d445f54c /block/accounting.c | |
parent | 7ee12dafe96a86dfa96af38cea1289305e429a55 (diff) | |
download | qemu-362e9299b34b3101aaa20f20363441c9f055fa5e.zip qemu-362e9299b34b3101aaa20f20363441c9f055fa5e.tar.gz qemu-362e9299b34b3101aaa20f20363441c9f055fa5e.tar.bz2 |
block: Allow configuring whether to account failed and invalid ops
This patch adds two options, "stats-account-invalid" and
"stats-account-failed", that can be used to decide whether invalid and
failed I/O operations must be used when collecting statistics for
latency and last access time.
Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: ebc7e5966511a342cad428a392c5f5ad56b15213.1446044837.git.berto@igalia.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/accounting.c')
-rw-r--r-- | block/accounting.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/block/accounting.c b/block/accounting.c index 49a9444..923aeaf 100644 --- a/block/accounting.c +++ b/block/accounting.c @@ -28,6 +28,13 @@ static QEMUClockType clock_type = QEMU_CLOCK_REALTIME; +void block_acct_init(BlockAcctStats *stats, bool account_invalid, + bool account_failed) +{ + stats->account_invalid = account_invalid; + stats->account_failed = account_failed; +} + void block_acct_start(BlockAcctStats *stats, BlockAcctCookie *cookie, int64_t bytes, enum BlockAcctType type) { @@ -53,13 +60,17 @@ void block_acct_done(BlockAcctStats *stats, BlockAcctCookie *cookie) void block_acct_failed(BlockAcctStats *stats, BlockAcctCookie *cookie) { - int64_t time_ns = qemu_clock_get_ns(clock_type); - assert(cookie->type < BLOCK_MAX_IOTYPE); stats->failed_ops[cookie->type]++; - stats->total_time_ns[cookie->type] += time_ns - cookie->start_time_ns; - stats->last_access_time_ns = time_ns; + + if (stats->account_failed) { + int64_t time_ns = qemu_clock_get_ns(clock_type); + int64_t latency_ns = time_ns - cookie->start_time_ns; + + stats->total_time_ns[cookie->type] += latency_ns; + stats->last_access_time_ns = time_ns; + } } void block_acct_invalid(BlockAcctStats *stats, enum BlockAcctType type) @@ -72,7 +83,10 @@ void block_acct_invalid(BlockAcctStats *stats, enum BlockAcctType type) * therefore there's no actual I/O involved. */ stats->invalid_ops[type]++; - stats->last_access_time_ns = qemu_clock_get_ns(clock_type); + + if (stats->account_invalid) { + stats->last_access_time_ns = qemu_clock_get_ns(clock_type); + } } void block_acct_merge_done(BlockAcctStats *stats, enum BlockAcctType type, |