From patchwork Mon Feb 29 07:03:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Dovgalyuk X-Patchwork-Id: 589718 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 3353714031B for ; Mon, 29 Feb 2016 18:03:19 +1100 (AEDT) Received: from localhost ([::1]:34730 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aaHrR-0004Cf-C4 for incoming@patchwork.ozlabs.org; Mon, 29 Feb 2016 02:03:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42720) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aaHrB-0003ul-RG for qemu-devel@nongnu.org; Mon, 29 Feb 2016 02:03:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aaHr6-0004lE-F4 for qemu-devel@nongnu.org; Mon, 29 Feb 2016 02:03:01 -0500 Received: from mail.ispras.ru ([83.149.199.45]:36660) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aaHr6-0004l2-7J for qemu-devel@nongnu.org; Mon, 29 Feb 2016 02:02:56 -0500 Received: from PASHAISP (unknown [85.142.117.224]) by mail.ispras.ru (Postfix) with ESMTPSA id ECEC754006E; Mon, 29 Feb 2016 10:02:53 +0300 (MSK) From: "Pavel Dovgalyuk" To: "'Kevin Wolf'" References: <20160215150110.GG5244@noname.str.redhat.com> <000601d16882$c9637270$5c2a5750$@ru> <20160216100208.GA4920@noname.str.redhat.com> <000a01d168ac$09929500$1cb7bf00$@ru> <20160216125453.GC4920@noname.str.redhat.com> <000601d16bad$e93f9eb0$bbbedc10$@ru> <20160222110644.GD5387@noname.str.redhat.com> <002101d16efa$c74b3850$55e1a8f0$@ru> <20160224131407.GF4485@noname.redhat.com> <000c01d16fab$d85e3b40$891ab1c0$@ru> <20160226090108.GB5668@noname.redhat.com> In-Reply-To: <20160226090108.GB5668@noname.redhat.com> Date: Mon, 29 Feb 2016 10:03:00 +0300 Message-ID: <001201d172bf$3aa580e0$aff082a0$@ru> MIME-Version: 1.0 X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: AdFwdEEHRh9c3zGWRgeKPGPWV9sepgCSpuOg Content-Language: ru X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 83.149.199.45 Cc: edgar.iglesias@xilinx.com, peter.maydell@linaro.org, igor.rubinov@gmail.com, mark.burton@greensocs.com, real@ispras.ru, hines@cert.org, qemu-devel@nongnu.org, maria.klimushenkova@ispras.ru, stefanha@redhat.com, pbonzini@redhat.com, batuzovk@ispras.ru, alex.bennee@linaro.org, fred.konrad@greensocs.com Subject: Re: [Qemu-devel] [PATCH 3/3] replay: introduce block devices record/replay 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 > From: Kevin Wolf [mailto:kwolf@redhat.com] > Am 25.02.2016 um 10:06 hat Pavel Dovgalyuk geschrieben: > > There is one problem with flush event - callbacks for flush are called for > > all layers and I couldn't synchronize them correctly yet. > > I'll probably have to add new callback to block driver, which handles > > flush request for the whole stack of the drivers. > > Flushes should be treated more or less the same a writes, I think. But bdrv_co_flush has different structure and does not allow synchronization of the top layer. Here is the patch for fixing this: Then I'll have just to implement bdrv_co_flush for blkreplay layer. This callback will manually invoke bdrv_co_flush for underlying layer allowing synchronization of finishing callback. Pavel Dovgalyuk diff --git a/block/io.c b/block/io.c index a69bfc4..9e05dfe 100644 --- a/block/io.c +++ b/block/io.c @@ -2369,6 +2369,12 @@ int coroutine_fn bdrv_co_flush(BlockDriverState *bs) } tracked_request_begin(&req, bs, 0, 0, BDRV_TRACKED_FLUSH); + /* Write back all layers by calling one driver function */ + if (bs->drv->bdrv_co_flush) { + ret = bs->drv->bdrv_co_flush(bs); + goto out; + } + /* Write back cached data to the OS even with cache=unsafe */ BLKDBG_EVENT(bs->file, BLKDBG_FLUSH_TO_OS); if (bs->drv->bdrv_co_flush_to_os) { diff --git a/include/block/block_int.h b/include/block/block_int.h index 9ef823a..9cc2c58 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -176,6 +176,13 @@ struct BlockDriver { int (*bdrv_inactivate)(BlockDriverState *bs); /* + * Flushes all data for all layers by calling bdrv_co_flush for underlying + * layers, if needed. This function is needed for deterministic + * synchronization of the flush finishing callback. + */ + int coroutine_fn (*bdrv_co_flush)(BlockDriverState *bs); + + /* * Flushes all data that was already written to the OS all the way down to * the disk (for example raw-posix calls fsync()). */