From patchwork Mon Feb 18 12:48:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Lieven X-Patchwork-Id: 221299 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A5D2A2C0C0D for ; Mon, 18 Feb 2013 23:48:47 +1100 (EST) Received: from localhost ([::1]:54763 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U7Q9F-0004ev-LW for incoming@patchwork.ozlabs.org; Mon, 18 Feb 2013 07:48:45 -0500 Received: from eggs.gnu.org ([208.118.235.92]:37435) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U7Q96-0004eq-7f for qemu-devel@nongnu.org; Mon, 18 Feb 2013 07:48:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U7Q93-0003qb-GU for qemu-devel@nongnu.org; Mon, 18 Feb 2013 07:48:36 -0500 Received: from ssl.dlhnet.de ([91.198.192.8]:37092 helo=ssl.dlh.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U7Q93-0003qP-B3 for qemu-devel@nongnu.org; Mon, 18 Feb 2013 07:48:33 -0500 Received: from localhost (localhost [127.0.0.1]) by ssl.dlh.net (Postfix) with ESMTP id E9DF814D82C; Mon, 18 Feb 2013 13:48:31 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at ssl.dlh.net Received: from ssl.dlh.net ([127.0.0.1]) by localhost (ssl.dlh.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZfPIg1yLJg5H; Mon, 18 Feb 2013 13:48:31 +0100 (CET) Received: from [172.21.12.60] (unknown [82.141.1.226]) by ssl.dlh.net (Postfix) with ESMTPSA id 9AEE114D765; Mon, 18 Feb 2013 13:48:31 +0100 (CET) Message-ID: <5122231F.8070309@dlhnet.de> Date: Mon, 18 Feb 2013 13:48:31 +0100 From: Peter Lieven User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 MIME-Version: 1.0 To: "qemu-devel@nongnu.org" References: <511E14D3.1080001@dlhnet.de> <511E1777.50101@redhat.com> <511E196A.205@dlhnet.de> <511E220B.2090207@redhat.com> <20130215121835.GA14477@dhcp-200-207.str.redhat.com> <511E47B8.4070901@dlhnet.de> <511E4EF2.7080006@redhat.com> In-Reply-To: <511E4EF2.7080006@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 91.198.192.8 Cc: Kevin Wolf , Paolo Bonzini , ronnie sahlberg Subject: [Qemu-devel] [PATCH] block: complete all IOs before .bdrv_truncate 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 bdrv_truncate() invalidates the bdrv_check_request() result for in-flight requests, so there should better be none. Signed-off-by: Peter Lieven Reported-by: Kevin Wolf Reviewed-by: Paolo Bonzini --- block.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/block.c b/block.c index 50dab8e..d8880e3 100644 --- a/block.c +++ b/block.c @@ -2427,6 +2427,10 @@ int bdrv_truncate(BlockDriverState *bs, int64_t offset) return -EACCES; if (bdrv_in_use(bs)) return -EBUSY; + + /* there should be better no IOs in flight when we truncate the device */ + bdrv_drain_all(); + ret = drv->bdrv_truncate(bs, offset); if (ret == 0) { ret = refresh_total_sectors(bs, offset >> BDRV_SECTOR_BITS);