From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:33878) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UEzao-000322-PC for qemu-devel@nongnu.org; Mon, 11 Mar 2013 06:04:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UEzaj-0008TC-6f for qemu-devel@nongnu.org; Mon, 11 Mar 2013 06:04:30 -0400 Received: from ssl.dlhnet.de ([91.198.192.8]:34635 helo=ssl.dlh.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UEzaj-0008T3-0Q for qemu-devel@nongnu.org; Mon, 11 Mar 2013 06:04:25 -0400 Message-ID: <513DAC28.8090303@dlhnet.de> Date: Mon, 11 Mar 2013 11:04:24 +0100 From: Peter Lieven MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH 2/3] block: complete all IOs before resizing a device List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "qemu-devel@nongnu.org" Cc: Kevin Wolf , Paolo Bonzini , Jeff Cody , Anthony Liguori this patch ensures that all pending IOs are completed before a device is resized. this is especially important if a device is shrinked as it the bdrv_check_request() result is invalidated. Signed-off-by: Peter Lieven --- blockdev.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/blockdev.c b/blockdev.c index 0e67d06..be36ed7 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1062,6 +1062,9 @@ void qmp_block_resize(const char *device, int64_t size, Error **errp) return; } + /* complete all in-flight operations before resizing the device */ + bdrv_drain_all(); + switch (bdrv_truncate(bs, size)) { case 0: break; -- 1.7.9.5