From patchwork Thu Sep 24 19:39:59 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: 272808 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 1969EC4363D for ; Thu, 24 Sep 2020 19:44:47 +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 82DAC2396E for ; Thu, 24 Sep 2020 19:44:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="N+67AqMT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 82DAC2396E 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]:59796 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLXAb-00066H-LU for qemu-devel@archiver.kernel.org; Thu, 24 Sep 2020 15:44:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53198) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLX6P-0002Bp-AD; Thu, 24 Sep 2020 15:40:25 -0400 Received: from mail-eopbgr30115.outbound.protection.outlook.com ([40.107.3.115]:7591 helo=EUR03-AM5-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 1kLX6N-0008DY-Bn; Thu, 24 Sep 2020 15:40:24 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VcFNR2iwgO65DssyDtHHbPGsLAtfX258QZdlRN84ED6uIahFy/ECtwJgzLi2GgN/EKM6bU8Be0e3H8VvNbWWL6V24GJ8RzRQxOktGD4bF2BmMO29GhIsUg2wyFhNmqYCx6BfUaAsWnLpPdg66MsZmUPTTfr0/n8NRqwBSuVFcSoUVpjyKnthHJojqyGkJhC2tmKE7r9cdJlaFD00nwh0UtZRWsPf8wXjmDBF4ViRjSTz9Koo+A6FN87CDVxLvaXs9NNVRLBKdTnQzRPv2wHPuk1ebto69Ds2f2Anw/isdDrkp01F3Re8x7Mnbiz46Dk5EAaWP6p+NFAxmHVvMrdHJg== 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=JkRfw4kEUxTSccJbhh4IDctQLCYHDfA4QRm9EPfk7/M=; b=OWF34cebTv55hIrsfMtSRP9xOUW3hXPN0tMZnTQr5bYdkCaroOjtiD5IqNexYT1k3dK8NqLLzKaKTJzCUXMJn+FuhcYvmScuhLIErihIsCpZha/AoOxYnvuwQ0Dwnp7NN4eIf4s6g65xd+fZ5ZUH960ytX1nEbFOtgw9JjHsjkDRFFwdxEwp5XwJcMXDnmr7ec+/wmWnSAOyw1uqfrgPwQoaefhzPvpe3DrUFBvLS2MniMI1PNFdLL04WYdsY3lGsNw9HpaBfiGTefod8xP4CjNI99V5wjU593PhB7mkQWlAIytsjt4jNjjhfEKMvHRtBF5sixB3v6obV52bkTjmAg== 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=JkRfw4kEUxTSccJbhh4IDctQLCYHDfA4QRm9EPfk7/M=; b=N+67AqMTXVK66RikcD4hsOxKrNDFj5VTD1wl9Jhhs3wV1lxY79ikcGq38j/0/VPcfyv3g5s9XC12mPSKBCOE/y72N0lr7rMtbaZVmLlSR2EEmNPJr4CT7bWhWPIeTah5nI2rLoG8kpJc+l9t8DJcVLYxl3kNi+JV3tDJsMiqTkM= 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 AM6PR08MB3288.eurprd08.prod.outlook.com (2603:10a6:209:47::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.22; Thu, 24 Sep 2020 19:40:15 +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.033; Thu, 24 Sep 2020 19:40:15 +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, den@openvz.org, vsementsov@virtuozzo.com, eblake@redhat.com, Alberto Garcia Subject: [PATCH v7 1/5] block/io: fix bdrv_co_block_status_above Date: Thu, 24 Sep 2020 22:39:59 +0300 Message-Id: <20200924194003.22080-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200924194003.22080-1-vsementsov@virtuozzo.com> References: <20200924194003.22080-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM3PR07CA0112.eurprd07.prod.outlook.com (2603:10a6:207:7::22) 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.94) by AM3PR07CA0112.eurprd07.prod.outlook.com (2603:10a6:207:7::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.14 via Frontend Transport; Thu, 24 Sep 2020 19:40:14 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.94] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9fc02405-c4e8-4c35-5348-08d860c1a8f7 X-MS-TrafficTypeDiagnostic: AM6PR08MB3288: 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: G5Fr0q3plh31MUQZ6c0CxL0vQH4C4Gw6b/a3W6ErZonl2eCTk0qfPJwLIcsRrB61ERPYNs97aNMfloIeU0Mnz2hkuKzRGe+ve00AETDIhZHwIHF772BL24EfmUqzvLk6hCYF8+3mPdc9IOawRMjK7gyv6dWsapYdCZSCnmuZxZcfe039qTdss5SEVeeRLvikVMoa6kubj7089YZnMc1lxVdDHCTvlTHzkLDARuRQFjU7fwDOIO5UqXBryM0lwd60kY//M0r7Kr0wLghBcd6uMZb72ryxWMjv9sZTIRKxgzME8oD5e56mFtpdDcLaY8Fgn5Q2TkBEO+EAzUXMFy2WZg== 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)(39840400004)(376002)(366004)(396003)(346002)(136003)(8676002)(66946007)(5660300002)(6916009)(8936002)(1076003)(26005)(66476007)(52116002)(478600001)(66556008)(4326008)(6666004)(186003)(6506007)(16526019)(6486002)(2616005)(6512007)(2906002)(36756003)(956004)(86362001)(83380400001)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: wU0s+vSs1GPsI8E17nAL2XmhUjRrw3wxiYQO1ZXhHxkZemm1rW/QW4dnE8i8dTH1Xlk6a3FjT4FNrlSwiMV4G1EQUDenWicROsnJQY5MSKcyGZiZeVE5xYW1O2cI4Xtx3ZKcrCe0LQJ5wNi6yvNObImP5TPd14sWsPY8c2EGhOBfvpsQY7bheCh7S1g8Xzk6+SmDtl7gMHrBjW4VGmuD6ws+VqW4Bqzp3CfnjRmax83yIjTj6fZegNxlQamiXnDT/QI5KucWS8uAn9EIgt9EZMtrnId9p1IQpG4DivWYtkH4pZcklGJNRl2GO0XknhrDMg/lJKMnwEzqsfqdVnSjLtnHSv4j8kmg8GQi1jDm1lfeaP4o3ZQycqCCbylTtBHnzjgDGEcd8dVlOSS8Zh/2KtUVS7XYLOrQd8Mpow0ltWuqO8YL9PMxoZMc6A5I3o289RqnAEuQCqncWLnMj6fNE9D0mHBuzAn1a87SJvyjxQed3y8TVGFPn0k7lDkOqVDz/vvhM6uYCMF32UKEIrjCQ+9Gcn6fq+05yKECcfS/9A26bzNRS4dDTsaF3ZQF6t74mJP4+zjTI9NhjhCfj0m3NqeEZSRohWLrnuQQ72qgB6GQ0bdP89eB24RyCaYlxgqAuOPzva0XQI+IbwHqumoDJg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9fc02405-c4e8-4c35-5348-08d860c1a8f7 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Sep 2020 19:40:15.4084 (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: ntR52+TFYMeF5tHoJQJu56yd0ScwDm8b3ZBXrD8oeynhM0oiNuzgf85HP7/vyc8QU703OPGs2nvopqjiKH2no9lNmcPuKDrkSe1V7LA+OUI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3288 Received-SPF: pass client-ip=40.107.3.115; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-AM5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/24 15:40:21 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 Reviewed-by: Eric Blake --- block/io.c | 68 ++++++++++++++++++++++++++++++++++++++++----------- block/qcow2.c | 16 ++++++++++-- 2 files changed, 68 insertions(+), 16 deletions(-) diff --git a/block/io.c b/block/io.c index 449b99b92c..4697e67a85 100644 --- a/block/io.c +++ b/block/io.c @@ -2350,34 +2350,74 @@ 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 = bdrv_filter_or_cow_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 = bdrv_filter_or_cow_bs(bs); p != base; + p = bdrv_filter_or_cow_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 b05512718c..a1bc16e202 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3860,8 +3860,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 Thu Sep 24 19:40:00 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: 272809 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 0ED20C4727F for ; Thu, 24 Sep 2020 19:43:06 +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 4FF722396E for ; Thu, 24 Sep 2020 19:43:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="funJJ1D6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4FF722396E 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]:55072 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLX8y-0003we-E7 for qemu-devel@archiver.kernel.org; Thu, 24 Sep 2020 15:43:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53184) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLX6O-0002BX-1p; Thu, 24 Sep 2020 15:40:24 -0400 Received: from mail-eopbgr30093.outbound.protection.outlook.com ([40.107.3.93]:8707 helo=EUR03-AM5-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 1kLX6M-00085Q-A3; Thu, 24 Sep 2020 15:40:23 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KH34U0xOcA4nWKutmkA+fb7dF/KhPm5HH9WRQOxUrlLxwuSNNW0bHnNToHR4JpyRQZiZaM92o7ErKDuSnIaYvIFSp7Hzgh5b8kHzRIvAIIYnok/FUYCz4kucjvvzTEEAZuVemDykqVexbWbD74h0/+4powQ2C+VempHPDcMLe8A32UGSdD3XiZUIpJDhwkwZxN6Tfr5/wEg9NOIr8REd/MjSxYdW/rSmtSM+ri1opKEEP/+8s9+VdGCXVDDl2OM0HDxdsUdWKCWrz8WFB9/bEy6o1lFmkUiH8VGaNoVrhyFQPINnF0W+uGoBXnrrEM7zmVeoX43FxgBQVdK+5JP7bQ== 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=+58a/LB3xSKkKutG4S7iaGWfFnh9DqSQ2RIdOK+eFyk=; b=OS6bwyLDSwhuV19wjEnz52eoRg0/pBVoVGAOoinX+JXcWBsjmlnhN405rsP4qYhPvts3qLI6sdFxLwV+thMQu6IVjh1jDCI7k365wFWWpEMv7uFJTmXLaX3rOx7j3iDz733MICQXyxN5zt7PJkpZs0SA+cNdOpBGjUnrIMIOCPawxwbEMCFAzfDpqoi+qsZPlzBwvW52032dqWik+BtEN+PfxpmCN4CX0yycLGwC6ABPK7loi2/OkC8UOdKtSqq0m8L4ePoUcWyVSHm+WOX1SoTJNfzJF3C/Hz9Fp6vAFqy2FU+CG5ZC1OY12N6WnSNKJvbTHK/Zjdk0kNe5tC0xlw== 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=+58a/LB3xSKkKutG4S7iaGWfFnh9DqSQ2RIdOK+eFyk=; b=funJJ1D66CIYN3Snn/2A9xfJ7x/kkQQcDiqde9HXDyQ6897pPVD2xfALvtDUvw19e6qrg8ygGpGd3vzdoZEeeAC9HylqWPRedgtH4PLyJCMQuceQPGoNsNe+8rkuytDvJO66hvGLlYCd7npGjuFw9wX9Qfnn24Rc4VQvJyOUP/s= 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 AM6PR08MB3288.eurprd08.prod.outlook.com (2603:10a6:209:47::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.22; Thu, 24 Sep 2020 19:40:16 +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.033; Thu, 24 Sep 2020 19:40:16 +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, den@openvz.org, vsementsov@virtuozzo.com, eblake@redhat.com, Alberto Garcia Subject: [PATCH v7 2/5] block/io: bdrv_common_block_status_above: support include_base Date: Thu, 24 Sep 2020 22:40:00 +0300 Message-Id: <20200924194003.22080-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200924194003.22080-1-vsementsov@virtuozzo.com> References: <20200924194003.22080-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM3PR07CA0112.eurprd07.prod.outlook.com (2603:10a6:207:7::22) 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.94) by AM3PR07CA0112.eurprd07.prod.outlook.com (2603:10a6:207:7::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.14 via Frontend Transport; Thu, 24 Sep 2020 19:40:15 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.94] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bf2a3607-3d43-4fe6-8612-08d860c1a979 X-MS-TrafficTypeDiagnostic: AM6PR08MB3288: 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: brKHj7A7BO8Riaqiq+NcEaVkpjm8dTxUzxmxDgKsllXp2lfMCKOYvNaVyJTG/KTMLUvCPXOLzNPS5ukJVIUvUwW12Gb1ZXl6cSW9aef2GsOZcQMVkWblvu87Ft0z0B+NoZuhURf7WFMLvdLfkskUZerQiIRc2xeq/rKvKNVkhHj3ieZo0GHpbkzHe0Glkl0mI2hSJ3mZezi6EUPzStz07damDHZoUr7tEz/LmS03+8Z8vP4oMgtc02e9ddXYlXlkCIH9M5p8RpQ0A8QM5LOjxPT9UHiWv9E74LvMgbJuTQZOLlnL77zeRvKmlIxEeuyRzBoO1t8P33Hql7vuCbYn7g== 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)(39840400004)(376002)(366004)(396003)(346002)(136003)(8676002)(66946007)(5660300002)(6916009)(8936002)(1076003)(26005)(66476007)(52116002)(478600001)(66556008)(4326008)(6666004)(186003)(6506007)(16526019)(6486002)(2616005)(6512007)(2906002)(36756003)(956004)(86362001)(83380400001)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: vczn48eHebnloMFHQ/OVUSDf+XCcju0BQ3ZMLEwU4jujZSRJ2gX/ePqGvsUoELEXrfRYx7/xofiSRdwN2RptEuT0apbaNNR3rkoeqAMRWHHT6XPDR+yATb/yJN70vKOMb4f04qhudMfeHaWDWTrrmRu1diRb2szUyib3jS362JXV82Vdsoc2xAhKBjHEVXkWOWs2q5B60+92nsxHcbPo0jdzODuDvJepgWcv3JLFh7/mDNPwzLWVCExG0tAaO5tpCt/2h80TnKpk1EGNj8Glst/PwI2FICVITJ5/Sqg0Q9DP9jYvTp4OpFClvk0vCact2rLVQKGJHwXELTWGzcpTKK0fqUHPZ1biLWzjI4k6q8ULDjwfJ5BnbF/JSxj2s9b64Lj/R2j2VBt3klHEaYclLJGUXhUo3vpYFcPFD0EauAVBu4XjQdh7Sc8oiXPMHmD6ZV+GTfOel0nIbCSVUc0vJ///Ahx7cz0Uk1WEMRBD3lvR/w8Eu+ZXRzv9Vs5CvLW9TxB7hJ3BorQvZMsqkGOwT6XjnrlFIwbPVyVf8EwQjpx8fIpfSG8Q5WaMrg42cyjw4TnVpHL0biX7s0PZ8ao6k6emIHZVqUSUi+MO7/Bc4kWo00l7+az0ht1Z0QlPtnXQFEQJ/j6+ACLS2a+9xzvJsw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: bf2a3607-3d43-4fe6-8612-08d860c1a979 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Sep 2020 19:40:16.2726 (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: V5h5rQqFGVpUcSl88FIAQeqe7kEqawmK8+G35eRQS6EQHyvfX5XeweNjQXlIjkvKdnTp3bS02B+wCP/uh4fM7YXj0YQnIXFUHZwYpeO8l/I= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3288 Received-SPF: pass client-ip=40.107.3.93; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-AM5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/24 15:40:15 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" 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 Reviewed-by: Eric Blake --- block/coroutines.h | 2 ++ block/io.c | 21 ++++++++++++++------- 2 files changed, 16 insertions(+), 7 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 4697e67a85..b88c7a6314 100644 --- a/block/io.c +++ b/block/io.c @@ -2343,6 +2343,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, @@ -2354,10 +2355,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; } @@ -2368,7 +2370,7 @@ bdrv_co_common_block_status_above(BlockDriverState *bs, assert(*pnum <= bytes); bytes = *pnum; - for (p = bdrv_filter_or_cow_bs(bs); p != base; + for (p = bdrv_filter_or_cow_bs(bs); include_base || p != base; p = bdrv_filter_or_cow_bs(p)) { ret = bdrv_co_block_status(p, want_zero, offset, bytes, pnum, map, @@ -2406,6 +2408,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. @@ -2425,7 +2432,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); } @@ -2442,9 +2449,9 @@ int coroutine_fn bdrv_is_allocated(BlockDriverState *bs, int64_t offset, int ret; int64_t dummy; - ret = bdrv_common_block_status_above(bs, bdrv_filter_or_cow_bs(bs), false, - offset, bytes, pnum ? pnum : &dummy, - NULL, NULL); + ret = bdrv_common_block_status_above(bs, bs, true, false, offset, + bytes, pnum ? pnum : &dummy, NULL, + NULL); if (ret < 0) { return ret; } From patchwork Thu Sep 24 19:40:01 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: 272807 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 DCD35C4363D for ; Thu, 24 Sep 2020 19:47:38 +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 3FEEB2220C for ; Thu, 24 Sep 2020 19:47:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="m53LeD6L" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3FEEB2220C 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]:35418 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLXDN-00080h-B9 for qemu-devel@archiver.kernel.org; Thu, 24 Sep 2020 15:47:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53214) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLX6Q-0002De-Dd; Thu, 24 Sep 2020 15:40:26 -0400 Received: from mail-eopbgr30093.outbound.protection.outlook.com ([40.107.3.93]:8707 helo=EUR03-AM5-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 1kLX6O-00085Q-Kv; Thu, 24 Sep 2020 15:40:26 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fCWZVN2xxD/ggOsyCkZJpyAA8KINACGVCTaZDFksLhOglcRVd5D4uy21Jo8zYu+lBqLKmKkg9BX9EA1o58ia9GP3ytLmw5/FyMjoDL7N+eIrpsfuuVEcRMm/ZuFVQL5ZNWGT70j9mV8PltAypAM6BVgsyoihhe7N26hqn2vBoht6bfMTmPuDxTJkxU5+qf3UBE+ag6MLQ/L3W83Yh+diESNKQwPzQQh7o9W0r2nCwT/GeKSdCciEUQN6HhWLZ8Kiq1Kk3zcz32RI1nvcWFxdlaVibBqFVkdCoupcfSOrASXuvhM1pejPmzGSsRGE6gdht3MBQxkeaWG1ciHmfX/8QA== 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=5132FUDEOt4Ku2kTboJY3laAYqCd3DLn1Het1veGTj8=; b=d3dwzdHbTlz1Ypc0rIKTVOK2842QF6IKqbRNuVlH5eH6n+aANciOaT7vASgfauya2GnAHp234nICOFSfD+IUSsqhr2YGuZKHvE7ASUigIz8QYwKrCIIiWRLUtJXzAbXkEVJstJMsZ/2vDNKdxOdStMIOmgpqLqF5DFKw/sV7wgPx2cQQQipgpmJSo2Fn7ZP2vnFhtAlgLn3gGukQ4Rh69Cwn8LcOYQ+LFWr2XKnBKvHwdz2rb616215ZbSnpjbG1EK7WMLwXv/W/WNZpasuKjngyNhy1mrYYEc9aPsMLKZdBft/Sozz4yZTnyGbY+zdnOZi+neU/0Kpw0MybMCPrkQ== 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=5132FUDEOt4Ku2kTboJY3laAYqCd3DLn1Het1veGTj8=; b=m53LeD6LVP7nS7FQftGEd0eZB1s9kS+FGkNpantLbejXCkA1XVshlt+ZQZ89t6de865q03bRKg71gGI9pw0UUOOzJ6LsZjXGxzFjubRS+Bi8i9GFFIj5uZNOmKlOf+AhK/G+ESx1c8Sf3x0uOMi+3a3Xh4xwvj8BNFmsxkC9yZY= 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 AM6PR08MB3288.eurprd08.prod.outlook.com (2603:10a6:209:47::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.22; Thu, 24 Sep 2020 19:40:17 +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.033; Thu, 24 Sep 2020 19:40:17 +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, den@openvz.org, vsementsov@virtuozzo.com, eblake@redhat.com, Alberto Garcia Subject: [PATCH v7 3/5] block/io: bdrv_common_block_status_above: support bs == base Date: Thu, 24 Sep 2020 22:40:01 +0300 Message-Id: <20200924194003.22080-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200924194003.22080-1-vsementsov@virtuozzo.com> References: <20200924194003.22080-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM3PR07CA0112.eurprd07.prod.outlook.com (2603:10a6:207:7::22) 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.94) by AM3PR07CA0112.eurprd07.prod.outlook.com (2603:10a6:207:7::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.14 via Frontend Transport; Thu, 24 Sep 2020 19:40:16 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.94] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8515d962-2476-4720-c2c3-08d860c1a9fe X-MS-TrafficTypeDiagnostic: AM6PR08MB3288: 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: LeSaHP3eimf13EIUGyKzfk3aQMNQZG5AN/pz0F0DoXGpVcKSUaKYgVg0XjQbvEIbVMoUCJML+RxRgJfKMOh1ePfkvgIF0EKZuafcvdwg0BEQBqJaadVq13itLiUu9J6LQTwzVxPkiD+O3tPefAhEDhJ9qJuXHlCaqeMNjr0CEX20hGfmxc5TahXdBgsCqCawfI6yIJ0fNcAq6VwpRLqGfUakUxxjcIwHXSA1EuwcIKAQoD7Q9Vz0R8ta6JG1qJ/YTZGv9xqy0nPE8R7HdtcJUDSy0KAmXML5ZPuksNklMVqPe9PBStdd5jOXUsGTF9JwzisggysJNPjH9UMs4v06cA== 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)(39840400004)(376002)(366004)(396003)(346002)(136003)(8676002)(66946007)(5660300002)(6916009)(8936002)(1076003)(26005)(66476007)(52116002)(478600001)(66556008)(4326008)(6666004)(186003)(6506007)(16526019)(6486002)(2616005)(6512007)(2906002)(36756003)(956004)(86362001)(83380400001)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: UFLrdMk2+Ie61urX2EuRdYZ6Nt0GAfrEx3iLfmcCkHVckBfiiZ05kqnPbs/WXMU2Ku60NovwWv75f8eNJa0dE2vuyBnDQnryoJZgL4KEjjfCQJD9t1b8yfbyqug1gx/hzyPpy4hoD++VUm/gXdhvGBCB39L8ztcvO7nUQ3aM+HVKKIS7+d+DZOhIjkSRhL+9COLr9xVBAWBfPM5v+Nd74gfbSUrln3UuQle3hH6wa2x2CAgcIa6Z8sYW8J2lmmV1bo7tSby+zZ+wxhJ5KdVcMvKrRcMk6wQgEnLnZAN6X2CEZyU78RE4f/1HLvAI4efZFuR057af/vvCHbaWNA1EtFKRbx1BGJX0XOzRzrY1vLfKwgCVBuRpcfBr8B+MhRcmGgXJ4r6vv3TH36hb34fdky31KvkF46POKvPUwdT29Jr7Aec7FFR6vAq21/BNg5rX/gWfq4f2f/6IEYnKjjOoLId3sEzlG9T0BqysuxQpQo01bIwrT+WhU1zZ05DIQX8cEZ0EvI3STG7Q8fXUs1F0O6IOl33uJKhfhBqDb1MUjL13rfBlW68U3vwOa4JF0XcXTe5dEzejTx/0ZU8YwkXSCqyr8xZ4MHxRBBtWF8lM5zkgHSRAJZSzXogRGrJTynhfiBDM5a/ZVETBaegnrvR/FA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8515d962-2476-4720-c2c3-08d860c1a9fe X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Sep 2020 19:40:17.1219 (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: +92eS/3EG8MHl2A44qtEP4XjrStYSlr8bcFdOtl9aMFcBj7wcDuB39vBZeDSLu4iGXAliboWn6iJhTui2BsUFqSkBlIKBXQKHy9+Ez6FwSc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3288 Received-SPF: pass client-ip=40.107.3.93; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-AM5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/24 15:40:15 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" 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 b88c7a6314..82a3afa3dc 100644 --- a/block/io.c +++ b/block/io.c @@ -2355,9 +2355,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 Thu Sep 24 19:40:02 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: 304482 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 842C2C4363D for ; Thu, 24 Sep 2020 19:43:56 +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 18E202396E for ; Thu, 24 Sep 2020 19:43:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="wch56g8A" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 18E202396E 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]:57914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLX9n-0005Ep-8p for qemu-devel@archiver.kernel.org; Thu, 24 Sep 2020 15:43:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53230) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLX6R-0002Fc-TJ; Thu, 24 Sep 2020 15:40:27 -0400 Received: from mail-eopbgr30115.outbound.protection.outlook.com ([40.107.3.115]:7591 helo=EUR03-AM5-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 1kLX6P-0008DY-Rw; Thu, 24 Sep 2020 15:40:27 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=To5yruTbdR8jpELyiDQimxFW9IY51LlPRmmhTjHslIfljuu/QKOG29RqYl36J88oIip/E53p8PDQ0mVH0ic+/D6AfyRrRVFVjqlFjRDFaZSUTkaKO9TpXfZmgmEw8I5zFm4qV4PgELieWXWt2cFowErfWbILCIEbVRG+tgmwd6lfvSdvXNJkBi01btqy8Ds0iAJTq1IAV+j7UjmrOvjEodakU+FJbR0O1tn0NLhViUooSUfHljZhRXZiX5LrAGiZk0sREfg7K8an/BmjF01Ah6w92zQSMN/IfBSJ8jQ4f+hYutoc+AQigzatSk2WAdRz+co4GSwYKAGtPMthB2VpUQ== 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=T1aC4vFeszLZooBKESYqHp+t0NRkhpkuPdFReSBcd1A=; b=Unw3dFc+ZB1JUt/p4sf4dU/R8j7RZfu4JuiDc0L8Eu9ANGuRm+3LPn/HS7U6CXLlnur8FVpU/O6nWo6PfNEpFYvF/3mWSCyF8NvWUTnXEgpIslXS+fPst7CHYiWgRO03lwDfCKWCZyl00eByGRjnvSB0n8mSHv/7Hl7Otlp08mtf6Kv6dU2zq9UlC43FQr1xTVbbvtCSJQ15k/MwodjmBjz0zQcKlyfijPsotEwL64wb1fiuEaZL+sxgxfYUpUbW+ayAnGEtrJhZToxLzqT6n7YMKn8vB3YIX7R6mzTiAnp31FlByA+TSuo4cbQds+b2hJMP7qugxb7CnlsB8lM9QA== 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=T1aC4vFeszLZooBKESYqHp+t0NRkhpkuPdFReSBcd1A=; b=wch56g8AvB4C8L0TwMty2YMOPKLnDGJeSPP6niewwbeMXvY7FUAS2p2PJS/gWcFNtL/Pc3mGVLEZuiMm9IQ8JDbUPKf9FWIExs2IgomXMWAlgFbnpgOx750FNyTHbFHo2JVIZ0zI181v9Pi4GNV8ERhd8Q5yW1qAzeTCfDrnx6E= 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 AM6PR08MB3288.eurprd08.prod.outlook.com (2603:10a6:209:47::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.22; Thu, 24 Sep 2020 19:40:18 +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.033; Thu, 24 Sep 2020 19:40:18 +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, den@openvz.org, vsementsov@virtuozzo.com, eblake@redhat.com, Alberto Garcia Subject: [PATCH v7 4/5] block/io: fix bdrv_is_allocated_above Date: Thu, 24 Sep 2020 22:40:02 +0300 Message-Id: <20200924194003.22080-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200924194003.22080-1-vsementsov@virtuozzo.com> References: <20200924194003.22080-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM3PR07CA0112.eurprd07.prod.outlook.com (2603:10a6:207:7::22) 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.94) by AM3PR07CA0112.eurprd07.prod.outlook.com (2603:10a6:207:7::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.14 via Frontend Transport; Thu, 24 Sep 2020 19:40:17 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.94] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a6316458-187e-4d2d-1609-08d860c1aa83 X-MS-TrafficTypeDiagnostic: AM6PR08MB3288: 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: DNaaNqzEy7WgaBeL/3vtmH8hOJqI1BjjlBB2hoqXUFXMmmBiljY+MyadZUhn0M+iOFFsxX1o0PD0YGDkf3pmWwskSyBnsispQlDggKhhihJhbjrRROacHlf4P+aDRJpMcep0c8RFuWtEEV7P894YOYBWd9Mc3MtaG8cEUJ/4DOwjzgJOEIOyevqaBnB2I1+PCSZVURPLB88dLvuigzZOLGLWGL6pV2fuo5Ut833LSdmzjkcUALxSqdhvJKg3HEPvfytcZOjyxsLHdoexgFUisLEDY9JbD6dLqI+3+0szCZwT3GZZVpy366Tf+bD44t1hDJshmHOmAhnN7r5iznp64g== 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)(39840400004)(376002)(366004)(396003)(346002)(136003)(8676002)(66946007)(5660300002)(6916009)(8936002)(1076003)(26005)(66476007)(52116002)(478600001)(66556008)(4326008)(6666004)(186003)(6506007)(16526019)(6486002)(2616005)(6512007)(2906002)(36756003)(956004)(86362001)(83380400001)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: V3IW7NDeeE0pZ3/XHd5+ktOI/oaI4+oI2NqZtl8yZjadfyRsDiR6TJp77ve22rDoSs5/5P5JvD6GO6ypQONpr4z22tCjF6J9Gi2cEKPMvxgH31Pe9xH8SzOVVqHHHrEW4LeUTkUB1RhnTCTevP/F8bBEzMvBm3Dzc7iM/3LCA2lUyxMRrvSOKC8qKrk9FhVO69OvSD6Axe8jxtJnnnB64brc3D6SvVH2vUgT0F3o4YyOOMAPFhCEvrIKeweYMGv94UaqkF5tDkQrmcy4Twij5NqC0WGJpgOYvYlGjBd+pBjc/0DEXEaR6DIDJw5CzU8pfYxJDTg9GC+iAylqL35Oovj46N3oJ1us9X47YYs8hhAT+ln5h5iO3BmRNY8Rx71THQOdodohY8hrmyVFUa+Qn1xx23B4vel4vvF09rRW9kOAyc3sZ+OL1TOf7gHvIInKfACHFf5QyI5XyumpHQWonFvbbN024vBFkQSA3pH0XkuYyjAdeSEa66br/AhRlM7jumrRFgqb05UUvj7esc5cJ30wyULfDbZc+TPJesJqYBn/6nNxDgHzM/K4PLRpxpP0mUs+uPPAoIUaADq8B/gsl7qvzvuIlUcpUUwzbaA8yxKldyAPpXedgL1OYsC+Ax51vK0lD2UERBl8Qd5D64QxnQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: a6316458-187e-4d2d-1609-08d860c1aa83 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Sep 2020 19:40:18.0349 (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: qskoEZ3oc8QHTaARJWHECfITrvwU7YGtKDF/EGicnkAl+O3V7udGeIn3K4vM+rk6+FgaAZlGpKgf475ZfdB2dQijGK5YtgiR1NStjuZFDz8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3288 Received-SPF: pass client-ip=40.107.3.115; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-AM5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/24 15:40:21 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_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 82a3afa3dc..36baf4fed4 100644 --- a/block/io.c +++ b/block/io.c @@ -2477,52 +2477,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 = bdrv_filter_or_cow_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 Thu Sep 24 19:40:03 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: 304481 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 80C98C4363D for ; Thu, 24 Sep 2020 19:46:15 +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 239342220D for ; Thu, 24 Sep 2020 19:46:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="nMcx5gZp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 239342220D 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]:33820 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLXC2-0007Hm-4K for qemu-devel@archiver.kernel.org; Thu, 24 Sep 2020 15:46:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53240) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLX6T-0002I1-4X; Thu, 24 Sep 2020 15:40:29 -0400 Received: from mail-eopbgr30093.outbound.protection.outlook.com ([40.107.3.93]:8707 helo=EUR03-AM5-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 1kLX6R-00085Q-2o; Thu, 24 Sep 2020 15:40:28 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VZFKUdR1tAEzx6EEf5EQyunvu8YFQSqOKDXi4uBgqe6vZAVKmxVWg/2MLdfnHgpQL/YcRllQOpEa/+SRzSPKqOmXLjiVMpd/QWSjlfv04rl2ccXVYjG08xHgUbW+D9ndg0OIP2UKVuzs/HrqaSuN1+VtVL0IenbbaXn1/eJz/V+EJluqVXltAvU57ohVtZJW+GwkYY9fApZ3ITWw6i+tkMN6CRGjgGjtoxdkMPNgYhDb6sH3xqAgZzL7eXDn6bMi6oGh5+qWzr0Rx+yOjRR/+jRNG7DVbXW41tVEjEMCsEOt9lfl8i5g6mU9ruzVLtonZAiZuf10sbjSXrVwnZIDaw== 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=gSWohvEYEA6sNkgXMZ64QkYiN7/w0mIqfTZzmn9ZZww=; b=fSaqyFR4HZpHwruO+usTh1/hRrskzXZzVi2UFUzVe3HzO1mGw3TIFe3aMg5W+9pvjXlzE8Cf780TTCVKSc0gaXJsK3xIOz3Fbmmn9+nvSz3USlN/WfWanICixxz5cfQgW8Ccne0pBfsr2NP8u6N3/0PA71s+q1iirLrfeA1PfzLbV5tH3NER22Pg2PxZsteXO1TwOfPQ1rwLtC5vgUMi1eMswZsLsBcd2iuMKPtmMgkv6UHOVFzXAgfswgBLsyXDAqw2msW9lA0p9klUpTXH+YY+HtaEWg+Wvinwxw/FJRHZVI0KKi1D0WfV5MFJlCKQZLk9QKEjoJZS8iQUq6eKXA== 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=gSWohvEYEA6sNkgXMZ64QkYiN7/w0mIqfTZzmn9ZZww=; b=nMcx5gZp73M2Yw2ENLwO8XoGKhgm62Pxr7N5xKdHye0dCAJS769Xf61fJY0T7lg8cRKPq8onfTDH/uDarMTTrSMIoj20HhqDhqcdW4nMtP2eTuLRa2IyzJMnhDlDTs4Ljjr4LD854G/TURriMaRd/BOcTLuDCnR96PjLLW8/qdc= 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 AM6PR08MB3288.eurprd08.prod.outlook.com (2603:10a6:209:47::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.22; Thu, 24 Sep 2020 19:40:19 +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.033; Thu, 24 Sep 2020 19:40:19 +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, den@openvz.org, vsementsov@virtuozzo.com, eblake@redhat.com, Alberto Garcia Subject: [PATCH v7 5/5] iotests: add commit top->base cases to 274 Date: Thu, 24 Sep 2020 22:40:03 +0300 Message-Id: <20200924194003.22080-6-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200924194003.22080-1-vsementsov@virtuozzo.com> References: <20200924194003.22080-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM3PR07CA0112.eurprd07.prod.outlook.com (2603:10a6:207:7::22) 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.94) by AM3PR07CA0112.eurprd07.prod.outlook.com (2603:10a6:207:7::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.14 via Frontend Transport; Thu, 24 Sep 2020 19:40:18 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.94] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6c6c487d-284a-4492-f1ad-08d860c1ab0d X-MS-TrafficTypeDiagnostic: AM6PR08MB3288: 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: Nza7c07hrc/nboFg+gcuHJNSkAM6jqBr2Nm8uN3PfrPRf4QtYwlp8zx8x8b+xd0N2MivrKIg/HJWGHr0oewD0TEhFD+Wubtve5RU8CVCgCodK0Dlpb8EP20brCQc9pVqmcVwkW3hw8w/Y4inO4qN3k80TJJjOkm6SAjgTakMZ/jJthURGyVcPdyBtYgZ+r32IsXyZvfrR1QlEjqWSM9BYzYz69QkvDsCVU5tVJCqiNDDynqLc0ZQsjkBpqTjYXMgNV3NKuAiMxFfFPLC/7kQT2ZYPkgvWqiK9h/YJAcL3CWxk66kxEhymKn/Megzg36d6dh9OqNsF9tx0udS5fktB10rxEaZZXvYKBhwR1ZJ0oOtIovb6ysfYrJDWU0PWyth 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)(39840400004)(376002)(366004)(396003)(346002)(136003)(8676002)(66946007)(5660300002)(6916009)(8936002)(1076003)(26005)(66476007)(52116002)(478600001)(66556008)(4326008)(6666004)(186003)(6506007)(16526019)(6486002)(2616005)(6512007)(2906002)(36756003)(956004)(86362001)(83380400001)(316002)(21314003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: rceNmgZTg5Wjmxt8b/VVAKfF+n+scpYrYP/BQvBQx9q74EQdpVlK4YwRUnmTxV3eimPBRM5Rgf90BxwEdx7l8XhZ7fq1u4PVzWfRgnP72wk0ePPyhvEySIfl7UbAVHns9oWLKDExgfZflsNOiD31ch7WbGb+B9WV2BM6P+iiT4w5d97IIh4hYYMGZ4HY/BemEJp/3gZJ0cXahZSCYFgFttj9oX9U7l7Fk3XaYQbQ62/seJigPWP9jMdv0NkWRj8bDqG34+mLAjK6Yv22+bv/QrxBMLXKZFZiSCTNBf834unb1iHIY3PH5fziI/kLZOdwdEp7Pz4D9O+9ar1dp1yOiR+mz3hAAknZs5m/LzqpgZm8ftldgScKKHwrRgsgsdPEXkkBPwgwofF1xdNBGz/RnclumqO0AicZNWxawIq08kunTqXXcChvhgowql2g8sdV4EEohXPa7o2ZB/SxvUSvgpWVGb0CFasNdjgNr1PGNjrJqDaapT6KPpo+KpBpbDP6KUACMRZArM+y37vYYDoqKXa7G74dKkW/YA0ZXvHQOVwSuXirzVUvVnF7MYboAKuvbFU+SFvZ50Yr0O45ewppkllGG7KMgDfaT+amJs84lXvdVaKiZB2LkVA3jj+rwXp39NPNYjegWw6fE1UxRKdvwA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6c6c487d-284a-4492-f1ad-08d860c1ab0d X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Sep 2020 19:40:18.9210 (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: kalUZ97UYfcCkATSSzOUEt4vKMAhxOUIFQrqjLCzhxGg7yWucQHegJ5OwIeKrcp9Ryr7ksDe/jQ5RZl1lmA3O1iMNlRunW8uyLYcex3oeOk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3288 Received-SPF: pass client-ip=40.107.3.93; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-AM5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/24 15:40:15 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