From patchwork Wed May 6 17:23:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: phoeagon X-Patchwork-Id: 469068 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 E3BE81402C4 for ; Thu, 7 May 2015 03:23:26 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=Iyycg6ys; dkim-atps=neutral Received: from localhost ([::1]:46408 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yq32Z-0000Yv-VQ for incoming@patchwork.ozlabs.org; Wed, 06 May 2015 13:23:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46466) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yq32K-0000IQ-5f for qemu-devel@nongnu.org; Wed, 06 May 2015 13:23:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yq32F-0002ki-PC for qemu-devel@nongnu.org; Wed, 06 May 2015 13:23:08 -0400 Received: from mail-ie0-x22e.google.com ([2607:f8b0:4001:c03::22e]:35518) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yq32F-0002kA-JT for qemu-devel@nongnu.org; Wed, 06 May 2015 13:23:03 -0400 Received: by ieczm2 with SMTP id zm2so19641217iec.2 for ; Wed, 06 May 2015 10:23:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-type; bh=TbwQM6yTHGT5R3AwCp0u9it7dNZdaKBeJ5mR4RHaOUs=; b=Iyycg6ys3f/91QyK4S0ahQ+YdDSVga7b5bZsIahHW8YYVzf2ahfjPeN23IQDTDUKqe A8iEUA6X8Idrb88PoxAdbXVCalKLhKLXxb/CmqDA9IQyicRaDxiX06qdIDmGJ5IYbfsO 66nvKl0TbJsncZYnfCqDPQjCwZEO+om1brq0GS7PLRfiy6sHC5w6WPgaS6u1PKRct/T6 i69qoV5rmn1i8Czg4AnJf69Vrpk+uA6dMZ9yCjzOkyV87mw413e55oYE1zePc2oVUdDj nyJJ86qni2tcIKQUPB+RsEu8Q7WqkPvUARNg1YdbvCi6Brj5ZGza6wqPpuaApz9/bNXB 7tkA== X-Received: by 10.50.57.51 with SMTP id f19mr9345132igq.6.1430932982749; Wed, 06 May 2015 10:23:02 -0700 (PDT) MIME-Version: 1.0 References: <554A4458.7090901@redhat.com> In-Reply-To: <554A4458.7090901@redhat.com> From: phoeagon Date: Wed, 06 May 2015 17:23:01 +0000 Message-ID: To: Max Reitz , qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4001:c03::22e Subject: Re: [Qemu-devel] [PATCH] use bdrv_flush to provide barrier semantic in block/vdi.c for metadata updates 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 Thanks for your input. So I changed it to: 1. Only call bdrv_flush when bdrv_pwrite was successful 2. Only if bdrv_flush was unsuccessful that the return value of vdi_co_write is updated. In this way we try to avoid messing up any potential return value checks possible while still propagating bdrv_flush errors. That return value was a catch and I admit I'm no pro with the return value convention in QEMU. bdrv_pwrite doesn't return the same value as bdrv_pwrite_sync I assume (they do return negative values when fail, but different values when successful) --- Signed-off-by: Zhe Qiu From 19b2fabbe00765b418362d8c1891f266091621f3 Mon Sep 17 00:00:00 2001 From: phoeagon Date: Thu, 7 May 2015 01:09:38 +0800 Subject: [PATCH] block/vdi: Use bdrv_flush after metadata updates In reference to b0ad5a455d7e5352d4c86ba945112011dbeadfb8~078a458e077d6b0db262c4b05fee51d01de2d1d2, metadata writes to qcow2/cow/qcow/vpc/vmdk are all synced prior to succeeding writes. --- block/vdi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 2.4.0 diff --git a/block/vdi.c b/block/vdi.c index 5d09b36..54a5fa8 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -713,7 +713,11 @@ static int vdi_co_write(BlockDriverState *bs, logout("will write %u block map sectors starting from entry %u\n", n_sectors, bmap_first); ret = bdrv_write(bs->file, offset, base, n_sectors); + if (!(ret < 0)) { + int flush_ret = bdrv_flush(bs->file); + if (flush_ret < 0) + ret = flush_ret; + } } return ret; --