From patchwork Wed Dec 12 13:46:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 205526 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 AA8C02C007D for ; Thu, 13 Dec 2012 01:00:32 +1100 (EST) Received: from localhost ([::1]:54734 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Timh2-0003EX-B7 for incoming@patchwork.ozlabs.org; Wed, 12 Dec 2012 08:49:48 -0500 Received: from eggs.gnu.org ([208.118.235.92]:59160) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TimfS-0000vY-1C for qemu-devel@nongnu.org; Wed, 12 Dec 2012 08:48:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TimfH-0003sW-Bj for qemu-devel@nongnu.org; Wed, 12 Dec 2012 08:48:09 -0500 Received: from mail-ia0-f169.google.com ([209.85.210.169]:49291) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TimfH-0003sO-7E for qemu-devel@nongnu.org; Wed, 12 Dec 2012 08:47:59 -0500 Received: by mail-ia0-f169.google.com with SMTP id r4so906420iaj.14 for ; Wed, 12 Dec 2012 05:47:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=1+4FyqniFo/1DvwSfAZ4x6cIchEKwvWxz0psqtppuLo=; b=ewOhgK82iolfb1EIvxMG8hahFWIwqeg6S+rhhAgmycMST6MStqHY1H9LhoLosNodaS 4gZo1GzEpCJsE2YnNIS7lv2UkyshtL9K1hbEMTFwhBMFpN5LdNMLZeC6s0EZKuY9gD7R WiIwhGLy8Ww8gugSkj6QcrqmyasMCq2o/rFBpBnugefTnsGNoSwJ8dCBlY27ej8XMbYy dBlO3Ts80+9boC7VbXqqm8VmGAjhwuaw7GnJbkH8W8DnrfpY2czEwEaaKoA9iCKfJopo 6Jxu6JNeUG+HrOLdxy1bm9I1NXaPvNA0t/3SYRJ7lpvJBrAPT9AXz3pr54segvKd3zwR k2aA== Received: by 10.50.156.196 with SMTP id wg4mr13353414igb.25.1355320078630; Wed, 12 Dec 2012 05:47:58 -0800 (PST) Received: from yakj.usersys.redhat.com (93-34-219-150.ip51.fastwebnet.it. [93.34.219.150]) by mx.google.com with ESMTPS id fv6sm1786818igc.17.2012.12.12.05.47.55 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 12 Dec 2012 05:47:57 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 12 Dec 2012 14:46:37 +0100 Message-Id: <1355319999-30627-19-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.0.1 In-Reply-To: <1355319999-30627-1-git-send-email-pbonzini@redhat.com> References: <1355319999-30627-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.210.169 Cc: kwolf@redhat.com, jcody@redhat.com, stefanha@redhat.com Subject: [Qemu-devel] [PATCH 18/20] mirror: add support for persistent dirty bitmap 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 A persistent dirty bitmap lets mirroring proceed with no waste of work after QEMU exits (either offline, or online when the VM restarts). It is also useful in order to communicate to management whether the switch to the destination was completed or not. Signed-off-by: Paolo Bonzini Reviewed-by: Eric Blake --- block/mirror.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/block/mirror.c b/block/mirror.c index 99c5bd1..3d37396 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -351,6 +351,18 @@ static void coroutine_fn mirror_run(void *opaque) } } + /* + * Ensure the set bits have reached the persistent dirty bitmap before + * moving on. This covers the case where no I/O happens between the + * beginning of mirroring and block-job-complete, but there were indeed + * some dirty sectors. In this case, the persistent dirty bitmap could end + * up staying all-zeroes all the time! + */ + ret = bdrv_flush_dirty_tracking(bs, true); + if (ret < 0) { + goto immediate_exit; + } + bdrv_dirty_iter_init(bs, &s->hbi); last_pause_ns = qemu_get_clock_ns(rt_clock); for (;;) { @@ -392,6 +404,9 @@ static void coroutine_fn mirror_run(void *opaque) break; } } else { + ret = bdrv_flush_dirty_tracking(bs, false); + assert(ret >= 0); + /* We're out of the streaming phase. From now on, if the job * is cancelled we will actually complete all pending I/O and * report completion. This way, block-job-cancel will leave