From patchwork Wed Jan 20 16:24:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 8072921 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5D0A59F1CC for ; Wed, 20 Jan 2016 16:30:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9141F2045E for ; Wed, 20 Jan 2016 16:30:41 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9B27A20456 for ; Wed, 20 Jan 2016 16:30:40 +0000 (UTC) Received: from localhost ([::1]:43927 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLveY-0004xY-3m for patchwork-qemu-devel@patchwork.kernel.org; Wed, 20 Jan 2016 11:30:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59060) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLvZZ-0003gp-0L for qemu-devel@nongnu.org; Wed, 20 Jan 2016 11:25:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aLvZX-00070Q-Jp for qemu-devel@nongnu.org; Wed, 20 Jan 2016 11:25:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55458) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLvZU-0006xI-Na; Wed, 20 Jan 2016 11:25:24 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 685238CF5D; Wed, 20 Jan 2016 16:25:24 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-62.ams2.redhat.com [10.36.116.62]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0KGP8CX032534; Wed, 20 Jan 2016 11:25:23 -0500 From: Kevin Wolf To: qemu-block@nongnu.org Date: Wed, 20 Jan 2016 17:24:59 +0100 Message-Id: <1453307106-28330-11-git-send-email-kwolf@redhat.com> In-Reply-To: <1453307106-28330-1-git-send-email-kwolf@redhat.com> References: <1453307106-28330-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PULL 10/17] block: Rename BDRV_O_INCOMING to BDRV_O_INACTIVE 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of covering only the state of images on the migration destination before the migration is completed, the flag will also cover the state of images on the migration source after completion. This common state implies that the image is technically still open, but no writes will happen and any cached contents will be reloaded from disk if and when the image leaves this state. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- block.c | 10 +++++----- block/io.c | 4 ++-- block/qcow2.c | 6 +++--- block/qed.c | 4 ++-- include/block/block.h | 2 +- nbd/server.c | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/block.c b/block.c index 6ac3191..95b2967 100644 --- a/block.c +++ b/block.c @@ -1191,7 +1191,7 @@ static int bdrv_fill_options(QDict **options, const char *filename, } if (runstate_check(RUN_STATE_INMIGRATE)) { - *flags |= BDRV_O_INCOMING; + *flags |= BDRV_O_INACTIVE; } return 0; @@ -3261,10 +3261,10 @@ void bdrv_invalidate_cache(BlockDriverState *bs, Error **errp) return; } - if (!(bs->open_flags & BDRV_O_INCOMING)) { + if (!(bs->open_flags & BDRV_O_INACTIVE)) { return; } - bs->open_flags &= ~BDRV_O_INCOMING; + bs->open_flags &= ~BDRV_O_INACTIVE; if (bs->drv->bdrv_invalidate_cache) { bs->drv->bdrv_invalidate_cache(bs, &local_err); @@ -3272,14 +3272,14 @@ void bdrv_invalidate_cache(BlockDriverState *bs, Error **errp) bdrv_invalidate_cache(bs->file->bs, &local_err); } if (local_err) { - bs->open_flags |= BDRV_O_INCOMING; + bs->open_flags |= BDRV_O_INACTIVE; error_propagate(errp, local_err); return; } ret = refresh_total_sectors(bs, bs->total_sectors); if (ret < 0) { - bs->open_flags |= BDRV_O_INCOMING; + bs->open_flags |= BDRV_O_INACTIVE; error_setg_errno(errp, -ret, "Could not refresh total sector count"); return; } diff --git a/block/io.c b/block/io.c index 2372994..5bb353a 100644 --- a/block/io.c +++ b/block/io.c @@ -1301,7 +1301,7 @@ static int coroutine_fn bdrv_co_do_pwritev(BlockDriverState *bs, if (bs->read_only) { return -EPERM; } - assert(!(bs->open_flags & BDRV_O_INCOMING)); + assert(!(bs->open_flags & BDRV_O_INACTIVE)); ret = bdrv_check_byte_request(bs, offset, bytes); if (ret < 0) { @@ -2463,7 +2463,7 @@ int coroutine_fn bdrv_co_discard(BlockDriverState *bs, int64_t sector_num, } else if (bs->read_only) { return -EPERM; } - assert(!(bs->open_flags & BDRV_O_INCOMING)); + assert(!(bs->open_flags & BDRV_O_INACTIVE)); /* Do nothing if disabled. */ if (!(bs->open_flags & BDRV_O_UNMAP)) { diff --git a/block/qcow2.c b/block/qcow2.c index 037afbf..340ae8f 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1141,7 +1141,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, } /* Clear unknown autoclear feature bits */ - if (!bs->read_only && !(flags & BDRV_O_INCOMING) && s->autoclear_features) { + if (!bs->read_only && !(flags & BDRV_O_INACTIVE) && s->autoclear_features) { s->autoclear_features = 0; ret = qcow2_update_header(bs); if (ret < 0) { @@ -1154,7 +1154,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, qemu_co_mutex_init(&s->lock); /* Repair image if dirty */ - if (!(flags & (BDRV_O_CHECK | BDRV_O_INCOMING)) && !bs->read_only && + if (!(flags & (BDRV_O_CHECK | BDRV_O_INACTIVE)) && !bs->read_only && (s->incompatible_features & QCOW2_INCOMPAT_DIRTY)) { BdrvCheckResult result = {0}; @@ -1693,7 +1693,7 @@ static void qcow2_close(BlockDriverState *bs) /* else pre-write overlap checks in cache_destroy may crash */ s->l1_table = NULL; - if (!(bs->open_flags & BDRV_O_INCOMING)) { + if (!(bs->open_flags & BDRV_O_INACTIVE)) { int ret1, ret2; ret1 = qcow2_cache_flush(bs, s->l2_table_cache); diff --git a/block/qed.c b/block/qed.c index 093d6e5..0c870cd 100644 --- a/block/qed.c +++ b/block/qed.c @@ -478,7 +478,7 @@ static int bdrv_qed_open(BlockDriverState *bs, QDict *options, int flags, * feature is no longer valid. */ if ((s->header.autoclear_features & ~QED_AUTOCLEAR_FEATURE_MASK) != 0 && - !bdrv_is_read_only(bs->file->bs) && !(flags & BDRV_O_INCOMING)) { + !bdrv_is_read_only(bs->file->bs) && !(flags & BDRV_O_INACTIVE)) { s->header.autoclear_features &= QED_AUTOCLEAR_FEATURE_MASK; ret = qed_write_header_sync(s); @@ -506,7 +506,7 @@ static int bdrv_qed_open(BlockDriverState *bs, QDict *options, int flags, * aid data recovery from an otherwise inconsistent image. */ if (!bdrv_is_read_only(bs->file->bs) && - !(flags & BDRV_O_INCOMING)) { + !(flags & BDRV_O_INACTIVE)) { BdrvCheckResult result = {0}; ret = qed_check(s, &result, true); diff --git a/include/block/block.h b/include/block/block.h index c96923d..2b7d33c 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -84,7 +84,7 @@ typedef struct HDGeometry { #define BDRV_O_NO_BACKING 0x0100 /* don't open the backing file */ #define BDRV_O_NO_FLUSH 0x0200 /* disable flushing on this disk */ #define BDRV_O_COPY_ON_READ 0x0400 /* copy read backing sectors into image */ -#define BDRV_O_INCOMING 0x0800 /* consistency hint for incoming migration */ +#define BDRV_O_INACTIVE 0x0800 /* consistency hint for migration handoff */ #define BDRV_O_CHECK 0x1000 /* open solely for consistency check */ #define BDRV_O_ALLOW_RDWR 0x2000 /* allow reopen to change from r/o to r/w */ #define BDRV_O_UNMAP 0x4000 /* execute guest UNMAP/TRIM operations */ diff --git a/nbd/server.c b/nbd/server.c index eead339..2265cb0 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -668,7 +668,7 @@ NBDExport *nbd_export_new(BlockBackend *blk, off_t dev_offset, off_t size, blk_add_aio_context_notifier(blk, blk_aio_attached, blk_aio_detach, exp); /* * NBD exports are used for non-shared storage migration. Make sure - * that BDRV_O_INCOMING is cleared and the image is ready for write + * that BDRV_O_INACTIVE is cleared and the image is ready for write * access since the export could be available before migration handover. */ blk_invalidate_cache(blk, NULL);