target/s390x: Fix typo
[qemu/ar7.git] / include / block / accounting.h
blob20891639d5307b8d8f50c1d2eaeac03b38a610e6
1 /*
2 * QEMU System Emulator block accounting
4 * Copyright (c) 2011 Christoph Hellwig
5 * Copyright (c) 2015 Igalia, S.L.
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 * THE SOFTWARE.
25 #ifndef BLOCK_ACCOUNTING_H
26 #define BLOCK_ACCOUNTING_H
28 #include "qemu/timed-average.h"
30 typedef struct BlockAcctTimedStats BlockAcctTimedStats;
32 enum BlockAcctType {
33 BLOCK_ACCT_READ,
34 BLOCK_ACCT_WRITE,
35 BLOCK_ACCT_FLUSH,
36 BLOCK_MAX_IOTYPE,
39 struct BlockAcctTimedStats {
40 TimedAverage latency[BLOCK_MAX_IOTYPE];
41 unsigned interval_length; /* in seconds */
42 QSLIST_ENTRY(BlockAcctTimedStats) entries;
45 typedef struct BlockAcctStats {
46 uint64_t nr_bytes[BLOCK_MAX_IOTYPE];
47 uint64_t nr_ops[BLOCK_MAX_IOTYPE];
48 uint64_t invalid_ops[BLOCK_MAX_IOTYPE];
49 uint64_t failed_ops[BLOCK_MAX_IOTYPE];
50 uint64_t total_time_ns[BLOCK_MAX_IOTYPE];
51 uint64_t merged[BLOCK_MAX_IOTYPE];
52 int64_t last_access_time_ns;
53 QSLIST_HEAD(, BlockAcctTimedStats) intervals;
54 bool account_invalid;
55 bool account_failed;
56 } BlockAcctStats;
58 typedef struct BlockAcctCookie {
59 int64_t bytes;
60 int64_t start_time_ns;
61 enum BlockAcctType type;
62 } BlockAcctCookie;
64 void block_acct_init(BlockAcctStats *stats, bool account_invalid,
65 bool account_failed);
66 void block_acct_cleanup(BlockAcctStats *stats);
67 void block_acct_add_interval(BlockAcctStats *stats, unsigned interval_length);
68 BlockAcctTimedStats *block_acct_interval_next(BlockAcctStats *stats,
69 BlockAcctTimedStats *s);
70 void block_acct_start(BlockAcctStats *stats, BlockAcctCookie *cookie,
71 int64_t bytes, enum BlockAcctType type);
72 void block_acct_done(BlockAcctStats *stats, BlockAcctCookie *cookie);
73 void block_acct_failed(BlockAcctStats *stats, BlockAcctCookie *cookie);
74 void block_acct_invalid(BlockAcctStats *stats, enum BlockAcctType type);
75 void block_acct_merge_done(BlockAcctStats *stats, enum BlockAcctType type,
76 int num_requests);
77 int64_t block_acct_idle_time_ns(BlockAcctStats *stats);
78 double block_acct_queue_depth(BlockAcctTimedStats *stats,
79 enum BlockAcctType type);
81 #endif