From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42176) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pIS-0001XM-0K for qemu-devel@nongnu.org; Thu, 11 May 2017 10:42:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pIM-00049h-Ho for qemu-devel@nongnu.org; Thu, 11 May 2017 10:42:28 -0400 From: Paolo Bonzini Date: Thu, 11 May 2017 16:41:56 +0200 Message-Id: <20170511144208.24075-7-pbonzini@redhat.com> In-Reply-To: <20170511144208.24075-1-pbonzini@redhat.com> References: <20170511144208.24075-1-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 06/18] block: access io_plugged with atomic ops List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: famz@redhat.com, stefanha@redhat.com, qemu-block@nongnu.org Reviewed-by: Stefan Hajnoczi Signed-off-by: Paolo Bonzini --- 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 dcb2b72f91..8d2854aeaa 100644 --- a/block/io.c +++ b/block/io.c @@ -2653,7 +2653,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); @@ -2666,7 +2666,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 0799098060..a11e405fa4 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -597,9 +597,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? */ @@ -625,6 +622,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; -- 2.12.2