[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v3 22/23] block: split BlockAcctStats creation and se
From: |
Fam Zheng |
Subject: |
[Qemu-devel] [PULL v3 22/23] block: split BlockAcctStats creation and setup |
Date: |
Thu, 8 Jun 2017 19:56:42 +0800 |
From: Paolo Bonzini <address@hidden>
block_acct_destroy is called unconditionally in blk_delete, but there is
no BlockAcctStats function that is called unconditionally in blk_new.
Split block_acct_init in two, so that it will be possible to create a
QemuMutex in block_acct_init and destroy it in block_acct_cleanup.
Cc: Alberto Garcia <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Alberto Garcia <address@hidden>
Signed-off-by: Fam Zheng <address@hidden>
---
block/accounting.c | 13 ++++++++-----
block/block-backend.c | 1 +
blockdev.c | 2 +-
include/block/accounting.h | 3 ++-
4 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/block/accounting.c b/block/accounting.c
index a279e0b..ce6dbf7 100644
--- a/block/accounting.c
+++ b/block/accounting.c
@@ -32,17 +32,20 @@
static QEMUClockType clock_type = QEMU_CLOCK_REALTIME;
static const int qtest_latency_ns = NANOSECONDS_PER_SECOND / 1000;
-void block_acct_init(BlockAcctStats *stats, bool account_invalid,
- bool account_failed)
+void block_acct_init(BlockAcctStats *stats)
{
- stats->account_invalid = account_invalid;
- stats->account_failed = account_failed;
-
if (qtest_enabled()) {
clock_type = QEMU_CLOCK_VIRTUAL;
}
}
+void block_acct_setup(BlockAcctStats *stats, bool account_invalid,
+ bool account_failed)
+{
+ stats->account_invalid = account_invalid;
+ stats->account_failed = account_failed;
+}
+
void block_acct_cleanup(BlockAcctStats *stats)
{
BlockAcctTimedStats *s, *next;
diff --git a/block/block-backend.c b/block/block-backend.c
index be2ddf1..828497e 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -219,6 +219,7 @@ BlockBackend *blk_new(uint64_t perm, uint64_t shared_perm)
qemu_co_mutex_init(&blk->public.throttled_reqs_lock);
qemu_co_queue_init(&blk->public.throttled_reqs[0]);
qemu_co_queue_init(&blk->public.throttled_reqs[1]);
+ block_acct_init(&blk->stats);
notifier_list_init(&blk->remove_bs_notifiers);
notifier_list_init(&blk->insert_bs_notifiers);
diff --git a/blockdev.c b/blockdev.c
index 6e7c8a6..0fa2e7e 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -595,7 +595,7 @@ static BlockBackend *blockdev_init(const char *file, QDict
*bs_opts,
autostart = 0;
}
- block_acct_init(blk_get_stats(blk), account_invalid, account_failed);
+ block_acct_setup(blk_get_stats(blk), account_invalid, account_failed);
if (!parse_stats_intervals(blk_get_stats(blk), interval_list, errp)) {
blk_unref(blk);
diff --git a/include/block/accounting.h b/include/block/accounting.h
index 2089163..55cb06f 100644
--- a/include/block/accounting.h
+++ b/include/block/accounting.h
@@ -61,7 +61,8 @@ typedef struct BlockAcctCookie {
enum BlockAcctType type;
} BlockAcctCookie;
-void block_acct_init(BlockAcctStats *stats, bool account_invalid,
+void block_acct_init(BlockAcctStats *stats);
+void block_acct_setup(BlockAcctStats *stats, bool account_invalid,
bool account_failed);
void block_acct_cleanup(BlockAcctStats *stats);
void block_acct_add_interval(BlockAcctStats *stats, unsigned interval_length);
--
2.9.4
- [Qemu-devel] [PULL v3 13/23] throttle-groups: protect throttled requests with a CoMutex, (continued)
- [Qemu-devel] [PULL v3 13/23] throttle-groups: protect throttled requests with a CoMutex, Fam Zheng, 2017/06/08
- [Qemu-devel] [PULL v3 10/23] block: access io_plugged with atomic ops, Fam Zheng, 2017/06/08
- [Qemu-devel] [PULL v3 14/23] util: add stats64 module, Fam Zheng, 2017/06/08
- [Qemu-devel] [PULL v3 15/23] block: use Stat64 for wr_highest_offset, Fam Zheng, 2017/06/08
- [Qemu-devel] [PULL v3 16/23] block: access write_gen with atomics, Fam Zheng, 2017/06/08
- [Qemu-devel] [PULL v3 19/23] migration/block: reset dirty bitmap before reading, Fam Zheng, 2017/06/08
- [Qemu-devel] [PULL v3 17/23] block: protect tracked_requests and flush_queue with reqs_lock, Fam Zheng, 2017/06/08
- [Qemu-devel] [PULL v3 18/23] block: introduce dirty_bitmap_mutex, Fam Zheng, 2017/06/08
- [Qemu-devel] [PULL v3 20/23] block: protect modification of dirty bitmaps with a mutex, Fam Zheng, 2017/06/08
- [Qemu-devel] [PULL v3 21/23] block: introduce block_account_one_io, Fam Zheng, 2017/06/08
- [Qemu-devel] [PULL v3 22/23] block: split BlockAcctStats creation and setup,
Fam Zheng <=
- [Qemu-devel] [PULL v3 23/23] block: make accounting thread-safe, Fam Zheng, 2017/06/08
- Re: [Qemu-devel] [PULL v3 00/23] Docker and block patches, Peter Maydell, 2017/06/12