From 850d54a2a9cf16f589f4aa40272515294671633f Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 5 Jun 2017 14:38:55 +0200 Subject: block: access io_plugged with atomic ops Reviewed-by: Stefan Hajnoczi Signed-off-by: Paolo Bonzini Message-Id: <20170605123908.18777-7-pbonzini@redhat.com> Signed-off-by: Fam Zheng --- block/io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'block/io.c') diff --git a/block/io.c b/block/io.c index 4a598299a9..bb1c9c5432 100644 --- a/block/io.c +++ b/block/io.c @@ -2645,7 +2645,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); @@ -2658,7 +2658,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); -- cgit v1.2.3