From: Paolo Bonzini Date: Mon, 5 Jun 2017 12:38:51 +0000 (+0200) Subject: block: access quiesce_counter with atomic ops X-Git-Tag: v2.10.0-rc0~123^2~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=414c2ec358;p=thirdparty%2Fqemu.git block: access quiesce_counter with atomic ops Reviewed-by: Stefan Hajnoczi Reviewed-by: Alberto Garcia Signed-off-by: Paolo Bonzini Message-Id: <20170605123908.18777-3-pbonzini@redhat.com> Signed-off-by: Fam Zheng --- diff --git a/block/io.c b/block/io.c index 98c690f306e..70643df494e 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 49f2ebb95a9..1824e0e1356 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -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; };