From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60439) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZsC81-0005VL-Cc for qemu-devel@nongnu.org; Fri, 30 Oct 2015 12:02:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZsC80-000383-8N for qemu-devel@nongnu.org; Fri, 30 Oct 2015 12:02:09 -0400 Date: Fri, 30 Oct 2015 12:01:59 -0400 From: Jeff Cody Message-ID: <20151030160159.GA23286@localhost.localdomain> References: <1446220661-18792-1-git-send-email-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1446220661-18792-1-git-send-email-stefanha@redhat.com> Subject: Re: [Qemu-devel] [Qemu-block] [PATCH] blockdev: acquire AioContext in hmp_commit() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Kevin Wolf , "Denis V. Lunev" , qemu-devel@nongnu.org, qemu-block@nongnu.org, Markus Armbruster On Fri, Oct 30, 2015 at 03:57:41PM +0000, Stefan Hajnoczi wrote: > This one slipped through. Although we acquire AioContext when > committing all devices we don't for just a single device. > > AioContext must be acquired before calling bdrv_*() functions to > synchronize access with other threads that may be using the AioContext. > > Signed-off-by: Stefan Hajnoczi > --- > blockdev.c | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/blockdev.c b/blockdev.c > index 18712d2..d611779 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -1120,6 +1120,9 @@ void hmp_commit(Monitor *mon, const QDict *qdict) > if (!strcmp(device, "all")) { > ret = bdrv_commit_all(); > } else { > + BlockDriverState *bs; > + AioContext *aio_context; > + > blk = blk_by_name(device); > if (!blk) { > monitor_printf(mon, "Device '%s' not found\n", device); > @@ -1129,7 +1132,14 @@ void hmp_commit(Monitor *mon, const QDict *qdict) > monitor_printf(mon, "Device '%s' has no medium\n", device); > return; > } > - ret = bdrv_commit(blk_bs(blk)); > + > + bs = blk_bs(blk); > + aio_context = bdrv_get_aio_context(bs); > + aio_context_acquire(aio_context); > + > + ret = bdrv_commit(bs); > + > + aio_context_release(aio_context); > } > if (ret < 0) { > monitor_printf(mon, "'commit' error for '%s': %s\n", device, > -- > 2.4.3 > > Reviewed-by: Jeff Cody