From patchwork Wed Sep 16 12:20:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 305226 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B751AC433E2 for ; Wed, 16 Sep 2020 12:22:14 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F19342223C for ; Wed, 16 Sep 2020 12:22:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="cGrbRidv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F19342223C Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:43312 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kIWRw-0006I9-VI for qemu-devel@archiver.kernel.org; Wed, 16 Sep 2020 08:22:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34776) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kIWQT-0004aZ-TH; Wed, 16 Sep 2020 08:20:41 -0400 Received: from mail-eopbgr40130.outbound.protection.outlook.com ([40.107.4.130]:3150 helo=EUR03-DB5-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kIWQM-0004Gb-Ho; Wed, 16 Sep 2020 08:20:40 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OpD8qcr7wUTpk9fKz1XvMSJ/pV7PkFFcMvqmvnv9USa7XUHiYgiQ1iIRLsTUFBq6aH9hXxKTzXAhViLJakujBpOHB0J9uCNhjI6NVJFBkO7tryFbCoGm5fSNPz1hyVjHhCLKdf8R/zMNgNW6w4yT1/8lVovO5UgI9EqX53FtQ2jitsglOHfNchYuYSh7/FF51HAcpKtwbopop42B/P4ZTPoBizhG17WhCWvPsOVc4vZc4lMl9e4Rg6bCB4M134lf4dE0GbPixBC9fO6vJTqs78Kz1fOPsSYEOnHyZZfPHu1rKcoxwD8VAnf+tJp8QeBGeZz8BzaaDXs+9VjTTU/H2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eutP0bt/A5kci9FdvkvwyiCx3/9AREBbZGbhPj/Zu+U=; b=F9jCxsL2S/B8WYhl9npv034lKiX3RJvzWanLR+aELL9qfS0XA33LfHcrx8HTsW1bJTtmKTpCdC76NV85Hj0sN1w4QUk7Ski8fF+XaYPPsWJwZd2n7r9ssPPL1PArBkZGdsScQ+6NpwynbE9HPvepNrFPz21wYohNL/JI6dMIAhlHcQqcPXgN1JEMxLyGKG0FRiwAKJedZHj2tScAM1q9nsZdFYVhREFmOVamJO4PEFL6zMSSgjjDEVPTzLSYm1yirm+6GesJk1ws5+9YF9LvYaL7Ml6ZJyKyIirI2B1DWDXSMpg9ev378l43R0yaX7FkHbKgY5NqA3iErKOKWKxcVA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eutP0bt/A5kci9FdvkvwyiCx3/9AREBbZGbhPj/Zu+U=; b=cGrbRidvKgS3FPlXkU4thq1P8v68hPYFtzznj6XuL/6M4kRpnmr2eDCeGc7vApIXncQUnpn9UuclBYdbQ/WOw7KwHC8R9huEwmLK3dz0lo0thNZfEWQKttSJlYFzGVpLeZ+jMGsPP0z/N0Sdr/e+xdCWruHfeOsS/it8gmTEhEE= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB5077.eurprd08.prod.outlook.com (2603:10a6:20b:e6::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.14; Wed, 16 Sep 2020 12:20:24 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%8]) with mapi id 15.20.3370.019; Wed, 16 Sep 2020 12:20:23 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, eblake@redhat.com, den@openvz.org, vsementsov@virtuozzo.com Subject: [PATCH v6 1/5] block/io: fix bdrv_co_block_status_above Date: Wed, 16 Sep 2020 15:20:04 +0300 Message-Id: <20200916122008.20303-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200916122008.20303-1-vsementsov@virtuozzo.com> References: <20200916122008.20303-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM0PR04CA0018.eurprd04.prod.outlook.com (2603:10a6:208:122::31) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.75) by AM0PR04CA0018.eurprd04.prod.outlook.com (2603:10a6:208:122::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.11 via Frontend Transport; Wed, 16 Sep 2020 12:20:23 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.75] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e94728be-5d67-44fa-b390-08d85a3ae314 X-MS-TrafficTypeDiagnostic: AM6PR08MB5077: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TtDvsHP3Qs0CtS+ciU4/PH3gQL/FyvC5gSn9R/GRtky7Es80SJKcy6s60AY0E/7QE6XZeTQfY75V6sT7kT8NiK6bNFj5NtOfR6PT4CdspSMXsB7dyn2F1FEI7VqC52OXl75FC0oD3WKoeVMYfARGFdX+rVD9VW85HRNg8mty/U/xZ/ZtLIYU87aYzP4jibsjfKbDnK/MXCGJAka57DR5d8c6zJ+YmCd8RLC6kDCbbkq82TAygm87rRsTSLvyRiWIXfvNuCI5pTkswJLCnP/h6EH8iT8oz+VcHNxmDKRDhrpX29XmrgmSxanyvj/yjyuGdS2exCukzTjEz+qs8XUk1g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(346002)(136003)(39830400003)(366004)(396003)(26005)(16526019)(6486002)(316002)(478600001)(6506007)(186003)(5660300002)(6512007)(2616005)(956004)(1076003)(36756003)(6916009)(2906002)(8676002)(66556008)(66476007)(86362001)(52116002)(107886003)(4326008)(66946007)(83380400001)(6666004)(8936002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: WT4/ZOUWldF/KaHzbpNDQAXjYBaXXYZ5o6Fnamr+BjirEzYMGloaHRZs7Ev7f0j+tvN+OC0estUhkFfzi1OvElFxUIgSIB4GnZEa1MTmLLEhEsvNA+f7d+DpYYk0xo7xAF1FaNQabLgAaF3DkA64Kiz+x2GsOtaRqvimMV99ZTIdqQ+XcfrrqKNVZWFXgo+dUu5q1FtddaHmj5N4jgHTotyv5YJIYTZjF1CdJwTqHVgZ+Iy2W3wJBfOhLMG1zUX0FZKYYYjwWONTt2piTY4r5wZ4IvCnicPw58vVmemk+RSGk1OBcScT/ubYaOG/ikFk89rU6CclnwkwPecfn8yLz0QKTZO5PWQzS4VFapLRb9dlwLOikYGdDjy3E1JbBZcFz/7gUC8RATg/zzlMJ534vdT/qQ7vvS2Zx3ci2jfTmmwh8enQmP1sntbdCpkKxw6sTugoSsy9qZ9K5xKafg6xO4gQGE9kpWogzzFCxa7T+VxEN74zrFFuQk//ngxw4ek+dgMP5dMR86UBI2ibQVUAYuJ4GGAzto74EzE23B64+7xvPYA/2H8+4pESqYFav2x6znW3/FRq1HhepU6Udv6pTU8xRtmr95+PP2T4Latv9WwuE9FGFnxz6tjJX9jwvj1K0+cEDVBvTJ9OnhA98UpUpA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: e94728be-5d67-44fa-b390-08d85a3ae314 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2020 12:20:23.8726 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7tevzm2bftraB4wHQlkQ2vr2kmxEvhgIc8Ebpdged1RUlLcDuF3XZ4e1s02hSB/rqUv8czn19xERve6yaDe0tFWorMsfygx84Rdu3IvGlC8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB5077 Received-SPF: pass client-ip=40.107.4.130; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-DB5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/16 08:20:24 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" bdrv_co_block_status_above has several design problems with handling short backing files: 1. With want_zeros=true, it may return ret with BDRV_BLOCK_ZERO but without BDRV_BLOCK_ALLOCATED flag, when actually short backing file which produces these after-EOF zeros is inside requested backing sequence. 2. With want_zero=false, it may return pnum=0 prior to actual EOF, because of EOF of short backing file. Fix these things, making logic about short backing files clearer. With fixed bdrv_block_status_above we also have to improve is_zero in qcow2 code, otherwise iotest 154 will fail, because with this patch we stop to merge zeros of different types (produced by fully unallocated in the whole backing chain regions vs produced by short backing files). Note also, that this patch leaves for another day the general problem around block-status: misuse of BDRV_BLOCK_ALLOCATED as is-fs-allocated vs go-to-backing. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Alberto Garcia --- block/io.c | 66 ++++++++++++++++++++++++++++++++++++++++----------- block/qcow2.c | 16 +++++++++++-- 2 files changed, 66 insertions(+), 16 deletions(-) diff --git a/block/io.c b/block/io.c index 84f82bc069..e381d2da35 100644 --- a/block/io.c +++ b/block/io.c @@ -2366,34 +2366,72 @@ bdrv_co_common_block_status_above(BlockDriverState *bs, int64_t *map, BlockDriverState **file) { + int ret; BlockDriverState *p; - int ret = 0; - bool first = true; + int64_t eof = 0; assert(bs != base); - for (p = bs; p != base; p = backing_bs(p)) { + + ret = bdrv_co_block_status(bs, want_zero, offset, bytes, pnum, map, file); + if (ret < 0 || *pnum == 0 || ret & BDRV_BLOCK_ALLOCATED) { + return ret; + } + + if (ret & BDRV_BLOCK_EOF) { + eof = offset + *pnum; + } + + assert(*pnum <= bytes); + bytes = *pnum; + + for (p = backing_bs(bs); p != base; p = backing_bs(p)) { ret = bdrv_co_block_status(p, want_zero, offset, bytes, pnum, map, file); if (ret < 0) { - break; + return ret; } - if (ret & BDRV_BLOCK_ZERO && ret & BDRV_BLOCK_EOF && !first) { + if (*pnum == 0) { /* - * Reading beyond the end of the file continues to read - * zeroes, but we can only widen the result to the - * unallocated length we learned from an earlier - * iteration. + * The top layer deferred to this layer, and because this layer is + * short, any zeroes that we synthesize beyond EOF behave as if they + * were allocated at this layer. + * + * We don't include BDRV_BLOCK_EOF into ret, as upper layer may be + * larger. We'll add BDRV_BLOCK_EOF if needed at function end, see + * below. */ + assert(ret & BDRV_BLOCK_EOF); *pnum = bytes; + if (file) { + *file = p; + } + ret = BDRV_BLOCK_ZERO | BDRV_BLOCK_ALLOCATED; + break; } - if (ret & (BDRV_BLOCK_ZERO | BDRV_BLOCK_DATA)) { + if (ret & BDRV_BLOCK_ALLOCATED) { + /* + * We've found the node and the status, we must break. + * + * Drop BDRV_BLOCK_EOF, as it's not for upper layer, which may be + * larger. We'll add BDRV_BLOCK_EOF if needed at function end, see + * below. + */ + ret &= ~BDRV_BLOCK_EOF; break; } - /* [offset, pnum] unallocated on this layer, which could be only - * the first part of [offset, bytes]. */ - bytes = MIN(bytes, *pnum); - first = false; + + /* + * OK, [offset, offset + *pnum) region is unallocated on this layer, + * let's continue the diving. + */ + assert(*pnum <= bytes); + bytes = *pnum; } + + if (offset + *pnum == eof) { + ret |= BDRV_BLOCK_EOF; + } + return ret; } diff --git a/block/qcow2.c b/block/qcow2.c index da56b1a4df..15ba0ce81a 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3872,8 +3872,20 @@ static bool is_zero(BlockDriverState *bs, int64_t offset, int64_t bytes) if (!bytes) { return true; } - res = bdrv_block_status_above(bs, NULL, offset, bytes, &nr, NULL, NULL); - return res >= 0 && (res & BDRV_BLOCK_ZERO) && nr == bytes; + + /* + * bdrv_block_status_above doesn't merge different types of zeros, for + * example, zeros which come from the region which is unallocated in + * the whole backing chain, and zeros which comes because of a short + * backing file. So, we need a loop. + */ + do { + res = bdrv_block_status_above(bs, NULL, offset, bytes, &nr, NULL, NULL); + offset += nr; + bytes -= nr; + } while (res >= 0 && (res & BDRV_BLOCK_ZERO) && nr && bytes); + + return res >= 0 && (res & BDRV_BLOCK_ZERO) && bytes == 0; } static coroutine_fn int qcow2_co_pwrite_zeroes(BlockDriverState *bs, From patchwork Wed Sep 16 12:20:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 273564 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C5FBC433E2 for ; Wed, 16 Sep 2020 12:25:33 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0D0D620659 for ; Wed, 16 Sep 2020 12:25:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="v7sOLXD1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0D0D620659 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:49222 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kIWVA-0000T9-2G for qemu-devel@archiver.kernel.org; Wed, 16 Sep 2020 08:25:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34800) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kIWQZ-0004ew-44; Wed, 16 Sep 2020 08:20:48 -0400 Received: from mail-eopbgr40130.outbound.protection.outlook.com ([40.107.4.130]:3150 helo=EUR03-DB5-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kIWQU-0004Gb-KJ; Wed, 16 Sep 2020 08:20:45 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eU1mpViYcU/yVKNd9pJPN5IEJsML5HbP5vGIaPap1zNaQgSEOfZmSMcW0tLNmVgNVufAm+VuIyWtqVqcwDmyq0sn9bVVN53mmqK5Bp9Eiw0jeOSmOst3buBN00QYb0wPOFRNAHRZ7JAcOW8y1eW8Kx1Q+u2HhW5xK9cHkL/hnXM9cDmmbtwz0npY+GD9MEU8DDmIT/GJE/j7F47Ip3rK+3sFAtWXlB6H5bYcZxgTMn1wK69p+rDCg1ynSNYmmA38zrgAzsrm2ZgjqAu2gQR2h100nA+cNY9IldCRD8ZtGcDVCg0XhUm06cpQjxPzLsekN8ZntTT41xaenEl3ISbWIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YHGui9e28287bTitd6Jgt1pRrEyLELX/dwjny1Dn7rk=; b=NHOMNJJNW6VDNhejfXfQX4yC+6ZtuswCPP9eHF1fM5uPCBk6aRZ6snjwefjhGH44dQBgjqLksfifgs+L0Axwj3F/Ps8gHcMN/82KFG4URywRdjDTo8ocY6ZbBhAYmly3LimoTbY7DG79V+V4EuXDdD24tB3OHj1lkLfz8f84dJRoaVh57TP9M3HLlTxKY7dApqiVjHPWRzQionotA3mVUaMh6qaiQ9OoFsyRpCMbHqnD+s6P5IXlu/WrdRhwAGwn6VQaofze4kbLgzVEBeKnUYhz5lbWtwDcRuXHjWKqCnOVq+hjb6AD/NaF0iTj2iYMo+/2VT7iYJsyebwP1yI6cQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YHGui9e28287bTitd6Jgt1pRrEyLELX/dwjny1Dn7rk=; b=v7sOLXD1tMYSkskSKCWEhLsl/i5xXQFbaHeJ9xExx5mBKvzSWFdK5PJST1wCe8SnP1PUd1pmAPd/utvAwowBYQPMjovRZrLNKzRoLqGA0iFdAqfyb240VilaovRM5xJHeDH5ztoQEUpWSqpnGZBhzsJHYfrNZkK4h5MWFmXDw70= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB5077.eurprd08.prod.outlook.com (2603:10a6:20b:e6::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.14; Wed, 16 Sep 2020 12:20:24 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%8]) with mapi id 15.20.3370.019; Wed, 16 Sep 2020 12:20:24 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, eblake@redhat.com, den@openvz.org, vsementsov@virtuozzo.com Subject: [PATCH v6 2/5] block/io: bdrv_common_block_status_above: support include_base Date: Wed, 16 Sep 2020 15:20:05 +0300 Message-Id: <20200916122008.20303-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200916122008.20303-1-vsementsov@virtuozzo.com> References: <20200916122008.20303-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM0PR04CA0018.eurprd04.prod.outlook.com (2603:10a6:208:122::31) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.75) by AM0PR04CA0018.eurprd04.prod.outlook.com (2603:10a6:208:122::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.11 via Frontend Transport; Wed, 16 Sep 2020 12:20:24 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.75] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a2c517bd-e9ba-4f50-b80e-08d85a3ae38c X-MS-TrafficTypeDiagnostic: AM6PR08MB5077: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1091; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R3wE52k8uQyNhK4Gsh63L2BBOkyfHYi7wd97agJ8a28BH0cF5mUrM6x1QaEb110DsvQftLK96YKbx59benaouo+WIMM/HJlsBeBcjPqOuhqxODO4MDX5V//RpM11pw6szx18s7hDPOQ88TA77bP36dwiq20pnbW937RfolQjfxcZDijnzLYHd0X/UsH5sSbHBKvTqU6GjwhP9lURVySqsKKyO1bAjPuogN22E6IfqkIPTS9PhGcvEoWeuDAVSmiMLJzio6OyCh099C4rkYo/GKfodDOW/KztVP202wUpITFTvC7FUJ96lFDWoTebzJsBgW0oN0/1gnHR5hLyXlTIcg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(346002)(136003)(39830400003)(366004)(396003)(26005)(16526019)(6486002)(316002)(478600001)(6506007)(186003)(5660300002)(6512007)(2616005)(956004)(1076003)(36756003)(6916009)(2906002)(8676002)(66556008)(66476007)(86362001)(52116002)(107886003)(4326008)(66946007)(83380400001)(6666004)(8936002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: i5IMuTVsBIq+roXxxZ89cbmtmH2C+rC7fDj22ErqQDMYYiUKZsbbu6x0Ij/rXepGss3mmO23f2oszWwZ1MDxRSslEcdk4e1dVu4O8u7wO8OIgYVmkV1n3XgJY2pc1F5vhSHIYltkEsXE3Wi2b/YU4uaRYT2X5gyboM/629hpGBejM9858YpM87ygAigBdPu69XwN3700cGZ9h9/LI2jDcWYPqO00wvpjLi5zKqt3pi2eIkLUDNHb7Ez6BGWgg8B8ZVFhayHGvEbHC6Jx9hCe7QPNujBlR3JMF12KQuR0YDM5ythUQNV89i2QtlQiATJtRMaqXXG9/nlEkYGzjK93EaqzMxNaRgklGYD6wAPjZLQ8ySlPhotkPp1Er2IhMsCimAENdtZULgdktyXC7NrDHAcWU7z7KFIkXRn69Ydx0mt8VCqBDqGtA0zIRz+ghufRsq/ube8k8J21SuTI7hx+ElDDxQzURZcvrtmYjOKyNIQFaEqNKbGNEnJznrKo/Br++LdMNcuYIfcaptBqM0Aapk/1dzTK68PwW5c2SHCQ2rGr/kba4YFdBO3vNG16msXGv/bGhQApAGlKVlLFoP068GbJ0x11+gVRjWSYjrz/3D/28zMOkKeAQI/Ncwd2i8iHGkeQ74fvCwZwwarFYbqXvw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: a2c517bd-e9ba-4f50-b80e-08d85a3ae38c X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2020 12:20:24.6472 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: XUtws1bhqSqUxoldI9rJVmtAhjrihXabQSjNxk0NUyi//bSjfV6q8fqp+TbS5E5dP/d/IsBzZRPdF9/WO7beeZIrf+Jn+L/D3W+ycjhbVGU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB5077 Received-SPF: pass client-ip=40.107.4.130; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-DB5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/16 08:20:24 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" In order to reuse bdrv_common_block_status_above in bdrv_is_allocated_above, let's support include_base parameter. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Alberto Garcia --- block/coroutines.h | 2 ++ block/io.c | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/block/coroutines.h b/block/coroutines.h index f69179f5ef..1cb3128b94 100644 --- a/block/coroutines.h +++ b/block/coroutines.h @@ -41,6 +41,7 @@ bdrv_pwritev(BdrvChild *child, int64_t offset, unsigned int bytes, int coroutine_fn bdrv_co_common_block_status_above(BlockDriverState *bs, BlockDriverState *base, + bool include_base, bool want_zero, int64_t offset, int64_t bytes, @@ -50,6 +51,7 @@ bdrv_co_common_block_status_above(BlockDriverState *bs, int generated_co_wrapper bdrv_common_block_status_above(BlockDriverState *bs, BlockDriverState *base, + bool include_base, bool want_zero, int64_t offset, int64_t bytes, diff --git a/block/io.c b/block/io.c index e381d2da35..0cc2dd7a3e 100644 --- a/block/io.c +++ b/block/io.c @@ -2359,6 +2359,7 @@ early_out: int coroutine_fn bdrv_co_common_block_status_above(BlockDriverState *bs, BlockDriverState *base, + bool include_base, bool want_zero, int64_t offset, int64_t bytes, @@ -2370,10 +2371,11 @@ bdrv_co_common_block_status_above(BlockDriverState *bs, BlockDriverState *p; int64_t eof = 0; - assert(bs != base); + assert(include_base || bs != base); + assert(!include_base || base); /* Can't include NULL base */ ret = bdrv_co_block_status(bs, want_zero, offset, bytes, pnum, map, file); - if (ret < 0 || *pnum == 0 || ret & BDRV_BLOCK_ALLOCATED) { + if (ret < 0 || *pnum == 0 || ret & BDRV_BLOCK_ALLOCATED || bs == base) { return ret; } @@ -2384,7 +2386,7 @@ bdrv_co_common_block_status_above(BlockDriverState *bs, assert(*pnum <= bytes); bytes = *pnum; - for (p = backing_bs(bs); p != base; p = backing_bs(p)) { + for (p = backing_bs(bs); include_base || p != base; p = backing_bs(p)) { ret = bdrv_co_block_status(p, want_zero, offset, bytes, pnum, map, file); if (ret < 0) { @@ -2420,6 +2422,11 @@ bdrv_co_common_block_status_above(BlockDriverState *bs, break; } + if (p == base) { + assert(include_base); + break; + } + /* * OK, [offset, offset + *pnum) region is unallocated on this layer, * let's continue the diving. @@ -2439,7 +2446,7 @@ int bdrv_block_status_above(BlockDriverState *bs, BlockDriverState *base, int64_t offset, int64_t bytes, int64_t *pnum, int64_t *map, BlockDriverState **file) { - return bdrv_common_block_status_above(bs, base, true, offset, bytes, + return bdrv_common_block_status_above(bs, base, false, true, offset, bytes, pnum, map, file); } @@ -2456,7 +2463,7 @@ int coroutine_fn bdrv_is_allocated(BlockDriverState *bs, int64_t offset, int ret; int64_t dummy; - ret = bdrv_common_block_status_above(bs, backing_bs(bs), false, offset, + ret = bdrv_common_block_status_above(bs, bs, true, false, offset, bytes, pnum ? pnum : &dummy, NULL, NULL); if (ret < 0) { From patchwork Wed Sep 16 12:20:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 305225 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71CD2C433E2 for ; Wed, 16 Sep 2020 12:28:03 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 99A9A21D24 for ; Wed, 16 Sep 2020 12:28:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="dbitehDw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 99A9A21D24 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:55700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kIWXZ-0003Hk-JF for qemu-devel@archiver.kernel.org; Wed, 16 Sep 2020 08:28:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34814) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kIWQd-0004ii-Dn; Wed, 16 Sep 2020 08:20:52 -0400 Received: from mail-eopbgr40130.outbound.protection.outlook.com ([40.107.4.130]:3150 helo=EUR03-DB5-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kIWQZ-0004Gb-Co; Wed, 16 Sep 2020 08:20:51 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g28Ze0l9FastYGLK0cfSlEma3WVlaLbXDR8H16LkuyIEW1Oxm2SqBLB44n0nIt1ruGWRpFmJbMMaTz9g4DjVizhbyJ87Kx8gisf2tCoLTcaS573e4l2yO/Onr3WfXNPOANDE6p4aQs1rwhVaTNRnuVwuDRB3wqI+pKMHHaT1/4SKR8agqGoIVrXu1/XIayNvBOeePQYBM+DAD4Ti2uRmFTp29dl3YuxNqbhTFsQMSZ4koG4M/2Hzfto8ngiV7y2bLt1zliXtM/HTJzzTQ5J7KRwX/yW/eMmuM0LRNPwuqzCtIrc99/z2GSCOC49OLyZpgCtp6IrYzjqdM931LspB+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Qk6mX2hGgoIVZs4ZKciVH8v7c8cE9zkajaY2lLjmRk0=; b=IXjZ/2fUpgnMZf/UUsqJVHCyUjrXUR17OMo7HmrmnPliwkpW49xrq3vXOIyw5U+sZTg/IFCxSPHUIrD6WuxpoCouUjA0Sx7uJSSlKf9uPMxxywF3vTdNkeKYxyZ2MOtgw4toJNqW4A19Hri59Q/8LPciHokVvIAFVgnyJ23NCbVBgK0NXy1t+q15OBJ0Rceou0OZNx5X6L/oI7Q3LiiUDoo06KzpEAqZdzjnmmX8G3YDtdVRBqPrYPvRXG3+0t41hsS5RhfSRCJATSdi0OusABaU6uc3mOMlCJ0xDitOFCO7BFFJuurdSo3YWQmiCTgqOkTFREs0x5kfL2Mj711ERQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Qk6mX2hGgoIVZs4ZKciVH8v7c8cE9zkajaY2lLjmRk0=; b=dbitehDw9JZ3ioj9T3TJCh4wVh2hWCLyFkCnl5mvObpDnMTKYpV6l587vq8eLR2GW1a/0seieluCzutlZSH4wa9ojcG422nMRLsOUPslDlg7CfZaU2SuTIcB0S5vK4QnCS5tcV2Pxr+zsKeSwMOwV1I5Ktq1GKc3ncMpHzZ9SGs= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB5077.eurprd08.prod.outlook.com (2603:10a6:20b:e6::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.14; Wed, 16 Sep 2020 12:20:25 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%8]) with mapi id 15.20.3370.019; Wed, 16 Sep 2020 12:20:25 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, eblake@redhat.com, den@openvz.org, vsementsov@virtuozzo.com Subject: [PATCH v6 3/5] block/io: bdrv_common_block_status_above: support bs == base Date: Wed, 16 Sep 2020 15:20:06 +0300 Message-Id: <20200916122008.20303-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200916122008.20303-1-vsementsov@virtuozzo.com> References: <20200916122008.20303-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM0PR04CA0018.eurprd04.prod.outlook.com (2603:10a6:208:122::31) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.75) by AM0PR04CA0018.eurprd04.prod.outlook.com (2603:10a6:208:122::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.11 via Frontend Transport; Wed, 16 Sep 2020 12:20:24 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.75] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a6d9865c-1ef5-484c-9f89-08d85a3ae407 X-MS-TrafficTypeDiagnostic: AM6PR08MB5077: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1417; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7MBYcV+cbDPOGU+Q7o2zKXPpW3cRd8sldzJZUjiAvOzeHFn/0fHR4lqn6npNWXMUIbZ5R9rEot24azUOAWW5VZtIhZYw3sWc/aaGqMa8NDM5bBUGd75GJCs0JZEjK3cMrvpBhjAHizfcHrH8fIRKAKuIXL9JTkQ0M+XSMr1O7e0apMZV8jQFrWadRR/4iInFNy0dCf2YWM2Qm247xjscabJwLBSaOcJQzQaaJvFqSlGVye87Q515K1EMC1fV8HcuFQA88u3c0NiaMIzyoNTwjc+bPVt46r5mH83WX7+ojYIJ8UkPv2freQVztW6BG899gRxqd/VDPDucR+k0px6OSw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(346002)(136003)(39830400003)(366004)(396003)(26005)(16526019)(6486002)(316002)(478600001)(6506007)(186003)(5660300002)(6512007)(2616005)(956004)(1076003)(36756003)(6916009)(2906002)(8676002)(66556008)(66476007)(86362001)(52116002)(107886003)(4326008)(66946007)(83380400001)(6666004)(8936002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: Py9um2yHlQh6nYQ0ouCUBYN9kKbP5q8HXlfTQmw77gZuBKAZHXLMwYd5pdtsuo7UvBcxvYOEFEuN6g2oFmh4vjnoDjsiH7wKWfpv7drxtGyrutBbpsWdUdX2mjH42mRSz6Uka8TxjNLjmFtlw7OzRC8ZOPid/nYBX2q/QsThCAglo/74V/auFMqeQfqy4GntnIvxLtuCj5Z1BJCNH0eQ/HcrXsnDB8VB+TkalZ73Az38/+jh2IzckZOIQw+l5egtO7w7+c568w9TjKcY5Mc0lropUEYYlHZB83Ps4Ajz3KV01qCog+BSXkIhCTdN5FkN4xc3KuZJx/Z0clxilig5DEsvgMJP61bU7Y30Bgu79uPoEqjC5Y/XJ9PDW33KVYJqHtQ5by278K3/e14nn2eRFxJTav1lvFTnjLVQu+5FhanDw8q0ME9tWyqsyVwz2uUfe+N/SeJXNKBEzzimCVs79nbFvbHMjIuZzCcAJIKPIz6px29xoA3JhQlqchqX6u1UEdI2qz6f0fiAOTfnKyw/1xoMn4UQ6k+m0nvEzjizAj56uY1I9ZozwWSbjyaWroOwzBKfixvIzVh3WVtrKrgKR+q2akXdgkvxuRWqAbvkHithl0VOmlHRkExmCKff5HSY0zjig42ZVA7i4KgAtDst0w== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: a6d9865c-1ef5-484c-9f89-08d85a3ae407 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2020 12:20:25.6020 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: VH6EUWBrCr0l/Cmm0yslBOjcY1/in7/Y4Hq9L6wPme3eQ3j8Svh+M7PO1Ov1wn2QWwq5i0VCxbSUU2hNw+TNM08ALZ4cf3qYK7d5utt7hTo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB5077 Received-SPF: pass client-ip=40.107.4.130; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-DB5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/16 08:20:24 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We are going to reuse bdrv_common_block_status_above in bdrv_is_allocated_above. bdrv_is_allocated_above may be called with include_base == false and still bs == base (for ex. from img_rebase()). So, support this corner case. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Alberto Garcia --- block/io.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/block/io.c b/block/io.c index 0cc2dd7a3e..d864d035ac 100644 --- a/block/io.c +++ b/block/io.c @@ -2371,9 +2371,13 @@ bdrv_co_common_block_status_above(BlockDriverState *bs, BlockDriverState *p; int64_t eof = 0; - assert(include_base || bs != base); assert(!include_base || base); /* Can't include NULL base */ + if (!include_base && bs == base) { + *pnum = bytes; + return 0; + } + ret = bdrv_co_block_status(bs, want_zero, offset, bytes, pnum, map, file); if (ret < 0 || *pnum == 0 || ret & BDRV_BLOCK_ALLOCATED || bs == base) { return ret; From patchwork Wed Sep 16 12:20:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 305221 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8F05C433E2 for ; Wed, 16 Sep 2020 12:37:43 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6C62822225 for ; Wed, 16 Sep 2020 12:37:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="A8QDfnqq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6C62822225 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:59182 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kIWgw-0008Dj-Ar for qemu-devel@archiver.kernel.org; Wed, 16 Sep 2020 08:37:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34758) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kIWQQ-0004Yj-TT; Wed, 16 Sep 2020 08:20:38 -0400 Received: from mail-vi1eur05on2101.outbound.protection.outlook.com ([40.107.21.101]:34273 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kIWQK-0004IB-5M; Wed, 16 Sep 2020 08:20:38 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XvMNxykX2tMSUXn5+fXaDVhhVteBw4IOQZaUUSYxaAaP+TYRzRVMdfWgpRD0LEmfYu3zQPPiVRvFVmRLBsj5Cts7snxSl3LNpUTt+0+xfSXzBA0Q61f0M9Kbrz3pssVww7dDO+aALdoOyv9eqGE9+o1IW5HtsDHiXf1Sj/k+8pwtIatlvPilB4XGfEIHVfI5FnmO3Y1kZQVQSk1zNRe2BbKDYlnFyiqtwYzYB8QbgsA6fmdyF2KwyG76d/HlEfUUHSWq9o8mpX9oVNG4MFY7bifOT63ENQTLNbgBd+GFDxj5LbAVv3TD8nJXjBtWo4i1dc0PlF9x5sqj6X/riFvcBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Zln+dVilZBQzfYEBMdhvqVsUNpWvuzPkRunQgJ15EEg=; b=dpd1vt7NWplJN1MrVFTvCQOzEdSjxF5r0WXv1tyh0Xim5Uc2ow9lCk7kgRiCgbtow/I7Z9uud7KWLr75ZJrJAo3R+/cjrGHyo6sUkrIB4kfO6owYjUydc2lEtu7EokVrdI4ohwj+HoKqasculPrpDWPXtrpOcOTWK2e8gRU6/oXouhJRX2WYCAuGZS1o6mcLOPUYxUiWXaSldNScsBzk0RCC0l2gT39s0ulANSRu6gtgonhUdIreji1TD3kot8uN9V/4EVyPS31zvvSyANEJVtxo8fe6gmlX5s21PiFBiqW2Zqa9FtczKDqtZbTp9ZB0LQ2AYPEHO8jQWsUMXU6OWA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Zln+dVilZBQzfYEBMdhvqVsUNpWvuzPkRunQgJ15EEg=; b=A8QDfnqqbCiom/0m7qPHdYVl5yOHIZR7HKvjmYdIzLi/4iU5eATycPHRHCe4oUB9USSaw9hSzhdYdYpU+nkl0C3p+HjUOCtLpAsxYQWNPo/rl1LSuQgu36U7N19SmF3+VK7PYT8O8NXiqfM5WezYTGBToMt9XuiMJq6A7FTvQOU= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4691.eurprd08.prod.outlook.com (2603:10a6:20b:cc::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.16; Wed, 16 Sep 2020 12:20:26 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%8]) with mapi id 15.20.3370.019; Wed, 16 Sep 2020 12:20:26 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, eblake@redhat.com, den@openvz.org, vsementsov@virtuozzo.com Subject: [PATCH v6 4/5] block/io: fix bdrv_is_allocated_above Date: Wed, 16 Sep 2020 15:20:07 +0300 Message-Id: <20200916122008.20303-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200916122008.20303-1-vsementsov@virtuozzo.com> References: <20200916122008.20303-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM0PR04CA0018.eurprd04.prod.outlook.com (2603:10a6:208:122::31) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.75) by AM0PR04CA0018.eurprd04.prod.outlook.com (2603:10a6:208:122::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.11 via Frontend Transport; Wed, 16 Sep 2020 12:20:25 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.75] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fa5fdafc-3c77-47c2-a566-08d85a3ae4a3 X-MS-TrafficTypeDiagnostic: AM6PR08MB4691: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /NG39plXrGQ81uYiKd+Lm+/XXJEhrgDzudkWij68g2vw6WIr9T5HVGdzzESwhAFJexAk5TCMx4FnDtUHCrpV7UJHTW7x8V/qBCwwPJwwfjokFsjGQlXVhAiKIS+83LOxU7oQW4UboGuHW0wIDLdoQMme2ih2ZtY0jUzbg6SnY7H7HCDXDm0bHPByxHCakrXuXR3oYo+JUdBQA4TmvRIaHZzvH+DhUyFba204l2+nSCZ8iW8BR34wxpxnlpX8rYX9Qg3EiCHjAejgvOI7m+34RYahAh28c+uEd155d5KZ3GPwCqNcM08O3WjR2VoxMUHcgVCxC4s+et/P5NkxuRvvkQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(39840400004)(366004)(396003)(346002)(376002)(16526019)(66476007)(66556008)(66946007)(86362001)(316002)(2906002)(26005)(186003)(83380400001)(6916009)(52116002)(6506007)(4326008)(8936002)(36756003)(478600001)(6512007)(8676002)(956004)(6666004)(2616005)(5660300002)(1076003)(6486002)(107886003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: jUS8+k3XU7zxXJ/BKoiL6ak9JNXNcp6iGqYd+3VL0MJtjx3ylCr1Gv3Vo19tiMdE+N7ZsE+ubI8I28ME9YjL9mxdCzkQ8k/PgTpIsQQPLLj56uhKE6MfUMEmwzE5YqRgez2gD3nl2r2v8XeRjDIUi1ogdo18FVyWkbqDsEElXVEJknfquBrmN1aMIbcwU8PUUP654xTjV9D9FdWW/0G/OhRJ0OsU2i28zu37mHxmT1HpiX2KiUCiIYo7bfqNd5MfXk4nUYgAhoApPuBBrzgYrX6OJHuHbyXH9LbDgBq2DQZUPa2k2gQrTMq1SfjGtVXPM9SqeWPlZ6DD6ZtvKp2Vew4v9NgDVC+brSzurkoOwLlZxo4oEgRzE3MsBjYAYeFueNfJ7xCfhddNS+EoMtt/2KZTqiVIbYqKg3SwTYT/PBbHDLCe1PyYYPPoJjKV8NEvBL0tnm0mPQ+0x3hq8W+8xJE9J2LJAUsvk7QukKaeN+S8w/3W+8tAqYgl0rVPdSqpWOodFqsOMdnq1p3l3Cv1Rc+tORt56Evq1CpZS+PhYwhsC6tNqkXY8nOlBfi9NesMQkVuspGNXiI5kVKhUTek6/RhgRgQanabUUpEpIQY7ksDhkTk8exiKDwp6CKcZy3R+GZP3HAQ4E7qqQ6Q7FQ99g== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: fa5fdafc-3c77-47c2-a566-08d85a3ae4a3 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2020 12:20:26.4652 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GVgI+nQvWDDHHCDb8jdeV5K+GFNdhCv2eAiMhRzSH7dUp36DLEYODsAmlFQU2jCQVaSPdVLFpPHYwcNRxAUGcvFclVTYiirpnpVxuKIkXKM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4691 Received-SPF: pass client-ip=40.107.21.101; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/16 08:20:27 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" bdrv_is_allocated_above wrongly handles short backing files: it reports after-EOF space as UNALLOCATED which is wrong, as on read the data is generated on the level of short backing file (if all overlays has unallocated area at that place). Reusing bdrv_common_block_status_above fixes the issue and unifies code path. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake Reviewed-by: Alberto Garcia --- block/io.c | 43 +++++-------------------------------------- 1 file changed, 5 insertions(+), 38 deletions(-) diff --git a/block/io.c b/block/io.c index d864d035ac..95b86429ca 100644 --- a/block/io.c +++ b/block/io.c @@ -2491,52 +2491,19 @@ int coroutine_fn bdrv_is_allocated(BlockDriverState *bs, int64_t offset, * at 'offset + *pnum' may return the same allocation status (in other * words, the result is not necessarily the maximum possible range); * but 'pnum' will only be 0 when end of file is reached. - * */ int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base, bool include_base, int64_t offset, int64_t bytes, int64_t *pnum) { - BlockDriverState *intermediate; - int ret; - int64_t n = bytes; - - assert(base || !include_base); - - intermediate = top; - while (include_base || intermediate != base) { - int64_t pnum_inter; - int64_t size_inter; - - assert(intermediate); - ret = bdrv_is_allocated(intermediate, offset, bytes, &pnum_inter); - if (ret < 0) { - return ret; - } - if (ret) { - *pnum = pnum_inter; - return 1; - } - - size_inter = bdrv_getlength(intermediate); - if (size_inter < 0) { - return size_inter; - } - if (n > pnum_inter && - (intermediate == top || offset + pnum_inter < size_inter)) { - n = pnum_inter; - } - - if (intermediate == base) { - break; - } - - intermediate = backing_bs(intermediate); + int ret = bdrv_common_block_status_above(top, base, include_base, false, + offset, bytes, pnum, NULL, NULL); + if (ret < 0) { + return ret; } - *pnum = n; - return 0; + return !!(ret & BDRV_BLOCK_ALLOCATED); } int coroutine_fn From patchwork Wed Sep 16 12:20:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 273558 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA74DC43461 for ; Wed, 16 Sep 2020 12:39:29 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 441982224E for ; Wed, 16 Sep 2020 12:39:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="bTwlHOt7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 441982224E Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:37466 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kIWie-0002PY-Ex for qemu-devel@archiver.kernel.org; Wed, 16 Sep 2020 08:39:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34778) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kIWQU-0004bT-Hv; Wed, 16 Sep 2020 08:20:43 -0400 Received: from mail-vi1eur05on2101.outbound.protection.outlook.com ([40.107.21.101]:34273 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kIWQS-0004IB-5D; Wed, 16 Sep 2020 08:20:42 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lCxB6la21i2aJ2POGZJvBDZ8Li8QbJnBoKsRtP+ze5aduDQ8dSMrRQKAD8ZzhrsTPZJjbtw7/3n0GDmExBZaCSqdBJ57ZUBPqtoxb4GbPzfW8Y8yQH2yVvN+YC0JfKLwtTBgCF/J2QfHJpzZUFiCcFLQSkTtB+0x9/RONz3nyoJOxJkVxVV+eydDa/OLIUCD/jMG84WIi4lPqUDzlpgFDe773hA4Hm+j9PVVS2MFa73U1DCHvLFMgrCMM05KoMENhHHI6OJI3mkyR2u5mqQmKE1EWsF0YBxsFA653nGnoE4hJ/JevjnoSdqdGVz6ylJjFoBRdqS8V6MyGMbssqdUTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nS9dYq7QxBiSKbXqtOjbG0yXITSbNbs8CVFY6Vr5rm8=; b=apsYRmy+wA5C63tXHXLP64rrwp12+ytlYvKmW+X+7Vroqj1XCGlkMR+coC6a5sXag4xINQpWGpxNAbKAvLDsyWO73QHtka1V7ImUVNewCpqOvyOzi6VsCZktmadFyzwdBhgbJgrIAQ7XfjDg+d0mANEPGXy4uILAeS00usRftUHNh5Ne51J5MStVwDuJXX/KwN3r/RvJgDOsmk4DRCKzX3UftyJyrdT6FlsW98EP3XgJFnKfsRm6Mqy5atKqtDaRU4qQCIXC8e8DCuJTPPAPxlNLeRNdLM8oWLywPd7/Bc0kM/rk0FKB9HiE7WGquDPSZJ8eoggBf7VUQY/aMOfFzQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nS9dYq7QxBiSKbXqtOjbG0yXITSbNbs8CVFY6Vr5rm8=; b=bTwlHOt7S7sHSRsYK1IZl6D25uB9auTv86Ohifo88M6gTXqpUl7UIJqKkaSVgt+WlsOB7YtZmsOpy0yTYnleqHTMZ+PAIFXm9qFk/uTDXi+4YmjixbGFE71l/72unZB+Qbwq4YA1+w175+yillUkA/CrupgS1zKgXmT4PXAH+AI= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4691.eurprd08.prod.outlook.com (2603:10a6:20b:cc::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.16; Wed, 16 Sep 2020 12:20:27 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%8]) with mapi id 15.20.3370.019; Wed, 16 Sep 2020 12:20:27 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, eblake@redhat.com, den@openvz.org, vsementsov@virtuozzo.com Subject: [PATCH v6 5/5] iotests: add commit top->base cases to 274 Date: Wed, 16 Sep 2020 15:20:08 +0300 Message-Id: <20200916122008.20303-6-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200916122008.20303-1-vsementsov@virtuozzo.com> References: <20200916122008.20303-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM0PR04CA0018.eurprd04.prod.outlook.com (2603:10a6:208:122::31) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.75) by AM0PR04CA0018.eurprd04.prod.outlook.com (2603:10a6:208:122::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.11 via Frontend Transport; Wed, 16 Sep 2020 12:20:26 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.75] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1c55036e-dfe6-430f-fe85-08d85a3ae525 X-MS-TrafficTypeDiagnostic: AM6PR08MB4691: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:61; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FNGJAWnf9s/TlaUY+Frk/iaURZl0rQ+4nkH0OKh1vLWa5gYX+AevsWPJVyH5ghvIbVG2H5DNgjIPo5F3sD/4A3gbUPTvtjxzvKZIvAT1rPRAb9H3OBB431ZV7u3jzrIcZ/PDChvJML+AJ360+b3EaWBPfo5vNWl++TDTsVw4AKupIsspHngELMUy0N/UspDK/1pPAtZDZ4RpDYDMUtC0TdairLjyOC3v1uC898ZRldS443kDC0Oy/C0C7Q4keosaqL8hPWMG7S0ymA3wbcxK+v3lDlgOArhJILoMBc7pw15blgF7BgxdJtVhwSUFkNOlMwX5MydlHAh0wwooQBaMZFJN1m6UNnA42QbExGYOI8lHJIg/qXYvKFJXp++WTKCh X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(39840400004)(366004)(396003)(346002)(376002)(16526019)(66476007)(66556008)(66946007)(86362001)(316002)(2906002)(26005)(186003)(83380400001)(6916009)(52116002)(6506007)(4326008)(8936002)(36756003)(478600001)(6512007)(8676002)(956004)(6666004)(2616005)(5660300002)(1076003)(6486002)(107886003)(21314003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: CpS6i8EKsa+gbBrHSIkEJewnjO8xpE7t1yr/tJy4D0R9hOKy7cltIIauwlZ7qUv78qYo1JbRGG0tqju3YMzXBkCWicF5KB3M8kauIIbD9HBC9blV+qH+FwEuBGQC0d2AU+zW5F92di9T2OUMgGctaJU0jL1khQpTfFzZzyksnh9Vba862LnaKFmvCPhK+syiyDNOCo/G0CoDAr8YEoxFEyOMSmpgr9Q0PN82CdzLjONycRyrsnlkV//DG8xGgQ7P5yB6fWrJxlIM5oOVZTGR4HmcX47p6KzEqAaURPOrZv2Il8yqRxcePHNos6QeQpIbdTWVrMkL57tuCXtMseyHM89wIiNqOVNAG+8dMms5DRVBqzpuTm8xUZaGH2SNuNf9o8al7H1J5PuFXng7R2kRPMecWl8QVHxGrTpVLDfRewcvRAPNU5aCVbKFaMp6boUxSQhW+i002AOkUmDEqbkhZ+ODwmeq6TohKD9HigKSuLgC9OQ8tYFPIp3XLe7UYeSS45zI5ioJrWPPPFzqvkJ2pnivukA6v+BZagWUzPskh5bVZexG4zcQvdly+dy6BW682F5c0OfcXg77Wx+gmc7xJY6hR4SxxtpxRIb4hq3wo5/DG8C3FHelUsFzru2eJQWmXXU0W3sVqJXcX7qeoDUsbw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1c55036e-dfe6-430f-fe85-08d85a3ae525 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2020 12:20:27.3772 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: WmuVSEkZE8z2aWLJ+Aemt+PpfcFPymwSYPhbQqVIVZn301dVNfpDvbAor91MZhRTSFJYxdfeM5vOa+TOVGQzPExcx5NkSqd9vLZ6EetdG2M= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4691 Received-SPF: pass client-ip=40.107.21.101; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/16 08:20:27 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" These cases are fixed by previous patches around block_status and is_allocated. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake Reviewed-by: Alberto Garcia --- tests/qemu-iotests/274 | 20 +++++++++++ tests/qemu-iotests/274.out | 68 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) diff --git a/tests/qemu-iotests/274 b/tests/qemu-iotests/274 index d4571c5465..76b1ba6a52 100755 --- a/tests/qemu-iotests/274 +++ b/tests/qemu-iotests/274 @@ -115,6 +115,26 @@ with iotests.FilePath('base') as base, \ iotests.qemu_io_log('-c', 'read -P 1 0 %d' % size_short, mid) iotests.qemu_io_log('-c', 'read -P 0 %d %d' % (size_short, size_diff), mid) + iotests.log('=== Testing qemu-img commit (top -> base) ===') + + create_chain() + iotests.qemu_img_log('commit', '-b', base, top) + iotests.img_info_log(base) + iotests.qemu_io_log('-c', 'read -P 1 0 %d' % size_short, base) + iotests.qemu_io_log('-c', 'read -P 0 %d %d' % (size_short, size_diff), base) + + iotests.log('=== Testing QMP active commit (top -> base) ===') + + create_chain() + with create_vm() as vm: + vm.launch() + vm.qmp_log('block-commit', device='top', base_node='base', + job_id='job0', auto_dismiss=False) + vm.run_job('job0', wait=5) + + iotests.img_info_log(mid) + iotests.qemu_io_log('-c', 'read -P 1 0 %d' % size_short, base) + iotests.qemu_io_log('-c', 'read -P 0 %d %d' % (size_short, size_diff), base) iotests.log('== Resize tests ==') diff --git a/tests/qemu-iotests/274.out b/tests/qemu-iotests/274.out index bf5abd4c10..cfe17a8659 100644 --- a/tests/qemu-iotests/274.out +++ b/tests/qemu-iotests/274.out @@ -135,6 +135,74 @@ read 1048576/1048576 bytes at offset 0 read 1048576/1048576 bytes at offset 1048576 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +=== Testing qemu-img commit (top -> base) === +Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=2097152 lazy_refcounts=off refcount_bits=16 + +Formatting 'TEST_DIR/PID-mid', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1048576 backing_file=TEST_DIR/PID-base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 + +Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=2097152 backing_file=TEST_DIR/PID-mid backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 + +wrote 2097152/2097152 bytes at offset 0 +2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +Image committed. + +image: TEST_IMG +file format: IMGFMT +virtual size: 2 MiB (2097152 bytes) +cluster_size: 65536 +Format specific information: + compat: 1.1 + compression type: zlib + lazy refcounts: false + refcount bits: 16 + corrupt: false + extended l2: false + +read 1048576/1048576 bytes at offset 0 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +read 1048576/1048576 bytes at offset 1048576 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=== Testing QMP active commit (top -> base) === +Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=2097152 lazy_refcounts=off refcount_bits=16 + +Formatting 'TEST_DIR/PID-mid', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1048576 backing_file=TEST_DIR/PID-base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 + +Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=2097152 backing_file=TEST_DIR/PID-mid backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 + +wrote 2097152/2097152 bytes at offset 0 +2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +{"execute": "block-commit", "arguments": {"auto-dismiss": false, "base-node": "base", "device": "top", "job-id": "job0"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "job0"}} +{"return": {}} +{"data": {"device": "job0", "len": 1048576, "offset": 1048576, "speed": 0, "type": "commit"}, "event": "BLOCK_JOB_READY", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "job0", "len": 1048576, "offset": 1048576, "speed": 0, "type": "commit"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} +{"execute": "job-dismiss", "arguments": {"id": "job0"}} +{"return": {}} +image: TEST_IMG +file format: IMGFMT +virtual size: 1 MiB (1048576 bytes) +cluster_size: 65536 +backing file: TEST_DIR/PID-base +backing file format: IMGFMT +Format specific information: + compat: 1.1 + compression type: zlib + lazy refcounts: false + refcount bits: 16 + corrupt: false + extended l2: false + +read 1048576/1048576 bytes at offset 0 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +read 1048576/1048576 bytes at offset 1048576 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + == Resize tests == === preallocation=off === Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=6442450944 lazy_refcounts=off refcount_bits=16