From patchwork Tue Oct 27 14:09:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis V. Lunev" X-Patchwork-Id: 536636 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 2F70414076E for ; Wed, 28 Oct 2015 01:11:08 +1100 (AEDT) Received: from localhost ([::1]:59856 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zr4xt-0004Cs-Ut for incoming@patchwork.ozlabs.org; Tue, 27 Oct 2015 10:11:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45639) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zr4wz-0002ux-HF for qemu-devel@nongnu.org; Tue, 27 Oct 2015 10:10:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zr4wt-00089Z-Vr for qemu-devel@nongnu.org; Tue, 27 Oct 2015 10:10:09 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:25808 helo=relay.sw.ru) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zr4wk-00087P-JD; Tue, 27 Oct 2015 10:09:54 -0400 Received: from hades.sw.ru ([10.30.8.132]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id t9RE9k9o015417; Tue, 27 Oct 2015 17:09:52 +0300 (MSK) From: "Denis V. Lunev" To: Date: Tue, 27 Oct 2015 17:09:44 +0300 Message-Id: <1445954986-13005-4-git-send-email-den@openvz.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1445954986-13005-1-git-send-email-den@openvz.org> References: <1445954986-13005-1-git-send-email-den@openvz.org> X-detected-operating-system: by eggs.gnu.org: OpenBSD 3.x X-Received-From: 195.214.232.25 Cc: "Denis V. Lunev" , Paolo Bonzini , qemu-devel@nongnu.org, Stefan Hajnoczi , qemu-stable@nongnu.org Subject: [Qemu-devel] [PATCH 3/5] io: add locking constraints check into bdrv_drain to ensure locking X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org as described in the comment of the function Signed-off-by: Denis V. Lunev CC: Stefan Hajnoczi CC: Paolo Bonzini --- block/io.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/block/io.c b/block/io.c index 5ac6256..2e98d45 100644 --- a/block/io.c +++ b/block/io.c @@ -247,12 +247,15 @@ bool bdrv_requests_pending(BlockDriverState *bs) void bdrv_drain(BlockDriverState *bs) { bool busy = true; + AioContext *aio_context = bdrv_get_aio_context(bs); + + assert(aio_context_is_locked(aio_context)); while (busy) { /* Keep iterating */ bdrv_flush_io_queue(bs); busy = bdrv_requests_pending(bs); - busy |= aio_poll(bdrv_get_aio_context(bs), busy); + busy |= aio_poll(aio_context, busy); } }