mirror of
https://github.com/utmapp/qemu.git
synced 2026-12-01 22:23:23 -10:00
block: access quiesce_counter with atomic ops
Reviewed-by: Stefan Hajnoczi <[email protected]> Reviewed-by: Alberto Garcia <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]> Message-Id: <[email protected]> Signed-off-by: Fam Zheng <[email protected]>
This commit is contained in:
1 parent
d3faa13e5f
commit
414c2ec358
2 files changed
+3
-2
No files matched your search
+2
-2
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -637,6 +637,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;
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user