[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 06/18] block: access io_plugged with atomic ops
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 06/18] block: access io_plugged with atomic ops |
Date: |
Thu, 25 May 2017 18:32:13 +0200 |
Reviewed-by: Stefan Hajnoczi <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
block/io.c | 4 ++--
include/block/block_int.h | 8 +++++---
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/block/io.c b/block/io.c
index 3a98b02..f34d030 100644
--- a/block/io.c
+++ b/block/io.c
@@ -2658,7 +2658,7 @@ void bdrv_io_plug(BlockDriverState *bs)
bdrv_io_plug(child->bs);
}
- if (bs->io_plugged++ == 0) {
+ if (atomic_fetch_inc(&bs->io_plugged) == 0) {
BlockDriver *drv = bs->drv;
if (drv && drv->bdrv_io_plug) {
drv->bdrv_io_plug(bs);
@@ -2671,7 +2671,7 @@ void bdrv_io_unplug(BlockDriverState *bs)
BdrvChild *child;
assert(bs->io_plugged);
- if (--bs->io_plugged == 0) {
+ if (atomic_fetch_dec(&bs->io_plugged) == 1) {
BlockDriver *drv = bs->drv;
if (drv && drv->bdrv_io_unplug) {
drv->bdrv_io_unplug(bs);
diff --git a/include/block/block_int.h b/include/block/block_int.h
index b690e58..d54ed75 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -611,9 +611,6 @@ struct BlockDriverState {
uint64_t write_threshold_offset;
NotifierWithReturn write_threshold_notifier;
- /* counter for nested bdrv_io_plug */
- unsigned io_plugged;
-
QLIST_HEAD(, BdrvTrackedRequest) tracked_requests;
CoQueue flush_queue; /* Serializing flush queue */
bool active_flush_req; /* Flush request in flight? */
@@ -639,6 +636,11 @@ struct BlockDriverState {
*/
bool wakeup;
+ /* counter for nested bdrv_io_plug.
+ * Accessed with atomic ops.
+ */
+ unsigned io_plugged;
+
/* do we need to tell the quest if we have a volatile write cache? */
int enable_write_cache;
--
1.8.3.1
- [Qemu-devel] [PATCH v3 00/18] Block layer thread safety, part 1, Paolo Bonzini, 2017/05/25
- [Qemu-devel] [PATCH 01/18] block: access copy_on_read with atomic ops, Paolo Bonzini, 2017/05/25
- [Qemu-devel] [PATCH 04/18] block: access serialising_in_flight with atomic ops, Paolo Bonzini, 2017/05/25
- [Qemu-devel] [PATCH 02/18] block: access quiesce_counter with atomic ops, Paolo Bonzini, 2017/05/25
- [Qemu-devel] [PATCH 05/18] block: access wakeup with atomic ops, Paolo Bonzini, 2017/05/25
- [Qemu-devel] [PATCH 03/18] block: access io_limits_disabled with atomic ops, Paolo Bonzini, 2017/05/25
- [Qemu-devel] [PATCH 09/18] throttle-groups: protect throttled requests with a CoMutex, Paolo Bonzini, 2017/05/25
- [Qemu-devel] [PATCH 06/18] block: access io_plugged with atomic ops,
Paolo Bonzini <=
- [Qemu-devel] [PATCH 07/18] throttle-groups: only start one coroutine from drained_begin, Paolo Bonzini, 2017/05/25
- [Qemu-devel] [PATCH 08/18] throttle-groups: do not use qemu_co_enter_next, Paolo Bonzini, 2017/05/25
- [Qemu-devel] [PATCH 11/18] block: use Stat64 for wr_highest_offset, Paolo Bonzini, 2017/05/25
- [Qemu-devel] [PATCH 10/18] util: add stats64 module, Paolo Bonzini, 2017/05/25
- [Qemu-devel] [PATCH 12/18] block: access write_gen with atomics, Paolo Bonzini, 2017/05/25
- [Qemu-devel] [PATCH 13/18] block: protect tracked_requests and flush_queue with reqs_lock, Paolo Bonzini, 2017/05/25
- [Qemu-devel] [PATCH 15/18] migration/block: reset dirty bitmap before reading, Paolo Bonzini, 2017/05/25
- [Qemu-devel] [PATCH 17/18] block: introduce block_account_one_io, Paolo Bonzini, 2017/05/25
- [Qemu-devel] [PATCH 18/18] block: make accounting thread-safe, Paolo Bonzini, 2017/05/25
- [Qemu-devel] [PATCH 16/18] block: protect modification of dirty bitmaps with a mutex, Paolo Bonzini, 2017/05/25