[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 01/34] block/accounting: Use lock guard macros
From: |
Kevin Wolf |
Subject: |
[PULL 01/34] block/accounting: Use lock guard macros |
Date: |
Fri, 11 Dec 2020 18:07:39 +0100 |
From: Gan Qixin <ganqixin@huawei.com>
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>
---
block/accounting.c | 32 +++++++++++++++-----------------
1 file 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;
}
--
2.29.2
- [PULL 00/34] Block layer patches, Kevin Wolf, 2020/12/11
- [PULL 02/34] block/curl: Use lock guard macros, Kevin Wolf, 2020/12/11
- [PULL 01/34] block/accounting: Use lock guard macros,
Kevin Wolf <=
- [PULL 04/34] block/iscsi: Use lock guard macros, Kevin Wolf, 2020/12/11
- [PULL 03/34] block/throttle-groups: Use lock guard macros, Kevin Wolf, 2020/12/11
- [PULL 06/34] fuse: Allow exporting BDSs via FUSE, Kevin Wolf, 2020/12/11
- [PULL 08/34] fuse: Allow growable exports, Kevin Wolf, 2020/12/11
- [PULL 07/34] fuse: Implement standard FUSE operations, Kevin Wolf, 2020/12/11
- [PULL 05/34] meson: Detect libfuse, Kevin Wolf, 2020/12/11
- [PULL 09/34] fuse: (Partially) implement fallocate(), Kevin Wolf, 2020/12/11
- [PULL 10/34] fuse: Implement hole detection through lseek, Kevin Wolf, 2020/12/11
- [PULL 12/34] iotests: Do not pipe _make_test_img, Kevin Wolf, 2020/12/11
- [PULL 11/34] iotests: Do not needlessly filter _make_test_img, Kevin Wolf, 2020/12/11