[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH 02/18] block: access quiesce_counter with atomic ops
From: |
Paolo Bonzini |
Subject: |
[Qemu-block] [PATCH 02/18] block: access quiesce_counter with atomic ops |
Date: |
Thu, 11 May 2017 16:41:52 +0200 |
Reviewed-by: Stefan Hajnoczi <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
block/io.c | 4 ++--
include/block/block_int.h | 1 +
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/block/io.c b/block/io.c
index a0de60acbc..3204e08c8f 100644
--- a/block/io.c
+++ b/block/io.c
@@ -241,7 +241,7 @@ void bdrv_drained_begin(BlockDriverState *bs)
return;
}
- if (!bs->quiesce_counter++) {
+ if (atomic_fetch_inc(&bs->quiesce_counter) == 0) {
aio_disable_external(bdrv_get_aio_context(bs));
bdrv_parent_drained_begin(bs);
}
@@ -252,7 +252,7 @@ void bdrv_drained_begin(BlockDriverState *bs)
void bdrv_drained_end(BlockDriverState *bs)
{
assert(bs->quiesce_counter > 0);
- if (--bs->quiesce_counter > 0) {
+ if (atomic_fetch_dec(&bs->quiesce_counter) > 1) {
return;
}
diff --git a/include/block/block_int.h b/include/block/block_int.h
index eb90c529cd..b529f894be 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -623,6 +623,7 @@ struct BlockDriverState {
/* do we need to tell the quest if we have a volatile write cache? */
int enable_write_cache;
+ /* Accessed with atomic ops. */
int quiesce_counter;
};
--
2.12.2
- [Qemu-block] [PATCH v2 00/18] Block layer thread safety, part 1, Paolo Bonzini, 2017/05/11
- [Qemu-block] [PATCH 03/18] block: access io_limits_disabled with atomic ops, Paolo Bonzini, 2017/05/11
- [Qemu-block] [PATCH 01/18] block: access copy_on_read with atomic ops, Paolo Bonzini, 2017/05/11
- [Qemu-block] [PATCH 04/18] block: access serialising_in_flight with atomic ops, Paolo Bonzini, 2017/05/11
- [Qemu-block] [PATCH 02/18] block: access quiesce_counter with atomic ops,
Paolo Bonzini <=
- [Qemu-block] [PATCH 06/18] block: access io_plugged with atomic ops, Paolo Bonzini, 2017/05/11
- [Qemu-block] [PATCH 05/18] block: access wakeup with atomic ops, Paolo Bonzini, 2017/05/11
- [Qemu-block] [PATCH 07/18] throttle-groups: only start one coroutine from drained_begin, Paolo Bonzini, 2017/05/11
- [Qemu-block] [PATCH 08/18] throttle-groups: do not use qemu_co_enter_next, Paolo Bonzini, 2017/05/11