summaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorGan Qixin2020-12-03 08:50:52 +0100
committerKevin Wolf2020-12-11 17:52:39 +0100
commitc37c97366097a5ce1919d6fe12535e5f889b0317 (patch)
treed8f11cef0bcfcfb7856be724876fc96a8507b302 /block
parentMerge remote-tracking branch 'remotes/bonzini-gitlab/tags/for-upstream' into ... (diff)
downloadqemu-c37c97366097a5ce1919d6fe12535e5f889b0317.tar.gz
qemu-c37c97366097a5ce1919d6fe12535e5f889b0317.tar.xz
qemu-c37c97366097a5ce1919d6fe12535e5f889b0317.zip
block/accounting: Use lock guard macros
Replace manual lock()/unlock() calls with lock guard macros (QEMU_LOCK_GUARD/WITH_QEMU_LOCK_GUARD) in block/accounting. Signed-off-by: Gan Qixin <ganqixin@huawei.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20201203075055.127773-2-ganqixin@huawei.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/accounting.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/block/accounting.c b/block/accounting.c
index 8d41c8a83a..2030851d79 100644
--- a/block/accounting.c
+++ b/block/accounting.c
@@ -199,29 +199,27 @@ static void block_account_one_io(BlockAcctStats *stats, BlockAcctCookie *cookie,
return;
}
- qemu_mutex_lock(&stats->lock);
-
- if (failed) {
- stats->failed_ops[cookie->type]++;
- } else {
- stats->nr_bytes[cookie->type] += cookie->bytes;
- stats->nr_ops[cookie->type]++;
- }
+ WITH_QEMU_LOCK_GUARD(&stats->lock) {
+ if (failed) {
+ stats->failed_ops[cookie->type]++;
+ } else {
+ stats->nr_bytes[cookie->type] += cookie->bytes;
+ stats->nr_ops[cookie->type]++;
+ }
- block_latency_histogram_account(&stats->latency_histogram[cookie->type],
- latency_ns);
+ block_latency_histogram_account(&stats->latency_histogram[cookie->type],
+ latency_ns);
- if (!failed || stats->account_failed) {
- stats->total_time_ns[cookie->type] += latency_ns;
- stats->last_access_time_ns = time_ns;
+ if (!failed || stats->account_failed) {
+ stats->total_time_ns[cookie->type] += latency_ns;
+ stats->last_access_time_ns = time_ns;
- QSLIST_FOREACH(s, &stats->intervals, entries) {
- timed_average_account(&s->latency[cookie->type], latency_ns);
+ QSLIST_FOREACH(s, &stats->intervals, entries) {
+ timed_average_account(&s->latency[cookie->type], latency_ns);
+ }
}
}
- qemu_mutex_unlock(&stats->lock);
-
cookie->type = BLOCK_ACCT_NONE;
}