From patchwork Wed Dec 22 17:40:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12697159 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 693F4C433EF for ; Wed, 22 Dec 2021 17:43:31 +0000 (UTC) Received: from localhost ([::1]:57224 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n05eE-0003sW-6v for qemu-devel@archiver.kernel.org; Wed, 22 Dec 2021 12:43:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52380) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n05bY-0000Ul-5H; Wed, 22 Dec 2021 12:40:44 -0500 Received: from mail-eopbgr70109.outbound.protection.outlook.com ([40.107.7.109]:22241 helo=EUR04-HE1-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 1n05bV-0002WE-Op; Wed, 22 Dec 2021 12:40:43 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RNnE9GS3Nf+fNOLM60f1KgNXTjU0w8dAvFvsuLG+Pr0FP70ls5vi8uX5y5jHW3sCwcaBqQ942ZLbxtagLVPpLZGHp8Za/xxYjiVkOyaycrQq2b8yBTt5NkKbQNF9LzlObKk+pZFTj7lBysEOQL2EFqIxfrf6BQSwFxZDwJ0YzsGZIcnwfBLfL+r5HZz9bvUKq/QBwgI3l+ziKXrKQ2uhlZnwV/3rL/9IkWZ9tRsUUTVZGl3tPpjpaoX9w8euOkGGimAPZoN9vss/xc6nSwj2G1dbUP0Hum2TKjyvdbQIyWVL2gK42T1gIQwTgBL1WokgXPj57pxDWBcQ1ZsYT63LNw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0W+c4GEJzYkqtX+5Fp3LT0W2so0PT2e/4svJn4jayjY=; b=M1ESPaJmM0FTWxPgwMrngiFjJkDDs1is6ylF36o+mD+z6/DIwzVacv7Zi+nZAKbLpb/AMbejqlzt4HK7eqrQg2wkJLYQ+7daBRlroVI3KfGAi/vT1EpcocL4s4M+vrej5/ZfS/uK1EwH6RQ3tOlQKChIfosB9FiV8hrwWg1TfUz96vBc06WxJVdznLrL8bM/xyXRCQpLb8/OpmX28d3sCUGJ4TM6Xh6J+ASr/ZB1m8flo27HznZfMX1Bxl5smufdikHT50jF/FzsSXM0GRr6rwuQlRK7zhwmn/I0psryb2eDKGvXEWciU+fkMXv2adxnzITIOz7IZqNqlZ/oKhRlEQ== 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=0W+c4GEJzYkqtX+5Fp3LT0W2so0PT2e/4svJn4jayjY=; b=f7jU1otXwf5ifFc9rXrj9Pq091MKpcxhYz3OROE+wRmw3eccyazZDFYnaG6j9XKttrtUpUcjPc6wEj8M1nCNDWG1y7pF47u82RFoJxKOaV94kxtXCIt0D8c9ekh0j75w6Ugrfr7y/UC0HEe2zl+V0hp7RZEZaRQ7W9TUxjgF4ao= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) by DB7PR08MB2988.eurprd08.prod.outlook.com (2603:10a6:5:18::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.17; Wed, 22 Dec 2021 17:40:33 +0000 Received: from DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e]) by DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e%6]) with mapi id 15.20.4823.019; Wed, 22 Dec 2021 17:40:33 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v3 01/19] block/block-copy: move copy_bitmap initialization to block_copy_state_new() Date: Wed, 22 Dec 2021 18:40:00 +0100 Message-Id: <20211222174018.257550-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211222174018.257550-1-vsementsov@virtuozzo.com> References: <20211222174018.257550-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8P250CA0017.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:330::22) To DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 30844477-f71e-43c4-448b-08d9c5722765 X-MS-TrafficTypeDiagnostic: DB7PR08MB2988:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:48; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9Or2O73p0HqTKBsMXiDIUz31c3VgK9PJKpfWBwTqAWAVkjRHbKCW6fFdUszeUzWIZjzsgWO4ZVvONYFRoEtV1nf/oKpknhDBmwrnfkUtWpKaghWyCSLDW5uL4Xn3rcJwUdlTWrd1Kl7BlJc2+uePiKQW0KeBE6JWYph7KIP+CYuAXwkDQ74mQNtPyUrd8bywtcvRH0YW+HFvaS5lUi/IqPa8MNROi/XTfGuA3GxF4ddsmXOBvTFHiRc9fruc+vfJcPAlcvJDKEd8sipJwSPFX/LY2I41ySqjIniOuwCV/FWnL8GEwjFj5bj7/2yUhOfem88fkS4O4VKvgIZWXH3qL5XSBqRBq5/kv2whxBh4evhs8+mfrL4B7aggpSaV4NQNNJ4RvVAdClXu+5yiTbCGzE+yXENkgxfYQRT8lU1avYrUi44GkwKVN8fo4+RUQ0dCHDhzHA6nUJrkikbFNNT/TOV/sIlwURWOApbvSOOazhU/UmIbUrSSITxHx3jDXPEok+2L0aDbu3psSzYmrDOuWLdPxoszeQ3cq9bxZKUhf0KnIC6K71SKJ53OV7fDnt68gAMihLvIGOhAi+FNKjH0EsMNq+Kx2itXjH/lYQR6aARn8MZgR6cQtJFqGBSai48PEqrdZsKelWBJktBpntGNYhQ3dwAn4W85GuLFC22K/ofLNYKQ8/6A0roZXUC1oeYVR+SP9eqFHXkNH9dE+w1W0A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB9PR08MB6748.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(66476007)(6486002)(66556008)(38100700002)(66946007)(8936002)(1076003)(86362001)(83380400001)(5660300002)(52116002)(36756003)(6916009)(2616005)(8676002)(38350700002)(508600001)(6506007)(4326008)(6666004)(186003)(316002)(2906002)(6512007)(26005)(107886003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vUDru4V0SxC73OkkK4QmFezQYiCu4h5S3gWYFiXz8ElGFabQSXupNfQAFRIqN9RxZSG9/rThdxSUWQD2qv83AjP3V5nRuRdJKrPn7o4yVH1sAD/xZ5B6HnaESYHLmActx7JYod7Py4yecPh2mYMDcxKQOkALmldEYseXdQoV0iQusj7JVKx4RqCx1/5nGGIKBFkaks1sZC9oxw4h/SzpQXhgmYhCvNoEEbK/WJddBZzr0+XxVjBm+20H9c0J66GVuGLaZ1BZJHXIl+cJwxJjFuJSzLrDSXzxcmA9gXhzAByT9uf4joddAw5d1+SlJXOkHUalyjFLFUG938Bp112599WDFAz/XGN0eTLv1Uv9QFWldiw7mE+GKJS5Ynxyx5AdC92yCfFiIjCd2jABsCVpFcDSok43Cyu5nv56bY6PbJZx/dRCOfdybkHmy3/efaipZB786QjEJ1jq7f+8PMkojkx1ma9LJkTck+dLwMHV0SYLNpbw1/gmQxD4tf2suubyAEG3EQ3uaVq0NTFrS146CZlRXZqel+YiYzArps9bPG8tiMV7uILJt6wrGF0LJfq27V+r97Ge/5SWdrjeDwzMl2W7daNX8LDM1VbZrqDyfX4daZcEqMReVXvMFdUL1OSJ788xGCnES9RH48WY3jEXLY4PqxOyo8Rk3FXlnAQc+9kI0Sbhmk3Hf6adSWnnriLByGUkuiGyhCUtZ0/hwflLBrj6j+nJYpZMJkuOxOjOJcJpgeTKYU6eVfsF2IPBrWt7z+xM6c/8P3G3JdNZWPIqAOfNR0c/s8oyX2PyI6ErDDR/txfVx3+tv+l9W6VKiFDN2YusK5F8/K/0+gajR4wG3rAI5a+z4KFZvQm+VeyfaTfXF5YcLDm8r3Tg+emrh7wqIJxXfQ7DJtLOd8XaTth9NGXDt/WwpNeLpBfgq90Rb7t8+/NBkZrd3qjtCmq14vgDpMDO+G0eo3J2AX/BNzWsgFquQtouN6TJvvlveTc+YjOlBJU2VKgz2DayJzTcTnOuMbFVIMpSqHZ6mi2Eu+XzjMTRfg8CA/sQRkZEWKDVkcsWT9/EpuynG2CQdnu9uVuMttA+SoHIBwF0Vqroa52xXpvYzgPgPfbIMIqhDaxOwbDI19eUNtrWt4ITdQOXyRyxDyXmErWQvfY1hF4hZX+Kt/PlTqEDyE075TexkS1FCd14hatO+SRQ3NVggw4pdasZ/I19aUfsYx7+fuCF+ckMAbciNMSs6H87mWNXkcNOeU66ol2l51B6cSxjejgjA3w5vpbdWljWy+nAbDJrkykVyXyq7jTFDxrhIO5yIidqjLBUPPQv0mkhhWFU8mgN8WoJY72fAAYiD4cZERSfBht/cbp70N6rXtEXdYfUhKpAT6uVwYypOlPQq3z1/kG6X+cC6OPny9SYZ0QUocXzqfr2Ab0J9AZo7tMiJMhM3jTXJDLEGrG/gqI9lFRz5LLfS+KWVNGFwc+KQvIqM0tgJhwDR5uSOnsFvvrq1tGeOyA6syaXOBYw+Czi8ZIKSXCqAnZPhhbu5ytsMM8h75u6kil467GroxymITLKuBoxOo6H5jpTQ6rNRqpDV+2pxZNDcJWq98kMJznxNysxGz9rt3SNVLd2NBSs+ZvS7U5RgGB2EhGApJP2uFc3VuoXz93DMx+1KKMs8eWuEh2KOCuzdEoW2xq4ekYycqIHODIcFD+RJmw= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 30844477-f71e-43c4-448b-08d9c5722765 X-MS-Exchange-CrossTenant-AuthSource: DB9PR08MB6748.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Dec 2021 17:40:33.0027 (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: kYCzqv+Eks8KXK2vC9k6gi5kVs3KXyOfjHqeGd627Vqe8QRLK3niPvpWrPmWBbz/ekcsm0qg0PUczsvZR+DSaHcZXKNAN3aY7S53v3hT1iU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB2988 Received-SPF: pass client-ip=40.107.7.109; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com 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, 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.29 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 complicate bitmap initialization in the further commit. And in future, backup job will be able to work without filter (when source is immutable), so we'll need same bitmap initialization in copy-before-write filter and in backup job. So, it's reasonable to do it in block-copy. Note that for now cbw_open() is the only caller of block_copy_state_new(). Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Hanna Reitz --- block/block-copy.c | 1 + block/copy-before-write.c | 4 ---- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/block/block-copy.c b/block/block-copy.c index ce116318b5..abda7a80bd 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -402,6 +402,7 @@ BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target, return NULL; } bdrv_disable_dirty_bitmap(copy_bitmap); + bdrv_set_dirty_bitmap(copy_bitmap, 0, bdrv_dirty_bitmap_size(copy_bitmap)); /* * If source is in backing chain of target assume that target is going to be diff --git a/block/copy-before-write.c b/block/copy-before-write.c index c30a5ff8de..5bdaf0a9d9 100644 --- a/block/copy-before-write.c +++ b/block/copy-before-write.c @@ -149,7 +149,6 @@ static int cbw_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { BDRVCopyBeforeWriteState *s = bs->opaque; - BdrvDirtyBitmap *copy_bitmap; bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, @@ -177,9 +176,6 @@ static int cbw_open(BlockDriverState *bs, QDict *options, int flags, return -EINVAL; } - copy_bitmap = block_copy_dirty_bitmap(s->bcs); - bdrv_set_dirty_bitmap(copy_bitmap, 0, bdrv_dirty_bitmap_size(copy_bitmap)); - return 0; } From patchwork Wed Dec 22 17:40:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12697165 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id DD688C433EF for ; Wed, 22 Dec 2021 17:50:53 +0000 (UTC) Received: from localhost ([::1]:46574 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n05lM-0007Mj-N2 for qemu-devel@archiver.kernel.org; Wed, 22 Dec 2021 12:50:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52420) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n05bb-0000aW-FX; Wed, 22 Dec 2021 12:40:47 -0500 Received: from mail-db8eur05on2127.outbound.protection.outlook.com ([40.107.20.127]:22544 helo=EUR05-DB8-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 1n05bX-0002Yd-Uk; Wed, 22 Dec 2021 12:40:45 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fq4QNpzxpTwWitNnjLeVwtUyqMUcIq82TU/hi/i1pdYho7oRt5ukHQ8zBwowMBgLP//isXmkdoGDxVtTL4jVUeH07W9+g8ErteMDXAcMzgyZdz0AqHrFTaSYoviQ/T3Im1xJZL3VpfJgQHxufE4EH+SpiQvUG4nfyyue76sPiLz6GpjuWpU/5QF6uZJfyYYKs0R6tRzRZ70SknGhsWasqD/iTHVXSDSKVPiUzD+hHyJmvCWm2UEFPah9JHHrcwh1DPS5NZtcjrSDpuu2IJH5Ou04a0JVCaSLN/C2r/UNNEIJQUNawAVbxZ3ZRUkfCIGwRoWnXwgeBqie0Pj7Q+pdnw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IGochcAmlq9WNCAxSlSglotwUEZXkkgcwtlvRC9XeWw=; b=WTdqtZabTfQmRyTauS6NwJTFvdQcByY5sZ/KkFSpx7pHeXOScG+A9Rg+J060xfakZ8BkNGrFlmrXz81lsZbABw9yDszDmWVOyX5qYenaeTplkZK7n0a0rtPJefF8oBWA5OwBMwwPQylrumtrz4XXm5brNu6oWZ807xLL0E8suBoXFXtnIubwpficRwZi3O4ICjDejreN1XiykzANr9g64Iq3/JK/FJ3znKQO/06/5Xv550Nu0QPxKVjqAaCVBP2Sc5kUvPwKGXjWN6DgBPfRtB5QZSyXljKnpvfRr7NYsJnrqLriCiNOLVv/KuUpLvt3sn8O4jUFIHkdACVKilEU1w== 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=IGochcAmlq9WNCAxSlSglotwUEZXkkgcwtlvRC9XeWw=; b=dFxlPV/RVSr9HBHgqyLYvdd7q+VxP3IV55mpjO9bqS150Oynz5P6a5Tx7EHjRJghhXs/l2n8qoK4lMEutcRHaT/HzaU2K+ezYNMQRkAsk5nlwPCbd6lAkis98fjJhfp8+9YDUlp4IVIC8uzCX5JhgO3mQMTmZ4AuoN0u0qLjQ7k= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) by DB7PR08MB2988.eurprd08.prod.outlook.com (2603:10a6:5:18::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.17; Wed, 22 Dec 2021 17:40:33 +0000 Received: from DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e]) by DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e%6]) with mapi id 15.20.4823.019; Wed, 22 Dec 2021 17:40:33 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v3 02/19] block/dirty-bitmap: bdrv_merge_dirty_bitmap(): add return value Date: Wed, 22 Dec 2021 18:40:01 +0100 Message-Id: <20211222174018.257550-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211222174018.257550-1-vsementsov@virtuozzo.com> References: <20211222174018.257550-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8P250CA0017.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:330::22) To DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5b567c6c-8349-4eb8-8654-08d9c57227ef X-MS-TrafficTypeDiagnostic: DB7PR08MB2988:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:431; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: l8dwKo1TWsc24DGI4K9N78gJcIko69/zxGYPvD9HDTvUegTsPHUxI6N2bdcBEnSCSqgABXTNta8aVapiwQ78d00vBsCBlJh9REP0eAxsb5Ve6zFS6yVFBOAJaT4/hCCShPYphC2qMJHGLcDmV3Jeq7tF0SdjSplgRbArmjxH3dBSUFIyu++IP89t+cpA3YerYJawd+WOgFM/5fbnkZVjtON7Fthv5T6D5CpxdK99ZwroLIpm+8AR9HdyMAAJhg7aeHuxEqa9g2nxNUab9jRIk9ouBftNQ0EqfmzTgM4v3EKMNCE0Extp7kAUlE2iTg1fHP+jxmeNmNvJcYjrs1hPoziuq4P2djOcMUwrpldC8SFfsFh751kgI/SbaDZHM+qZSYI5H7EIYvoQ6tI9W++fvEOHIcG2PBqH8iIEuQf2sbPFxBc4zS97sQUmAcDqSUAJ9uFfDtD9GW8svV8Kq7xXeEF7a58v9RWrL+VkXoF0Z0a/cCWj7HRGX+/NALNi3+oQN7JIJFEXihHjLCKxIm4NyaGwsmBTzIUqbunvOiDUmFWUKAuj3lFFMpLRIKZ+TCIMYhp7BqDvuwf5dlmyqnZ3HMSw3/HZWbyRLY9Hg4ujNMnkDycgfRu6u8PUuPezHrCnKVmPUD1lQtOvzhNbheLtIXNtXm+YAlrRum2ID2bozszVxleGgJCoKhLR2FLr0Lay1b4WuhGdlqxVPQOewNMjL3Ef2k+wqdNpdEx0XzFuc5c= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB9PR08MB6748.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(66476007)(6486002)(66556008)(38100700002)(66946007)(8936002)(1076003)(86362001)(83380400001)(5660300002)(52116002)(36756003)(6916009)(2616005)(8676002)(38350700002)(508600001)(6506007)(4326008)(6666004)(186003)(316002)(2906002)(6512007)(26005)(107886003)(14143004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: puv7Gnx6x/7xLVozz99e8wXtI3DEaUWC/soBSDf9XjUQqz25lM9sXyF+ZsaEDwYOJTRoAhBfSk+dE2QcTcz6C7bSjCUvJP86E9p/VdWXW6LBiqdSvga2itcTqVXEO/4m4r6BimXqBUq4rIUofTLqZdH5iiv3vkDOVUvu0chp6qy9eWMQGYgPNZBbjWcvZ02+G9y3U7hTaFU9/UvOGlh3b5h7OLq7medT2yt2zM8WFhNWRMr0tU+os6sbl2QSqD0NJGIGQJCtLvSHDoblUb++gp4NLyXAc+MaPPaDEjunhcOlC+Om8PXFKcUs4GwFxeJfOqt/ZbFMgnUmHrKa7JmyI8vWAjTUm49ICFsYE6hlWMGVdMMHmVPTJmiemauMroEayjUYJp3l5/y2oUFMnUN7sRSS8oaw3pAAJL9ftWuwGwUOSthWQfosKzCgOttSZMbpZ8O9KQdbsb40rTWEnDcBfPjC8lvVO0Q1nn/sk/wTWTS73lwcxb6hEYH4wbmpgo682cXWw4URIcVaNfM1M1it/U016Zc+x0IeEJYmVPXR3m92IQogOyZWycOijy0V37ArZ1DyekDDqBELLczjUxCAclYExqEx+Mjl8jgkfe5DbqmW2mQB0iFv470soMOOeZ8Tz+HLnThEFL/prttq4V2442lsCNxUYMyl64TxyS/x+F59o+nZTVQTfH/3dKABW9xYQFGZcltYtovJdCpz5uQ4h7L5zJSF/MTAhK9+f18vSoKRvfFtnDlJO0nNp2qFaGZkMS9Aiq00jvs83I07522qleQ0i4Kk6g+a1utbG9kZ6mMKax86xEoJkparqp0e/1zXBguL/Bn9ptCE1Y+0aR2WQdRK10EBaUQiXwUPp8f+mnDqnY3neYqs8rLJ1VZPPITj6fGnTv9cMR3ROrUZg204LPtudpCH8bhM6KoqrRcDciGYOf8fkwHh2sGXVlBVJ91Oso6aoM7EVND8HjXlp5mGFILFCImfHJQHl/9XyPEQ6qjLvUiThjoUVIk3py8XN0/JoZdyyyBWeqJCSP+Y1WPmfLkTxpz6zKKrilBnHKsrrSW1opd4/2X+GCgSbz8kiEPI+P3Rc5FCT2J2dNgMy7A91E3YBzVLJ1kgU09yLFiX6iiNlT1rIgfgapToGJzGT/y7xDI0q6EcreJ+rTfDErURljolzLU5ityOBj72xLiZHD7bR6kNzlDbzkMpkadTdrmYJ1V+oOSwPSzeMRqzjKZQwhpcvbU4J9XkK+HvhcHKGxs+tHm+/waYaD4WHp+rvB62YeeDVgyS7TSLeHArq9XWvvW2uadHS1uHyBXqXMOntxMRnTLo38syHVzIiKHFF4FaTWPgthZuC4K1SAgM5OCSxGrcFntXuW83BcgUGOuXNqK3J7m3XTvMhNtLymXH/sRCk2CvBVi/BaA8lieR8N90D4gFaOo0BTuzoCbARM4L3YVsqLaR+DKMaY4ZakM+J4z8oja+UEUim4gMBNYFChmII9ayBe4RkQXK1Ygz9dNV0EKRMbZU63U0tGCTlzdhH16ZdKZ3rh8FUU7oFR0aEKujC+ecsoo+K8lueP3CanZlelS7Y52L6JnwdygbK9yVbkxzxiyzKEdq+vQgaNtTVLSuJUFV172rKHjdbi3PiTP1lD+BhYw4925wfmdJpUgBib8aaj3XywY4OHlHn7zsGTG2X0VVV6TEe62w8pkynnSl7Ss= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5b567c6c-8349-4eb8-8654-08d9c57227ef X-MS-Exchange-CrossTenant-AuthSource: DB9PR08MB6748.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Dec 2021 17:40:33.8619 (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: p9S3wtQ1EAzFY7mbEZerrZuJQrMvXcopHc1143MngE+RgzTymDA50iRjnTCXRTxvsHGoQ+EAEqWcHATF+/wi6S8huY6MFgBsy8i4fF7RcPQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB2988 Received-SPF: pass client-ip=40.107.20.127; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com 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, 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.29 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" That simplifies handling failure in existing code and in further new usage of bdrv_merge_dirty_bitmap(). Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Hanna Reitz --- include/block/dirty-bitmap.h | 2 +- block/dirty-bitmap.c | 9 +++++++-- block/monitor/bitmap-qmp-cmds.c | 5 +---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h index 40950ae3d5..f95d350b70 100644 --- a/include/block/dirty-bitmap.h +++ b/include/block/dirty-bitmap.h @@ -77,7 +77,7 @@ void bdrv_dirty_bitmap_set_persistence(BdrvDirtyBitmap *bitmap, bool persistent); void bdrv_dirty_bitmap_set_inconsistent(BdrvDirtyBitmap *bitmap); void bdrv_dirty_bitmap_set_busy(BdrvDirtyBitmap *bitmap, bool busy); -void bdrv_merge_dirty_bitmap(BdrvDirtyBitmap *dest, const BdrvDirtyBitmap *src, +bool bdrv_merge_dirty_bitmap(BdrvDirtyBitmap *dest, const BdrvDirtyBitmap *src, HBitmap **backup, Error **errp); void bdrv_dirty_bitmap_skip_store(BdrvDirtyBitmap *bitmap, bool skip); bool bdrv_dirty_bitmap_get(BdrvDirtyBitmap *bitmap, int64_t offset); diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c index 0ef46163e3..94a0276833 100644 --- a/block/dirty-bitmap.c +++ b/block/dirty-bitmap.c @@ -880,11 +880,14 @@ bool bdrv_dirty_bitmap_next_dirty_area(BdrvDirtyBitmap *bitmap, * Ensures permissions on bitmaps are reasonable; use for public API. * * @backup: If provided, make a copy of dest here prior to merge. + * + * Returns true on success, false on failure. In case of failure bitmaps are + * untouched. */ -void bdrv_merge_dirty_bitmap(BdrvDirtyBitmap *dest, const BdrvDirtyBitmap *src, +bool bdrv_merge_dirty_bitmap(BdrvDirtyBitmap *dest, const BdrvDirtyBitmap *src, HBitmap **backup, Error **errp) { - bool ret; + bool ret = false; bdrv_dirty_bitmaps_lock(dest->bs); if (src->bs != dest->bs) { @@ -912,6 +915,8 @@ out: if (src->bs != dest->bs) { bdrv_dirty_bitmaps_unlock(src->bs); } + + return ret; } /** diff --git a/block/monitor/bitmap-qmp-cmds.c b/block/monitor/bitmap-qmp-cmds.c index 9f11deec64..83970b22fa 100644 --- a/block/monitor/bitmap-qmp-cmds.c +++ b/block/monitor/bitmap-qmp-cmds.c @@ -259,7 +259,6 @@ BdrvDirtyBitmap *block_dirty_bitmap_merge(const char *node, const char *target, BlockDriverState *bs; BdrvDirtyBitmap *dst, *src, *anon; BlockDirtyBitmapMergeSourceList *lst; - Error *local_err = NULL; dst = block_dirty_bitmap_lookup(node, target, &bs, errp); if (!dst) { @@ -297,9 +296,7 @@ BdrvDirtyBitmap *block_dirty_bitmap_merge(const char *node, const char *target, abort(); } - bdrv_merge_dirty_bitmap(anon, src, NULL, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!bdrv_merge_dirty_bitmap(anon, src, NULL, errp)) { dst = NULL; goto out; } From patchwork Wed Dec 22 17:40:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12697160 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 0BAB1C433EF for ; Wed, 22 Dec 2021 17:44:23 +0000 (UTC) Received: from localhost ([::1]:58864 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n05f5-0004zz-1M for qemu-devel@archiver.kernel.org; Wed, 22 Dec 2021 12:44:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52522) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n05bd-0000jx-3S; Wed, 22 Dec 2021 12:40:49 -0500 Received: from mail-eopbgr70109.outbound.protection.outlook.com ([40.107.7.109]:22241 helo=EUR04-HE1-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 1n05bY-0002WE-SE; Wed, 22 Dec 2021 12:40:48 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jiqk3hcmDWVXTGEI5jyTaJguFPSOo/9TMCSzkcpvHHMTGCyhgcwlZE5HWX2WiO778W0XO33YdZH/wv82sb39WoQvl08lrHSeqUUDkSBbTOy7PhmXb3QG8kHbIijxjwKR4fOkb+hubzMDTxh1w4scaXyNBw8EqTIh4ii/yTxoxok9SJTj4Qs3Yu/zOXOvsDATMd2wgC5Mo+EEzSGsI/YGjmJnrepVCFezIYz50JMqWxZebGxuQk+dL8roFXChVOG1bp1wj4XyviwQ+45r6aT/dOiKcqmJRA2eOKlmt6lpdv2RmrkkFWAMMmA7+BekmJ7my/zGQK/9H+nJfgK+s+97sA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JNdVYZCjXAFpP7kOUC2W/0ZCiZ5Ei+0Ej97yjyNW43Q=; b=Ou1V4/XuuSOMEUR0PuyjvU8gcLeRIYymDtpz22/eFtLthxwjacX/iWzdHzgKVZaf4NaN42o+Fryrqfpj/26nXOhJ3gqEpPUELCbZ4bRFgDG4f//1KnwTNMo+Vm7tf7i1jDXkGtC2GymA8rI6hJSahm206dEnNVwnk0FtMMwLqLxt/mP/h0KBDt8xQWy96V9ZihdGWLgMgIKez2q6MunbzdwxiG8u+Ptb2KkR9SZ8jUwPpm+OtcFxhWcejPutEMfdX4wOPsZpa1ZpsAyTkDmqk4vjMHK2dAc2YCMfMCVRF3l9553vUTFVDsrlRpD6+ajmfM9VnVpoipnJEmm+nOU4QA== 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=JNdVYZCjXAFpP7kOUC2W/0ZCiZ5Ei+0Ej97yjyNW43Q=; b=IPw3lTTcHQvXVeOFQmC8Pqf1KM22T4VIl90yibm1yrgjorEeECFs4nlt+FvTYK5gvZ1q0ZIr7NSagpHb0HyuMnSxgzsKJcEvnI8WN3+G0IcTDLwkWFiEK4h6WsbBgbJWAGZS4xUJWlKnLkGbroVuCMN/7mxftPxg+YrIG4N47DE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) by DB7PR08MB2988.eurprd08.prod.outlook.com (2603:10a6:5:18::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.17; Wed, 22 Dec 2021 17:40:34 +0000 Received: from DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e]) by DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e%6]) with mapi id 15.20.4823.019; Wed, 22 Dec 2021 17:40:34 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v3 03/19] block/block-copy: block_copy_state_new(): add bitmap parameter Date: Wed, 22 Dec 2021 18:40:02 +0100 Message-Id: <20211222174018.257550-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211222174018.257550-1-vsementsov@virtuozzo.com> References: <20211222174018.257550-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8P250CA0017.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:330::22) To DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: aeb0595f-075c-42c4-61b7-08d9c5722864 X-MS-TrafficTypeDiagnostic: DB7PR08MB2988:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:27; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TjcEWWeOOop0qa3USt4bA9QWfC7zfjQxOP+SHRXMBD1gR62LAM7JFx5IKLEn8u3ExXTM1CI5ab8QujglCRudnJjAm9fFHX4vJPqQr3rkDYOf0fzJ97LmUo1CxqtioYK3mZQcjX4Kp/iLDaGvkK2l/oKtSvuvb4kfV+tDGE7aygcziCsy2VBQl/ejq2WghuADanV+5kxAfP4Fv7IJtQC8no+Mo98+o6U4PvLScvM7otYHMsBW9spu84R2DxIVXCpvES9cph1CDMGKuc7Si2/voeA5f8nl/HcyAy208RXor++w+bSZPPMeuDYe5wLF4xjzmPGn8a2yiYxJTXIHH5DXSq0QqpOrMVJpM0vl7P4TuahtIx7FPZZzw6yu1vhj6f43KyaeVtEIt4qhBvSCqb8LdlJR4mymbQ+1tZKveFNUjVeSJczfhFzDirtAs4pQ96aza/+fLUWNOI3RyGWXAN/jOcN4Vy2BIpVjapaK6XTUNSKHfwuc2nl/+GsJt1oGV6AK4EieIgCc0sc2c2kHc11jMp9bVM6qpCkjiD4H7BmgyyrmpzBRBrqCphTte0MgjaVloJgNOkt/dJ8dTGcbO46sDO+igZ9QVAgtvyCV+f8x1tKr7QoRLtCShdNwVcR7u78YjDKEQ4KizrBsXBYybHE8y9R5MlPIXagcHOXb4VAOaMMKrNTQkJC5m4UlGFfYsLt6xVWNZPOR4cs4mNzTSQSO7Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB9PR08MB6748.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(66476007)(6486002)(66556008)(38100700002)(66946007)(8936002)(1076003)(86362001)(83380400001)(5660300002)(52116002)(36756003)(6916009)(2616005)(8676002)(38350700002)(508600001)(6506007)(4326008)(6666004)(186003)(316002)(2906002)(6512007)(26005)(107886003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bWIcr/wT4fIITjSEIEld06Dy42bmtZT71p///DeubyXabhuFJb5ybSdQXyNCqbCI+UAcy8HyCAfJMKwZtJG+E/SpefcZUI0jcJhsKq/MapTz176mHrJonuz4Qia1i/vDF4UwWL5Pa3r4JJvBoJIF7UKh8KnQldYEVqhIVp09rfL3nIaRBcwKA0a7r0ckPC8DGkln8X+OOuRvRe/6Bk3lUojY4nTxMPjw8S8ItZ+d4NBaDiqKUT6MP2Ce/5YTaXY8/rUFv1Fz5XfUswPSb3aI6dYFgbnjS03rrbuDQboasW0yGeJdmtnKoMBfzAJLQX0//xEnrjMcw3jqdVAMgyI9QWlrf9aDApvQk1HuYI8Hp83uvUBz/+8HnuH5e0UoluBwt3pcrlC73rkmsItEFQe7z5SY2QMbW+Mf6ieoOyjBdUgtw43SeeiyT6p4znx8phAjDu99MRDyp269ha0Z/hzMUdYAonLW72bi2eoMTdHXNNbhbqcHBaAagbSMUTkjeApdL9afaWNXyUYsYzGEnPpyh+KgZ1iqqmOhfCivcQBiInWtkcCDMBA1GvrQbMHomhhrN0KOieA/OyhAcM5gvDnMmGAE3M0l0TvQMLfuSbiTF2DDTIiXeUoyfmksHIhR92rFGOh/M3nSK7f2BX0WZ4bJOktWWYZup/Hr0Ao4OJsAj5B9U9elUsx7G48PJW50H7DTmhfa805enJN34ZiOCG6vXsCYpwHqSUptold/5N9sajdLYI0M9uYsGeiOTfU6XWMUNp91W0zzaQDkNYZkJPv6Rr3l2NUv40lx2Rgi4QLo71OFWft0am5VUNXA1slYgTs2T0RQg0W9gHrjmd+9L1KwJxXeYsXReKp9hrBx9HD1Rq2nBKCoD5QVnkq6YTuuu7Sv3Fc4d4Z+0iXUcyNklrEvKEebckLq30zvO/pIage3vHDy04DbjENXHc7rtIbZyvE8VZFeR6kIDmW2BH8YDi0i72RUkQ7w4NW6suG/gP4CZk9FLhatl6RMQlHgVrFuhFUKSthUOjfG/mT01QJSejDLfipAWX4DMitH6ss8WZPWPQNBk4pUokQ4Mh11RwEkTz+/1L0G79r6fV4t2cfJsgcJ9Wk+PLbYQa7ILX6y/1aZSwsfsiOloN7LB2X8IUNs5YwGSnjLjYruQXRcbVx37JETFxNuTp7gFIlfDiys3Q5m7jRVex7OHP2iUMaHHQIndO2G7gFgaKJWftw49uoMC1+AdW2leq2kr4mJXCxkn8Xkema4NS8g86dFRuAnmQBzZ7te4tH1In1lso3UsJ1/1VS5rxPWmXxcfQ9yFqVNtyp449zmPjq1GgAVqdxPWn8o1gAe/zbwVz1ckjMua1DxD8pTfcLiAVKtPlwQYjCKR+fMCWoGGtIkFS7eYYVV68BoTVq7L9HL6kdrBC5PSD1Z5LmqM3+zzdbzEDwo5Zyt/w1aaz2jqKF7GV9YxUEY7pdX8O1DrqX2ELWGsgT3UO1WIy2H1lpzUMLHPbLQTKQ+pXglWz4hHjjbocnqsoBQchNELG0AdYUAMnQu4CwQE3faGnCY3zvqgU/A28tfMEdEJaxyPyS3oYw6I1Z7Ph0dm9x8M2EQEQcJfAFVMjN4bKSQ48IN9aPUgCbe5zrpi8jmwI/f5ZIIH1iAhbirqBNuDTX2B8ArSTVQgec5yXJTzPW1Gi8q4I/CPUaw18KtiwIT9HTQDx0= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: aeb0595f-075c-42c4-61b7-08d9c5722864 X-MS-Exchange-CrossTenant-AuthSource: DB9PR08MB6748.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Dec 2021 17:40:34.7058 (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: uPs+XbQenR7DY/2xjOfcdpEPEObFAck3b2q4DofIJn7aqr7cO8FNxiELSNV9rruM0BWoQDtG5RbZFOJ97ITEe4rUkdxl/BBdlZD+9WaE0Vw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB2988 Received-SPF: pass client-ip=40.107.7.109; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com 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, 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.29 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" This will be used in the following commit to bring "incremental" mode to copy-before-write filter. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/block-copy.h | 2 +- block/block-copy.c | 14 ++++++++++++-- block/copy-before-write.c | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/include/block/block-copy.h b/include/block/block-copy.h index 99370fa38b..8da4cec1b6 100644 --- a/include/block/block-copy.h +++ b/include/block/block-copy.h @@ -25,7 +25,7 @@ typedef struct BlockCopyState BlockCopyState; typedef struct BlockCopyCallState BlockCopyCallState; BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target, - Error **errp); + BdrvDirtyBitmap *bitmap, Error **errp); /* Function should be called prior any actual copy request */ void block_copy_set_copy_opts(BlockCopyState *s, bool use_copy_range, diff --git a/block/block-copy.c b/block/block-copy.c index abda7a80bd..f6345e3a4c 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -384,8 +384,9 @@ static int64_t block_copy_calculate_cluster_size(BlockDriverState *target, } BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target, - Error **errp) + BdrvDirtyBitmap *bitmap, Error **errp) { + ERRP_GUARD(); BlockCopyState *s; int64_t cluster_size; BdrvDirtyBitmap *copy_bitmap; @@ -402,7 +403,16 @@ BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target, return NULL; } bdrv_disable_dirty_bitmap(copy_bitmap); - bdrv_set_dirty_bitmap(copy_bitmap, 0, bdrv_dirty_bitmap_size(copy_bitmap)); + if (bitmap) { + if (!bdrv_merge_dirty_bitmap(copy_bitmap, bitmap, NULL, errp)) { + error_prepend(errp, "Failed to merge bitmap '%s' to internal " + "copy-bitmap: ", bdrv_dirty_bitmap_name(bitmap)); + return NULL; + } + } else { + bdrv_set_dirty_bitmap(copy_bitmap, 0, + bdrv_dirty_bitmap_size(copy_bitmap)); + } /* * If source is in backing chain of target assume that target is going to be diff --git a/block/copy-before-write.c b/block/copy-before-write.c index 5bdaf0a9d9..799223e3fb 100644 --- a/block/copy-before-write.c +++ b/block/copy-before-write.c @@ -170,7 +170,7 @@ static int cbw_open(BlockDriverState *bs, QDict *options, int flags, ((BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK) & bs->file->bs->supported_zero_flags); - s->bcs = block_copy_state_new(bs->file, s->target, errp); + s->bcs = block_copy_state_new(bs->file, s->target, NULL, errp); if (!s->bcs) { error_prepend(errp, "Cannot create block-copy-state: "); return -EINVAL; From patchwork Wed Dec 22 17:40:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12697163 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 079EFC433EF for ; Wed, 22 Dec 2021 17:46:56 +0000 (UTC) Received: from localhost ([::1]:38566 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n05hW-0001wr-Ua for qemu-devel@archiver.kernel.org; Wed, 22 Dec 2021 12:46:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52484) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n05bd-0000hC-3k; Wed, 22 Dec 2021 12:40:49 -0500 Received: from mail-db8eur05on2127.outbound.protection.outlook.com ([40.107.20.127]:22544 helo=EUR05-DB8-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 1n05ba-0002Yd-Dq; Wed, 22 Dec 2021 12:40:47 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jsLPbs2lVssrbnjZog0cgMoR4WkuYlJlNrChV2pytNaMIsg1sPN+G64TeOuXqOYxaXon35yxNm2LMG+kDrI7O4Q5UCL+yH/Q1R7t4g7ixAIVvl2SRuwYJfljkgwjQqm3Q0gg99JZO3y0Kj1FnB2mtP924jhdGIPisaoGDNpymY+s9IOXHQ9Mt/5Oh4BoVA6OPvVkL+pwtgP/ff6EFTo4k+mB0/Acl1zUPFjLdyCltmFdEjwIMiWkdoY8UVpFJqqurKtWWwY3TlUNSsJUi92g0JotK44U4Sa7q7ojcUKg+RyUiRcivli1TqgHCSCxyX8vWh2QBed3QaE5p69VWtgsgw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=EhaMl/LpD+r5VyjgfnB0lOUVKm+Hpn23oXfZZOnNIuY=; b=BPFvrbujG3a78ueZoPx57RdQ/xogXjWBuoaLS+8KS/U1Au5ydZpFU2ofhU/iuqopZQ2M/lmdt+tPlldVMmNlRAK0Kdp3sZlnrXgaeZzcM6oUBTZT0mnMaSXughF+/kjZRKL429FmO7xBNB+bHdl7mohZqawtfBY8men1bOJAywa/43SocDbUV0PUVKWJkcRFAarOUHkJ2Hjq5eDq3VcVesVhJNfZ0gn8eQzc7eY/PkDw8xp98+8uJOJIs1uZQu/dHZg2ksZfjlzH0lbqftGEG4RzatB8ZUb4fzi6VueQxFNTkW1Gej5hQK3bh5JCFe+3GSaJb26rLn045XfeQS06uw== 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=EhaMl/LpD+r5VyjgfnB0lOUVKm+Hpn23oXfZZOnNIuY=; b=uzipKsJww1iJvQKIKAnsR5LrkxeI03tYe7sPJYal1pJxDQVdA8AyR4VJUzQ26xb7QvicCV+x1lL3Xf6Rf714PutFESKLsXyPGogZ0q5JAbsrxEc5VRjgZHv3ARcxjG42BYJ+77ZiqvlRu8wGtxjtGhqC0tLCXR5Ap0XenvUOcus= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) by DB7PR08MB2988.eurprd08.prod.outlook.com (2603:10a6:5:18::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.17; Wed, 22 Dec 2021 17:40:35 +0000 Received: from DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e]) by DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e%6]) with mapi id 15.20.4823.019; Wed, 22 Dec 2021 17:40:35 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v3 04/19] block/copy-before-write: add bitmap open parameter Date: Wed, 22 Dec 2021 18:40:03 +0100 Message-Id: <20211222174018.257550-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211222174018.257550-1-vsementsov@virtuozzo.com> References: <20211222174018.257550-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8P250CA0017.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:330::22) To DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6d0c6964-2913-4067-f3c3-08d9c57228dd X-MS-TrafficTypeDiagnostic: DB7PR08MB2988:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:415; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hi/wavGcgQhYzjDBNoIAX3nEMsyMJ64yAfSwMXu5giHeennTwXPthrvwveOKJQ0oBoUVAuv9WbDEz5qMjIp8sDIiqYkw7Vg7lC3yGLtCWASU1qJvhYGj/FQJLcv0IoZE/f8E0+uhmos/6sE/yep6S9tH1lvsKgAbGXQcUkCqPw+OiaDrpFyB7zWhwSjs4F4JQp8lZDJA84T8NTm+9dVJxx2iQ9V7xxd1Fb4rVuV5QX66XqnXzn+d2hMpyexuoNZX4tn0/V/nQ+oFgdB8v2xn+Sr6qQqBdQeE9gzV0o3FC/fI0PSxIxq6LhTDiHr6k2NNWa0EB2p7K16ImnH0KBliiUbR7TNK4WZC7FSLYd8IO/XAynPmrnnaRvx2fx+Gs2J4JJ0S9cZbDXCsW1Fq7Qe6Ek9o8F7u+WRkt4lQpgoy/CfdOmH8mlxmbRSUBoyf87XMYMGoqMreZLEq958axjbdubTJa2vOcOzyUfVziQJUjsa8E/33+ECk9SXWrC++FBgDmIpHqoHTiR4TOtVdQtf+smMMg7F/Up7c01n7KmJr+5WdtJjuJb1btYUJQGftNrMVymaBV5tdgRT/SEx4lx8wpsqoQ8UfzcwKL039AXWixG+cTmf4uMgH2B5/tgm3qwjpoue424NLvzw3NMDrBkNN/lonWpownBt8BfSEfCRy5AJdB6YoU5/3ABiSS0asJkHfa3UkmQ7JXa3f4dsilRFoVg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB9PR08MB6748.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(66476007)(6486002)(66556008)(38100700002)(66946007)(8936002)(1076003)(86362001)(83380400001)(5660300002)(52116002)(36756003)(6916009)(2616005)(8676002)(38350700002)(508600001)(6506007)(4326008)(6666004)(186003)(316002)(2906002)(6512007)(26005)(107886003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +dAF1qihkfx2JHz4RW38Xys1BQ+654EdRr0maOizykbIVQuvuuyc1Rip10dLjX5BRmuqr86CxFPW004/pheK+B2NeW7gZKZjrcoG59Ru2X3OBr6MDDeVvk6tns0iQgApevZR8gt7SHdRgRRHSAizPUnz6b5MN+6JIsjgYwylBksLCmMK4I/BcYZLBwsv0U86SaHGAnZMdUWwIMbnGwPWwaPkYz5HhAECLepm+ZwyMoATxoGZdNymge4/teH7NRkVo2FbDQk6yQXiloCj2CrwlOWemWtrOYCUf+SysmXTqAq1Ua3h6Ay5mAVvKyGyKzcYP0P214qPfw33CQKurWUaYBH208uIY7aSlPq74l++U1mnSGVxAIqfbz6XAidfqOMdA7DqpLI51wOBXAGvJSkLulEfL9ekXm6QpQxuWv/zh2HTknPKJeJvyEvFld2G8xHaFxxh/lQhjO/i7JkonsARgZDX2y3TUpx1MXnpnDwkrGDCF0H+QO1aiBjrCrGjV91fr+RxutriEj0i4ZGg6IP0zSdEDvLCxvv6MZv6+IQbZgSsTqia+ICKRrEdnNlm22bShrSrLlZlutTOjapHpL0rfpoX+3+onWh9va0cnKZUIB9ZBJp96olD9IXsB0EsnBf41LGOFka9BVE2zlO6nH8FLoGb7GjcXiIiiARrPMr6jRzfkrnl/Xt2wVZJx6lBuEeTwDIKcWstdAe0fU6OUoBf69Nb/U+acurP2zftn8Hne2VLSc1DiVzxRVrP4OPnie5CW6xZUztycl+KLvs7ls7FSvpz0JGQ4iNYx2c7aAsq+BOPbHw3sP3TKcfZNjrzR1SjbfpevysuU8gDypd+5gRTIXORFZRtneqcc/Qlyl8gHvIq2BH/YSACBVlYmXCXjAvjZF/rCodFibaJepXPdTtGxIVyitp87fgpCa6zXym+IV5nq6Ky1WQ02GJ+VOwU+8yTdmBxY+0SOS6r/jbv/ib6QHg7uGJbO7G/CS4A39mEBhfM7Ia/eNI09dxD/JozkZgZTUmi/2MfBxRfwJ7Mgdlp27SQPzVPwvZLxIX/1uSdAOdDfmG3qIB8hgppRoGY6eqsNFnQjO+ag4Lk59I7A4vX5eCfWJ4TPH5NqR5Pvqt8q3lEcjaP8GohWuJ7RWgLz8y1yVjSMPNuUKGNsZJx0eBhLo2RJxf/xUjMujdn4dg08o2SCVWzySMfbKPnvRfM4Nu0T3FC04GJbhThhRqSRsRjG7l9TRUQik8yv6nqLYpFLOw5HeqeM7k0noGsvsiP2v0IGAbgo3CXZCKWyl6dU4eIr1TzJg+77WLyi52npgmuvabLNkSxhZlC0dOn0yrP6iZX2Rtjgt7xM9wbsrAaQFB+dgntu4d5c6UIbo4bFxQiIVoai7WqK5spulD3kz00p9ERjJ1jneQZDK5Gz6oZcnqBLp6/JsNIT0XW6J9TFUxa6BA5wwbFYWX+QDR4LbXErXWbpnICXM7z/XRGr/+s9ZXcjUzQWht8INmUAjVqDdrdnFa9IqwkD+hml7YDv6vu0xB73zeoLHon3NLYMr0Rou56/ACxAq/2/haGA69BkcxFr21aKIoPeI144MtigTvsvkTnoA0yw2qPtKCn/S8aQQFWxLpM/dGQwK6jCrVCrpbFUnNgvTQ405ZUn5Nm4L3oLXZrlwEhUcFlFJsEG1T2XAYnQjFekHguBlZXCkXui9RzsJA= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6d0c6964-2913-4067-f3c3-08d9c57228dd X-MS-Exchange-CrossTenant-AuthSource: DB9PR08MB6748.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Dec 2021 17:40:35.3619 (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: 0RdjLp34R8pCLTKnEbmEgr5Rxbkk/rK59p7/tHEjiQ/2ZvZXlG7RWvpmHu9ZpBoLG1TCsSWZNEVpilgkxZuM+6dKC9gIsdqc26xDWmf6ISg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB2988 Received-SPF: pass client-ip=40.107.20.127; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com 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, 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.29 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" This brings "incremental" mode to copy-before-write filter: user can specify bitmap so that filter will copy only "dirty" areas. Signed-off-by: Vladimir Sementsov-Ogievskiy --- qapi/block-core.json | 10 +++++++++- block/copy-before-write.c | 30 +++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 1d3dd9cb48..6904daeacf 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -4167,11 +4167,19 @@ # # @target: The target for copy-before-write operations. # +# @bitmap: If specified, copy-before-write filter will do +# copy-before-write operations only for dirty regions of the +# bitmap. Bitmap size must be equal to length of file and +# target child of the filter. Note also, that bitmap is used +# only to initialize internal bitmap of the process, so further +# modifications (or removing) of specified bitmap doesn't +# influence the filter. +# # Since: 6.2 ## { 'struct': 'BlockdevOptionsCbw', 'base': 'BlockdevOptionsGenericFormat', - 'data': { 'target': 'BlockdevRef' } } + 'data': { 'target': 'BlockdevRef', '*bitmap': 'BlockDirtyBitmap' } } ## # @BlockdevOptions: diff --git a/block/copy-before-write.c b/block/copy-before-write.c index 799223e3fb..4cd90d22df 100644 --- a/block/copy-before-write.c +++ b/block/copy-before-write.c @@ -149,6 +149,7 @@ static int cbw_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { BDRVCopyBeforeWriteState *s = bs->opaque; + BdrvDirtyBitmap *bitmap = NULL; bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, @@ -163,6 +164,33 @@ static int cbw_open(BlockDriverState *bs, QDict *options, int flags, return -EINVAL; } + if (qdict_haskey(options, "bitmap.node") || + qdict_haskey(options, "bitmap.name")) + { + const char *bitmap_node, *bitmap_name; + + if (!qdict_haskey(options, "bitmap.node")) { + error_setg(errp, "bitmap.node is not specified"); + return -EINVAL; + } + + if (!qdict_haskey(options, "bitmap.name")) { + error_setg(errp, "bitmap.name is not specified"); + return -EINVAL; + } + + bitmap_node = qdict_get_str(options, "bitmap.node"); + bitmap_name = qdict_get_str(options, "bitmap.name"); + qdict_del(options, "bitmap.node"); + qdict_del(options, "bitmap.name"); + + bitmap = block_dirty_bitmap_lookup(bitmap_node, bitmap_name, NULL, + errp); + if (!bitmap) { + return -EINVAL; + } + } + bs->total_sectors = bs->file->bs->total_sectors; bs->supported_write_flags = BDRV_REQ_WRITE_UNCHANGED | (BDRV_REQ_FUA & bs->file->bs->supported_write_flags); @@ -170,7 +198,7 @@ static int cbw_open(BlockDriverState *bs, QDict *options, int flags, ((BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK) & bs->file->bs->supported_zero_flags); - s->bcs = block_copy_state_new(bs->file, s->target, NULL, errp); + s->bcs = block_copy_state_new(bs->file, s->target, bitmap, errp); if (!s->bcs) { error_prepend(errp, "Cannot create block-copy-state: "); return -EINVAL; From patchwork Wed Dec 22 17:40:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12697166 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 9985BC433F5 for ; Wed, 22 Dec 2021 17:51:07 +0000 (UTC) Received: from localhost ([::1]:47260 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n05la-0007oa-Nn for qemu-devel@archiver.kernel.org; Wed, 22 Dec 2021 12:51:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52556) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n05be-0000pH-Fx; Wed, 22 Dec 2021 12:40:50 -0500 Received: from mail-db8eur05on2127.outbound.protection.outlook.com ([40.107.20.127]:22544 helo=EUR05-DB8-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 1n05bc-0002Yd-Kl; Wed, 22 Dec 2021 12:40:50 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KBUfVpY6NHt7PQ4z+1bIuFrJXxPcwCsQrItlUpC3aGEHX2IKgya2zmdpH35FcqqGsYzznEs9HFHw3fVvbAElYBd14Q/2bYRa2Hmbnl6pAtL/gwc2bA91G0+VSnoqxcrNKwmVER8Sg5Cd5nJ6klDpP3IDauVVtLQAN9a2N3CcHJsZVGa70nU2tEg+vEoh6FwueUGoTBmbgoNKUL0y0Nbs/9VcL1wqQJ5LWoKzVyVHwN2olFprDFtZazsC6IugpNk8aaWx4rbf4Zaj7sYxK1RzprQR4Z/LnoVaUEMukaJzeqkR0S2rzPNeCfE6ybxaEjbfcQGtMBligxUzVpllSG+A9w== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ASMuc1iD/rgUApJoFMSK1L7vSXAimDsPhGlCLCMesH8=; b=OBvR+WiSxhu1rEXT+F8IjS56h1bkeHUZH81KxXFgXkOmzLhP/2ZJFazClLR1fvBBciwzOQbXOxIj1Ae23R1knvMlQvnOSm5u7WyTvxqVq6VOykcGY54LhYFOotpO2xpQYJHnC+1egpJ94kLJRZBuuvgQUXO1e58rEnsjK0cKA2sv3wXiByUysbokZ4Se1p41k/nFk61tKB8BkIsmHVRdrZq4zgvKxb9835egcuzsU3QiA+OVDcUdcuy7ahNmzNI4XH19M+XrAFPuSY20Y4FET7sHjRWAkYBs9RoX0Aj24QQHgYxUkx93vysufXNUvBqzRWrmonGNTS/bFf6BNO/K8Q== 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=ASMuc1iD/rgUApJoFMSK1L7vSXAimDsPhGlCLCMesH8=; b=QXNV9/w9sqz092NMgm973Ef4Y2IEyvSN7ezXt896fOm9MtXyHByB18ehnRzQ5QiwaPtBWOBJNbPHvnNkpTDipqgxg/F0Eo+QWfDiq3rMBATNE3zi/i66YWDosZTf8WMeX5pXMcxIICQ+PSWb6YakzEWqCv2tWovxv4mgZaX55UA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) by DB7PR08MB2988.eurprd08.prod.outlook.com (2603:10a6:5:18::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.17; Wed, 22 Dec 2021 17:40:36 +0000 Received: from DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e]) by DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e%6]) with mapi id 15.20.4823.019; Wed, 22 Dec 2021 17:40:36 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v3 05/19] block/block-copy: add block_copy_reset() Date: Wed, 22 Dec 2021 18:40:04 +0100 Message-Id: <20211222174018.257550-6-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211222174018.257550-1-vsementsov@virtuozzo.com> References: <20211222174018.257550-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8P250CA0017.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:330::22) To DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a9683bcc-7188-42c3-37c7-08d9c5722968 X-MS-TrafficTypeDiagnostic: DB7PR08MB2988:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:69; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ULeZyRZm8BEFDG+2Vtvkx7QNgSnV4Tu/jeoUGxyCxe3lTdXQ98uV69PiYqHjBuGuW6xkvmV+BjQTL7SkNm+7so6G7wudkMIT/Qvx+4YvTgCeb4Ef/bKlUZWmZVvnNY3HvJ6Lz09ZkDePbx+LdO7wMMRh34fYH1X+E0mmsg5+aJO0N84otuuW42KEHfn5yW7xOuumzpjHYa+ORH2VjIWXveC1Wgn1FY45HH8PwOav3gYZxBaDd2nXwHdtXGiHOMiqNmAExOOVMO/qbkRNwu01W4LCGDMK+UgDYhxA72Td2UBz4uuXgksiwbeuILZ3jdv1D0mtrOGojgpXvSA8DLcdnIvCxyeXu74EvFuTke4Uy/U12GrHFVSTNVBDjuvsr17mK2aiavmS+W738HpQ5h3hJhFR8QiS/n8fwaCHbTvAs29LqW4G/idUbmgcsgeztFA5DNWxe/KeT/Ak5tZGygROXoZFDO3ppSP7N0KZHyzYN/ObrfdqzH+EHRRnZC7yNXEOefd2vdVizgLKMRqRpGfey870Fi3bIyuF3Z/Zau7paLvcQr4ELqSa2cy6PYSMBDHNOBHqDMBLnWiFJ7jxJ8PiGMRoGZTJJdyhiByZgVm/Pk1w/1pn/Crak0BmQXMaktPAuAbW5ONFfzUL2J36w0d2+9KNn9DDUugKA/mQbkYvfk8/B8w4ASNVB2adKbjJKIf7FOKWofv6MAsC6h+7Wj5P4A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB9PR08MB6748.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(66476007)(6486002)(66556008)(38100700002)(66946007)(8936002)(1076003)(86362001)(83380400001)(5660300002)(52116002)(36756003)(6916009)(2616005)(8676002)(38350700002)(508600001)(6506007)(4326008)(6666004)(186003)(316002)(2906002)(6512007)(26005)(107886003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 71eg1mymFUEqyaEh9POXBDXkepEvaOWH13SP0S/9nYcDFWb5Nq2j9ebyp7wyHJqEB+gOYjjNZqGzEbDGvo0XtwVBk0JGSccvZhFiXR+UUAJzlyOH5TzdpzzFqTn+bYnDMQJDtGYW2oiRNbRYmHACLWcrI1Fgmrtk+AmpOFyfAorgwz/anMYhBggg45+svHTXPU2UucceXz8nugb+n0ZlcWvBKUhS+38NkDhZX7UOLSs1D19/2vLI5nhF+D3rYrFU/r/d9hjysW5KxjEUtHgX4MZMrprf1l8NQ7Dy94DrjJD0b5DdUcV2k6uDdc2FCcnrrzSyF6+zypSHxuT7rMGFqyVZSAmibJLvwjF4rqcZzu8gf7SG6CTFNiiixoP4F65tpey699AmqA1mG0wEoRBRre39GXTe+ZIokc3g89puo9wxHyPT5BwVfBEtn12QNYmXJ+8W485q6hrAlJJhsdCNaBsS8kgHNK6uUJRsEXHdhdTPGFZEXZAziWFilpSdgiIwDlOqmlfYklCSVTJxMUEwsGGRybXUaUa9VJeAQ85zpBGGVjIe9vUj0czR0NaVI+ol8VjYP9exQIf1lSuS/MGvreR0+qHc267hb6svW6m8pHZzcKqqY4KtvJn/yAKkNOVtr3JxNq9kDZ3DQcXoWvdU8yaFKx9jgVW77jQ6RpneYoErjloEuQYNKcL4YMaXE5IMMhTAze5TcU1T+SqwHiZpOWiEPQVxmNdc8NXIpfYmxEOflQAp9baNuwNrbfce6jT/7eCjpPjNsT3MaPM6zWnJmpEk237CQMXLf5mf5+AkCZptVL817jE/u1dyHfXs5I09ChC/ypGergso0zNFvY6dtVj8jomag49q9+PkVi3YJnFp6whyAcPi00+cFE9maZLgFnLMCDharTjdhVDaxM4WZhSf6wcKB7iUgr6roZQaTGCJM/oarIqnvMAB8HbmXtPzffHUKYK5alc3N8/GjtRYVA4ywwIs/VYuHBme2BV9xlaMmGifslCYy0zoVu4gNtMCAxwbfE2t5iwYSZvvXmdK9zuBhz6oOEQbmBqIVJivrb+i2UUilfkhE7rEoqxa+BluRHrVe9WC+Nmsis5IsNJV6pnvAXH6QdBjr6RDdafYsfg9yP1UODew4UcHZ3SS1tnTMyDIX6tj1b9IJOMJJuKZhf1FR9bXEzf4YYj/leneQPeUqRjj3GYE0M8h7EvrehDEwdmqH39O3NbzBFXlGIYg20O1Ky/DeOPFgaMr6m5q1vp7UxNGdO107l7b2W0oxyiJUPiMQitPNer5zpXcFiAuA3qWmYqK2D1DslChnWhwQEQn+lB/Ss5KH7tdVUJQO1nP0ATBvi+zjsa/D9VG6aSfL/UcevM/mFlEkp8V8jSqkbYgupznvrPu/UOn0UIiQW1d4EvnIrIFCTbFi7aQSPM34VJkKN4riPVDpoBmfopd0DBHOxUMndnT6YR3ZQZRDh1nfelxPxGzjYsvjG77vsOSBJjGdcbVe4tljtRPnGrC7NOXYJvwtcSLwE5+GAi6FE54NflnORCySr1RLuEg57sKuCH8W7VZGFrVQgZE2OQT6bKVrxRCUQ+zo92NXWWTdbIWYRjj6sRC/Tl0uw5Nt+sTOT068kD6H1Mhf8f5rEeuW/mqzonOJKverntbsr8uIf+EJIOA8pD766psLtWCwLMbz+kauvfFsAWWX3fQOm2ywzM= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: a9683bcc-7188-42c3-37c7-08d9c5722968 X-MS-Exchange-CrossTenant-AuthSource: DB9PR08MB6748.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Dec 2021 17:40:36.2836 (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: /KelLESCBsJ/NAY0GrAbUzixpHbUb8l0/kQlbyD1jIaIMxXXd6OrcS1w24KoYcQtV0cTRe7Obgcu67+3FQZb5WmmXtcwSLHbQi5oU+6HYAM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB2988 Received-SPF: pass client-ip=40.107.20.127; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com 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, 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.29 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" Split block_copy_reset() out of block_copy_reset_unallocated() to be used separately later. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Hanna Reitz --- include/block/block-copy.h | 1 + block/block-copy.c | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/include/block/block-copy.h b/include/block/block-copy.h index 8da4cec1b6..a11e1620f6 100644 --- a/include/block/block-copy.h +++ b/include/block/block-copy.h @@ -34,6 +34,7 @@ void block_copy_set_progress_meter(BlockCopyState *s, ProgressMeter *pm); void block_copy_state_free(BlockCopyState *s); +void block_copy_reset(BlockCopyState *s, int64_t offset, int64_t bytes); int64_t block_copy_reset_unallocated(BlockCopyState *s, int64_t offset, int64_t *count); diff --git a/block/block-copy.c b/block/block-copy.c index f6345e3a4c..6228cf01d4 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -690,6 +690,18 @@ static int block_copy_is_cluster_allocated(BlockCopyState *s, int64_t offset, } } +void block_copy_reset(BlockCopyState *s, int64_t offset, int64_t bytes) +{ + QEMU_LOCK_GUARD(&s->lock); + + bdrv_reset_dirty_bitmap(s->copy_bitmap, offset, bytes); + if (s->progress) { + progress_set_remaining(s->progress, + bdrv_get_dirty_count(s->copy_bitmap) + + s->in_flight_bytes); + } +} + /* * Reset bits in copy_bitmap starting at offset if they represent unallocated * data in the image. May reset subsequent contiguous bits. @@ -710,14 +722,7 @@ int64_t block_copy_reset_unallocated(BlockCopyState *s, bytes = clusters * s->cluster_size; if (!ret) { - qemu_co_mutex_lock(&s->lock); - bdrv_reset_dirty_bitmap(s->copy_bitmap, offset, bytes); - if (s->progress) { - progress_set_remaining(s->progress, - bdrv_get_dirty_count(s->copy_bitmap) + - s->in_flight_bytes); - } - qemu_co_mutex_unlock(&s->lock); + block_copy_reset(s, offset, bytes); } *count = bytes; From patchwork Wed Dec 22 17:40:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12697172 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 4A80AC433F5 for ; Wed, 22 Dec 2021 17:57:23 +0000 (UTC) Received: from localhost ([::1]:37374 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n05re-0003SP-EM for qemu-devel@archiver.kernel.org; Wed, 22 Dec 2021 12:57:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52596) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n05bg-0000w4-Gy; Wed, 22 Dec 2021 12:40:52 -0500 Received: from mail-eopbgr70109.outbound.protection.outlook.com ([40.107.7.109]:22241 helo=EUR04-HE1-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 1n05bd-0002WE-Rl; Wed, 22 Dec 2021 12:40:52 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ijIuKgD5ggafStyIejDLjkH7rPcu0qG/4B53cqq3giLNyvH8gES2l4aZEdkGDsf0kEmwMxY6DzdMRdrYpLmEyWpALgKl9jPa4z5c2rYx1AtYXZFbRGtZd1h9uv4++ez80C4axXikNzO4i+MhoE8GThboLekBT4EF2WxlJMPCgBUiHIPyMntQUJs6hE4jVcARduEkgl/xyyE098OqH3VZwxXYaEEgEq2k9HYvzwp7EPUHZKnP1RKFDO7kkLyCzgRv83wBG4Vd3l9hgw8yUnCKcXMdsTbbwbo3qH3TLzy312MnDk+Q3WpRmhXP9HsicvNn29q21ZxX2ELzuJgkP/OHtw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6Ru12ndVWXyNiun1iuUmfzTlTRHk1C3BI9pVGj3l5Tw=; b=ZwewiFGc+W1EXKI4Sxz/OUAJMf7iM1IaXTMOK6QFQ72brC7BFpFlUwwR+rWZdOSefFz9SCqouXGuVhCyYt8u01ul6bAEmI2ugcmRZu7d8ZqCjVgjqm0rEtUWxl0x9J968ZHzR1pAQgDV7uFJ/HQJqfpia3Iizq06da9ijBcm230cNR3nHze4l6M1hdqgenXjdyBEY+AsSZeZCSq4IAWiUhiaR+67PMTXA4EMKyEVPr0kA4PEVEx4vg4JRSGBK+Q1T2axuqs508IOB35tmX1SPlSTfNXFivnWJ5fufRV9RpZtamINWDQiKqRfceNXYIgZAajdLXR9QUV9d2nM7DLRzQ== 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=6Ru12ndVWXyNiun1iuUmfzTlTRHk1C3BI9pVGj3l5Tw=; b=bpCq/LgauwLjYPyDd1TIiRa9gEDdNcUa3zHc+6M5ZOVLMLtkJCrYifqE7PwhpAu1zKNRAzerLyenrprjI1rDSh1KH9vzFIXYyBEKJxIYTfzqi2guUs14lWqYus3UzYRjMg6kIMjZsczr+m1egBeFLOQSKNGhoiVUf+6fx9ujKJ8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) by DB7PR08MB2988.eurprd08.prod.outlook.com (2603:10a6:5:18::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.17; Wed, 22 Dec 2021 17:40:37 +0000 Received: from DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e]) by DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e%6]) with mapi id 15.20.4823.019; Wed, 22 Dec 2021 17:40:37 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v3 06/19] block: intoduce reqlist Date: Wed, 22 Dec 2021 18:40:05 +0100 Message-Id: <20211222174018.257550-7-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211222174018.257550-1-vsementsov@virtuozzo.com> References: <20211222174018.257550-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8P250CA0017.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:330::22) To DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 22eb1320-d5a7-44a5-4ad9-08d9c57229d1 X-MS-TrafficTypeDiagnostic: DB7PR08MB2988:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: z/oQeGwJxjDa+GQRFnqbZbZgphcRI9l8usfquLqgmrzrK/tsmnn21L1vwUJXEC+RFkDIPjAfQgWEi3Sp6i1BppznCTcRbvUecwlhAPLpT6bsVLOA2mRPyRpk3TPJUhw3+A7dM4JamTZT8SpWD4dhoXe2ddD/zgUkcT4mXGsklMloaK03cCaoBDJIMz/KE2vx7YeFpsFZcgihUq6FlPHs71cmcC+BFaLUsgSfvSq2QAtZlrRznAgyxqNSuOrrpNXdEzpDqUCI5OMyHekc2ykbJKUN/XrvqCsn0az3pOFPJzcSzM7oPsuiOe/qdPKmFn2l+feNITBux5TtRsJi6QSlWq6zVqykiV4RPhNr/ZbMnerI4m26UvYOcbwiejUCbrUvzCCQ0Drfory452igJRl+qsJ5EWxqmsvvw0DmmBaFFS8e5dkUYpdXDaZqZONAxNeF84PhYUV5lfHyUXW0Mslps/4b9XAtUto+h/umFFIySNdgcnyzudf5h3SrZZwiaugsLtf0S8Bu8euBAUX7YpPwkwIFP8yVpXfksTh9k+fDnwokdSqmXzjobIxskUEDX3+0tol0ViRd4WScgcodBB2n7fibzXmDIdisn2cR9NUuYdneNxTWZJ8hbjM8esML/25E870oAAHtw20h4ghO59faeuiNasp21SyLPUFsIDZuWOJfivK1r6fx+4/UZdZTlLNi6Dl3Qbs+Kfus7dDMaxfBng== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB9PR08MB6748.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(66476007)(6486002)(30864003)(66556008)(38100700002)(66946007)(8936002)(1076003)(86362001)(83380400001)(5660300002)(52116002)(36756003)(6916009)(2616005)(8676002)(38350700002)(508600001)(6506007)(4326008)(6666004)(186003)(316002)(2906002)(6512007)(26005)(107886003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jnHOtKxWBVPPOG5zqTl/xkQj2frHxPgbT1WAJpDdE+8yeOJa6tUMtPTEIVBSs6gKaEwpMwcV0F8oRu0cc/leyxtwQOZJiLAz091Ttwk1D2zQD7+YuxRq8FAQUBYuN2h/w8rajC1KYLx69t10ihvq6VXFWxnPIdYYwYsGTT0idnd7XPYaUCtcKO6n1NEbGf9BecguO1/EEPT9aFG9KOenmshTHr+iBIU2WZUm4dcpFfYz2DHloeepzUHPbnHPgnsgjWrdA2bPfXoEBJH0/I3K4U+8ju21g9d2pOBlfAppwO5gHzlhWOeU5ppQVxySw2K2/TJzA9qHeLvqcZUp7ynRQstNPQ6sg5ofs3bn9QmbxSMZo/p8QrL3dylo0fQnDfCH7i2ynBhjH/ltBEcwulgn8fO/wd3BSUaicMGqqgJ4IwOg3cyd4gW7jhoIvLCSTgo3VEthZRIzYfzjVJ/rxAl+mGsau7kGdfWX/eQjgJ6oIhEdxAPiuKqgWj3zK9c3kA7gxW3uObq2QMM3Nauc3kawHQUnbk/ZGTImldyCXF0F8y29ZiZJvCWJelh6EV3rO/jtkvi5N6f6UHwMPBeNFzJpCi69u3flwX+7RUSns8/X0XJWmv8DAWkhP4JATKSSahcvPLb3LFNEv6RFF0iaD/C4YLC06pRbWE6/I8CZqziQUzQSFoDEUDVHZ6UNHGS8cDXEN4Ka4pV+yOdshKsWPKmQU1xMyDebVrceqUBNn0p3hwvpPn7iul5YSSZS9CRtjsf2zv8skg2lIDbIUXW+D2tbdC/7dfba4hBwwgKNEB7SKToAHqHu/lfirhtQkwLXFVG84OV21a59AepgFfmV/xVZDHBArSE2WB5gG3f++dIUwGLCy/V37SUkkCda9RBqEqLzRfDvogi/qZYQLaDrfxQn8vWlyX08lwizXyeqtbkgug+ZU6NugrS/4NzvDLqkr1LcAGGm39tWpL01p47Iphqi4kSWGIxE8L2Z3aGYts6u8QMsYOlinYaDZY9bu8EjcVpek9ZE2j6Cbd7StK9wbNwDs1zyOXvMT6mfnvMMzdFpkXM4caX8zGtBq/chuU4S3Qtm4mJA0/qwBfan+9VRC4QPhGXPycURxcQlAQ6wRfOiWj4ikfIMbR72F8ZAmZZhdlUeLpg2RIudvGxTMjWnMhNGakZ5y8rcRnQ0K21yvIIndEf+doGIRMTM5fmw50H5lBvnS2Ub3dLynyQh1emcyr1sC8RU2JSxuboHbjBR3fdvAcSx1jPxSoDB1ZWa4x9263pXrIL+pnHBfHWyuqfx6rTecdSO2vcV8lI6JnpiU/+ZnbB+MR0piOKRKoOwHph5H/4xwF0u9jjUzaHlHOis7ONlgl2iV1bZiXE4wtsFsH/xwcLtLxZhwkECaWkCy3vPrjpjTc5b50FU35GBo+WxGsGU2C+FrKbrufs6hPqMzZsvx/SLrMD8FwhSPX5ifby6cKIU4yW8W+tL5PYK3zUrVHKvsccOxamws2jQghYzodz7gi12OaOvedLMLJpYC0YYhzgRGddDlgY7ziJ5z+WaMqP9BmiHfyqNooA6tgqGLLX8aKRKYAOksfpvUP2xGgYQTWYf9Y9+bGQXxmv4W/t10JTFmaq3zbxvYDT3YssNVyKv1I1+roWpHTEfpHxNQmLhc5FTOyOSNVWbWlNbO54dsY+XWDoG9phXpPIXD9tRxuTTtJ4= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 22eb1320-d5a7-44a5-4ad9-08d9c57229d1 X-MS-Exchange-CrossTenant-AuthSource: DB9PR08MB6748.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Dec 2021 17:40:36.9879 (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: uu2ttAVbhgiJnOo/j7C067OgJ9rAINPSG0cHIuMVa3vNxGeGJnUeMmD4iHu0QY8kdYwd9U6qQ92PdejMoQEtYWjAuNWOI8gl3D2xho02yRw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB2988 Received-SPF: pass client-ip=40.107.7.109; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com 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, 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.29 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" Split intersecting-requests functionality out of block-copy to be reused in copy-before-write filter. Note: while being here, fix tiny typo in MAINTAINERS. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/reqlist.h | 67 +++++++++++++++++++++++ block/block-copy.c | 116 +++++++++++++--------------------------- block/reqlist.c | 76 ++++++++++++++++++++++++++ MAINTAINERS | 4 +- block/meson.build | 1 + 5 files changed, 184 insertions(+), 80 deletions(-) create mode 100644 include/block/reqlist.h create mode 100644 block/reqlist.c diff --git a/include/block/reqlist.h b/include/block/reqlist.h new file mode 100644 index 0000000000..b904d80216 --- /dev/null +++ b/include/block/reqlist.h @@ -0,0 +1,67 @@ +/* + * reqlist API + * + * Copyright (C) 2013 Proxmox Server Solutions + * Copyright (c) 2021 Virtuozzo International GmbH. + * + * Authors: + * Dietmar Maurer (dietmar@proxmox.com) + * Vladimir Sementsov-Ogievskiy + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#ifndef REQLIST_H +#define REQLIST_H + +#include "qemu/coroutine.h" + +/* + * The API is not thread-safe and shouldn't be. The struct is public to be part + * of other structures and protected by third-party locks, see + * block/block-copy.c for example. + */ + +typedef struct BlockReq { + int64_t offset; + int64_t bytes; + + CoQueue wait_queue; /* coroutines blocked on this req */ + QLIST_ENTRY(BlockReq) list; +} BlockReq; + +typedef QLIST_HEAD(, BlockReq) BlockReqList; + +/* + * Initialize new request and add it to the list. Caller should be sure that + * there are no conflicting requests in the list. + */ +void reqlist_init_req(BlockReqList *reqs, BlockReq *req, int64_t offset, + int64_t bytes); +/* Search for request in the list intersecting with @offset/@bytes area. */ +BlockReq *reqlist_find_conflict(BlockReqList *reqs, int64_t offset, + int64_t bytes); + +/* + * If there are no intersecting requests return false. Otherwise, wait for the + * first found intersecting request to finish and return true. + * + * @lock is passed to qemu_co_queue_wait() + * False return value proves that lock was NOT released. + */ +bool coroutine_fn reqlist_wait_one(BlockReqList *reqs, int64_t offset, + int64_t bytes, CoMutex *lock); + +/* + * Shrink request and wake all waiting coroutines (may be some of them are not + * intersecting with shrunk request). + */ +void coroutine_fn reqlist_shrink_req(BlockReq *req, int64_t new_bytes); + +/* + * Remove request and wake all waiting coroutines. Do not release any memory. + */ +void coroutine_fn reqlist_remove_req(BlockReq *req); + +#endif /* REQLIST_H */ diff --git a/block/block-copy.c b/block/block-copy.c index 6228cf01d4..f70f1ad993 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -17,6 +17,7 @@ #include "trace.h" #include "qapi/error.h" #include "block/block-copy.h" +#include "block/reqlist.h" #include "sysemu/block-backend.h" #include "qemu/units.h" #include "qemu/coroutine.h" @@ -83,7 +84,6 @@ typedef struct BlockCopyTask { */ BlockCopyState *s; BlockCopyCallState *call_state; - int64_t offset; /* * @method can also be set again in the while loop of * block_copy_dirty_clusters(), but it is never accessed concurrently @@ -94,21 +94,17 @@ typedef struct BlockCopyTask { BlockCopyMethod method; /* - * Fields whose state changes throughout the execution - * Protected by lock in BlockCopyState. + * Generally, req is protected by lock in BlockCopyState, Still req.offset + * is only set on task creation, so may be read concurrently after creation. + * req.bytes is changed at most once, and need only protecting the case of + * parallel read while updating @bytes value in block_copy_task_shrink(). */ - CoQueue wait_queue; /* coroutines blocked on this task */ - /* - * Only protect the case of parallel read while updating @bytes - * value in block_copy_task_shrink(). - */ - int64_t bytes; - QLIST_ENTRY(BlockCopyTask) list; + BlockReq req; } BlockCopyTask; static int64_t task_end(BlockCopyTask *task) { - return task->offset + task->bytes; + return task->req.offset + task->req.bytes; } typedef struct BlockCopyState { @@ -136,7 +132,7 @@ typedef struct BlockCopyState { CoMutex lock; int64_t in_flight_bytes; BlockCopyMethod method; - QLIST_HEAD(, BlockCopyTask) tasks; /* All tasks from all block-copy calls */ + BlockReqList reqs; QLIST_HEAD(, BlockCopyCallState) calls; /* * skip_unallocated: @@ -160,42 +156,6 @@ typedef struct BlockCopyState { RateLimit rate_limit; } BlockCopyState; -/* Called with lock held */ -static BlockCopyTask *find_conflicting_task(BlockCopyState *s, - int64_t offset, int64_t bytes) -{ - BlockCopyTask *t; - - QLIST_FOREACH(t, &s->tasks, list) { - if (offset + bytes > t->offset && offset < t->offset + t->bytes) { - return t; - } - } - - return NULL; -} - -/* - * If there are no intersecting tasks return false. Otherwise, wait for the - * first found intersecting tasks to finish and return true. - * - * Called with lock held. May temporary release the lock. - * Return value of 0 proves that lock was NOT released. - */ -static bool coroutine_fn block_copy_wait_one(BlockCopyState *s, int64_t offset, - int64_t bytes) -{ - BlockCopyTask *task = find_conflicting_task(s, offset, bytes); - - if (!task) { - return false; - } - - qemu_co_queue_wait(&task->wait_queue, &s->lock); - - return true; -} - /* Called with lock held */ static int64_t block_copy_chunk_size(BlockCopyState *s) { @@ -239,7 +199,7 @@ block_copy_task_create(BlockCopyState *s, BlockCopyCallState *call_state, bytes = QEMU_ALIGN_UP(bytes, s->cluster_size); /* region is dirty, so no existent tasks possible in it */ - assert(!find_conflicting_task(s, offset, bytes)); + assert(!reqlist_find_conflict(&s->reqs, offset, bytes)); bdrv_reset_dirty_bitmap(s->copy_bitmap, offset, bytes); s->in_flight_bytes += bytes; @@ -249,12 +209,9 @@ block_copy_task_create(BlockCopyState *s, BlockCopyCallState *call_state, .task.func = block_copy_task_entry, .s = s, .call_state = call_state, - .offset = offset, - .bytes = bytes, .method = s->method, }; - qemu_co_queue_init(&task->wait_queue); - QLIST_INSERT_HEAD(&s->tasks, task, list); + reqlist_init_req(&s->reqs, &task->req, offset, bytes); return task; } @@ -270,34 +227,34 @@ static void coroutine_fn block_copy_task_shrink(BlockCopyTask *task, int64_t new_bytes) { QEMU_LOCK_GUARD(&task->s->lock); - if (new_bytes == task->bytes) { + if (new_bytes == task->req.bytes) { return; } - assert(new_bytes > 0 && new_bytes < task->bytes); + assert(new_bytes > 0 && new_bytes < task->req.bytes); - task->s->in_flight_bytes -= task->bytes - new_bytes; + task->s->in_flight_bytes -= task->req.bytes - new_bytes; bdrv_set_dirty_bitmap(task->s->copy_bitmap, - task->offset + new_bytes, task->bytes - new_bytes); + task->req.offset + new_bytes, + task->req.bytes - new_bytes); - task->bytes = new_bytes; - qemu_co_queue_restart_all(&task->wait_queue); + reqlist_shrink_req(&task->req, new_bytes); } static void coroutine_fn block_copy_task_end(BlockCopyTask *task, int ret) { QEMU_LOCK_GUARD(&task->s->lock); - task->s->in_flight_bytes -= task->bytes; + task->s->in_flight_bytes -= task->req.bytes; if (ret < 0) { - bdrv_set_dirty_bitmap(task->s->copy_bitmap, task->offset, task->bytes); + bdrv_set_dirty_bitmap(task->s->copy_bitmap, task->req.offset, + task->req.bytes); } - QLIST_REMOVE(task, list); if (task->s->progress) { progress_set_remaining(task->s->progress, bdrv_get_dirty_count(task->s->copy_bitmap) + task->s->in_flight_bytes); } - qemu_co_queue_restart_all(&task->wait_queue); + reqlist_remove_req(&task->req); } void block_copy_state_free(BlockCopyState *s) @@ -448,7 +405,7 @@ BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target, ratelimit_init(&s->rate_limit); qemu_co_mutex_init(&s->lock); - QLIST_INIT(&s->tasks); + QLIST_INIT(&s->reqs); QLIST_INIT(&s->calls); return s; @@ -481,7 +438,7 @@ static coroutine_fn int block_copy_task_run(AioTaskPool *pool, aio_task_pool_wait_slot(pool); if (aio_task_pool_status(pool) < 0) { - co_put_to_shres(task->s->mem, task->bytes); + co_put_to_shres(task->s->mem, task->req.bytes); block_copy_task_end(task, -ECANCELED); g_free(task); return -ECANCELED; @@ -594,7 +551,8 @@ static coroutine_fn int block_copy_task_entry(AioTask *task) BlockCopyMethod method = t->method; int ret; - ret = block_copy_do_copy(s, t->offset, t->bytes, &method, &error_is_read); + ret = block_copy_do_copy(s, t->req.offset, t->req.bytes, &method, + &error_is_read); WITH_QEMU_LOCK_GUARD(&s->lock) { if (s->method == t->method) { @@ -607,10 +565,10 @@ static coroutine_fn int block_copy_task_entry(AioTask *task) t->call_state->error_is_read = error_is_read; } } else if (s->progress) { - progress_work_done(s->progress, t->bytes); + progress_work_done(s->progress, t->req.bytes); } } - co_put_to_shres(s->mem, t->bytes); + co_put_to_shres(s->mem, t->req.bytes); block_copy_task_end(t, ret); return ret; @@ -769,22 +727,22 @@ block_copy_dirty_clusters(BlockCopyCallState *call_state) trace_block_copy_skip_range(s, offset, bytes); break; } - if (task->offset > offset) { - trace_block_copy_skip_range(s, offset, task->offset - offset); + if (task->req.offset > offset) { + trace_block_copy_skip_range(s, offset, task->req.offset - offset); } found_dirty = true; - ret = block_copy_block_status(s, task->offset, task->bytes, + ret = block_copy_block_status(s, task->req.offset, task->req.bytes, &status_bytes); assert(ret >= 0); /* never fail */ - if (status_bytes < task->bytes) { + if (status_bytes < task->req.bytes) { block_copy_task_shrink(task, status_bytes); } if (qatomic_read(&s->skip_unallocated) && !(ret & BDRV_BLOCK_ALLOCATED)) { block_copy_task_end(task, 0); - trace_block_copy_skip_range(s, task->offset, task->bytes); + trace_block_copy_skip_range(s, task->req.offset, task->req.bytes); offset = task_end(task); bytes = end - offset; g_free(task); @@ -805,11 +763,11 @@ block_copy_dirty_clusters(BlockCopyCallState *call_state) } } - ratelimit_calculate_delay(&s->rate_limit, task->bytes); + ratelimit_calculate_delay(&s->rate_limit, task->req.bytes); - trace_block_copy_process(s, task->offset); + trace_block_copy_process(s, task->req.offset); - co_get_from_shres(s->mem, task->bytes); + co_get_from_shres(s->mem, task->req.bytes); offset = task_end(task); bytes = end - offset; @@ -877,8 +835,8 @@ static int coroutine_fn block_copy_common(BlockCopyCallState *call_state) * Check that there is no task we still need to * wait to complete */ - ret = block_copy_wait_one(s, call_state->offset, - call_state->bytes); + ret = reqlist_wait_one(&s->reqs, call_state->offset, + call_state->bytes, &s->lock); if (ret == 0) { /* * No pending tasks, but check again the bitmap in this @@ -886,7 +844,7 @@ static int coroutine_fn block_copy_common(BlockCopyCallState *call_state) * between this and the critical section in * block_copy_dirty_clusters(). * - * block_copy_wait_one return value 0 also means that it + * reqlist_wait_one return value 0 also means that it * didn't release the lock. So, we are still in the same * critical section, not interrupted by any concurrent * access to state. diff --git a/block/reqlist.c b/block/reqlist.c new file mode 100644 index 0000000000..5e320ba649 --- /dev/null +++ b/block/reqlist.c @@ -0,0 +1,76 @@ +/* + * reqlist API + * + * Copyright (C) 2013 Proxmox Server Solutions + * Copyright (c) 2021 Virtuozzo International GmbH. + * + * Authors: + * Dietmar Maurer (dietmar@proxmox.com) + * Vladimir Sementsov-Ogievskiy + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" + +#include "block/reqlist.h" + +void reqlist_init_req(BlockReqList *reqs, BlockReq *req, int64_t offset, + int64_t bytes) +{ + assert(!reqlist_find_conflict(reqs, offset, bytes)); + + *req = (BlockReq) { + .offset = offset, + .bytes = bytes, + }; + qemu_co_queue_init(&req->wait_queue); + QLIST_INSERT_HEAD(reqs, req, list); +} + +BlockReq *reqlist_find_conflict(BlockReqList *reqs, int64_t offset, + int64_t bytes) +{ + BlockReq *r; + + QLIST_FOREACH(r, reqs, list) { + if (offset + bytes > r->offset && offset < r->offset + r->bytes) { + return r; + } + } + + return NULL; +} + +bool coroutine_fn reqlist_wait_one(BlockReqList *reqs, int64_t offset, + int64_t bytes, CoMutex *lock) +{ + BlockReq *r = reqlist_find_conflict(reqs, offset, bytes); + + if (!r) { + return false; + } + + qemu_co_queue_wait(&r->wait_queue, lock); + + return true; +} + +void coroutine_fn reqlist_shrink_req(BlockReq *req, int64_t new_bytes) +{ + if (new_bytes == req->bytes) { + return; + } + + assert(new_bytes > 0 && new_bytes < req->bytes); + + req->bytes = new_bytes; + qemu_co_queue_restart_all(&req->wait_queue); +} + +void coroutine_fn reqlist_remove_req(BlockReq *req) +{ + QLIST_REMOVE(req, list); + qemu_co_queue_restart_all(&req->wait_queue); +} diff --git a/MAINTAINERS b/MAINTAINERS index 5dcefc0d01..7f24ee4b92 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2418,7 +2418,9 @@ F: block/stream.c F: block/mirror.c F: qapi/job.json F: block/block-copy.c -F: include/block/block-copy.c +F: include/block/block-copy.h +F: block/reqlist.c +F: include/block/reqlist.h F: block/copy-before-write.h F: block/copy-before-write.c F: include/block/aio_task.h diff --git a/block/meson.build b/block/meson.build index deb73ca389..5065cf33ba 100644 --- a/block/meson.build +++ b/block/meson.build @@ -32,6 +32,7 @@ block_ss.add(files( 'qcow2.c', 'quorum.c', 'raw-format.c', + 'reqlist.c', 'snapshot.c', 'throttle-groups.c', 'throttle.c', From patchwork Wed Dec 22 17:40:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12697161 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id B436FC433F5 for ; Wed, 22 Dec 2021 17:46:28 +0000 (UTC) Received: from localhost ([::1]:36810 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n05h5-0000kL-NF for qemu-devel@archiver.kernel.org; Wed, 22 Dec 2021 12:46:27 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52372) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n05bX-0000S2-9T; Wed, 22 Dec 2021 12:40:43 -0500 Received: from mail-vi1eur05on2133.outbound.protection.outlook.com ([40.107.21.133]:46561 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 1n05bV-0002Xs-8w; Wed, 22 Dec 2021 12:40:42 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PAltX2xgJR3RtpsaMzeLLYF6aQGoo/DuA36hADqn9Iq+0gUWzD4wUg7tHAgpKzQln7HjCdDgOfsjCrne3uxRgMRpVe8Sf2LUZSn/QicNl7LD6k2ajq4RXRpTN282jQlmOJ1ZZODSQObSclJ5e30pueIye5CIOrFqgbOSYSwAxU7PB1bad7EpCH+oC03XehHTD7ii62kUdn9153bkxmx9d6nUlHjJM8fLvDNxt+liDZi5YQNAXY33A4y0W2aOfl5cofFcJJB2K/rE3eG7Mx1eMkN3wUxv2ma1xnvgtscui6vHfqkUDxVOC2NQ7VaP6cawZSE/FgxwIgu1UavuxgHc1A== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6xIkKyxGqeuiG9MnQOfs5KiTMK35rIKITsT89echrjs=; b=llncm8JyGyOMYKocZHAEoNS2WlbAnwm+QsY4xCBr1ExnXowjSI1OpJOG0AlDxfSAzIs6V3HeiEhd+SgGOLK6KDGyECIQYcfR0FYZTrLmtN1gc1UzUKvhh2IvtVQ+hqUHxV0lDLfxcAj50d+7nADqsa1qc/bRen6kLLo7XXvB1yn4evDRVM5uIRITOj0QsScirlv4+SY7gTEpxykKzy0VdLehDvh8LdMUvzvMrKOIDfsxZsIVHChZSTUxrR7dL41eF8D8ECJAr+cJ2yQSuX8ssNVPEYwtK0F1EEt3TWVkiCTuzXOGQ4b5I2s6xp2xOh7+VcHaWRU5d+UGNedo7z3nRA== 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=6xIkKyxGqeuiG9MnQOfs5KiTMK35rIKITsT89echrjs=; b=H4hXbO554isvJzEDan10h4c8O0YIzC3WkWOZgxL2ZBI7c3hMjZIM+jeha9hJvWHXLwSFr5XIrlsAAqFrmI4Q98TK7iyQf5LJI4GWKp0+95iPTpu22/1Br5/peuS+ItDgsbdAmwH/XiSnlplwECq3/GbdfCjdbKs+M3kWZ5b82Mg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) by DB8PR08MB3964.eurprd08.prod.outlook.com (2603:10a6:10:a4::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.17; Wed, 22 Dec 2021 17:40:38 +0000 Received: from DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e]) by DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e%6]) with mapi id 15.20.4823.019; Wed, 22 Dec 2021 17:40:37 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v3 07/19] block/dirty-bitmap: introduce bdrv_dirty_bitmap_status() Date: Wed, 22 Dec 2021 18:40:06 +0100 Message-Id: <20211222174018.257550-8-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211222174018.257550-1-vsementsov@virtuozzo.com> References: <20211222174018.257550-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8P250CA0017.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:330::22) To DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7ad96009-9b2c-4215-8f8e-08d9c5722a3c X-MS-TrafficTypeDiagnostic: DB8PR08MB3964:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2089; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YC0EWv5EVNqFLQrG8FmveM+Ot97Cy+qcJsmt9xStod0i9LSNok8/M1OTt8ok5WJbAq/4HMcHhjZWuG1mushvAIFMIlMGSrpNTnG/kmqCKZ7tt2k7w+PSBHOHftEC1hh3pKd64T+yMf6cOd8jh1q03jGIWZTip56lrbp7/zNl9ZVNN5zcBZB34No9w7Ibvbxc+NwY6Tg7N7hDwyv03wY5NWmvbmTh5Em9pmsriciBeUkTJTMHyEmgX09GEN4gHkCxeUfSk51bAlMhB3cANszGKmd6yfMFXKoCGijgnOvJpDHpQGG1WA1+Qy2cn88Xd9wsbj7nE9XXClERghlSZkufhn0pQX3tCpDcbMYLVxuTxJax5wBy+QjhVgn11arWEdlkhQGWL581z7heKXnvP5za5Ksx+1vpbAdXX48vF67EK2kds1ATml7ULoHI+ywv4SqAY0gODRVmP7DOI0ZFBr1jZqpQ9gC2Tqz4kZt/H+yIlibyovwYMFlc848Tu6o2U/2MIl4LusPx06BbUk+acuAyS+wd8PR4CVPBCbXOp2Ag2JgwS9T5ucav5aVAJ1oSucLe4keltEMBros/s6T6cfPjQ0ovvAS8gpYBhmP1y8MQJYZfkdvaYeKPtyd6rwerkYZ+Cgz1IutnRiIMt9e+R2kGeBXg09gSStc3Y5W7ClIqajXk2vIDo/TTs4Gh9fAluavhPKFgkAXok9OHWo53ddqDhbL+1pYoKpjZYH7q5G440A4= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB9PR08MB6748.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(107886003)(6512007)(6506007)(26005)(316002)(52116002)(2906002)(186003)(508600001)(6486002)(6916009)(4326008)(2616005)(8936002)(5660300002)(6666004)(8676002)(1076003)(38100700002)(38350700002)(86362001)(83380400001)(66946007)(66476007)(66556008)(36756003)(14143004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CJQroUCPvLHh1m5Ox7pz8qSRFnz38FR3lSm50Jtn7LMMcjzuuDRvIg5Z6TbApmqU2rBPueln1Qr4yS9M9mKdxGWyZXtLmhddtC7gcMHyiHGBRmf6Q/i2slSK4FFNFbTZ2qsSEoo92hOneUvUO/8UKD9Jv4Vq+MWoaxwsqajrrS63jWLxVQFUQ/uXLPgysahIZlpm8netao9fSS63F4cQUMs+T590YfdBjlVWyPiad0WCd/sk3atetcy6LQVKB89/D8Y3NTuEdXm4oTyG2AYJ8lF9w5Sal782NtDNPUQnv0gD1P0+DiVhcA4C4w07aBr5TBf8n8eNvx7QnjerssEp8GaIeJfIXRUNb+GYL5NkDkRsLPgVgADda4Ah4VaQtQYNGUCHC8gr/AvPrDxj044yPDOniGjXJZXax6WowjKLrD5bkxzHZ94V4F0ZT1Nl4e34boLfSF+pAnq+RkzihPEgHplxhCjm6yolCyOtI2yBJYlOv/bUU+W4vM153mLsaoaWLqUImCIc9DrjBQxS3y/bDdI8lyYeKU2d7ixl4redwfA9u+y5TdYAh4IWn94zwpfdEDu97gLOQcJDyRNP2hwUuQgIcvV0aioDUi59UaS90uiaLScRsEPgdayV76M+kChZbSfz/oc8S/NB7d87QVCwGl9huU4cjKX19m+pSf04+cHKdtfd48J1iF5rbxDLyp6M0G1QzIppFh3TPnKNhlWjIbcIBP1QCkezPiyWdrp1xmmCLKHHPoE4zOKenbbUB1cTnRNEXvNrEsqfBBqm1xPzYyGryvO8eY32VfSUCjUVLwHSBpUYXVv+jnyg3TOkMyH3iLIGeI7WDPwKCuZN9UJKfyoED3qJ/LtDA3MBUYlcmPWsgvmCYSNBnAjSjm6k7ZwxF8qlSGuBri3DUBE5tjjjUZfZhoyvT2VKiP89KwLeMU/ihIS3oMURsocPSMu9J3WTsyqHHegtPai2CGNHPkegC1b1cYqDmui1TpWwfGKJ6qXuIACOqkrUGHLjZ/Jl/YLTVoSNmy6DybFj9AQ/T88FnuDwKjfyBSNCk5MA0pIQIknaZByU+USKDKnzjxtd8vW3TkSafKDNkOBkJvqAZy/PE/t3hZwdrhCl5EgCJZqzqf+wJCd5p++iPbGatIjObA9Xb+76TVz9qpHHvXRSYXQfdxWSGQE9rx1xZxmZMT+cjHtcrAIMWqpCU01fOREpamhqxOY0hk3/MSGH3hPwALdoCHTOSPaStci4lsR+ScasxBBPA+Ln42a86w0KX3lWdQNj657rqXcm2HMo6/5Pu3nQDfrBopfSnG45ATim3EpMis8q2QJOavk336GaXvqgutAiN92gjcjudVJ7sNoHHS5R8dgbLM1z91UIuCQR2Cnk0fEdUemMzK34p2DObDZQKhX/DdBUJ68gt8dSxL1SeHDPWJ8J1YtGPSWUSWlu9NWPpFBMNHT702KVh5+5mAwX7rzBhWCFyz1/SLxA8yvHf9HpdhfTN+ZiqL56BfZfinLLKGXXnIJ9Vt1llXoC+ExSmZVXdkmay6zyGQiW5NmBHW5Z3eVXtO9eQ7FveG3QBxR8y5ju0Vnh83D6ker3y9TS0WWPhD1fZ80WCOa/18KmUCzn0fba6JFwJ8H2oAjDmA3OBfzKYR3jAHLPIHSNrX/8UbZFvqYhMrByDmXBMuk7MAYdIwqjd0LQe7y5OMXW1OuGjl4= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7ad96009-9b2c-4215-8f8e-08d9c5722a3c X-MS-Exchange-CrossTenant-AuthSource: DB9PR08MB6748.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Dec 2021 17:40:37.8628 (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: xvwttW/aCG84HwLt3/BYPEy8zAeQK19yDfUvxYlPUsnHB8oypdoImz64IoEUKogcxFmEyj+ZY5Sz8LIKPRUNHBOLWM4NksLHTFmNYQ4gLjI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB3964 Received-SPF: pass client-ip=40.107.21.133; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com 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, 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.29 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" Add a convenient function similar with bdrv_block_status() to get status of dirty bitmap. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Nikita Lapshin --- include/block/dirty-bitmap.h | 2 ++ include/qemu/hbitmap.h | 11 +++++++++++ block/dirty-bitmap.c | 6 ++++++ util/hbitmap.c | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+) diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h index f95d350b70..2ae7dc3d1d 100644 --- a/include/block/dirty-bitmap.h +++ b/include/block/dirty-bitmap.h @@ -115,6 +115,8 @@ int64_t bdrv_dirty_bitmap_next_zero(BdrvDirtyBitmap *bitmap, int64_t offset, bool bdrv_dirty_bitmap_next_dirty_area(BdrvDirtyBitmap *bitmap, int64_t start, int64_t end, int64_t max_dirty_count, int64_t *dirty_start, int64_t *dirty_count); +void bdrv_dirty_bitmap_status(BdrvDirtyBitmap *bitmap, int64_t offset, + int64_t bytes, bool *is_dirty, int64_t *count); BdrvDirtyBitmap *bdrv_reclaim_dirty_bitmap_locked(BdrvDirtyBitmap *bitmap, Error **errp); diff --git a/include/qemu/hbitmap.h b/include/qemu/hbitmap.h index 5e71b6d6f7..845fda12db 100644 --- a/include/qemu/hbitmap.h +++ b/include/qemu/hbitmap.h @@ -340,6 +340,17 @@ bool hbitmap_next_dirty_area(const HBitmap *hb, int64_t start, int64_t end, int64_t max_dirty_count, int64_t *dirty_start, int64_t *dirty_count); +/* + * bdrv_dirty_bitmap_status: + * @hb: The HBitmap to operate on + * @start: the offset to start from + * @end: end of requested area + * @is_dirty: is bitmap dirty at @offset + * @pnum: how many bits has same value starting from @offset + */ +void hbitmap_status(const HBitmap *hb, int64_t offset, int64_t bytes, + bool *is_dirty, int64_t *pnum); + /** * hbitmap_iter_next: * @hbi: HBitmapIter to operate on. diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c index 94a0276833..e4a836749a 100644 --- a/block/dirty-bitmap.c +++ b/block/dirty-bitmap.c @@ -875,6 +875,12 @@ bool bdrv_dirty_bitmap_next_dirty_area(BdrvDirtyBitmap *bitmap, dirty_start, dirty_count); } +void bdrv_dirty_bitmap_status(BdrvDirtyBitmap *bitmap, int64_t offset, + int64_t bytes, bool *is_dirty, int64_t *count) +{ + hbitmap_status(bitmap->bitmap, offset, bytes, is_dirty, count); +} + /** * bdrv_merge_dirty_bitmap: merge src into dest. * Ensures permissions on bitmaps are reasonable; use for public API. diff --git a/util/hbitmap.c b/util/hbitmap.c index 305b894a63..ae8d0eb4d2 100644 --- a/util/hbitmap.c +++ b/util/hbitmap.c @@ -301,6 +301,42 @@ bool hbitmap_next_dirty_area(const HBitmap *hb, int64_t start, int64_t end, return true; } +void hbitmap_status(const HBitmap *hb, int64_t start, int64_t count, + bool *is_dirty, int64_t *pnum) +{ + int64_t next_dirty, next_zero; + + assert(start >= 0); + assert(count > 0); + assert(start + count <= hb->orig_size); + + next_dirty = hbitmap_next_dirty(hb, start, count); + if (next_dirty == -1) { + *pnum = count; + *is_dirty = false; + return; + } + + if (next_dirty > start) { + *pnum = next_dirty - start; + *is_dirty = false; + return; + } + + assert(next_dirty == start); + + next_zero = hbitmap_next_zero(hb, start, count); + if (next_zero == -1) { + *pnum = count; + *is_dirty = true; + return; + } + + assert(next_zero > start); + *pnum = next_zero - start; + *is_dirty = false; +} + bool hbitmap_empty(const HBitmap *hb) { return hb->count == 0; From patchwork Wed Dec 22 17:40:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12697162 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 682C2C433F5 for ; Wed, 22 Dec 2021 17:46:44 +0000 (UTC) Received: from localhost ([::1]:37768 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n05hL-0001PD-F6 for qemu-devel@archiver.kernel.org; Wed, 22 Dec 2021 12:46:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52416) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n05bZ-0000a8-LR; Wed, 22 Dec 2021 12:40:45 -0500 Received: from mail-vi1eur05on2133.outbound.protection.outlook.com ([40.107.21.133]:46561 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 1n05bX-0002Xs-VW; Wed, 22 Dec 2021 12:40:45 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P0FB3Och6EEzS8My4zjzjwQ+MfIvhKLYnpHtZNGL3KHiSpV/WttRqa4ul8i21n8KaYehYE8AC5nSx59bT7NbzMwpIUQdwL/KPqhKchRH7Hjq1/uqQD6i2lLeUNV27hq05DU2axH7c9NVONmBu/yct8sQGn4lN74bTuJhAkOw8+rp2QBAwBQzjLgWhvk2g4Sms2DgMIuZj3Ui6AbCM4UQ+5qf+O9otY7T9PDyYyBjCDorN6Aazbb3whQ8DG5Vs4Rp5rCShoOeT9vR1caH+3S0onJrSKrmbwwe6qvnCs/j4H+aqP/ckXntW5kXjKFNOdiwPv1kaaUQhqv6cBbrgp8w5g== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cPuHYFNucM2eM+aQcWNiQMeC4pPolROBBjoh9XsJKb4=; b=D+rBDUo549DsnpmtKf+nvirk5tL0GV1XTIyoTemLTvhfNSXFr9eil02J5lATSOcghWzMK5X+THfQ0tH6VSLEDirhYZsYUgFvrmVCBF8/lkM8zIAhM7DO+m9pLVk07ycPCAWyp0/+r1cYZiOq7VSqZVz06BC2FAYW2TDQ1iwfoy5eqXpB3Xx0mLZ0VoZG3AwsMZ6QPfLyVrZrcKwPOL8V34mjbl/uDu94yyf9D06RHeWULocyerxUPcCHLYO0o8LTCi9he3JvejO+0UL/VfQXCGfVQ+wDoGuO4B3qsQY14hj6BixR6WX2j/L2+G1Vobqngp7nMvzW4o1IvmEtVGJBdg== 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=cPuHYFNucM2eM+aQcWNiQMeC4pPolROBBjoh9XsJKb4=; b=DZLp8TImkiNeHSEbTHBEOvJqiOQwLk8ccmPEQTI8mcgnARS2+qf4Bzh1X9JCXOVbYLk1BJNg24P5L5houfkjkmCf66B3CzwTEuaBNQgwE+DdNvUbGyRKPD2eHEHmcnAnfC/+GfyCs6yA0gdwOK4Z3pSO2rKYlZwRXCip1eklEVs= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) by DB8PR08MB3964.eurprd08.prod.outlook.com (2603:10a6:10:a4::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.17; Wed, 22 Dec 2021 17:40:38 +0000 Received: from DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e]) by DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e%6]) with mapi id 15.20.4823.019; Wed, 22 Dec 2021 17:40:38 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v3 08/19] block/reqlist: add reqlist_wait_all() Date: Wed, 22 Dec 2021 18:40:07 +0100 Message-Id: <20211222174018.257550-9-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211222174018.257550-1-vsementsov@virtuozzo.com> References: <20211222174018.257550-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8P250CA0017.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:330::22) To DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0c407063-c348-400a-7770-08d9c5722adc X-MS-TrafficTypeDiagnostic: DB8PR08MB3964:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:411; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JCgkTrafR+jnxUdUhdQyw4thXrdvUD/MH32YIXVbzjxJNmhKR0o6/IMgX5OFsnW37Y79u+bghw1cxa6r8pxpLomJWOsVNFcbIDmg18EaxM3OiiTfQwY8DiVKGQxCA+3Y6e7OmvzbY5xsm/kKi4bRkHPLBGHwQe4swM5R5PhOSYpZEUbMMmz06p/F/7L8022IhqBEP8Rj8s7aC/hkQoc28A0rRQPYZ2vqVVXIRBqKohevu9CPU/DkcT9HORa3sb0V7Y22Yx9Jm7FRRcTpZrRSOss719p1MR6WgvPADLFQpRenJ0KDkgTSo5GSO5yR40Cflafam6KIUFLQN7ZLvC/DXTyQZv11Vdm7EzgTnMY2rd2ALS3pxxNHQQDxPXIL93vB+BBZDiD6AdDO/Xb22tu8tAhgrWNM8wHDDR0qDPbGm86mRVq+HgwLK6haivVLTa0uSVz+tTsmRQFpvd090iivLIJjR1iTHwch5oB+cINbF/WDXuC285vtcDAz2FKQyZly1XSowgxw9IuQTrBfjJb0FfI47yejCWGtG/umXT4rqwfX4Cp1PUw/k5fh1xtLd83hcYQnLYHcgplUGlBIiwoDzm/wdfageuHfohvoviVMB2Lwc+J07wzQAaRh+Qqf7fBeKhnzLOHfdHcUOytFfVMvXhr9Q6pL4/17ammVUCFSSNMrTiwfUjfN62jZHh9+NOryCWFGSZw6GNi1JU9FlmLmOw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB9PR08MB6748.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(107886003)(6512007)(6506007)(26005)(316002)(52116002)(2906002)(186003)(508600001)(6486002)(6916009)(4326008)(2616005)(8936002)(5660300002)(6666004)(8676002)(1076003)(38100700002)(38350700002)(86362001)(83380400001)(66946007)(66476007)(66556008)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vwigR9oDTK3QElAILjI8rmX6q5qoeDJTNw5vbqXYGK09X7LpItGOGdeyBjSrKCkec5ugS/VLBKQfTbOpA3+Lc0fuA5SPpGVYNkOhjEcYpNyAr/MrzWXpQcnkrGJr5pCnZXD6Ex6xz7o95cyjN0W/3sclFgL6yZjY92ELsfksE/Hum3x8i0r61URbLrrsVr8dv57aohmaPSTBb+AS4PDvjqXN2hL8hJzyx7IimvCHkN4kUr8bERqDzATGCrEpyNM7WPU4O1VQ1YxZNmYLtyUxkS9zFy473vX3qI6ht/HVZWNtC1Z3DZ4XLEk/txsyQHWk9yVbTBYDjp9C0Gqk+rpRWDRUA0QDkTO2J86mCOljNfsilJq5dBn+WmFxxEEuXWH4zOX3tFW3CSbaLsQ29HCcx9w/EmPVUG8N13QNk/Cj0IQgHIGePDh5Llt2ln9pHg6fPCLj+hHyJusEP/O62lefVEFYl+WjKF799hZDmo3YPR3vtweljG9+wOgLRi7kbR2gmRhT12rv/bwUYit+ihdqEqaaVqVAZ9OlBTNNRzxdTuqaxUJ2jxk592r9hXwzVqZleXHCFHzQMBmzG9SjLtjEsp4xaXpscp2gPdbhQXqrxP2m1Xk76MJHyQ5Cok0A2Uh65YAKMN6iTfjp7XOO65D++7IcPgLUnb5f06iiC71BW7poXinEEks4uUnKIyFBIRKzQeN/HidYdtDtaTxtmtBAJEW7nkvyGeSedh+UHcz7Y4aR4MIz+uynW4DwbVdhEHHpKnnRPbnuFiGqBD5H7IVnhuZG2daBHTvcFX/ZOBI4pVUw1WxM8mglu6vG/TaamlnMfESY4WhIuolhtIEZEkWmI4krAnAavE5Wx4WeC5n0BeUuWtpg8Q+znFWZvxhck0O0NhpbXLMmR/87PVeA9blzAcCx9lT6AExIRIr1Q7Qkfz+IXSy526Konq8eEkzHZaM5atf41CQHUix9jV+4AUqx5s45zj9unaDRPqEjjBxJ8EcTmJ8VWh+Yg7HYI07YTwQHY388pvibpgagTslrJ0l5zl46deU/yorbCueLmUNxH8t3XqBq47SdI5MvXjPbfrsS+Aqgp15jszrPvRXSkl92zQyZNnT0UsG6DTSMvzS4Uvr4XTa8nh5sL+9/9elUC4Kk14AyPW/ZKzCt/+ymMMrNtrSYGUJmB92YVPm1FJkItEmSO+CmKk5/ItIrai4/u+TkDE5LOXuVNIpx9EBAFNCLiSLpvwQuOFAfI1Ce71RaGQG6HV2/uBHOhwIgAVG3KC7p+zu6HwvQGTguCgi2HFC43qG5+nLMjQONujLiB9x8q5CRlbyI6CC1Jlc/AR+L8P34EyLwCn5qBpMC9D7xXteo/uuWvPA5TdNad2lIY+1ilt6GI2ZQV3czjLyCmWOLutcUW6YFOVJ2biZHhSCgArP6qNsOEl//a5337wekL6JLkb61wNS64Tz6mxq2XJsJvznml26sIgZemDwE4ARPn4OKIeZdmyshaElBbG7ruC5wu5C86dR0pkNf7LmmCizVV+A72jkGh28pSEWiI/5rB0nvQEmp4hwivwlDPL/4wKbkHl1zpLG4QDGgrS8qd8DmP5UDP5KVhthO0k9o4iYoc5qySy6BPymirgAkH93GMbacXscBA1oF96kGIxQUmAVENdrdmn2XCHrwC2uQMqDI2AgprP2Gyzeqz08Uk4rllywsZsc= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0c407063-c348-400a-7770-08d9c5722adc X-MS-Exchange-CrossTenant-AuthSource: DB9PR08MB6748.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Dec 2021 17:40:38.8326 (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: eboAZLA45OlF/TZViNuNp3sVUNgqG5iJQlA2mvps5IDJLpq+ny1qW0A+nWKY5R68FSMW9AqS+h52pwHby4nJfLKsDXxQVgrdovHbsRP1EuY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB3964 Received-SPF: pass client-ip=40.107.21.133; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com 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, 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.29 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" Add function to wait for all intersecting requests. To be used in the further commit. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Nikita Lapshin Reviewed-by: Hanna Reitz --- include/block/reqlist.h | 8 ++++++++ block/reqlist.c | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/include/block/reqlist.h b/include/block/reqlist.h index b904d80216..4695623bb3 100644 --- a/include/block/reqlist.h +++ b/include/block/reqlist.h @@ -53,6 +53,14 @@ BlockReq *reqlist_find_conflict(BlockReqList *reqs, int64_t offset, bool coroutine_fn reqlist_wait_one(BlockReqList *reqs, int64_t offset, int64_t bytes, CoMutex *lock); +/* + * Wait for all intersecting requests. It just calls reqlist_wait_one() in a + * loops, caller is responsible to stop producing new requests in this region + * in parallel, otherwise reqlist_wait_all() may never return. + */ +void coroutine_fn reqlist_wait_all(BlockReqList *reqs, int64_t offset, + int64_t bytes, CoMutex *lock); + /* * Shrink request and wake all waiting coroutines (may be some of them are not * intersecting with shrunk request). diff --git a/block/reqlist.c b/block/reqlist.c index 5e320ba649..52a362a1d8 100644 --- a/block/reqlist.c +++ b/block/reqlist.c @@ -57,6 +57,14 @@ bool coroutine_fn reqlist_wait_one(BlockReqList *reqs, int64_t offset, return true; } +void coroutine_fn reqlist_wait_all(BlockReqList *reqs, int64_t offset, + int64_t bytes, CoMutex *lock) +{ + while (reqlist_wait_one(reqs, offset, bytes, lock)) { + /* continue */ + } +} + void coroutine_fn reqlist_shrink_req(BlockReq *req, int64_t new_bytes) { if (new_bytes == req->bytes) { From patchwork Wed Dec 22 17:40:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12697175 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 60574C433F5 for ; Wed, 22 Dec 2021 18:05:00 +0000 (UTC) Received: from localhost ([::1]:55996 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n05z1-0007mH-77 for qemu-devel@archiver.kernel.org; Wed, 22 Dec 2021 13:04:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52640) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n05bm-0001GP-HF; Wed, 22 Dec 2021 12:40:58 -0500 Received: from mail-eopbgr60133.outbound.protection.outlook.com ([40.107.6.133]:36163 helo=EUR04-DB3-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 1n05bb-0002Zq-C1; Wed, 22 Dec 2021 12:40:58 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vsjbv0TxH/+CkiGr8W+295O8L5mGi3iBPtT8gvtsnJnnChkQAauiM/n6Jrm0Mma9J3e4Mt8om3D2WAxcIgPvOUvd9/0rPb8CEYSJ9Ik1rpr9LJ/QjjY8T/LPs+H5eL8ZibZ46azkb+kpiTSwThRBzeGNu+8yApxjEX73o4PwamPIPfRtUWQApAzT4kbdB+ZkRe7z0VpcdrZFJjww4OKkWTPNicNTxk3sFf5OtK5iRklBF8BYY8/mcgzMFm1rOrzU7BaEyB3V1Two7de0KOXtUXPuKsBs3L/y1ib11HyUx4PLleNKazFMZtHuUibOChtfkHhqkyUz9/8bk3axLjDAmg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=P5ATDaSVy6Q6GRqF8gPOf+PPgc/Mwjv3iBcH1wu9/0U=; b=A6PztfnAWjSZPUDoTjbb+bkxoofXSLu7P2AjKmatF038Rn7tZWUa8YTKMW6g2xo0Mj5OcHrsw3gNqKAusmQUmvGsWIFx0IGDRfaeVS0/at/RW0T+keTlgUJ52cY5CXt3hm9QKbztHcC5Vcvx7bLGAtXtOEZ9WD9WR7aFDepQYYkB2lNmdlsHz3vrpe0R7GMK1Z9JjjdT+/Riau0ShLXJn4C2Zhh+qrIpxBnDBPXCJgg90JtXmVrfMKf34i0d1exs6TuC9NdrRhbgdbgdxYIW3TXvDSuPSxLpdUvVGKe9MSAszUyWtH3e9sG6wszLd7ySKxIh0jrmvnNSzGCdA8HxMQ== 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=P5ATDaSVy6Q6GRqF8gPOf+PPgc/Mwjv3iBcH1wu9/0U=; b=gTBnDWVRZeHk49gLkXAy8f7gVmOTtpbM95DIeC0KVtWY6HwL3v0eLSS1nYlw+58KKW7ywvDhACwWmKAz7hr2hxTw+nuVvzrh11U++BhECsHJ3h37ZbzDeoYIg7nVETqOQnera1fxF6QPKU/2KdZOZL2e4cAB1Kt20A18EiJAGHY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) by DB8PR08MB3964.eurprd08.prod.outlook.com (2603:10a6:10:a4::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.17; Wed, 22 Dec 2021 17:40:39 +0000 Received: from DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e]) by DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e%6]) with mapi id 15.20.4823.019; Wed, 22 Dec 2021 17:40:39 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v3 09/19] block: introduce FleecingState class Date: Wed, 22 Dec 2021 18:40:08 +0100 Message-Id: <20211222174018.257550-10-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211222174018.257550-1-vsementsov@virtuozzo.com> References: <20211222174018.257550-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8P250CA0017.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:330::22) To DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7fd94107-49b5-48e3-e067-08d9c5722b55 X-MS-TrafficTypeDiagnostic: DB8PR08MB3964:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2958; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SVLAEhLMofgQTq8ZnpxOy9rR73WsBn+aVPz6VRHaJ0+HmuEetzlrhrGBUZyapnEqSoFcrIt+80d5pv2dg9TW7doiAZC0egMZ7AJGE7WSBv05COgjFTq3sWiAk475Y96lzrom7a0e2xYhmFVVc1CF81szzDieSGRAVlw5SHXzjHsxsgzHuA+GVXA6NMZGuCTn3R5YKQllsfsD28ZQGVIoYZ9pl7OsEVMe9ji9fq+u1bLDoNxX4mcIzD9ninY67RVl2kTktuFN6QTLuYtcUd1cYO6AEJ5oiUtXhdWfuJQl5NYKW8PpLo2SYwD4KLwW3MgrHVldXIsU7PUm6mG3wIatYIVS8AdvlZYFMXvp2cFz4T86emt639eQk3+FV/OgnqEOmIdBYJaxYsX71IN5BI3pYfmvfWdWwvPZegvPstUQBwL0jFvXVEf9rz8bqDLexrbhr5+lzyB9pDlb1c+qckBdiKWlwAFDn4WsAoEci+xrY/QrDaYN3kAaemxu0Y076OUVXXhM1BI0e3q6mmkoyZau1nxUWaqdpK6GYW2N+9ke+JieSALHon20xatGKRAF70NMzH5pBrA/UPttgMxe5ULwnkh/SPPC7ro32yD7OrGrMfGupvAYtw4YPdPkX9bq7m4Msb+7hDbbL6mfHFD2PTwi/JmgGDWRjlmfkiX6x2tHomRGRfWBf3UEcPcXabqVaFzxeE3ls2F7UpRdSzdXpf/MiWl8/vcQ2QC+zPVsSK1+u2abXScUGFMA8ZTWpA/jEx+zqYWovNQZRZdD6F1QzR54CClEQSqU6B1sogx47LL+N8j/G+2sbP7Zx/ymuRRqmUEH X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB9PR08MB6748.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(107886003)(6512007)(6506007)(26005)(316002)(52116002)(2906002)(30864003)(186003)(508600001)(6486002)(6916009)(4326008)(2616005)(8936002)(5660300002)(6666004)(8676002)(1076003)(38100700002)(38350700002)(86362001)(83380400001)(66946007)(66476007)(66556008)(36756003)(2004002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ehx4iZylqaXxBAQ/D8dWC9Hwt3/A3pZNx6m71gpISPducUhDF3GfoPTGZlXp1qjsh9sa5yNTefAOG6VwNb4VbL8Segnz9Q5PX6Ts9A91PJielL5AZfHYVZ33U+N56f3i1o5u/yUB+44TMqFqwruwp1e+L7xFDmz8bbNe0ajMyBXlMvpN007VlECOjcOp4fsxvao1s6ZTFBJIZS0AjEQo/GZP4jxf0McXL7jXbQnh/bW4ie/KQ/VHpnewVJPda1r80cOrvCDwSvIQzmtbKcKbn+vEg+yc7gZDw7PTD8f4uVQRWtfa3K5pKDzeyjJxuOuyBSd0oh9qVl9sfb5wkFHfrYohv/Jo7dx9Q6IEHLQn7AEwmcYFwBoWHsGWtER6HTkNWqpJfQQ89/99T4xMFr1gmFjLN5N4aM8pf+B3mmQS3TN+4+uDpKOMr2rIcglmLTD7yc8VZ7NX/nwdbslGZFcr7OXgdCxfyJpezP5vymMgM+PwGLBws7VHckXQMvIf+9N24D6kHueCOZjegq7j6zph35F5G5pXJSA5Bnleoy6nj1DR4Nv0Ayhzi56vB0qW/vw/ab1ka57viC6RSZguPpvqcdJ3xhbuE8OpgpFfWgZoNonxz4dn/3T0Sg3nkHK4mRQpjztZHnfwc4pcm2mVBVusUXOIQk40eHido0LyNx/+CJksZZsu0pCkf0BXyvgp1lpx8vJ9ZT0FLpdsfdrtfeB5J7T3K6f8DcLP2wqFtlPhzZ/7CldEsG6ROaKtpYqRAlUZ5chRm5ZlWR8hcxxWP7wjJQcKuVmuaUTXI7AvallcwvB8651k1l8mEYqL+3doMvWdcnaaW957e8rUpctUK9yl36sW8/K12hPARg63fpTvP+uSU26XKBP+43mv5d/CEq5MdUXIHDdVgusIaWkvqHSWnpkYwvo8ygWSZ1XeaJK/8fHhh1M6zE7kZDX2VvOoug2wAf5LLZhiw1zhhcEzxeZN/QgwUN/yG9iVTkAyWgq9zmXHZMaKmflm8dDZkv4xMcP97ddcP5f1IX3SJMrZxKp4NNBMlgikPZ43qmbXTMnThSKQuryVmbYcN9T2Pj+4sSXVaBZ8c3kHDIXc5urYflqcliiNHFsAYstIKYfHl6I+il6++Io5nuoWgQgtbOoeGGbK4TywNPPp43LYlEbLbpiGR7h3G2Ujr+gjJezaR2lUTuACH9lVnRufO7Kf4WIRxga2jW9kTFaEaMPVtqwlf1u6PoKvOizvoz9j/3epgQsbl6bBYmn7rE5RCzbfJDxEBSsNeebMcVTOySDgbrRcUREdwu9VRpZ1Ko5Ii2Ughih0ow+L5rWHDabgO9YDLlRlPp8tBsQ3PIW7REet7YnehxTmXNKcRRGMOpI7ToJ1xJhrCwGNaX57XcKcizAqOnKfrEJIXwEZxblAuUf3QCL3uhT7B3rX/rk9tl16FnPMNVwh2OQ5gB3NCG3L5970RwYw9j1oHyecfN6q97xemw/crPSc6wadqz3/OiPgM+7SkgctOhUhQk+Gs6SpWo92x/FKxgdd1zTGKClU1NFzPAbbCLZ0hIusra5uy4+UOuph4RY92wkCXNKEcAkNgb6nyiACTZmDqJJmTooQiibEgWKDsgxgSdhbaalYOXcvmWVWcj1bJbt0C8ukuwKxhD169cGass6WdCwp2lJHkyQSeLAinxHkQ8BJ6EF6YaEAVlCeA8274Ag= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7fd94107-49b5-48e3-e067-08d9c5722b55 X-MS-Exchange-CrossTenant-AuthSource: DB9PR08MB6748.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Dec 2021 17:40:39.5985 (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: 8QkxwS8b/aquiV63aNRC/4No37SChFr8b/eZNQs89FaD77hrsuUi2QQYBOicbiLeYtG/TKohKaMgq4usluMl/BpDtGM8jD0rAooGvvTSHIw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB3964 Received-SPF: pass client-ip=40.107.6.133; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com 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, 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.29 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" FleecingState represents state shared between copy-before-write filter and upcoming fleecing block driver. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/fleecing.h | 135 ++++++++++++++++++++++++++++++++++ block/fleecing.c | 182 ++++++++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 2 + block/meson.build | 1 + 4 files changed, 320 insertions(+) create mode 100644 block/fleecing.h create mode 100644 block/fleecing.c diff --git a/block/fleecing.h b/block/fleecing.h new file mode 100644 index 0000000000..fb7b2f86c4 --- /dev/null +++ b/block/fleecing.h @@ -0,0 +1,135 @@ +/* + * FleecingState + * + * The common state of image fleecing, shared between copy-before-write filter + * and fleecing block driver. + * + * Copyright (c) 2021 Virtuozzo International GmbH. + * + * Author: + * Sementsov-Ogievskiy Vladimir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * + * Fleecing scheme looks as follows: + * + * [guest blk] [nbd export] + * | | + * |root | + * v v + * [copy-before-write]--target-->[fleecing drv] + * | / | + * |file / |file + * v / v + * [active disk]<--source-----/ [temp disk] + * + * Note that "active disk" is also called just "source" and "temp disk" is also + * called "target". + * + * What happens here: + * + * copy-before-write filter performs copy-before-write operations: on guest + * write we should copy old data to target child before rewriting. Note that we + * write this data through fleecing driver: it saves a possibility to implement + * a kind of cache in fleecing driver in future. + * + * Fleecing user is nbd export: it can read from fleecing node, which guarantees + * a snapshot-view for fleecing user. Fleecing user may also do discard + * operations. + * + * FleecingState is responsible for most of the fleecing logic: + * + * 1. Fleecing read. Handle reads of fleecing user: we should decide where from + * to read, from source node or from copy-before-write target node. In former + * case we need to synchronize with guest writes. See fleecing_read_lock() and + * fleecing_read_unlock() functionality. + * + * 2. Guest write synchronization (part of [1] actually). See + * fleecing_mark_done_and_wait_readers() + * + * 3. Fleecing discard. Used by fleecing user when corresponding area is already + * copied. Fleecing user may discard the area which is not needed anymore, that + * should result in: + * - discarding data to free disk space + * - clear bits in copy-bitmap of block-copy, to avoid extra copy-before-write + * operations + * - clear bits in access-bitmap of FleecingState, to avoid further wrong + * access + * + * Still, FleecingState doesn't own any block children, so all real io + * operations (reads, writes and discards) are done by copy-before-write filter + * and fleecing block driver. + */ + +#ifndef FLEECING_H +#define FLEECING_H + +#include "block/block_int.h" +#include "block/block-copy.h" +#include "block/reqlist.h" + +typedef struct FleecingState FleecingState; + +/* + * Create FleecingState. + * + * @bcs: link to block-copy owned by copy-before-write filter. + * + * @fleecing_node: should be fleecing block driver node. Used to create some + * bitmaps in it. + */ +FleecingState *fleecing_new(BlockCopyState *bcs, + BlockDriverState *fleecing_node, + Error **errp); + +/* Free the state. Doesn't free block-copy state (@bcs) */ +void fleecing_free(FleecingState *s); + +/* + * Convenient function for thous who want to do fleecing read. + * + * If requested region starts in "done" area, i.e. data is already copied to + * copy-before-write target node, req is set to NULL, pnum is set to available + * bytes to read from target. User is free to read @pnum bytes from target. + * Still, user is responsible for concurrent discards on target. + * + * If requests region starts in "not done" area, i.e. we have to read from + * source node directly, than @pnum bytes of source node are frozen and + * guaranteed not be rewritten until user calls cbw_snapshot_read_unlock(). + * + * Returns 0 on success and -EACCES when try to read non-dirty area of + * access_bitmap. + */ +int fleecing_read_lock(FleecingState *f, int64_t offset, + int64_t bytes, const BlockReq **req, int64_t *pnum); +/* Called as closing pair for fleecing_read_lock() */ +void fleecing_read_unlock(FleecingState *f, const BlockReq *req); + +/* + * Called when fleecing user doesn't need the region anymore (for example the + * region is successfully read and backed up somewhere). + * This prevents extra copy-before-write operations in this area in future. + * Next fleecing read from this area will fail with -EACCES. + */ +void fleecing_discard(FleecingState *f, int64_t offset, int64_t bytes); + +/* + * Called by copy-before-write filter after successful copy-before-write + * operation to synchronize with parallel fleecing reads. + */ +void fleecing_mark_done_and_wait_readers(FleecingState *f, int64_t offset, + int64_t bytes); + +#endif /* FLEECING_H */ diff --git a/block/fleecing.c b/block/fleecing.c new file mode 100644 index 0000000000..f75d11b892 --- /dev/null +++ b/block/fleecing.c @@ -0,0 +1,182 @@ +/* + * FleecingState + * + * The common state of image fleecing, shared between copy-before-write filter + * and fleecing block driver. + * + * Copyright (c) 2021 Virtuozzo International GmbH. + * + * Author: + * Sementsov-Ogievskiy Vladimir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "qemu/osdep.h" + +#include "sysemu/block-backend.h" +#include "qemu/cutils.h" +#include "qapi/error.h" +#include "block/block_int.h" +#include "block/coroutines.h" +#include "block/qdict.h" +#include "block/block-copy.h" +#include "block/reqlist.h" + +#include "block/fleecing.h" + +/* + * @bcs: link to block-copy state owned by copy-before-write filter which + * performs copy-before-write operations in context of fleecing scheme. + * FleecingState doesn't own the block-copy state and don't free it on cleanup. + * + * @lock: protects access to @access_bitmap, @done_bitmap and @frozen_read_reqs + * + * @access_bitmap: represents areas allowed for reading by fleecing user. + * Reading from non-dirty areas leads to -EACCES. Discard operation among other + * things clears corresponding bits in this bitmaps. + * + * @done_bitmap: represents areas that was successfully copied by + * copy-before-write operations. So, for dirty areas fleecing user should read + * from target node and for clear areas - from source node. + * + * @frozen_read_reqs: current read requests for fleecing user in source node. + * corresponding areas must not be rewritten by guest. + */ +typedef struct FleecingState { + BlockCopyState *bcs; + + CoMutex lock; + + BdrvDirtyBitmap *access_bitmap; + BdrvDirtyBitmap *done_bitmap; + + BlockReqList frozen_read_reqs; +} FleecingState; + +FleecingState *fleecing_new(BlockCopyState *bcs, + BlockDriverState *fleecing_node, + Error **errp) +{ + BdrvDirtyBitmap *bcs_bitmap = block_copy_dirty_bitmap(bcs), + *done_bitmap, *access_bitmap; + int64_t cluster_size = block_copy_cluster_size(bcs); + FleecingState *s; + + /* done_bitmap starts empty */ + done_bitmap = bdrv_create_dirty_bitmap(fleecing_node, cluster_size, NULL, + errp); + if (!done_bitmap) { + return NULL; + } + bdrv_disable_dirty_bitmap(done_bitmap); + + /* access_bitmap starts equal to bcs_bitmap */ + access_bitmap = bdrv_create_dirty_bitmap(fleecing_node, cluster_size, NULL, + errp); + if (!access_bitmap) { + return NULL; + } + bdrv_disable_dirty_bitmap(access_bitmap); + if (!bdrv_dirty_bitmap_merge_internal(access_bitmap, bcs_bitmap, + NULL, true)) + { + return NULL; + } + + s = g_new(FleecingState, 1); + *s = (FleecingState) { + .bcs = bcs, + .done_bitmap = done_bitmap, + .access_bitmap = access_bitmap, + }; + qemu_co_mutex_init(&s->lock); + QLIST_INIT(&s->frozen_read_reqs); + + return s; +} + +void fleecing_free(FleecingState *s) +{ + if (!s) { + return; + } + + bdrv_release_dirty_bitmap(s->access_bitmap); + bdrv_release_dirty_bitmap(s->done_bitmap); + g_free(s); +} + +static BlockReq *add_read_req(FleecingState *s, uint64_t offset, uint64_t bytes) +{ + BlockReq *req = g_new(BlockReq, 1); + + reqlist_init_req(&s->frozen_read_reqs, req, offset, bytes); + + return req; +} + +static void drop_read_req(BlockReq *req) +{ + reqlist_remove_req(req); + g_free(req); +} + +int fleecing_read_lock(FleecingState *s, int64_t offset, + int64_t bytes, const BlockReq **req, + int64_t *pnum) +{ + bool done; + + QEMU_LOCK_GUARD(&s->lock); + + if (bdrv_dirty_bitmap_next_zero(s->access_bitmap, offset, bytes) != -1) { + return -EACCES; + } + + bdrv_dirty_bitmap_status(s->done_bitmap, offset, bytes, &done, pnum); + if (!done) { + *req = add_read_req(s, offset, *pnum); + } + + return 0; +} + +void fleecing_read_unlock(FleecingState *s, const BlockReq *req) +{ + QEMU_LOCK_GUARD(&s->lock); + + drop_read_req((BlockReq *)req); +} + +void fleecing_discard(FleecingState *s, int64_t offset, int64_t bytes) +{ + WITH_QEMU_LOCK_GUARD(&s->lock) { + bdrv_reset_dirty_bitmap(s->access_bitmap, offset, bytes); + } + + block_copy_reset(s->bcs, offset, bytes); +} + +void fleecing_mark_done_and_wait_readers(FleecingState *s, int64_t offset, + int64_t bytes) +{ + assert(QEMU_IS_ALIGNED(offset, block_copy_cluster_size(s->bcs))); + assert(QEMU_IS_ALIGNED(bytes, block_copy_cluster_size(s->bcs))); + + WITH_QEMU_LOCK_GUARD(&s->lock) { + bdrv_set_dirty_bitmap(s->done_bitmap, offset, bytes); + reqlist_wait_all(&s->frozen_read_reqs, offset, bytes, &s->lock); + } +} diff --git a/MAINTAINERS b/MAINTAINERS index 7f24ee4b92..78ea04e292 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2423,6 +2423,8 @@ F: block/reqlist.c F: include/block/reqlist.h F: block/copy-before-write.h F: block/copy-before-write.c +F: block/fleecing.h +F: block/fleecing.c F: include/block/aio_task.h F: block/aio_task.c F: util/qemu-co-shared-resource.c diff --git a/block/meson.build b/block/meson.build index 5065cf33ba..d30da90a01 100644 --- a/block/meson.build +++ b/block/meson.build @@ -18,6 +18,7 @@ block_ss.add(files( 'crypto.c', 'dirty-bitmap.c', 'filter-compress.c', + 'fleecing.c', 'io.c', 'mirror.c', 'nbd.c', From patchwork Wed Dec 22 17:40:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12697169 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id DF7F1C433EF for ; Wed, 22 Dec 2021 17:54:18 +0000 (UTC) Received: from localhost ([::1]:56534 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n05of-0005iu-JA for qemu-devel@archiver.kernel.org; Wed, 22 Dec 2021 12:54:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52538) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n05bd-0000m9-Mg; Wed, 22 Dec 2021 12:40:49 -0500 Received: from mail-vi1eur05on2133.outbound.protection.outlook.com ([40.107.21.133]:46561 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 1n05ba-0002Xs-SR; Wed, 22 Dec 2021 12:40:49 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mJI/SljCmIDGhiPXKdOA8V+2wvT3Qoln0d4YjahpgU3kUZXS+fLPYPJymnH7rDEXOVDecHNby/Z0XyUqoF3auCj6evQDWhuODBfsD5JAaqGlo9gTkpOofQsvAlGedVHVLW+R6utfCJUxjWl3kyvZwlGKpjCh+eShnWGTCQ8Gs0je8Sil7m9OUbFuOSmdPnFX5n/KQWS3gYwdNUp+Z5WduGYtW5GFrVOtJBMvKpy4fhTbSgv6YKwkFsmzFK8lOHvqSJGr7ERk+Y20vI7nTtYuUE3dYa5FroV0/BlmrB7rTm2YBjuaXsJZsYJx1MSdZQPmr67ucXTjfNJpBHCA0NjPVA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=UmflLzZBTAU1snzUjeZl36iVtlE9noG60L8d7L71WY8=; b=U/wCNbKdvCJd9874k8tdu7uv+Y/0mZwK5bteg6ZzZIL9axVPEH3onZIA3yvuyF29zbB4eQuXEioZ5uC701lhNmczbCShAlEz+5dXrRNFIAhl8yC0klOsERdzVLx6p7ZGxBaTRr2O13gnMvpt6v8NeZ6sOL6YGPvmDkC1FGSAwJmx/KTIJ5rXkiCMZX/x7kqIQjQRrwGWQMssoEkaVw1UV6BFBBVHOfRI5wTKRaG2rNQpHu9H80Ph5XY8gdVRFiI9daiXktax3i1wmHmJe80yj8Hbv/V9Az8esGiHeKGgFM+2NKgYcE4fHbe09LgK10vNLvYGsuSt733y19loDMyL1A== 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=UmflLzZBTAU1snzUjeZl36iVtlE9noG60L8d7L71WY8=; b=BPqP2kFo+oZ1CIAHQXhrVwa4jqkBBJi3eFC+rvQnss1wjmf176hD86AzJyQnuftxyc0WhPdnjH+W6ZJd0B9orcQU5e7ktv85o5sPxL3jtv9gone72ATDTS8zVUdiBw2gGupTS8/FJ8W2MNv/sFBpsgdRH+tx4VjCQKwmybiXhVU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) by DB8PR08MB3964.eurprd08.prod.outlook.com (2603:10a6:10:a4::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.17; Wed, 22 Dec 2021 17:40:40 +0000 Received: from DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e]) by DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e%6]) with mapi id 15.20.4823.019; Wed, 22 Dec 2021 17:40:40 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v3 10/19] block: introduce fleecing block driver Date: Wed, 22 Dec 2021 18:40:09 +0100 Message-Id: <20211222174018.257550-11-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211222174018.257550-1-vsementsov@virtuozzo.com> References: <20211222174018.257550-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8P250CA0017.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:330::22) To DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2d59649a-9984-4901-3178-08d9c5722bd9 X-MS-TrafficTypeDiagnostic: DB8PR08MB3964:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3bqmxx47iIy75zsOgLmYJHz2es30F63ABAeIPuyI0gjKx6FHLyJRlxCtciQ376RirbBQuaSIT0hX8o4xvMTCNfw0K4GICk6jBryFjtfnBc8qG7B5XKcStwXeJXszj78WUBPeyfGGM+xFaQSdt2eh8jmZIaqINvkrmFyyy41PS3tD7azpXLrf6trOnnYK5RlkASNBRKsYjlp4GHgtWmsYh9h4fIMpP/S8AzX1LppzhVTyZT03iPeZtrBlLx6jSr8PvDMCAPlDTM0H+eMzUBuMKUcpma+MMYtAeaTqaD0Ma6LugRwHO1pyJzFChtLchnM24l9LYJYdMMtJl4pqzQ5TRElF5Lb5dRkvURrJzJEa2gNiT8mn9j8LSMcItqy6HOOG0e9Of9N7q3mesLtIZtsnLfNUvi0ZEr+xSLBw73dVeuG7sL6QnpNxslmwj3yGf1K6D40CIiFt94OOKuZ8eT1zY0+oEkLPZw9ceTrOQSGdX0yYdcnu5jbkgIT60P0+6KxkHvbYeqvTeBETCRiZ8gfhuPTlT8ZfLa8utczFuVMjKKmYDnQ+xqlqVNMAp4ufdRmz973aWdRF/tXE8mvpMJVvlAB5HAfpSZWQ5qxIwkNSmHFgzKKyYycsOIadaD+qafmpcsHnV3I7rrB2IXt1qmhb8U+bpkDUsLXsIpUcEfXBQRaPu97sjaGeVpMbJd+5GdGiMCC6+d9l8Bu1b+vAdM9FPqV6UO6J/YPQUs2L95xH68GX4p/JaH5EnY7H4mmSUg4KK77jyNrFjrJTgXpHWdRJ0itHGBAOQR4QwDkeEhGMBZ/Jv3bzzsHpv5Y1UOJLSoeS X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB9PR08MB6748.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(107886003)(6512007)(6506007)(26005)(316002)(52116002)(2906002)(30864003)(186003)(508600001)(6486002)(6916009)(4326008)(2616005)(8936002)(5660300002)(6666004)(8676002)(1076003)(38100700002)(38350700002)(86362001)(83380400001)(66946007)(66476007)(66556008)(36756003)(2004002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TtujZrd5dbmwuasaGTKmfnGLUIkQN9alAPt4psDpjUjjKgvqDNFB/z3pNB6kvooF/igz3tRgzeGO4gYqOqFQbtBGEfPvB4JiioAaNRPy28Y9za7T0sbdN/InTDFqN7/pqtNJaj2a9Z1n4G6XB4LGISoBTMliIqwgSpYxQ2gkh7nrEv6Wex12SejKzuIDtIPfF8ezz1flE/IIz4Vzen2cLmxUdbZlr+xHkn1+IGVXo4bOR/60oFfzOem7aRQnL0kiY/bK0y1JRvoiu4jgXShSR82KnqcWnpBdeC2vxHjEjnWvdjHKmt6rR+hLe1jX5BSE90Ix3j+aT9yfFeMp0eUk+XmOSDrI7DYhl3U8Q+En92EU7ocv1OKz22IcJIY26ACdrI7IflOCKKpnBA1CA7Dl8d/1SrhefUMUS96379fE29uZwSayb5JXqkMX4w4bnDr7h9168S0N9IwSn96Irr2oYDtqTb70lrXI8qTRaeKGX+pQy/Psh/QTgg6pFcGEfloQeqXZ0E8ftW1syET7B12qlQl/CL7hmlwI9mmJiuxfmRK6coXUkP06tHWoKODwMz1hxVna9QXXsZc1PJGnKK3jaDRjPr0CuNMpIm7bU+uA6OQueV7CLV9T0Igy52kQvN9xM4F5ggPp9+cW3RRCiWV/SOOnF9jB6OBnafJgm6toxa6GR9RRx34qcPj3t3S78v0Nwjn0PySMy57bfk6+NDzctHqhKhG82Ln3B3IbSso6SR8VPOYfJNJWOvYsWeas8EE42FAHg0r5qRTIFLejnv+YZB8s5WES4uzTU7nNMlYWB8XDr+CP1bEjM2iqqmV+vHraqqXp52mb0tAa/19KWzPfCxBnFJJm95mTnQeCz9Djx4vrN6hRTfBvW9MxLH7xnXAWdfcoPsq2+Qd5Myh/nz5gMseIGA7eQK2iIVBSCXSzprB5avlxoMyZuPoL3WMj7HqLCfBeTIWPLezDkQluKt/RnjKPljiXXUQT5lEyinLl/wEO55prqaQ9DksoyFKOAaqcw15SRpBmJRyv/7H6n/N7NPJCuicdRfW0ZC6QoslHdkdurHd4iIl7ubV9C5zDEXm2fv9NvcoBad5ZRGY3pPZ59Z1DAYlhLHL1KVkBoWnSm3zFCnoLP7m7UB9iS6N0wYO6SBbrXEF8ZQ/KryL4KqKs+7x+O2jm3xgD5NZk3Gzyd84fPpVSzGhHQgClpV4A1vbvKb1c7eUeXUzcROj0XZwmQikU1bWsVgplLoKG4KGHsbIAiAVqGmj9zvVI3mFW8fny+NQvq/JqL+tFMatzwbXu4iY8Ftw07no3UTxJKroOKKYr02UicDCHo0VfZ70B9Mb5S/ywFSBSABs57xmDJXajqVb2reS4kwtTpHVCEgTpaccVQP0DMh2iDVHFMqW1DFE1IGREQGna+zlzPOqFnseMjA7hLk6nWreMNGaS+Q3qz+x/PEtG5TGlqiudpDV9WYwi8sbcTufbCZs7mE68v+cs8URbo5Jf8suIxlU0aDT/+xSGUUVWC1mhYH7i730kmbKy9PP7cpfdUI8Xz8WJnYLXe6AY0dxEj4/tsGoik5vjUm7TV9JSpFkimQwiFGtzJWTGw/wYcA81ZBMLPMgjDhQR3xKkZNENC5gZB78QQrAHakGmhbpoBMPOlHUkFQ0SaBJI43WhjOUIdJ60P1+rxyzD3l3VUPcpxqPKINULCs942G8= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2d59649a-9984-4901-3178-08d9c5722bd9 X-MS-Exchange-CrossTenant-AuthSource: DB9PR08MB6748.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Dec 2021 17:40:40.4277 (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: n3gEbVHXwzMiv8UZWYuhNp5xYJAC9heit2FkxVGBsmlNf7b3j4c0d1vPCv1TrInw7D34/IoL+EEFOVmRKZB0wl8l0K9fAmPROnSycUxWNLQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB3964 Received-SPF: pass client-ip=40.107.21.133; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com 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, 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.29 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" Introduce a new driver, that works in pair with copy-before-write to improve fleecing. Without fleecing driver, old fleecing scheme looks as follows: [guest] | |root v [copy-before-write] -----> [temp.qcow2] <--- [nbd export] | target | |file |backing v | [active disk] <-------------+ With fleecing driver, new scheme is: [guest] | |root v [copy-before-write] -----> [fleecing] <--- [nbd export] | target | | |file | |file v | v [active disk]<--source------+ [temp.img] Benefits of new scheme: 1. Access control: if remote client try to read data that not covered by original dirty bitmap used on copy-before-write open, client gets -EACCES. 2. Discard support: if remote client do DISCARD, this additionally to discarding data in temp.img informs block-copy process to not copy these clusters. Next read from discarded area will return -EACCES. This is significant thing: when fleecing user reads data that was not yet copied to temp.img, we can avoid copying it on further guest write. 3. Synchronisation between client reads and block-copy write is more efficient: it doesn't block intersecting block-copy write during client read. 4. We don't rely on backing feature: active disk should not be backing of temp image, so we avoid some permission-related difficulties and temp image now is not required to support backing, it may be simple raw image. Note that now nobody calls fleecing_drv_activate(), so new driver is actually unusable. It's a work for the following patch: support fleecing block driver in copy-before-write filter driver. Signed-off-by: Vladimir Sementsov-Ogievskiy --- qapi/block-core.json | 37 +++++- block/fleecing.h | 16 +++ block/fleecing-drv.c | 261 +++++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 1 + block/meson.build | 1 + 5 files changed, 315 insertions(+), 1 deletion(-) create mode 100644 block/fleecing-drv.c diff --git a/qapi/block-core.json b/qapi/block-core.json index 6904daeacf..b47351dbac 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2917,13 +2917,14 @@ # @blkreplay: Since 4.2 # @compress: Since 5.0 # @copy-before-write: Since 6.2 +# @fleecing: Since 7.0 # # Since: 2.9 ## { 'enum': 'BlockdevDriver', 'data': [ 'blkdebug', 'blklogwrites', 'blkreplay', 'blkverify', 'bochs', 'cloop', 'compress', 'copy-before-write', 'copy-on-read', 'dmg', - 'file', 'ftp', 'ftps', 'gluster', + 'file', 'fleecing', 'ftp', 'ftps', 'gluster', {'name': 'host_cdrom', 'if': 'HAVE_HOST_BLOCK_DEVICE' }, {'name': 'host_device', 'if': 'HAVE_HOST_BLOCK_DEVICE' }, 'http', 'https', 'iscsi', @@ -4181,6 +4182,39 @@ 'base': 'BlockdevOptionsGenericFormat', 'data': { 'target': 'BlockdevRef', '*bitmap': 'BlockDirtyBitmap' } } +## +# @BlockdevOptionsFleecing: +# +# Driver that works in pair with copy-before-write filter to make a fleecing +# scheme like this: +# +# [guest] +# | +# |root +# v +# [copy-before-write] -----> [fleecing] <--- [nbd export] +# | target | | +# |file | |file +# v | v +# [active disk]<--source------+ [temp.img] +# +# The scheme works like this: on write, fleecing driver saves data to its +# ``file`` child and remember that this data is in ``file`` child. On read +# fleecing reads from ``file`` child if data is already stored to it and +# otherwise it reads from ``source`` child. +# In the same time, before each guest write, ``copy-before-write`` copies +# corresponding old data from ``active disk`` to ``fleecing`` node. +# This way, ``fleecing`` node looks like a kind of snapshot for extenal +# reader like NBD export. +# +# @source: node name of source node of fleecing scheme +# +# Since: 7.0 +## +{ 'struct': 'BlockdevOptionsFleecing', + 'base': 'BlockdevOptionsGenericFormat', + 'data': { 'source': 'str' } } + ## # @BlockdevOptions: # @@ -4237,6 +4271,7 @@ 'copy-on-read':'BlockdevOptionsCor', 'dmg': 'BlockdevOptionsGenericFormat', 'file': 'BlockdevOptionsFile', + 'fleecing': 'BlockdevOptionsFleecing', 'ftp': 'BlockdevOptionsCurlFtp', 'ftps': 'BlockdevOptionsCurlFtps', 'gluster': 'BlockdevOptionsGluster', diff --git a/block/fleecing.h b/block/fleecing.h index fb7b2f86c4..75ad2f8b19 100644 --- a/block/fleecing.h +++ b/block/fleecing.h @@ -80,6 +80,9 @@ #include "block/block-copy.h" #include "block/reqlist.h" + +/* fleecing.c */ + typedef struct FleecingState FleecingState; /* @@ -132,4 +135,17 @@ void fleecing_discard(FleecingState *f, int64_t offset, int64_t bytes); void fleecing_mark_done_and_wait_readers(FleecingState *f, int64_t offset, int64_t bytes); + +/* fleecing-drv.c */ + +/* Returns true if @bs->drv is fleecing block driver */ +bool is_fleecing_drv(BlockDriverState *bs); + +/* + * Normally FleecingState is created by copy-before-write filter. Then + * copy-before-write filter calls fleecing_drv_activate() to share FleecingState + * with fleecing block driver. + */ +void fleecing_drv_activate(BlockDriverState *bs, FleecingState *fleecing); + #endif /* FLEECING_H */ diff --git a/block/fleecing-drv.c b/block/fleecing-drv.c new file mode 100644 index 0000000000..202208bb03 --- /dev/null +++ b/block/fleecing-drv.c @@ -0,0 +1,261 @@ +/* + * fleecing block driver + * + * Copyright (c) 2021 Virtuozzo International GmbH. + * + * Author: + * Sementsov-Ogievskiy Vladimir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "qemu/osdep.h" + +#include "sysemu/block-backend.h" +#include "qemu/cutils.h" +#include "qapi/error.h" +#include "block/block_int.h" +#include "block/coroutines.h" +#include "block/qdict.h" +#include "block/block-copy.h" +#include "block/reqlist.h" + +#include "block/copy-before-write.h" +#include "block/fleecing.h" + +typedef struct BDRVFleecingState { + FleecingState *fleecing; + BdrvChild *source; +} BDRVFleecingState; + +static coroutine_fn int fleecing_co_preadv_part( + BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags) +{ + BDRVFleecingState *s = bs->opaque; + const BlockReq *req; + int ret; + + if (!s->fleecing) { + /* fleecing_drv_activate() was not called */ + return -EINVAL; + } + + /* TODO: upgrade to async loop using AioTask */ + while (bytes) { + int64_t cur_bytes; + + ret = fleecing_read_lock(s->fleecing, offset, bytes, &req, &cur_bytes); + if (ret < 0) { + return ret; + } + + if (req) { + ret = bdrv_co_preadv_part(s->source, offset, cur_bytes, + qiov, qiov_offset, flags); + fleecing_read_unlock(s->fleecing, req); + } else { + ret = bdrv_co_preadv_part(bs->file, offset, cur_bytes, + qiov, qiov_offset, flags); + } + if (ret < 0) { + return ret; + } + + bytes -= cur_bytes; + offset += cur_bytes; + qiov_offset += cur_bytes; + } + + return 0; +} + +static int coroutine_fn fleecing_co_block_status(BlockDriverState *bs, + bool want_zero, int64_t offset, + int64_t bytes, int64_t *pnum, + int64_t *map, + BlockDriverState **file) +{ + BDRVFleecingState *s = bs->opaque; + const BlockReq *req = NULL; + int ret; + int64_t cur_bytes; + + if (!s->fleecing) { + /* fleecing_drv_activate() was not called */ + return -EINVAL; + } + + ret = fleecing_read_lock(s->fleecing, offset, bytes, &req, &cur_bytes); + if (ret < 0) { + return ret; + } + + *pnum = cur_bytes; + *map = offset; + + if (req) { + *file = s->source->bs; + fleecing_read_unlock(s->fleecing, req); + } else { + *file = bs->file->bs; + } + + return ret; +} + +static int coroutine_fn fleecing_co_pdiscard(BlockDriverState *bs, + int64_t offset, int64_t bytes) +{ + BDRVFleecingState *s = bs->opaque; + if (!s->fleecing) { + /* fleecing_drv_activate() was not called */ + return -EINVAL; + } + + fleecing_discard(s->fleecing, offset, bytes); + + bdrv_co_pdiscard(bs->file, offset, bytes); + + /* + * Ignore bdrv_co_pdiscard() result: fleecing_discard() succeeded, that + * means that next read from this area will fail with -EACCES. More correct + * to report success now. + */ + return 0; +} + +static int coroutine_fn fleecing_co_pwrite_zeroes(BlockDriverState *bs, + int64_t offset, int64_t bytes, BdrvRequestFlags flags) +{ + BDRVFleecingState *s = bs->opaque; + if (!s->fleecing) { + /* fleecing_drv_activate() was not called */ + return -EINVAL; + } + + /* + * TODO: implement cache, to have a chance to fleecing user to read and + * discard this data before actual writing to temporary image. + */ + return bdrv_co_pwrite_zeroes(bs->file, offset, bytes, flags); +} + +static coroutine_fn int fleecing_co_pwritev(BlockDriverState *bs, + int64_t offset, + int64_t bytes, + QEMUIOVector *qiov, + BdrvRequestFlags flags) +{ + BDRVFleecingState *s = bs->opaque; + if (!s->fleecing) { + /* fleecing_drv_activate() was not called */ + return -EINVAL; + } + + /* + * TODO: implement cache, to have a chance to fleecing user to read and + * discard this data before actual writing to temporary image. + */ + return bdrv_co_pwritev(bs->file, offset, bytes, qiov, flags); +} + + +static void fleecing_refresh_filename(BlockDriverState *bs) +{ + pstrcpy(bs->exact_filename, sizeof(bs->exact_filename), + bs->file->bs->filename); +} + +static int fleecing_open(BlockDriverState *bs, QDict *options, int flags, + Error **errp) +{ + BDRVFleecingState *s = bs->opaque; + + bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, + BDRV_CHILD_DATA | BDRV_CHILD_PRIMARY, + false, errp); + if (!bs->file) { + return -EINVAL; + } + + s->source = bdrv_open_child(NULL, options, "source", bs, &child_of_bds, + BDRV_CHILD_DATA, false, errp); + if (!s->source) { + return -EINVAL; + } + + bs->total_sectors = bs->file->bs->total_sectors; + + return 0; +} + +static void fleecing_child_perm(BlockDriverState *bs, BdrvChild *c, + BdrvChildRole role, + BlockReopenQueue *reopen_queue, + uint64_t perm, uint64_t shared, + uint64_t *nperm, uint64_t *nshared) +{ + bdrv_default_perms(bs, c, role, reopen_queue, perm, shared, nperm, nshared); + + if (role & BDRV_CHILD_PRIMARY) { + *nshared &= BLK_PERM_CONSISTENT_READ; + } else { + *nperm &= BLK_PERM_CONSISTENT_READ; + + /* + * copy-before-write filter is responsible for source child and need + * write access to it. + */ + *nshared |= BLK_PERM_WRITE; + } +} + +BlockDriver bdrv_fleecing_drv = { + .format_name = "fleecing", + .instance_size = sizeof(BDRVFleecingState), + + .bdrv_open = fleecing_open, + + .bdrv_co_preadv_part = fleecing_co_preadv_part, + .bdrv_co_pwritev = fleecing_co_pwritev, + .bdrv_co_pwrite_zeroes = fleecing_co_pwrite_zeroes, + .bdrv_co_pdiscard = fleecing_co_pdiscard, + .bdrv_co_block_status = fleecing_co_block_status, + + .bdrv_refresh_filename = fleecing_refresh_filename, + + .bdrv_child_perm = fleecing_child_perm, +}; + +bool is_fleecing_drv(BlockDriverState *bs) +{ + return bs && bs->drv == &bdrv_fleecing_drv; +} + +void fleecing_drv_activate(BlockDriverState *bs, FleecingState *fleecing) +{ + BDRVFleecingState *s = bs->opaque; + + assert(is_fleecing_drv(bs)); + + s->fleecing = fleecing; +} + +static void fleecing_init(void) +{ + bdrv_register(&bdrv_fleecing_drv); +} + +block_init(fleecing_init); diff --git a/MAINTAINERS b/MAINTAINERS index 78ea04e292..42dc979052 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2425,6 +2425,7 @@ F: block/copy-before-write.h F: block/copy-before-write.c F: block/fleecing.h F: block/fleecing.c +F: block/fleecing-drv.c F: include/block/aio_task.h F: block/aio_task.c F: util/qemu-co-shared-resource.c diff --git a/block/meson.build b/block/meson.build index d30da90a01..b493580fbe 100644 --- a/block/meson.build +++ b/block/meson.build @@ -19,6 +19,7 @@ block_ss.add(files( 'dirty-bitmap.c', 'filter-compress.c', 'fleecing.c', + 'fleecing-drv.c', 'io.c', 'mirror.c', 'nbd.c', From patchwork Wed Dec 22 17:40:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12697168 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id BD1A3C433F5 for ; Wed, 22 Dec 2021 17:53:52 +0000 (UTC) Received: from localhost ([::1]:55858 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n05oF-0005Hk-JN for qemu-devel@archiver.kernel.org; Wed, 22 Dec 2021 12:53:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52594) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n05bg-0000us-7D; Wed, 22 Dec 2021 12:40:52 -0500 Received: from mail-vi1eur05on2133.outbound.protection.outlook.com ([40.107.21.133]:46561 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 1n05be-0002Xs-DS; Wed, 22 Dec 2021 12:40:51 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BxjTkGOJDv27lkkpci6VnZfitczlbZVtrqcpCvdD0MzxAWfDud2jbwF6q5uLWtADmxxO0pyW/FmezndTVUnQBmh77sSn7kF5Ut7vkKW6QGL4XnIJXJhpcB6ViDqhpGTJm97umvVxy8PM+dEBM8sTm2e2gENQAY1VTd784z4f1NvXQFdSDvRiLbBeYWdcjtH2Ui7BWOGJNzZ5FcMO05iVwcAMVTwMR8qGsBqsK1rPiodRP8VOMbLjK/9rlbLfur5zvCRONC2QLvi8kuJVQewzq2yfANp5VuThKufA/BYVCtX+zClpY8ZylsVuWI8WTaGcLqGWbl3ZvNns4fwsdvigtg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kilZ0cKlui50PjjNGbfGpxKy6GeZgO2xRJyR82+edik=; b=HCGLTUc8bq7ta5OuMC5dd0RiKi6rdbK5FUOWpCArDLQrQDAz9iBCmK50OZs666XbXAhKRYCzj3PAYnNp6uQnhrfXK/+vdl4Z1Eq5LjLWRdgVV2vcT+CiC5vj/5kCkgjZBLZrQvO9X3l4CWmpnOjHhhifRCDPFUJhSSwpM+ALFPM6z23zwa2mjPGhSnfVH7wNepXxYI6IilBwP0mF5bzfHIt+O9bnY7yRSs2rkkp/kqgehOGsBnzoUQlwKK5276m5j1FMsxQZtDrWynWIgTpoo2nnjLDShJgDEtXgIrFmTl4tqAjMv55gWjTuvyc03cR4aJGiRrs10twWHAxRwk7AAA== 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=kilZ0cKlui50PjjNGbfGpxKy6GeZgO2xRJyR82+edik=; b=sIhn43nYypBEYR0FIxa1Ub6WqNm8QKhM4/lEHQV2GfLy+V9W2bm20wXuM60TR/KhfyRz/KSNzzgbYxy1nX5vR0+h33AEUMop6PWy+T4KjeEpWq7vtT+95KdVuWEghm8f+MGePVsSedeq63yNFYsABam/zTL654Rple8scJ+h0vY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) by DB8PR08MB3964.eurprd08.prod.outlook.com (2603:10a6:10:a4::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.17; Wed, 22 Dec 2021 17:40:41 +0000 Received: from DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e]) by DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e%6]) with mapi id 15.20.4823.019; Wed, 22 Dec 2021 17:40:41 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v3 11/19] block/copy-before-write: support fleecing block driver Date: Wed, 22 Dec 2021 18:40:10 +0100 Message-Id: <20211222174018.257550-12-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211222174018.257550-1-vsementsov@virtuozzo.com> References: <20211222174018.257550-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8P250CA0017.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:330::22) To DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d6084423-dc93-47c1-08ea-08d9c5722c66 X-MS-TrafficTypeDiagnostic: DB8PR08MB3964:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:55; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GO8p6+IbjtWyuillWjWQPhMn7Hi13RomInJqydeIEPxjXwaTlzu7dOv2x3Jb2inLVhRLGGAFKTjYnwE6g5TfpOALRzMJ9j1Uam2sKr9Eujo2Demrj1gBrwE57y8MgGk8gDCQQnOv0ySVo+0aYvHLTAyvSj0bY0xdYRZEW9U9CIxYAtcKCQ4qrux24ZE6VchbJRNX7MSudWg24QoZdOVWAigZVRjQU9EV3BbjQDugonkyQxy6vd6zsptOIzDVbMjA1/RG+vGXsCdUHSOk+zDyNdioYi361bUBnWFXM+JyVw71nB5u4xqdwAxhVggGwpLM8ctVtj1HRQ0epjIylVGDkQoE6aYugHgwoFDmffOqgu6872mTHMZ6J82/yXMAyz6kBcjcQYGufJ0UFg5CvIbXD/w0hbFsQQMdgXeOY2ScfH3BZnDMwad2rX49C2FsC7ns2P5sApYNzeG96jdg8rE04QpOOCDzJnwFUGUWTB+mnb/EivzakH+2a614Ua7Nv0v27zunLZOMmWiOGbX7rh9JckLVJ6wBtW6WFnWxdOtiLyMzWaxIQh//Fxt/blG/UzlCCE06aQUOh7Vd+fmnafiqS6pmh0ZP8CLWD3wKTm8vevC3AxJbvrwL03g2cqNuknJ+8J3lNlo2/CrTcwWdDz1kGPk/cy9ck56P0jLsEb2aX8QU1eFPmRianFZ1+fAKFcOdXSAoS+WzbDzdBbfbh6m9sQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB9PR08MB6748.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(107886003)(6512007)(6506007)(26005)(316002)(52116002)(2906002)(186003)(508600001)(6486002)(6916009)(4326008)(2616005)(8936002)(5660300002)(6666004)(8676002)(1076003)(38100700002)(38350700002)(86362001)(83380400001)(66946007)(66476007)(66556008)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RbxtpdpYQ/sPUPs4mv11ErOwd+3gNrPPagb5IjGqb/1eES+oVY7zDE8m8dTUl3DRZmDjSJ1riB9zEKBTCi6mmFZs41/DjlSlxrKIIhii0UdjrIjFkdaXiYmk/6IFb5J7ozhadL+VshjP8hAXfDg7ZxbSbmlN6Euu3xmw5CL/N3qxEBSFxYIUQyE66u8O6og/bguAeiDBS6mREbQqabcjQpJ+IU925mUNMsM91RGhOVW1upCSBZqZIBEDJlolnVVEJpOY9GjuVL32/ZFharSBQZWLh04cDNa0Rn2W932B0INiKVhxMAYWDWOgWXsD/2fdrkJu6qoRgCF852Mavtw1JZ2/bOSu9NwMQFAXppxc+cKAs5+/5rJHR2hoF4yfayLGvIkKKrF+YyMDRuMZWE7TbF5cLrQcYa2MDcg+3c/ckQgp87P116G72pwQHQx8OrvhsQFZAik8EsV88KGARSbhOEKj/IZ+7A5G1e5FSMl1nVMkmBFSgKWbZBZojbmnVm+d6nPLNJpmEk15UTpP9BXUybbnJmghyyqyECEXo5dCU8J4mIDjyQ8KiUKGNmz72HC09NEuVkBfC93FlpnRPoC7SDTVO92de9VafPh2784iMO6xZ6uaP8WaDFN1yrq8f7NJjKIHqVmq0vaK9/SCfTDB5Gfxvvtpd3nw7Kagi1yMNwfE/6h2lCWGGdfUAP3tz0EVct4+fjgOC0JBIp0Z+NsQqNlrRZFKT21YRRqpLeKz8ZswzB/7Ua1DO/fVUJyg5sPUk+UKLShwGJVI3GWj1G6IG1k04u8Q80NOxdoa4HGT3oCwswc7VJHBx+fv5YxpzPp7PghEYYdADt//HJG44gJpU0ALUiQ5z8h0XDORZ52wk1vs1S8j25T6GCieO7zSaO1NsW66qZPsG8xE8W8X6u8c8rdJ31/NQy7DBLheLSMlz/zqPxLmttkH4pP7V+ydZDVoR5Esr9vTz3EfpJv+8k+Md/WxHekVxv5mrN4GUUlDmcZfLeH8VVeulasWGHYE5C40o5ZqeaPz6i7bkiIu5vbm7hqJPSPa13pJzClBlCTmdmXxD8Ye97rX/eCNGlQoXgKCmQloY/oIF2tIuYs8Eh4K6U8uzfsePTeFZOSj7QBY4IxYzAGPr//XrS7yoMMr9+Dgiag8FnpOnEXFkRn5qG5s6hSJgaPeFr7cFN9twl/vh/0A26FTjb3vcV52bVzXmeMfC1cdZEVANqyi7//bx1bq9RajpMd7/nzQln3DmPxbOuaMpcjq9W9x06VwrCqdwRdL6LDvYp73biQvdpVgcIQtjxWw3k+lIy1MTd/J7Op/47J4sE6kOnZjws34rxh1VAy8o36FzoYDrHX1JgApQsmJ+KpFjwWr10SkxyCd3buV0pcOe71xXAfQS+F7TmwzqDf7pA3XdTgZU44/8Qi5ZYgJ+Qi0iyba2WpvIwH8AozeviHUgLISjxFdvNSOkXzVnKQ3pEc1NdjpotTuYVTORMvBpHYOlpQmtS6m40vzuTzKr3lQkN3E/6ujjxyETSeL+Di/JRKlIH9hG2EQrWl+sAyrDgjSq+8fVRNiVLKpJFv7tM1BhW820gSQJ4tATQ9+Al4u/F5SI36U0ZAQhUP9kKNa68+IJ4iyENThRb+C7XO6YUHydh06IM3sehOGwD5wo3qbhdRTTDQe+fulYi4OgAKd9e2KpfDXQlBTsAkE1hTKTXg= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: d6084423-dc93-47c1-08ea-08d9c5722c66 X-MS-Exchange-CrossTenant-AuthSource: DB9PR08MB6748.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Dec 2021 17:40:41.3651 (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: 6P35FwNXXh25TSb/5qiSrZYLRhSyNNTZ3VWM1D1mcu7Bu+oyp1HxU0AjMkMs3E5Q/w4n5N9rw0wr3r14lmAZLnAZUdnkxbA/DqKiqqNF0jQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB3964 Received-SPF: pass client-ip=40.107.21.133; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com 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, 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.29 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" The last step to make new fleecing scheme work (see block/fleecing.h for descritption) is to update copy-before-write filter: If we detect that unfiltered target child is fleecing block driver, we do: - initialize shared FleecingState - activate fleecing block driver with it - do guest write synchronization with help of fleecing_mark_done_and_wait_readers() function Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/copy-before-write.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/block/copy-before-write.c b/block/copy-before-write.c index 4cd90d22df..2e39159a7e 100644 --- a/block/copy-before-write.c +++ b/block/copy-before-write.c @@ -33,10 +33,13 @@ #include "block/block-copy.h" #include "block/copy-before-write.h" +#include "block/fleecing.h" typedef struct BDRVCopyBeforeWriteState { BlockCopyState *bcs; BdrvChild *target; + + FleecingState *fleecing; } BDRVCopyBeforeWriteState; static coroutine_fn int cbw_co_preadv( @@ -50,6 +53,7 @@ static coroutine_fn int cbw_do_copy_before_write(BlockDriverState *bs, uint64_t offset, uint64_t bytes, BdrvRequestFlags flags) { BDRVCopyBeforeWriteState *s = bs->opaque; + int ret; uint64_t off, end; int64_t cluster_size = block_copy_cluster_size(s->bcs); @@ -60,7 +64,16 @@ static coroutine_fn int cbw_do_copy_before_write(BlockDriverState *bs, off = QEMU_ALIGN_DOWN(offset, cluster_size); end = QEMU_ALIGN_UP(offset + bytes, cluster_size); - return block_copy(s->bcs, off, end - off, true); + ret = block_copy(s->bcs, off, end - off, true); + if (ret < 0) { + return ret; + } + + if (s->fleecing) { + fleecing_mark_done_and_wait_readers(s->fleecing, off, end - off); + } + + return 0; } static int coroutine_fn cbw_co_pdiscard(BlockDriverState *bs, @@ -150,6 +163,7 @@ static int cbw_open(BlockDriverState *bs, QDict *options, int flags, { BDRVCopyBeforeWriteState *s = bs->opaque; BdrvDirtyBitmap *bitmap = NULL; + BlockDriverState *unfiltered_target; bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, @@ -163,6 +177,7 @@ static int cbw_open(BlockDriverState *bs, QDict *options, int flags, if (!s->target) { return -EINVAL; } + unfiltered_target = bdrv_skip_filters(s->target->bs); if (qdict_haskey(options, "bitmap.node") || qdict_haskey(options, "bitmap.name")) @@ -204,6 +219,14 @@ static int cbw_open(BlockDriverState *bs, QDict *options, int flags, return -EINVAL; } + if (is_fleecing_drv(unfiltered_target)) { + s->fleecing = fleecing_new(s->bcs, unfiltered_target, errp); + if (!s->fleecing) { + return -EINVAL; + } + fleecing_drv_activate(unfiltered_target, s->fleecing); + } + return 0; } @@ -211,6 +234,8 @@ static void cbw_close(BlockDriverState *bs) { BDRVCopyBeforeWriteState *s = bs->opaque; + fleecing_free(s->fleecing); + s->fleecing = NULL; block_copy_state_free(s->bcs); s->bcs = NULL; } From patchwork Wed Dec 22 17:40:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12697173 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id F3706C433EF for ; Wed, 22 Dec 2021 18:00:54 +0000 (UTC) Received: from localhost ([::1]:47060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n05v3-0001ZN-OP for qemu-devel@archiver.kernel.org; Wed, 22 Dec 2021 13:00:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52614) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n05bi-00011V-VJ; Wed, 22 Dec 2021 12:40:54 -0500 Received: from mail-vi1eur05on2133.outbound.protection.outlook.com ([40.107.21.133]:46561 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 1n05bg-0002Xs-RX; Wed, 22 Dec 2021 12:40:54 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GlQM2QIryIeTwMpLHHSYBrQiG+g2apGt+JzL/g/im5USo+0Y3wRFvqmr/B+8eNF03Os8jg3SRc37HGRoAvk9cCjMvQxP3ZC8QJdEbxHSqo2wkFEWXV2KUK5ibNLz8LqB1muxS7+gvXjJLxSoMpfAf4yLric8234BDDTKWsx6tMxSTfYztfQpiZIkXlR7LRHox7/GbUXrz/0DveF/16OKsK2pfKLFPC/NmxEi6A7+NQ46JkOOi2ZBPZkhf9wcSZZiJaFobOVt5d2AO+xiTY8phchpuCStWJlFd7R3xq5VlFhBSVnLaMJoNppDQSCwinRY+3qvBxePSugLppHZnlsZLQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=pd/qewr9SDzF23I/ULCRlytcdbAdS2Q58Z3FFjT66qE=; b=D+sNcLYx+1sgq//Em1YiyqOrnr7g4av0mA8Bbd2/Rk8S8TAKBK5KSKPlX+wcjEisQifUtoTILQwk3HNtLQPhCpGkjdQ9zKDO65YAwDONTXyGh65fUA4SzPUTuWc6BlUqtnU7gFJOd3C+E7yKSLD8+uROauHUHWAQ2zjmrzLRNcmeZFnT0HV69/iCst+DXVy8GqsgTC2os14Kv8t9Zsq1W55dBmNChSiWvv1rjovVsTcvV/IIk5RwwCJVnWur+23NzFVB7L8HSrB4huwvmsHCoHvHqa4IlVmQp87PsUkENfAOyVI7GjZoHNqGVR/DB90il2ebYI1xayUyOZsxIigDUw== 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=pd/qewr9SDzF23I/ULCRlytcdbAdS2Q58Z3FFjT66qE=; b=R113iBFFciCBh/KNhFb/wmrIVfwBVXmGpC3Gui05EascrcS6IDildwXbI+wi0gMpLn9EzShPlFdm8pLcAt4ACm5gWaSsmjGZ/es6vEimGcYS3oqN/hwnpBnkNtrTycxy/jFrXE8onKuf20Z+hfy3COX+jemhg+RUTjqg+/4AAmA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) by DB8PR08MB3964.eurprd08.prod.outlook.com (2603:10a6:10:a4::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.17; Wed, 22 Dec 2021 17:40:42 +0000 Received: from DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e]) by DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e%6]) with mapi id 15.20.4823.019; Wed, 22 Dec 2021 17:40:42 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v3 12/19] block/block-copy: add write-unchanged mode Date: Wed, 22 Dec 2021 18:40:11 +0100 Message-Id: <20211222174018.257550-13-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211222174018.257550-1-vsementsov@virtuozzo.com> References: <20211222174018.257550-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8P250CA0017.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:330::22) To DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cb140f11-744c-4ce4-9b02-08d9c5722cdf X-MS-TrafficTypeDiagnostic: DB8PR08MB3964:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:109; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6Dr1A1JoIvsf/Qj/UBzRA1q+Ee+1kFhsfIZnCCjBjAdNcfwVTFItb3/fWbi19UKXmKYDow6aFlhzIbALwNc9gWPQrZb4vX02x2E6bFOCqN90msE4Vd7KAMYSuZxv5F0DfRLF949tqnnaqhiWg5uW5klBOcHsNE+Lt0gcfpqFRXY0p+E9rqXk2lFgcdfM4Mrha6rn7J8pzFkIY8mh+MoYdaY2uEeML4+Rhg5wgwn5MawOM0/X8rGaZD337U7NY5xqJK2ZpKWRgB3zzXJaxGDUiW15TJJj+h7/feWmszhwU8upz2iEPf6+T71f96EXwlIeR54sCtFpprorkOcEv3VekuPQJpwn8m2o+MDwGb/Mi4vpMDfUEXqLUQlg8+bnjkm0vWQz4/MOGLQM1qQt9oVGHTfu+fb8CGgKUXjTEwGsjDnZyCP/rmDfD+WoOATNSzuu0a9mZ+X4KzjqG9aCyhKk+5zXvptg9WOqZFGMO3YMZWdVAtrNCAd0IU1SL0U2KGw2k16far8+pzwTuDq+AMYz39qJqHERczIh4BubzdzcbmWmtsWwApLOzRZykhhFpVjxgq3wMwsMsIH0EDXLwV+xEwn7pFZkkoKc3tKzKJxsL4QedHl4yE5+qAMsxaGG4FSG9VjiQm9pDYlDh615ot/ERl37o1Wvsk56n59JOuHRc8RFxASIF0nHqSqVgEs4y6tNAyvpI+Ir18TygxVwwSntEA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB9PR08MB6748.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(107886003)(6512007)(6506007)(26005)(316002)(52116002)(2906002)(186003)(508600001)(6486002)(6916009)(4326008)(2616005)(8936002)(5660300002)(6666004)(8676002)(1076003)(38100700002)(38350700002)(86362001)(83380400001)(66946007)(66476007)(66556008)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: laDiibu6gzO1ZLDJCfteFjS/g+TSMs5S8MWnJOa2CP7PESi77VZlQ45nvzWGsqgNH34HFzEptiUxnyrgS73ZXKRvcopbBdQ1NGdnzppfJFkapm+2kI1NHEtpR+rYz5sm7/0ZzTA1pyvtUkb6U1Qu4I3a3j9nxEvPgW5985nvdNy2bOqmSr5sGEK+v5/iid9AvWIxB5nQRAeqZgNiXgcgsb1/DY/HRA5KD8ywaJmJj+IbaJztvapmh/z20buXtIjZ+vJ3SzjEUPsB0YMwD9uQ4aPBXqTtWgpR/H9F+A50bqhjEZlbu+JIp99UCeGLVx1lWmr1BEvvmvILShYRi/tGOp4ANkHyLeLsVI6H+bjZ5jExKenQ3am0QTPKWGliScrnpEKTKZRhO/dYbpWAYFCMdUwbgqrbSHmQ1i4eKWEZWpUZphik9Z6KwnZ5wMfgyzz2ZnwOSyJAE3OEAWusrk4goxk4o+uYyMOhSZy4dTq7DYRBXpLaWwRbQdCp6biMFBGyLZotNRatBah867Tnf2I3ZcLmcBYzdMHo4h1FBai/PHQmpVQgKb8KXHMyY/sDtwDnB4NsZcI/SPMcfK6ri2ABYOxMveIHe1bRnJk8v0zQYzQ4rmxcrWOKmxr2vwLj4lcjSLv8n2ziO2o/v7lQiBua+zvA2lrcWswYrzjtkOEbHvX2GotH+t54BYVPXwqVyMndiX/Zs6cUI21wUddgI3uomslUshqagFT2WAqO6NOxRFqypXKyyF2qHobVc/xjyTFKPmFsU9TOYucy6qHtasI59YO1cLB6osnz1bKS3qpbwKHety4KT+6TtMTmZQAU2McHItuAR/DpmhpJhX+E83xg2owxGRZaUi61JyhXeP4BW67f2Z6KPJo3DJzLXFXk0Fm5sh0/n7AI/qvaFeDtBks2YXpdfFSViPDMHAPb9JfV34s2iOOEmi2i2wc+yzD18hDY572fsqYbmmOstHtg+Yp99WuXdkH620C5T0qnt8/8zMkWfy/7A+LdpER/uCpDpfSb5zwpAHdoyeN/mhUsgkuX7P5DMXxA++12Oz7fhqH1WSlCB2taVSZkaqHWOd1zi1kHNe1GWYgbCUAm/CZTAfbx8f2jOVI8MKbi+a1a1bySFBkZ4vjrUQjQ2RviNv39ixix8V6Hd/fGxILMVRCvvfuekztTbyu0OKH3TzCQbmVV/dE0aHSXmaTIewT71ZBQy5g35NA4dvE+RAbX1DUqjWrWSxBDPDtOCstHakXaREgunw5gvLaB8+PgatjNc8If2dJDu0QYg+ItVngacyUeSx1ychN/trn98FXIz1iWeW/IP16orugzrdU2xc66FSZbcP3QX353XWr3I2Xg/pkcQVVCT581dXy1v/2QKTyBO2/QaDaJWsr9+shcQ5V4yidNK1EjjRd56WOdcO1OsSMs0iwDkFtV5Ny93W/mPZC8D5LHveQKL3L1fUoAcJKSPU7xY1rOhkrh4bGBLxxLiaiE4PvPZlNOQlUqMmo9NmbBBZdPNfxZ4U54Zb0Q+tX7o5s4yRcOZImNEh9Vd2ed+JQ/U89Gvk0Z0nlI5/bcYfcmmYdTnNQnWcYd0+Dr9rBm1FR1i7vpaQpuNifFtjmnz01o3hzsA2680Cw/mSWtup7TjxVZ4hJmYXQ9vAuKAqMd1B/YhSGRMQt9AtnLUjcpvqWWIAVmGsdcRymT2+gQV0ADba7fyYY= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: cb140f11-744c-4ce4-9b02-08d9c5722cdf X-MS-Exchange-CrossTenant-AuthSource: DB9PR08MB6748.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Dec 2021 17:40:42.1930 (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: ikf17ZvRB4myIknWBnErUDnTSZFhx5Y9Er8ffudh60RFCejQL6kABI7waG5Wdf1SzdyCj2kTMdspc4K85i/RqESLnq68aRbY5bF+/cTwqck= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB3964 Received-SPF: pass client-ip=40.107.21.133; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com 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, 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.29 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 implement push backup with fleecing scheme. This means that backup job will be a fleecing user and therefore will not need separate copy-before-write filter. Instead it will consider source as constant unchanged drive. Of course backup will want to unshare writes on source for this case. But we want to do copy-before-write operations. Still these operations may be considered as write-unchanged. Add corresponding option to block-copy now, to use in the following commit. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/block-copy.h | 3 ++- block/block-copy.c | 9 ++++++--- block/copy-before-write.c | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/block/block-copy.h b/include/block/block-copy.h index a11e1620f6..a66f81d314 100644 --- a/include/block/block-copy.h +++ b/include/block/block-copy.h @@ -25,7 +25,8 @@ typedef struct BlockCopyState BlockCopyState; typedef struct BlockCopyCallState BlockCopyCallState; BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target, - BdrvDirtyBitmap *bitmap, Error **errp); + BdrvDirtyBitmap *bitmap, + bool write_unchanged, Error **errp); /* Function should be called prior any actual copy request */ void block_copy_set_copy_opts(BlockCopyState *s, bool use_copy_range, diff --git a/block/block-copy.c b/block/block-copy.c index f70f1ad993..e2cf67e335 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -280,7 +280,8 @@ void block_copy_set_copy_opts(BlockCopyState *s, bool use_copy_range, bool compress) { /* Keep BDRV_REQ_SERIALISING set (or not set) in block_copy_state_new() */ - s->write_flags = (s->write_flags & BDRV_REQ_SERIALISING) | + s->write_flags = (s->write_flags & + (BDRV_REQ_SERIALISING | BDRV_REQ_WRITE_UNCHANGED)) | (compress ? BDRV_REQ_WRITE_COMPRESSED : 0); if (s->max_transfer < s->cluster_size) { @@ -341,7 +342,8 @@ static int64_t block_copy_calculate_cluster_size(BlockDriverState *target, } BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target, - BdrvDirtyBitmap *bitmap, Error **errp) + BdrvDirtyBitmap *bitmap, + bool write_unchanged, Error **errp) { ERRP_GUARD(); BlockCopyState *s; @@ -394,7 +396,8 @@ BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target, .copy_bitmap = copy_bitmap, .cluster_size = cluster_size, .len = bdrv_dirty_bitmap_size(copy_bitmap), - .write_flags = (is_fleecing ? BDRV_REQ_SERIALISING : 0), + .write_flags = (is_fleecing ? BDRV_REQ_SERIALISING : 0) | + (write_unchanged ? BDRV_REQ_WRITE_UNCHANGED : 0), .mem = shres_create(BLOCK_COPY_MAX_MEM), .max_transfer = QEMU_ALIGN_DOWN( block_copy_max_transfer(source, target), diff --git a/block/copy-before-write.c b/block/copy-before-write.c index 2e39159a7e..f95c54dbdf 100644 --- a/block/copy-before-write.c +++ b/block/copy-before-write.c @@ -213,7 +213,7 @@ static int cbw_open(BlockDriverState *bs, QDict *options, int flags, ((BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK) & bs->file->bs->supported_zero_flags); - s->bcs = block_copy_state_new(bs->file, s->target, bitmap, errp); + s->bcs = block_copy_state_new(bs->file, s->target, bitmap, false, errp); if (!s->bcs) { error_prepend(errp, "Cannot create block-copy-state: "); return -EINVAL; From patchwork Wed Dec 22 17:40:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12697171 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 43EC8C433EF for ; Wed, 22 Dec 2021 17:57:21 +0000 (UTC) Received: from localhost ([::1]:37130 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n05rc-0003H0-22 for qemu-devel@archiver.kernel.org; Wed, 22 Dec 2021 12:57:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52634) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n05bl-0001Bi-Ah; Wed, 22 Dec 2021 12:40:57 -0500 Received: from mail-vi1eur05on2133.outbound.protection.outlook.com ([40.107.21.133]:46561 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 1n05bj-0002Xs-Kn; Wed, 22 Dec 2021 12:40:56 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MHR+jE21Y/5xsM/zdFrXK/DOQ+fK1Hldz2NLXNB/uLdffC0LocQ1C797HFjMahyASi7mjCBREO04VKiaS00NTjySCMBi4MvEvI8pi3As/ovyjc95s/rYaiJpwrQcAGz5jlQVPGopEMHMW1arx4feInEbqnHDIzk4+w8o2sptfYCeUR1N/E5H9nDAhdMl/nBQ0Ln6jxWYDyDJLPhLyRMJsgaWXa7lqjmUB0tptQSeQ5xvldy/nRfiXkNV8xiLnQst23nnivatj2QE6VkfrnSHLdsxl8/KcFADLjlHd1ZE7Pk3ROPW0BHQDcQKfB2UaxijssGdirLssLJIhlvBTG83iw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4CbIakG8Bpry9mIDvB9GIJfrqIDoKVb9JXqzYEcnay4=; b=h6hZ9q1cnY+UvRo4ku3uOiOPmCiERVerw9uiV0rNMBFrUtFpDSxoDyNDB82CCDkEgMkiozOmxDlzihlo2Vf8243xcDnhZgTJhaDFcbn/VEvTPn0lVzT/vXf40T39r8u6IRFEyG5hc0UtgC3qO7RyfNKUbtHUXd/6DY7eiNtmRXOML/p66qIG5k1f3H3oRoXWlo2v6X0Av/ZPlq++pPvYn4xFir3C3SXTIlXKLw6IcgZsFyVRyhy7VREK7BdhjTAbzIQnDLohpYfS8WFH77VDOfbOa9COEyQ5JPsb5jsiTW2TkolMCbfsh26qMd5IXqQkOUdPq464ODIGDVuS/Ra5RA== 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=4CbIakG8Bpry9mIDvB9GIJfrqIDoKVb9JXqzYEcnay4=; b=ickScpv7o4dyD61bgQCmt37mZx/UNL0kYXh9LGmmfAiGwu/RujTjy0GsNC8w+0sEY9vi2fBRkgIau9oUb/P1cp0gd4kPzAy18nri/RXR6kIuH7SClBRg4Xkw18ET4amKLjXOrsesL4MLVcZFy3V7ImUa+FK6o89gcJMYnyZkJx0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) by DB8PR08MB3964.eurprd08.prod.outlook.com (2603:10a6:10:a4::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.17; Wed, 22 Dec 2021 17:40:43 +0000 Received: from DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e]) by DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e%6]) with mapi id 15.20.4823.019; Wed, 22 Dec 2021 17:40:42 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v3 13/19] block/copy-before-write: use write-unchanged in fleecing mode Date: Wed, 22 Dec 2021 18:40:12 +0100 Message-Id: <20211222174018.257550-14-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211222174018.257550-1-vsementsov@virtuozzo.com> References: <20211222174018.257550-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8P250CA0017.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:330::22) To DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cc1ff496-c2f6-4064-5f99-08d9c5722d59 X-MS-TrafficTypeDiagnostic: DB8PR08MB3964:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:62; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5mqza9U4ef3qmx7GO0L6U172np1eKG9tpn+q74+r5UfU+0kyiArAu+dck6mcpwy3p5pM2i7yuGTHB9lYU84GXPZ/7IwD7jdkWocSF6/mUYgOJLbU9O+TMMdkT/2nklEQFZ0Qy/Ed6u/ZVJtV8PT27ZsFXNNa8LzpACVKd8YagDdVvK+WZ/r8hD5JROrMkExq5nE3blFdoVmhyJwHkMZ0hL5voYjYose1lytPVGHa0Hw4L3UftFbcaR0pHM/CtuqEaiO2vT+pKh3iP79bIx923Qnn8/VDeKXHadA9GE40HqZmivw/Vzut6GRi8fn2kmQmhQAjWlh8nyfufdHNbitTSn9Qy4oi20S/ms/DTgS9Yd+kZBBPr65MQEJc2COYVDvJp+HbWOSbfHh5uqIzUPJywQfMvKJC622kv/r0UZDPeAXSIbUnUKHtYQtDVIQYvosN+MclTWmKU7NocUdecoJ5EjF8jyNiPSZasDNwck0n5lMU7wcmL2V03+ywv/cNdiQiq0QmkMuvyauxUYbQezN62ZrwILo2EzEdUejSKzC2AeiXfITpCqUvwq9Dh5J6YQ9ci/HKyODUleOSj/dazWIm/TELenK4sdoMeQJRwaQy9o1TapUNQ5ZdumLs39nPNUhsb/3FWaNIdShoDBHKFvkJjA1uy6AGbjY0qzh1TOSje8GZnE/go/RQ+C9/ay8uAIqhmc1jD2lex/OCFVyU+0eK8w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB9PR08MB6748.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(107886003)(6512007)(6506007)(26005)(316002)(52116002)(2906002)(186003)(508600001)(6486002)(6916009)(4326008)(2616005)(8936002)(5660300002)(6666004)(8676002)(1076003)(38100700002)(38350700002)(86362001)(83380400001)(66946007)(66476007)(66556008)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UnBGbblkTKpStWwpo+ZWaTIaqq7+Z/JO6nT3WJowzIybyvkfJH3ngCD/6iKlGqW8CPlvjLg08ma8wmcbkSk7s/m1tupN0jnlU7zNlB26fC2feTWzSpKL4r7gBlB9SwOlgppXhHL3ISE7uGPc6MUQP+JKRXynVHkgWlLWoXlWXGySh3oRuicXE908tXqVFS2qRk3r6twOtDvH6DyutZ+S6AP+wfLc5fXwhblIRYR5CkhlIxnK6mmbg2CQQjfmvmK1LWdQPDZdsjezlFcNJTx9TVhi1uKTzY4rtmwjexIy/ycc5IWxc9A7LOHuUiXrcFDlB6ZTYu1sGiEmOaCG8y4ohHRRmTZCVEBhnmf4xI5H5GLsHCrmwszYy3DxJAQIniVDUdqhdtVMpJtpE/C3DrbjTYnWHBO/9ooU81nzg6rJERvviFfreiBbfW5OQHpsj6PBv8ho0UVQZrtaZ54G+fHHohMxNvKEGi8j6QNT0GFlBkz7vgLbJptYIt1mZduRiPTv8GqZYNZcnTr9rIOvrwDk1FNGXNbsTR/CwijUreTTWfrT0Uq/3TuTe4wjoLTvUQ3/cEgy4O/bV1uNx1jhFF1qDHvUMfKvrHEXM55Au5ik4aJjMSXoYTQyeCrTWGrnGcvHcz6qlboJ+Zd7JznTG5HBQkx93W87y/b8D56yVBMSKCkKoZa3WEgPTFmlhfNWWsZYN/ibXvzvzhuPMTtIeAEiMNYLlsWKEka8kNiyJhwlyj1tL6yTgfUWpfcBFTZJq1XpqzI0PyfPIFJrmDakajCatyNIhZdIOswtuMWMPJ10OyitmCZLNtXrnpGdnMEO0/sp8E+X3ZZV+BjL+26QY4bxttaiPDixuJlH1HCvG7BYrgVP8cOaPUQRl6rdESeXFzFeq+SecxQaBWueGlrdPLzAATVnJvfggZOF2+PN3laYi5mA0RTIJWAswTJb+vUZDtXj/M6ck2qSf6xWYJcoCzpHptZIK+CHlWTul44qPN3m9Xbrq3m7jieSpxuUJz4W9pxKRJhmisjj2xhydA0m2Yb9DHLVGukPduy9XVntJuXbuSnBHUaLaRiwK0TlIi4x9S2j6apyNls+ZiqfQOLrmfQ23y7lQlPlKWDim8N8/5gH/23sHNs5JcstMZaUvT1qSuyrXjrQu1Gyj2n+4xNMrOLT5OwVDsowqIEu1NJDIPAxrLsnyl0rMjqpfIOR6nzal1LY95LxbY6+pXVqUfxbR8lgcOGZC/Z6+SXNNQHtmrZHKlBSmjXRCuEiHkE3x89okG6ezKb2evkMOJExss06MzpfvfeO0aBKiIlx+jV8VQt2/4rma3wVK13SFv5rUTWNvJOeHDIcrHjtrTlnxv1uh7NKqb0gULIcETNMT4P9T7m/c4iTo4nc4ysLkOAWjcmg4od8lVtwYOKfMNILrE1JL6HMN8bIiCnV+yz5SbqESrAmEJUruqW+84qGytUK/krx9vE4T2EuF18E5gRrqtXx57xetgtymPkeDECbWT2yDw67t4DP82T/yRwZ+b4rhpYAgF7ujNCrhi2AzvOePWoEH0tkJqA2aGY/df+ybXGOiLlEwtY6BPpUoZ6Nc76WYK4KVciMhkC8bOo9FYr/YGjhtb7fADQYrLIYo+c/MO/JBYZO+B62WmUGEFm798FavfH8Mkuj+uk7H66BR9XG+BbXUgXpudL8A7rEYofjlAFqhHAA+KU= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: cc1ff496-c2f6-4064-5f99-08d9c5722d59 X-MS-Exchange-CrossTenant-AuthSource: DB9PR08MB6748.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Dec 2021 17:40:42.8505 (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: iBW+WKzWd6tXp8YdcofO9qc6WX1poUUt1S32RYuMutrV4AOz/VJDp7h8JwDZkNSn9WT+Dhd0ZqLiUCO+cMnsxln2DgF1fhIQWfLHV8qt6YY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB3964 Received-SPF: pass client-ip=40.107.21.133; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com 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, 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.29 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" As announced in previous commit, we need use write-unchanged operations for fleecing, so that fleecing client may unshare writes if needed. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/copy-before-write.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/block/copy-before-write.c b/block/copy-before-write.c index f95c54dbdf..ca0d7fa5ff 100644 --- a/block/copy-before-write.c +++ b/block/copy-before-write.c @@ -133,6 +133,8 @@ static void cbw_child_perm(BlockDriverState *bs, BdrvChild *c, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) { + BDRVCopyBeforeWriteState *s = bs->opaque; + if (!(role & BDRV_CHILD_FILTERED)) { /* * Target child @@ -143,7 +145,7 @@ static void cbw_child_perm(BlockDriverState *bs, BdrvChild *c, * only upfront. */ *nshared = BLK_PERM_ALL & ~BLK_PERM_RESIZE; - *nperm = BLK_PERM_WRITE; + *nperm = s->fleecing ? BLK_PERM_WRITE_UNCHANGED : BLK_PERM_WRITE; } else { /* Source child */ bdrv_default_perms(bs, c, role, reopen_queue, @@ -213,7 +215,14 @@ static int cbw_open(BlockDriverState *bs, QDict *options, int flags, ((BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK) & bs->file->bs->supported_zero_flags); - s->bcs = block_copy_state_new(bs->file, s->target, bitmap, false, errp); + /* + * For fleecing scheme set parameter write_unchanged=true, as our + * copy-before-write operations will actually be write-unchanged. As well we + * take write-unchanged permission instead of write, which is important for + * backup with immutable_source=true to work as fleecing client. + */ + s->bcs = block_copy_state_new(bs->file, s->target, bitmap, + is_fleecing_drv(unfiltered_target), errp); if (!s->bcs) { error_prepend(errp, "Cannot create block-copy-state: "); return -EINVAL; From patchwork Wed Dec 22 17:40:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12697167 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 407A5C433EF for ; Wed, 22 Dec 2021 17:51:33 +0000 (UTC) Received: from localhost ([::1]:49138 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n05m0-0000gy-1c for qemu-devel@archiver.kernel.org; Wed, 22 Dec 2021 12:51:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52662) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n05bn-0001Ln-Sf; Wed, 22 Dec 2021 12:40:59 -0500 Received: from mail-vi1eur05on2133.outbound.protection.outlook.com ([40.107.21.133]:46561 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 1n05bl-0002Xs-TV; Wed, 22 Dec 2021 12:40:59 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nPxcJTeGuJX4S5bEPhHiGmpypG+OvJ6BW3/M58S7T7OAFonCyNOEqh3YgEEIwK9RIGQ8NIMi9FnB+MLGYg97T8wzQEzTxvwmA/sDW58R6QNrF83V82LAVT7kWyh9wy/Bu0erLSxpevTLORtUKPkvTVGh/MYULk9xCoxmJZv2N5zHcdG1PO+lrBceePZXcXamZd4x6CkFwldx4Woq6CUu2L9lU2SwbcMwfFalkJkY92vNG9jOhQqgMJ//iZOMCfqhl0erj9Q7NljMNLBFxu7L5g/YJqHIvxWnMPSuTzYm0BqLWywLQHjL0J3fuPUZMeOKHD8QdsmXlRvT3o5jstHvuQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2JFv4Ywktgv9DuYVzG0rBqLdPov3WegBCIbYpmaTa28=; b=mK3tNV9TbY1nFcLhFdyR1lM9DHRlaUpbV6RH98s24ruWAm6pr+UqlgYr+aOHd/FVF/uFUtMzbQJKo04BP1Dq9+NF3pWhdcWM5eaHtssDNRPKkOYcROZdfl+fnb0o71Wo7vR4NTb+xu4XFfYbRYt4WoApb3MkU6l7y9txxnehkiNLOmOTJLXL8Mq+3tOvxZcZiMa+wPadijvWGahPgCuEkCnXEfIutccmoDSYzUhYxfqZkuhKt5mlOC1KdPy6xrFkAZ38mu1drCdtUXbrv2Uxby1RlMraElnE7ZW8z0zZNk6plEhLZUP6Tfv9z995RRR0hAaEZQneN/MLMisO8+2FfA== 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=2JFv4Ywktgv9DuYVzG0rBqLdPov3WegBCIbYpmaTa28=; b=i71sw6Ba2ly/48XuOwtIX8FlRosKmOUsiJkpfghY09Q6Fv4TZyIOBySE20m3QULbZOjia4TCwZxjAhOu7ZXAkBuZGkkdHM0sf3eJoMuca8Vu52Pw71lwsCAwkPMlfbWa8+y1mcp2Vnzxm5D7FUpgjK8iRjwZwkxNE7Fd0r6xDTo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) by DB8PR08MB3964.eurprd08.prod.outlook.com (2603:10a6:10:a4::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.17; Wed, 22 Dec 2021 17:40:43 +0000 Received: from DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e]) by DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e%6]) with mapi id 15.20.4823.019; Wed, 22 Dec 2021 17:40:43 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v3 14/19] iotests/image-fleecing: add test-case for fleecing format node Date: Wed, 22 Dec 2021 18:40:13 +0100 Message-Id: <20211222174018.257550-15-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211222174018.257550-1-vsementsov@virtuozzo.com> References: <20211222174018.257550-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8P250CA0017.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:330::22) To DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7bfeef1d-2925-4da4-ddea-08d9c5722dbf X-MS-TrafficTypeDiagnostic: DB8PR08MB3964:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:459; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ESWF+6AXwgqAhX9kdyGtvqKnHXPQW4b3Xie1Hsb4avcMiF1wwvaLQ/HVR4PZqsViW3dajhkKP1aMZp+CAcWGj7d/Gp1v9+4+Tqno+SNtqIVIk2kXF5KFZwoOvXWtaTgDn/5tIS2omue13e0+G5KOUgRaQyFpe9uJzChQZLQqdWL1rWGXVIqQcUEY/NZfznMfOJGCgwN3F04qqPxHfJa+92u1a3Vk0Efk/T/IcJx9pDgRwlHvs4+QSeE2C0ZLtW4y3IRp9/vC9Q1FJ7PNfcUGbOPe43T2euk/d4HbK+qyFDPGFAcdjbM4z7U0aPzJw8c0hP4ckHLmmaJRAW0M1U648FTX5PYYst+ZRRcc8v5ZuA5Y8Uzot+Pg7c/fYwM5lNZmKKQgbk+Ew2diRNZqTluCLX79RHsJh9Ka82KEV94iNDXMGhKtauRsDJXWDKViXN/eVe7PpJsCCNRS7h6e0mD3FAIj0siBDUhnIazveWdMSVmKIZQ1mLTb8ylKGiC3AJjFFmKE+a52PUi0ncQr4Jvmbk5SRcTWgWzkhuhRbesY2s5RqB1fP07rtWJmNSzr80bOgFVKOAzG8hiCtU8zrbFHqVqE68aebd/FJTeuNFgAByFIb+0HrMXOKNUjZDbDo3e/gYlvmcGptn+LKPb8ZvibPB0CgIcDqEUaijhHZPLcxEImT6PhIePZk7d1it3BSBXAjof2MEoYvw94qTAGA91U2Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB9PR08MB6748.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(107886003)(6512007)(6506007)(26005)(316002)(52116002)(2906002)(186003)(508600001)(6486002)(6916009)(4326008)(2616005)(8936002)(5660300002)(6666004)(8676002)(1076003)(38100700002)(38350700002)(86362001)(83380400001)(66946007)(66476007)(66556008)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uYQJ0i2kJl3saA8Q3mTKlGskfjIm0u4NYq1TV4D36sUpwBUFfxWJsym2WBfdrRlFMHa6/AS6KMImyo4Q9nhWLV9fuO6w7HBKQs5HWAdnoMaY2KlGYlNNAUrAiR7pYmBniQPsrUlve5CQPYUKEB4NCxRn0aFH76g49W8LEnYecuiT7KAfCRm+XXh+7hCrRgIaJbbq3eGqCXocN0S0EDU6yTHX9fRcU0gSQgGLsKMZboz/FmpLn2tvSBPTnve4mPRpCrw1ncoMmE24h/boUEWNx3f6tES22xkIlaPHQUHE5VH+fkfw5M1+dCtws1+U2N0ItTTHFZE0cizhMUJDodvuBRjStHwWOQ1yVh7fRSj/SS76hasBeyjP/ITOrl2WUQgBILzVnwQxgQCkjgGPdFF4ycfMND0PN9fVRcF9LNi5to//Sw/AEaSwKnyO69HHRAIcVyKB8sDpkbmPaSB0l7dkPCjkwA0wMsGvEGwg423TPgB/bURGAMzd3ys5uFLKAm2/0XUwRHAssgV+Ns+jofafdfk0iFQVLiZNaxt0quv/D3e4eh9p3yGPJLZkJGm31VF9xrXmzbdJ9b6RbBSqLxbkuxuJz5CAFFNvN0RuaCwOnjRXZvVWitbaXkr22NiwcpPiLBGYKu1UXUUde6wV1hHTSeEx3eT2nSpwO4FEn3U171+YS6SsC9Dnhj1KyFSd6fKXsde76iR87QK5nRcRy/vsascnT3CMIS6hDybtnf0PKJn4KX+q27sQayJpBG67pKH9eLsUqMc2SibXvqo6209k6DrDKg21eCrcMtwv7QooMf2CTq0ie04Ivd6lvAVz5tmQwhC82zdBfhNCAnmgbI8qlcfxNQ3qqDSyYZkie/7fEdq08ffGikHWaBJ+liwPFRChgwpuv8x6tT1zfhKJWtwvsCqJ/4T1qag+usQNNuTWTDy+IzjSlFx0MZume7AeXG6FWlPKRXi0+8AEz+pdMXB8q9Zqw8OLH2/UHHGKPeTTYoE9GLO7quCVEX1/msZMfK1QfQhPQIIYN4Vt2Nj4RdtqKRTL4+Ya2e1qHN5KwjGNqm8yGrbTFCIYnrfg7gS2YHiOdiNm5eooizeb8NsNom3DbTcdaRF0qWyVENBAjHVpPsLWW18RRgvxr+IbnVAbs1IqueyMNMQP14F8cSmwZNRNIFpxsi8vfLRrNOaZHaY/bqcGYXaa6AvyY7qnv1639MgHaZmMHnoMX/opsiG5bVOMCels1nl0cVXGt1kMvLwoE09r74GpBhQDKatXU7AY0lHr4KnV7645/kEHuzdZwCBUf+x5w3lKAlBtwuDq8Gw94vquSTPee8d0UlVWQeJ8HqH3QiJUQ6IKPcLwRcoXMqt16EMgLYPJ+gcDc/NT3futHfIYY+PVZLVWPfUtlZJDJsEDG4RxNP32LEne8EDN8pQQeCyn2nVg5zvimTV+GlDLsb7pDEBmaBgv8t0/H5bDpTYgQgotSZvthBQa+MUG9q+0kwtV/5S80BBb1JkWwp1ueWdqF9tVaFa1IgpEkIRGC1fNBpHEvJv8xeDvdSBotpDEEkcIOD8YfnsWx7PvwNLLekpDVpb2OEW519ZPSUm4wCbaLQHFpxxy2N9XfvMkfl6Q4fUwcrmedrVqVvU8sUZ4I75zWfZIBLRqmwdxwK69dnSmcoVvRXEHszjmO45NBEtAFivZ3Fud10Fc8RZPHeKFKXU= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7bfeef1d-2925-4da4-ddea-08d9c5722dbf X-MS-Exchange-CrossTenant-AuthSource: DB9PR08MB6748.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Dec 2021 17:40:43.5690 (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: mXD1IjenCiOIyA6mDmucmSDnIRdvtwlNxCjY9UEW7BB1xH2KBIy1NDJ/9nkmoGNLXMp2uEmlEzU1tc2BVHsr2eCeEBAyRg05pdi7dfv7fgs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB3964 Received-SPF: pass client-ip=40.107.21.133; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com 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, 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.29 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" Signed-off-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/tests/image-fleecing | 67 ++++++++++++------ tests/qemu-iotests/tests/image-fleecing.out | 76 ++++++++++++++++++++- 2 files changed, 122 insertions(+), 21 deletions(-) diff --git a/tests/qemu-iotests/tests/image-fleecing b/tests/qemu-iotests/tests/image-fleecing index a58b5a1781..2544782c28 100755 --- a/tests/qemu-iotests/tests/image-fleecing +++ b/tests/qemu-iotests/tests/image-fleecing @@ -49,12 +49,17 @@ remainder = [('0xd5', '0x108000', '32k'), # Right-end of partial-left [1] ('0xdc', '32M', '32k'), # Left-end of partial-right [2] ('0xcd', '0x3ff0000', '64k')] # patterns[3] -def do_test(use_cbw, base_img_path, fleece_img_path, nbd_sock_path, vm): +def do_test(use_cbw, use_fleecing_filter, base_img_path, + fleece_img_path, nbd_sock_path, vm): log('--- Setting up images ---') log('') assert qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') == 0 - assert qemu_img('create', '-f', 'qcow2', fleece_img_path, '64M') == 0 + if use_fleecing_filter: + assert use_cbw + assert qemu_img('create', '-f', 'raw', fleece_img_path, '64M') == 0 + else: + assert qemu_img('create', '-f', 'qcow2', fleece_img_path, '64M') == 0 for p in patterns: qemu_io('-f', iotests.imgfmt, @@ -81,24 +86,39 @@ def do_test(use_cbw, base_img_path, fleece_img_path, nbd_sock_path, vm): log('') - # create tmp_node backed by src_node - log(vm.qmp('blockdev-add', { - 'driver': 'qcow2', - 'node-name': tmp_node, - 'file': { + if use_fleecing_filter: + log(vm.qmp('blockdev-add', { + 'node-name': tmp_node, 'driver': 'file', 'filename': fleece_img_path, - }, - 'backing': src_node, - })) + })) + else: + # create tmp_node backed by src_node + log(vm.qmp('blockdev-add', { + 'driver': 'qcow2', + 'node-name': tmp_node, + 'file': { + 'driver': 'file', + 'filename': fleece_img_path, + }, + 'backing': src_node, + })) # Establish CBW from source to fleecing node if use_cbw: + if use_fleecing_filter: + log(vm.qmp('blockdev-add', { + 'driver': 'fleecing', + 'node-name': 'fl-fleecing', + 'file': tmp_node, + 'source': src_node, + })) + log(vm.qmp('blockdev-add', { 'driver': 'copy-before-write', 'node-name': 'fl-cbw', 'file': src_node, - 'target': tmp_node + 'target': 'fl-fleecing' if use_fleecing_filter else tmp_node })) log(vm.qmp('qom-set', path=qom_path, property='drive', value='fl-cbw')) @@ -109,16 +129,18 @@ def do_test(use_cbw, base_img_path, fleece_img_path, nbd_sock_path, vm): target=tmp_node, sync='none')) + export_node = 'fl-fleecing' if use_fleecing_filter else tmp_node + log('') log('--- Setting up NBD Export ---') log('') - nbd_uri = 'nbd+unix:///%s?socket=%s' % (tmp_node, nbd_sock_path) + nbd_uri = 'nbd+unix:///%s?socket=%s' % (export_node, nbd_sock_path) log(vm.qmp('nbd-server-start', {'addr': {'type': 'unix', 'data': {'path': nbd_sock_path}}})) - log(vm.qmp('nbd-server-add', device=tmp_node)) + log(vm.qmp('nbd-server-add', device=export_node)) log('') log('--- Sanity Check ---') @@ -151,16 +173,19 @@ def do_test(use_cbw, base_img_path, fleece_img_path, nbd_sock_path, vm): log('--- Cleanup ---') log('') + log(vm.qmp('nbd-server-stop')) + if use_cbw: log(vm.qmp('qom-set', path=qom_path, property='drive', value=src_node)) log(vm.qmp('blockdev-del', node_name='fl-cbw')) + if use_fleecing_filter: + log(vm.qmp('blockdev-del', node_name='fl-fleecing')) else: log(vm.qmp('block-job-cancel', device='fleecing')) e = vm.event_wait('BLOCK_JOB_CANCELLED') assert e is not None log(e, filters=[iotests.filter_qmp_event]) - log(vm.qmp('nbd-server-stop')) log(vm.qmp('blockdev-del', node_name=tmp_node)) vm.shutdown() @@ -177,17 +202,21 @@ def do_test(use_cbw, base_img_path, fleece_img_path, nbd_sock_path, vm): log('Done') -def test(use_cbw): +def test(use_cbw, use_fleecing_filter): with iotests.FilePath('base.img') as base_img_path, \ iotests.FilePath('fleece.img') as fleece_img_path, \ iotests.FilePath('nbd.sock', base_dir=iotests.sock_dir) as nbd_sock_path, \ iotests.VM() as vm: - do_test(use_cbw, base_img_path, fleece_img_path, nbd_sock_path, vm) + do_test(use_cbw, use_fleecing_filter, base_img_path, + fleece_img_path, nbd_sock_path, vm) log('=== Test backup(sync=none) based fleecing ===\n') -test(False) +test(False, False) -log('=== Test filter based fleecing ===\n') -test(True) +log('=== Test cbw-filter based fleecing ===\n') +test(True, False) + +log('=== Test fleecing-format based fleecing ===\n') +test(True, True) diff --git a/tests/qemu-iotests/tests/image-fleecing.out b/tests/qemu-iotests/tests/image-fleecing.out index e96d122a8b..da0af93388 100644 --- a/tests/qemu-iotests/tests/image-fleecing.out +++ b/tests/qemu-iotests/tests/image-fleecing.out @@ -52,8 +52,8 @@ read -P0 0x3fe0000 64k --- Cleanup --- {"return": {}} -{"data": {"device": "fleecing", "len": 67108864, "offset": 393216, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_CANCELLED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} {"return": {}} +{"data": {"device": "fleecing", "len": 67108864, "offset": 393216, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_CANCELLED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} {"return": {}} --- Confirming writes --- @@ -67,7 +67,7 @@ read -P0xdc 32M 32k read -P0xcd 0x3ff0000 64k Done -=== Test filter based fleecing === +=== Test cbw-filter based fleecing === --- Setting up images --- @@ -137,3 +137,75 @@ read -P0xdc 32M 32k read -P0xcd 0x3ff0000 64k Done +=== Test fleecing-format based fleecing === + +--- Setting up images --- + +Done + +--- Launching VM --- + +Done + +--- Setting up Fleecing Graph --- + +{"return": {}} +{"return": {}} +{"return": {}} +{"return": {}} + +--- Setting up NBD Export --- + +{"return": {}} +{"return": {}} + +--- Sanity Check --- + +read -P0x5d 0 64k +read -P0xd5 1M 64k +read -P0xdc 32M 64k +read -P0xcd 0x3ff0000 64k +read -P0 0x00f8000 32k +read -P0 0x2010000 32k +read -P0 0x3fe0000 64k + +--- Testing COW --- + +write -P0xab 0 64k +{"return": ""} +write -P0xad 0x00f8000 64k +{"return": ""} +write -P0x1d 0x2008000 64k +{"return": ""} +write -P0xea 0x3fe0000 64k +{"return": ""} + +--- Verifying Data --- + +read -P0x5d 0 64k +read -P0xd5 1M 64k +read -P0xdc 32M 64k +read -P0xcd 0x3ff0000 64k +read -P0 0x00f8000 32k +read -P0 0x2010000 32k +read -P0 0x3fe0000 64k + +--- Cleanup --- + +{"return": {}} +{"return": {}} +{"return": {}} +{"return": {}} +{"return": {}} + +--- Confirming writes --- + +read -P0xab 0 64k +read -P0xad 0x00f8000 64k +read -P0x1d 0x2008000 64k +read -P0xea 0x3fe0000 64k +read -P0xd5 0x108000 32k +read -P0xdc 32M 32k +read -P0xcd 0x3ff0000 64k + +Done From patchwork Wed Dec 22 17:40:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12697174 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 70AD5C433F5 for ; Wed, 22 Dec 2021 18:01:00 +0000 (UTC) Received: from localhost ([::1]:47160 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n05v9-0001eG-B5 for qemu-devel@archiver.kernel.org; Wed, 22 Dec 2021 13:00:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52696) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n05bt-0001ZD-2C; Wed, 22 Dec 2021 12:41:05 -0500 Received: from mail-eopbgr60133.outbound.protection.outlook.com ([40.107.6.133]:36163 helo=EUR04-DB3-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 1n05bm-0002Zq-WC; Wed, 22 Dec 2021 12:41:04 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mkNpOPbA3fQURCBpkMglgj6HNXSgfQtqzkdXYpRYAv03Bd3PI93w52AZuEWAvRbMlsWv/J7op+3qTicCsYmcFEGjyokA8dkM6XyVJsNWboYaeFmJ1LXC36gi8Ccts39tqmTcVplPZsD+/0KfU+VZOQ0+gBhOm5P53OEu+CX23/krHvO4WXPZsdETFrOIx9D3D/B8gYjqTedwB2Wdx5OcFPBwDaYX8KOeMVehoMtgstXY6M6kn0kx9LiHisVpjIPWSGqinQyOVrFFIYDyNU1FjHDP4mjblpsK8C1AUUfanMRvCQ2icamis0KuCE90OhxuDSb0rk9kgHNTcOyjwGODsA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mniKP/3EA5x2CHyTzvADdVyDSQ5tMhsYoqy4/Vu7G9o=; b=XColKTcMMJYhqXHJ9aVM8Aja6nrgWANUBZ5vCs+mnZ3XkNMesr7r+N0rNVUXdMWSR8UW3uITDfEiK1xLPzY7cWTlgMd9lEd84kSt5XVFxSv56VO9lKGnfAdLp+VKSS+ZNjS/rroFak3Ko8dSii9zoB7VXij/V2H2OusWtkcaWt0lnSNmZVu9LBEsYLPOB+EmAuRAtng3KoFJAeDadN3ZWs2PVeiPGvuzNBwTkgFG78Dv9UBKJ40r/sxnjVHBn9EMZxXR29yiX6YjOe/hqHckhMh7r0oATVj0mHDaSLcIbzWdz1hvA7piymXvh+RAyJ4z6WVzd8GfHj/VOS53EOvYdA== 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=mniKP/3EA5x2CHyTzvADdVyDSQ5tMhsYoqy4/Vu7G9o=; b=Yf2g5/Cl45FU28OAPKw4kDYhmgMyb+7wwvOCiO8vCBVO+m9QCQmhRKvdmxnNj5XybXOYi43wWQYE44CkUAurrXlpFPLe+HlxT4DwkB7gqlOZaqbhColUfmPq6nA/PTwZVYyqPi+4d4pqrYCD/1gI9HX3wjhSnGHyMN7HPw7bIFg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) by DB8PR08MB3964.eurprd08.prod.outlook.com (2603:10a6:10:a4::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.17; Wed, 22 Dec 2021 17:40:44 +0000 Received: from DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e]) by DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e%6]) with mapi id 15.20.4823.019; Wed, 22 Dec 2021 17:40:44 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v3 15/19] iotests.py: add qemu_io_pipe_and_status() Date: Wed, 22 Dec 2021 18:40:14 +0100 Message-Id: <20211222174018.257550-16-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211222174018.257550-1-vsementsov@virtuozzo.com> References: <20211222174018.257550-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8P250CA0017.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:330::22) To DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 93cd1802-2277-4f53-fcec-08d9c5722e2a X-MS-TrafficTypeDiagnostic: DB8PR08MB3964:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:337; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JNt8LnGgsuxYpoXIIwFNQFcSduBK08/q8JxGT+rLAFejnWsAmxATicx73Qcc0qXBNf7s+QAS4RTpFBQH/bEmG7/Fh+RaDCEC4JsQq7GZAD+cNay2NqDxh6x+o1wxND4VuDKOStzZphWtpR9IIjC67wxTcL3V67ED7fONKOAUJG7zYWdMAekNMRXeT6fCHPzYFFYQMocgxiPTKF58i8XLMgIl9xlvtISFfuujPUAni9f5ceqwM6CEEs441ujQLb2BQnfzO/WPj7gJjRiBFq8QufKKz0WQtOmTMDg1wzZW7e3GTTQLTYglaBoaI5g9VugHHftaB61L4FZpt4ypsP6k2kUFSUEufg2o/4yDjN2CKWkgJsGK4orbxeNTCInTKgjNDwq0Rtk75oAcIaEkCQQqfmRUW12GuZXy3wqofJg73gkMdfQRcfRhzy81Ezm61QOGsjjd5zFU6qV30uZCE/CFIV6b9C0AVHnJ1rP1ISzAOYFcg5MI9ptjEkiTMIuUIAHzeTk307nscrfrTdlXzI3wMVcjnlvhhyFrth1t6RITZZ5wPw8B7dzsf+5oLPFY4qo4eYWI2Ib8sYmV/PqGLroc2YLb6xG3mkoim4Gt4XlH8/lNnz68QDL11bEenx2RYZOICg59dvbOSQQzTxAfEdbaEaVnbbPQ9l6ehc0UR3cHXi1YzV+MdoGNqXXSIu32zeAZ0Ws84W3rriw4vkKJnjFqjw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB9PR08MB6748.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(107886003)(6512007)(6506007)(26005)(316002)(4744005)(52116002)(2906002)(186003)(508600001)(6486002)(6916009)(4326008)(2616005)(8936002)(5660300002)(6666004)(8676002)(1076003)(38100700002)(38350700002)(86362001)(66946007)(66476007)(66556008)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1g0O13t37A01KtduKFkxl9Xg0GxRHuWPeTzKbXx0U0/z3aRJF5ge+MLWt05yU/A97sSxhaTe6RTIGZNBMqvnKBcpT7A3LN/xPcv1OU5XvcvtTH/kRaXZOblKjw+btjRpokcIxdYve7D6RpfBpBuP543VPjdfBkR8X6GTlj3FQPCur0lhgFizQYGgsSmhrDecZxAbTsLL3feDDq6xQ/HqdsimHh+mir5hhtGGzyghso1gpTk5IeyhKrL44+ewvlc26Oq9OBORpRDreaujkORVmExlIbY85RI1ztoHyTcrFZ8NXIkkBUoQ71aHVv9paMqm5N9+HQ7M6iSUFssOkR7wVAcdexZzlMSNEvDuoAkUq9amLQJ6A5I9bUthb7gJoXBIXR6uuQWwUGSLiNWA4apr8jfdOkAO73WAJYegaQPPDg/1qjNWer8S9IyBEZbX76tk5UN4KXhfRU/ND5/Piub2FxJ8Fq7QgnsHfeT7PqCQtXd6+1/wapUAVsePTe22lnkrjhM0YprL2IW9RaiQIkX09DI7aq7DMncAcshXUE7H1uj80PwehalWrDV6lX1hNkg7GkofqrOI8EzJInAykC4IuE8x1XexNGzy1A3n2BeU86AUqu8G7i+ifQeUrG+3AKBYuoHNn5/ksjNGNa2m3+vm6mQi1aTq+pbXYvRXfWBwyTTrryu6WhUY517qWluzk88E3zTpY37hBuReZFeO/wEFzplyUhE/W/Udwm8cEumIwC/s8jPAeEsOlS5cLrY/oeigkuI5SYbHAR6/ck2hsnVyR1e4Bzg4lzdN4CfTgNpYqqJYO/GxubCW5PMzj0DGbqlgLi77DeNFaouzNxTQiUQhx5MiwpOGU2S9KMIprOX4Z8M1qE/92TcKIMrTA3oxZ0k1Vomg8+yFo+AqaBnyqn14KEg6wwbhUGgemiDgOPfy5f9WjrBdQVRRgfXrdjbSXK6WgYd3QZ4l1FF63o15yp9lPDQeX4XVn3YQDn0Bt8hOsgvkfVUIwq3SWNdY9MAxSq4ajcmYUyW/5RD7P5MwAk/6d0TrJNZBUDcIJup2RL7bm7BGUodiJ5Dd1HAUKPBpAbguUgwteQCVgYL0CoJxCRq8M23+lk0HcIanBvFQeQ/uX1cZqKf7aeognwKhuFzvTkOo426vTYPoYtcnAweAZ7kba1gM1SCEp32lVgHTezlMT63uTrG/moLtaK2LrYIad/F4/lIRjyWc7EXeebsdgrp6KrIj42ZbSmZa/AsRIjMmrK/J+C/7D9Z6Mkfew5ns3TQA0vDP6GPAtQrTyOU3yhSN77QNjsyiNI4TgvsnD39pgSiEiShrKJqnGesTJig3D2eDPtI2SPIAj0zMj0X60PqCisAzg4oI414Y24JUnpDUxEcXEHIvUH5kl9/HgWztFfm7CHRq3SNYyJOk6MDIyvM1IPtLr2MmLvB6z0jX42U3bJFIkiGzfZG4o6CAicoGSY5lHOmo+TkiS18mwHA7WY0Lv7xl0hOVtg95aYYOhc29MQjwz7mQhLoWCEK7SX8JN/f0hoWhtQzE6GdPCYnLueD+zGOyc9SmT/QPNfXlLj0YXUk7Dd1WyzyXY65TUkhz3mucU5X4ZYnZ9Akmy6qYewA09i5PNMOfHzts52nLP8S1yZOTtUgr3w3Vqachllq2wurtszVM02ZxuQfNo6DXcpMrPA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 93cd1802-2277-4f53-fcec-08d9c5722e2a X-MS-Exchange-CrossTenant-AuthSource: DB9PR08MB6748.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Dec 2021 17:40:44.5536 (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: Q58bpxZsvKcnpyF8kjd/KbpHP/cRCxws7PxpfX7B5C5q3xyP3aGfNhLuDosGcg50eBoysT04dMMPSzfRDdIzWh5Q7AL637NF8vYA7cRCVRQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB3964 Received-SPF: pass client-ip=40.107.6.133; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com 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, 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.29 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" Add helper that returns both status and output, to be used in the following commit Signed-off-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/iotests.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 83bfedb902..b5e6216517 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -238,6 +238,10 @@ def qemu_io(*args): args = qemu_io_args + list(args) return qemu_tool_pipe_and_status('qemu-io', args)[0] +def qemu_io_pipe_and_status(*args): + args = qemu_io_args + list(args) + return qemu_tool_pipe_and_status('qemu-io', args) + def qemu_io_log(*args): result = qemu_io(*args) log(result, filters=[filter_testfiles, filter_qemu_io]) From patchwork Wed Dec 22 17:40:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12697176 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 7515EC433F5 for ; Wed, 22 Dec 2021 18:07:35 +0000 (UTC) Received: from localhost ([::1]:33164 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n061W-0003Jq-D0 for qemu-devel@archiver.kernel.org; Wed, 22 Dec 2021 13:07:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52698) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n05bt-0001Zn-8q; Wed, 22 Dec 2021 12:41:05 -0500 Received: from mail-vi1eur05on2133.outbound.protection.outlook.com ([40.107.21.133]:46561 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 1n05bo-0002Xs-Iu; Wed, 22 Dec 2021 12:41:04 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NSDpOHzfcNnXPh86omy6tE7BryOcco69h/fEeNNw4RBbc8smYOuwY9ZgI2jvesG4tmZB3MS7bYzP327da+wPa6iSEAwDiG/6Xdt+nuxtEuHJdzb1mkI0aCCZ87cgJWKQ8FYkKdvQBH0E+q8WgJg0pDvMDVYlnXruL1GolOS7+aZyGi+kCiMfi2O7Oryzy2+3s0W8SoZNdAyfLnDGR+8nlUBtaGjWZtqm29kHMQ8G0FJbwhihZwvFqZcIYcuj+ED2mJKvRWk8U07Jje2hl1pdrW/pypfYkAcG92taBh2q2moX1M0S2DZgyZ4r477wdRVh3Rq+rE0JQrHZtWEhznlLXw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lnYuXNDZQvKTRTRCGk8qXER7c/B0pHdB/vCQAl3rh+A=; b=ZmlLo739NMQveArhuh4L+gUxUmqlaa8b0BQIxQ2TJMLHoYAg1FLz9jaYYIt3bPqgEtbgCWx8sZbyu//W6yHkhr5EcwMVcjA+5jKa4RXentTg/9ecQ4sGw3PDVIlQrMk6L0gLpKU6CWsD35y3nFbrc2QsBxeyZec0Ck6oBheOBsPPsPstJx/KXMF9VdlwKrDdNp86H9MlRGjfx3YoeFpUU1+Kh4DpF8WXVsySWtqq59yJUNO0PZLPHxTiL7qPemw0ubvdomZxmylENhtDSOFC4m3NKHD8kYrZ4YT5iiPDi6G8Kzlv2bc6hrXZN8Ct0nntjE4VeSvfrY8W7pCMFi2c7Q== 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=lnYuXNDZQvKTRTRCGk8qXER7c/B0pHdB/vCQAl3rh+A=; b=S/1Kj+uJnesx+QJ9uetbpXFB57c2puEjZRUawsUGmx+V8KFKTR2n7JWtsBrK3aWyhBfcVWXW6/d8xbg7pSDEWCFL3/MJN6clTUpSOdXFWwzjp++/XihIX1MxTcXLhNWpCCZN++0gtWm0cqdS0AXGY2kSqUNrf0Z9xx6sJvBQnDM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) by DB8PR08MB3964.eurprd08.prod.outlook.com (2603:10a6:10:a4::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.17; Wed, 22 Dec 2021 17:40:45 +0000 Received: from DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e]) by DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e%6]) with mapi id 15.20.4823.019; Wed, 22 Dec 2021 17:40:45 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v3 16/19] iotests/image-fleecing: add test case with bitmap Date: Wed, 22 Dec 2021 18:40:15 +0100 Message-Id: <20211222174018.257550-17-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211222174018.257550-1-vsementsov@virtuozzo.com> References: <20211222174018.257550-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8P250CA0017.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:330::22) To DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4fd1686e-5280-4916-fe20-08d9c5722ebe X-MS-TrafficTypeDiagnostic: DB8PR08MB3964:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:73; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eQC3tC32j+e6/pwcWMo6hW/tsNYdwUakjF21PWgr3avsEleqwbTrKHjc4pyhT1s5lvf0ufiFn2Z2S6S+9uGiyO40niqmU1hesWT6rnHkuy3phR0TVb8INf/FtUqMenxVK1zUFiPQfTUf7xb+OSs5tqzKOgQmORGbz3e53/ANTntr0MHy7AtZWMBx7U/AlHrDvsDFauQW+B7uXbce2QxkTpELe0aA2sNmqIR6noCaNZc5mRy7qR6H8FXBNPcpgnFJAVHaI5yKwO7jvoaL5fvwJpM8xFb1IiGyKofIK54JmkBoY0snNQQcn7dPxPAqTmtvK88B3a4vPJX2ztGStlVvmxD3jLyq7QwAfegFbNIK82Ev/20xTq+G1Vetc60PhX5QHOzXfUg7DY055/QZ9aTG03A9L1lobyKzxaArNJrIHZoleyPN/j6Qo5GvWRS7336ld7ad+kh9DlTK1dEa6Wt9QpukID4DZiyuZhe85ZyNfmMnbybpY2drMHEsD990wlFFy0g6Ob296zmjxMM6sOmGYfzq9WLZHYJI0o5vevFUwnFXKtFwokhWmSgmSwK71csLgvdN/uQAAIk50IT+R2TPhEQ5DykRdp3w/J1+lZn3hTdc97oKjPMc626zmDfWEa3JAnn8PRt0/QnOpsNbb0Zn2GSmA9bGWHhxacCFzDITbm6wFN7h8yFIORDE8CA5+CdvBeIQSTpuxinxLEH2qfNzJA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB9PR08MB6748.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(107886003)(6512007)(6506007)(26005)(316002)(52116002)(2906002)(186003)(508600001)(6486002)(6916009)(4326008)(2616005)(8936002)(5660300002)(6666004)(8676002)(1076003)(38100700002)(38350700002)(86362001)(83380400001)(66946007)(66476007)(66556008)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hElKcPXP/RrtWIZeDGkoW84AWBVLDkQ3DK80H1Du04JFi6/9p60T0tFmAGeExvD32qvEuDgXPowUQDKwVdfgoNLFqTvGAojUsbD8juAciZWSW2n4ZzTjXyyq7lZZH8PVn2V/Wf14Z7OVbOFJmAKOY+sTBTS1HBeMDdx7C4qwDNdBERSkszFBK16RWF7A/j4Ur6UhP7Jw0urh2SXmtjB6IE9XENYnBMX4Duj6NtfeZIJCtM6XZUggWpwH0QI9qgaZlp27vwP52Z+2pqQAD04+mVEPXCntQKXwEhMh9UyqGo3LTPB2HJ2kHryTolZZU4cbecRJaaMCWAA/USoycU/+dx4UMCK+PmlT5N625JbNZuptWmAPOOGTY6oNlWffugGwZn/jFZ2C3HKny6v1UpgL8hS1695ilS9VEJHDEclH+UDRUGuYG9YahPZH9KrmWk9sBX+Vw9Kt7IMnebxVv/noh9HcJLsezRHnqy//yrN8UJoIGbwYzwxLYy5a86cYzhfGGjmti944yRwNx9uyHyiJlvKV/7i4dtywRlt8Jh3MPBAbNLl/uq9/nu0jlbArY9DtWkm6pdzBP6haJJp+Pr7CLKnfX6rLV7h6OIKf+Bt3EmdUw3/MO1aOklXd350ep/SxBNEqL1HdQK6r+o7vNuoGhduK90vIk+P+Op7WOUUluZPjvDn+HjqTrPxhUxA4qSvy+3JIHgPkw3PHDqXn9SPnT1XnGSJEji4nK/hpWKakTBlaJ28enc8/sk0nrP/OFRz/XxWt/DjM2jIdxlvYkS1RMYHWrSB3qzIGRIhpf94mo9PPI+vInAJDeTLb3mkoqg+2l9CJej/WtRaz0O1LWKSIwjs8+ZitrBxI/az6C4TywDS3wce0NmCoN4nmNvDxbOQxxbQ5KBO0JQFBWYmmFymWyv2xadNpbAa5Uh1Ue9N7EGNo0h3hsuLYS5TgOPwg0z0zrStCKVQsGJmUySJwzTFVPjdrDief1JXrkrhnvs+Cn3H+Dze7xFcT1wUVVZ4lLTbsFtS/HNk/WX/acAO5LeUo70+6VlGubM4bopApYuRQsJRRJ9xh+7m9ZKhWl2Zhh73Z7VqSEzYMxZulEM0Nrv55+n31nElVhkCAQFM8W9gl+QlcYDucflUAHmO5uozZJu1+3as4ViTW44wvOkFVjHDSDectI6/pVAXaPXdEuaimRdetyxTLU/CKZOJAlbQ+l2PKaCsnMIxKrlW8rR2S1SaNTysKRBgU0uFWSGfN76fiVMm4bxUP46q7CWY1RAE2KVxGPLJT0vvW44NhGPX5gBFyDfzG5gaItNETNAdj+QYf3VgU1tFYEv0w/0nK4Y4vibA+gbbzFCJ8BmI32ufMEtx7K9DYlU8J1Dh1EZOEjdub0IpKO9jnzmDppPgL41GHwCS+riEJ5wtcC2rJkubL7zCV16JiCcz8uJz8/HR+3X+At4REqrR5jAnTezgS7j1jEAhrd8ZqVK5H04fViSGmrv+fxUTuvJrqegDhWVMYoWN6kE9+WTUckt0B5pirElvr0dhgQ6i7+/H4L18xK0t90Cym/U5iHfF09jh1i+UNt/cKZsYObY4msbOTwL9wmiYsX7Yb7WKGyDw9UbP27V70u4bGdmsYGVp6unJTmLwup+WMG5c/rF/RzGGdCimYGwi8hl4lRwigZGsTFDsen/fY2diMXg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4fd1686e-5280-4916-fe20-08d9c5722ebe X-MS-Exchange-CrossTenant-AuthSource: DB9PR08MB6748.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Dec 2021 17:40:45.3347 (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: A5fAgzOnnV8EaGtbYVtFlwf16HgDZGOhHQ6bbhij2+pZ8ZupZsFgbqiK2hI2+rwhYJGIY3jvZXFzDZC7IeYy+eDo70ChczgjJjxCttuQZoM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB3964 Received-SPF: pass client-ip=40.107.21.133; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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" Note that reads zero areas (not dirty in the bitmap) fails, that's correct. Signed-off-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/tests/image-fleecing | 32 ++++++-- tests/qemu-iotests/tests/image-fleecing.out | 84 +++++++++++++++++++++ 2 files changed, 108 insertions(+), 8 deletions(-) diff --git a/tests/qemu-iotests/tests/image-fleecing b/tests/qemu-iotests/tests/image-fleecing index 2544782c28..279047b19c 100755 --- a/tests/qemu-iotests/tests/image-fleecing +++ b/tests/qemu-iotests/tests/image-fleecing @@ -23,7 +23,7 @@ # Creator/Owner: John Snow import iotests -from iotests import log, qemu_img, qemu_io, qemu_io_silent +from iotests import log, qemu_img, qemu_io, qemu_io_silent, qemu_io_pipe_and_status iotests.script_initialize( supported_fmts=['qcow2', 'qcow', 'qed', 'vmdk', 'vhdx', 'raw'], @@ -50,11 +50,15 @@ remainder = [('0xd5', '0x108000', '32k'), # Right-end of partial-left [1] ('0xcd', '0x3ff0000', '64k')] # patterns[3] def do_test(use_cbw, use_fleecing_filter, base_img_path, - fleece_img_path, nbd_sock_path, vm): + fleece_img_path, nbd_sock_path, vm, + bitmap=False): log('--- Setting up images ---') log('') assert qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') == 0 + if bitmap: + assert qemu_img('bitmap', '--add', base_img_path, 'bitmap0') == 0 + if use_fleecing_filter: assert use_cbw assert qemu_img('create', '-f', 'raw', fleece_img_path, '64M') == 0 @@ -114,12 +118,17 @@ def do_test(use_cbw, use_fleecing_filter, base_img_path, 'source': src_node, })) - log(vm.qmp('blockdev-add', { + fl_cbw = { 'driver': 'copy-before-write', 'node-name': 'fl-cbw', 'file': src_node, 'target': 'fl-fleecing' if use_fleecing_filter else tmp_node - })) + } + + if bitmap: + fl_cbw['bitmap'] = {'node': src_node, 'name': 'bitmap0'} + + log(vm.qmp('blockdev-add', fl_cbw)) log(vm.qmp('qom-set', path=qom_path, property='drive', value='fl-cbw')) else: @@ -149,7 +158,9 @@ def do_test(use_cbw, use_fleecing_filter, base_img_path, for p in patterns + zeroes: cmd = 'read -P%s %s %s' % p log(cmd) - assert qemu_io_silent('-r', '-f', 'raw', '-c', cmd, nbd_uri) == 0 + out, ret = qemu_io_pipe_and_status('-r', '-f', 'raw', '-c', cmd, nbd_uri) + if ret != 0: + print(out) log('') log('--- Testing COW ---') @@ -167,7 +178,9 @@ def do_test(use_cbw, use_fleecing_filter, base_img_path, for p in patterns + zeroes: cmd = 'read -P%s %s %s' % p log(cmd) - assert qemu_io_silent('-r', '-f', 'raw', '-c', cmd, nbd_uri) == 0 + out, ret = qemu_io_pipe_and_status('-r', '-f', 'raw', '-c', cmd, nbd_uri) + if ret != 0: + print(out) log('') log('--- Cleanup ---') @@ -202,14 +215,14 @@ def do_test(use_cbw, use_fleecing_filter, base_img_path, log('Done') -def test(use_cbw, use_fleecing_filter): +def test(use_cbw, use_fleecing_filter, bitmap=False): with iotests.FilePath('base.img') as base_img_path, \ iotests.FilePath('fleece.img') as fleece_img_path, \ iotests.FilePath('nbd.sock', base_dir=iotests.sock_dir) as nbd_sock_path, \ iotests.VM() as vm: do_test(use_cbw, use_fleecing_filter, base_img_path, - fleece_img_path, nbd_sock_path, vm) + fleece_img_path, nbd_sock_path, vm, bitmap=bitmap) log('=== Test backup(sync=none) based fleecing ===\n') @@ -220,3 +233,6 @@ test(True, False) log('=== Test fleecing-format based fleecing ===\n') test(True, True) + +log('=== Test fleecing-format based fleecing with bitmap ===\n') +test(True, True, bitmap=True) diff --git a/tests/qemu-iotests/tests/image-fleecing.out b/tests/qemu-iotests/tests/image-fleecing.out index da0af93388..62e1c1fe42 100644 --- a/tests/qemu-iotests/tests/image-fleecing.out +++ b/tests/qemu-iotests/tests/image-fleecing.out @@ -190,6 +190,90 @@ read -P0 0x00f8000 32k read -P0 0x2010000 32k read -P0 0x3fe0000 64k +--- Cleanup --- + +{"return": {}} +{"return": {}} +{"return": {}} +{"return": {}} +{"return": {}} + +--- Confirming writes --- + +read -P0xab 0 64k +read -P0xad 0x00f8000 64k +read -P0x1d 0x2008000 64k +read -P0xea 0x3fe0000 64k +read -P0xd5 0x108000 32k +read -P0xdc 32M 32k +read -P0xcd 0x3ff0000 64k + +Done +=== Test fleecing-format based fleecing with bitmap === + +--- Setting up images --- + +Done + +--- Launching VM --- + +Done + +--- Setting up Fleecing Graph --- + +{"return": {}} +{"return": {}} +{"return": {}} +{"return": {}} + +--- Setting up NBD Export --- + +{"return": {}} +{"return": {}} + +--- Sanity Check --- + +read -P0x5d 0 64k +read -P0xd5 1M 64k +read -P0xdc 32M 64k +read -P0xcd 0x3ff0000 64k +read -P0 0x00f8000 32k +read failed: Invalid argument + +read -P0 0x2010000 32k +read failed: Invalid argument + +read -P0 0x3fe0000 64k +read failed: Invalid argument + + +--- Testing COW --- + +write -P0xab 0 64k +{"return": ""} +write -P0xad 0x00f8000 64k +{"return": ""} +write -P0x1d 0x2008000 64k +{"return": ""} +write -P0xea 0x3fe0000 64k +{"return": ""} + +--- Verifying Data --- + +read -P0x5d 0 64k +read -P0xd5 1M 64k +read -P0xdc 32M 64k +read -P0xcd 0x3ff0000 64k +read -P0 0x00f8000 32k +read failed: Invalid argument + +read -P0 0x2010000 32k +read failed: Invalid argument + +read -P0 0x3fe0000 64k +read failed: Invalid argument + + --- Cleanup --- {"return": {}} From patchwork Wed Dec 22 17:40:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12697164 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 98872C433EF for ; Wed, 22 Dec 2021 17:49:21 +0000 (UTC) Received: from localhost ([::1]:43330 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n05js-0005BK-LZ for qemu-devel@archiver.kernel.org; Wed, 22 Dec 2021 12:49:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52732) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n05bv-0001fA-2P; Wed, 22 Dec 2021 12:41:07 -0500 Received: from mail-eopbgr60133.outbound.protection.outlook.com ([40.107.6.133]:36163 helo=EUR04-DB3-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 1n05bt-0002Zq-HZ; Wed, 22 Dec 2021 12:41:06 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nmSoEp9J7FqFl24uWtyjK+mDFpp8Hn6YES4rUzOFNKpN1vYn7GVB7bOBr71RDWWCLmvMCAFR3szLAyFF1MLv2IsVHb/7YdpMKBOqfdzZQ1Yn3oqCUrB4Y7iB6QPIw7hgLu9Lysi5FGM+1R1D26n6YrgPwFBPHBnwucJrttZsekkuCLDfwsyK07KN2OCbkV/r6BH4uEyYDudnGRqXJmNyiOg//syh1u7mmAVg+Bsfpaozisun3cq9pjo6k9hlhYbM3bZCNbcvnkDeKUhON1jnAlba4hH2yFfGTdz6vAD5cQjbJcuoqG0H2oP1q6LmZPHtV1V3lr8C9AuBuOcfD3T9ng== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=CYPK7ncijaZryIqD+4Q2YvASdig5B1EuqVTP0NbiT9E=; b=YyKshYg1wVXYufv01BX51ft9zmiQQU9cR2Tt7pARycbPIU5UPZpKx6SjVavIb7Bo1raW4OdzwAK+xn2IW5+HvSmLWsxiVqCM7nFJNCOyxCemiLKWCvMc/9PEVrLgHx+prXwKjzP1ykNhi7xHn8x+Hvxb/hPHGZFTc1XuwI1GVGwE6hfQXsKcDnj7yQQMfZk1jnX5KiZlz2ZgZ3JxWd3r6fgwAkUueU7c23a9P8E2eTwD0WSID9fBihe3U3iVPLSfNLt5HnzbFyPzXokTh/RCrWO05sY2hdBhrwWKO7X2UNZUAAWVidWfYYLotB7NAOnQ2B0QZNeddRxBgn3ssDEuRA== 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=CYPK7ncijaZryIqD+4Q2YvASdig5B1EuqVTP0NbiT9E=; b=HM8XwnDc/y8SW1X9E48D1JPgMdys5uuo1CcnWCD0bdRpXaqCtwiystwSdXdEMeaGfm6WI62FfBMhT8XkcpFovJLSyjsoy7GOkqKceUt4pOB//ei4MvQgjIej+sdYjgfScwJlOgkjtx6McLXdFP8gLnr7TjpJtne7ZRnu9pkxzm4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) by DB8PR08MB3964.eurprd08.prod.outlook.com (2603:10a6:10:a4::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.17; Wed, 22 Dec 2021 17:40:46 +0000 Received: from DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e]) by DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e%6]) with mapi id 15.20.4823.019; Wed, 22 Dec 2021 17:40:46 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v3 17/19] block: blk_root(): return non-const pointer Date: Wed, 22 Dec 2021 18:40:16 +0100 Message-Id: <20211222174018.257550-18-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211222174018.257550-1-vsementsov@virtuozzo.com> References: <20211222174018.257550-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8P250CA0017.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:330::22) To DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 82f94930-93a7-4193-f2ae-08d9c5722f3a X-MS-TrafficTypeDiagnostic: DB8PR08MB3964:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zI2XJtx0n5lK6NdKmXUwit+NvGM4JEcimo0orUYZHOLzliXbWZAvQYQR+F68DT2xq4TWpECVRpwtqvFs1sN2fUmT2tzlkk6cKsNTg8+zqZ9LZo4nxy7ZQh8fKPTqy6Q6gswDi1vaPvBp/ZgqJzVq4po7ErqvSxwylwqOzjzeyt30ilyzW205w9j9TeeHVwS3/k07H0qGlcKwgOmHJg+MSohxGpqvjCyAiQKgoDV9NfcTi/g1mqYfDDbnb/TUIk+OL7iP2uxijbgBEy0FWqupfgl37WZp7A2PuGBhaTomMrIwjbK7n8P7vVwR75EKunLv4t4LkLJIVlPvcx49aojA1+VcwLcknNwoFx7g/OKQ4KiZo//9xjD1sS+Ck614OOP6NOtpqCTT3IHSYNC7A6L0qR5Iqu3woPH8zZ1oUECdl4M+fvCs7UtFBS0pY63TfwZYtho2I/h106KOQnT3UzjDdEu8smtnYUbQ99VVafFJGITQ3RzvyQbVjGo+PpbMh0XFNlJ/dHjh83nL3FiEH2cJOPNv4Fs4nycQY8nfaHoK/ppcVtZggoI4pEVqtbIuhQFk4Soef4IZz76T3B1s4FXtEXNUj9C1NheOlYzZd4CBzAY3bvJSA3DSAsdBjvnyBANMR5YcosfUoYslIuBu2+SaRry1MaHPNLLY9BAKvAqEqRsxdFpBcedQ6Tawkj6u8qpuSsfkFzguBuccTVWYGIJ/wg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB9PR08MB6748.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(107886003)(6512007)(6506007)(26005)(316002)(52116002)(2906002)(186003)(508600001)(6486002)(6916009)(4326008)(2616005)(8936002)(5660300002)(6666004)(8676002)(1076003)(38100700002)(38350700002)(86362001)(83380400001)(66946007)(66476007)(66556008)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5fMJlK6g9Snyr87pEUZ8dDy6RtRHwc/90d0lntHQI7unXtPziw0w48MCfcnBgFL4jS7IJjTz0j3nCeA40/bMeEyYa1suzfnDrQ4uaDJTUGv5jmsi6gxsNKPs8bAMcJ14xOxiizGb+EZe4m8fTZFsv1UnE23WLny3FvKXADTEf/vWjCEIzhYu1PNcVezNrs5xD+P/fsUEWBylp3vuY2hz6m46lCB+84HnTECEIQfsIjXDYG8+EpiymhnZ3y8gPv7yRUzTZSBEvRSk7Qrq24NaFqFEmURWwI1WFx2YsYiJ1liBlXuFIQ60LrrvBZuh6wvW9OXtc4Y84V7tNhclZSax1u8cMMnmF5s240BShvOUxGW76Z4lFN6qFTyu2TPXnzDYmDkkHD2b6QRDZKexIG26JqeGHNzEIYPudebsOl9G+cwPurGCnt10agjX3wuwLJYevkzqVXHJb9VxLQMVJsuQwuB6OaQoCo9TolVOciXhXNvFc31D3Dqxjtfddc7BBh0qd5Fp48GVPS5U+PlRFDem53hJJJDFRiFP6qym5UMY9ouPpFQYjK2odZTzIpa+lfkxn0BAsMqql9pP/EG7lNZy3kf8R6lmQFvMEJO1JF0FJiSuxHGNA0wJDGCh7WWOECAnWjGGLNLI1snTVY6ZUEDbhOKPXc5nRnsgXmzvcnwUIwmhmdca5dQTtyrcHU6XEXrph/fG8r3BuX2fgUdwzTRehW5CLfnBEw4iOKwF53JAlywjWy7XDRELW8dI5j84hcsEb92odR79lKt6Ft/EEbdujw0ox9DG0vf6k1UXDpJCM9bDbPirB/WPY0x1l+MGtObyOgDtgTgOCXqIGwImF7u49El2AvzHecs05LJD6bAk3dHF1FUmb0tJZ99I2VV2mLKIIpW5wiZcdUSf3hJ7RiIcoShRnACYXx9xQ6i43U9dANy3PbbXc9i9phiwXjL6ONUw8vMQI3XQBEd3JQhSKVmsk8HAjKymU6oX4qi28zf6nHkuDCgSLmcDYC8vNQkUM9hg9j6q+CW0zyJmcJVKm1LKSneJ5076RqrqCZTnrZboOC95U0S/KX+Vt3crml0i8osee+pOlxdshLq6DbCPGdYSe2ap2ASIwoEtSBnpkNuED/mbk6HUxM2XY1/q4Cc+v+AHSFbEusIRcmNB4w/h9CpGNZpZyoPNKW749kH+5+kSuEjq7fKjRIvn3SjxPAJeAf33x6ePpUuuVBwnBLWIIq2SHEa87pf8tFga/spc/1a+3xGu6fs1Gp03DDhm7nWf6TNBsd4IS3DeT3univEUPw2zBGZn1rmydKKDfwLdwPlZhKy03geaTKBJYZhvypjlV16UvW+VrhcLaqhAWBJklLaJ9X/DeaK5MZ/jgXe4844U5lAAkVUMD5tfjguh7WsW6GAX5HEcY4FtAjvhnFlWjttxTW9IMGgHM5WgiUI3sbEeyLS3wEYBoAiQUyulg0mZPvFFTJsodprmk05mThAJ7bDteSx6e0LIZfmGPfZrunQoo0MW4iEKcIpZKbVSLzCWgcmHpKfv4EEKrEzYhhj80grdYYw9cpPGQ+Ez5NPXQfl5FfyforXGemOqj8HvsOE++TLBAxcRix8k2/pLgqWRB9jx/36EmJx7zgak8+NC5UCEVbypx8XGjrbIax3rm6F6svoW8jPELF2Q+6M7cBTi9AiZAg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 82f94930-93a7-4193-f2ae-08d9c5722f3a X-MS-Exchange-CrossTenant-AuthSource: DB9PR08MB6748.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Dec 2021 17:40:46.0065 (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: 1Dai5iFvMh7GUxH9ouuDF80rOLJMTysbHrKp3tptzgZFSwgXDvxtykay6Ht3r3+7k+X2Ly9BKV5/aQ5dIsqV/qteK/K6ah2RDmajPYV7CUM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB3964 Received-SPF: pass client-ip=40.107.6.133; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com 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, 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.29 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 the following patch we'll want to pass blk children to block-copy. Const pointers are not enough. So, return non const pointer from blk_root(). Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/sysemu/block-backend.h | 2 +- block/block-backend.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index e5e1524f06..904d70f49c 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -277,7 +277,7 @@ int coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in, int64_t bytes, BdrvRequestFlags read_flags, BdrvRequestFlags write_flags); -const BdrvChild *blk_root(BlockBackend *blk); +BdrvChild *blk_root(BlockBackend *blk); int blk_make_empty(BlockBackend *blk, Error **errp); diff --git a/block/block-backend.c b/block/block-backend.c index 12ef80ea17..d994a0f096 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -2438,7 +2438,7 @@ int coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in, bytes, read_flags, write_flags); } -const BdrvChild *blk_root(BlockBackend *blk) +BdrvChild *blk_root(BlockBackend *blk) { return blk->root; } From patchwork Wed Dec 22 17:40:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12697170 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 175DDC433F5 for ; Wed, 22 Dec 2021 17:55:39 +0000 (UTC) Received: from localhost ([::1]:58594 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n05px-000783-Ts for qemu-devel@archiver.kernel.org; Wed, 22 Dec 2021 12:55:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52752) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n05bx-0001jC-37; Wed, 22 Dec 2021 12:41:09 -0500 Received: from mail-vi1eur05on2133.outbound.protection.outlook.com ([40.107.21.133]:46561 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 1n05bt-0002Xs-Ta; Wed, 22 Dec 2021 12:41:07 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kCO4pmJyRMxdB/WwR1slbk0+kRkjEzFAu3UL6qBc7Qqs3vzBAFaJN9f5D5yoY7xk/42FGxgJR9aqNW3zhfa+OnorhyIuSo8btGhkhIHah0ZAby9p1byTP9Brvpvp5vvMrIjPpNwzicLj53RvNrtmXlCv1HgL9RFRJLIpwSXg/UX/NqVv29bhHy4JyTfRTfOa5CffI98C79OU1y8i6FGA89npMq14D3RLY+rP7DP4PDZ6PSfxzUvC7ktH8EwwN6QpEqMQCabrI4rxHzbxxNCJYm9DQ2Mxbwz3VXmwWTHkq77C446o4gWBW62lai91GHvTIYmJlgsxTANnYLl9BgdpGA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=eTSzb7KD7j5SDUVI7rtElgBrilXEn34+nzaSC5E+1SE=; b=izgpMYSb6SSdHGK32LhIoqkSvCnN0NoNxnEu4mFRUn93xQK1GVJsrMR1r+OedufR5zCQsYbBEFoVBW4wfeVY6uxwLL+BJ7/7WP0sOEEDAVVXQ1cjpGf8v7Ydn7hHKxfMowbA27rLzHBVxFHhvfzxrPvcphEkr7nQHVV1QtR5c46mdxGObmmNJrF8y3ijlTVZh11oLMHzLPBvXjxbjgqS3gSxu1Hd8HJHEkMzeaeHM02KEn1sm2cHdH+efF6TN7wt6svWgpPMglHxL7tIkfCjZqMC/nHpHaQ0lTsRCA1Khe8UVpx+/6lecPaqQ2srYSe20wv2TxUgNxO0Ce1b8FUjnw== 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=eTSzb7KD7j5SDUVI7rtElgBrilXEn34+nzaSC5E+1SE=; b=bAZFBD7cFGyXWtaUDfAkZtLeG7xUJ0wxcVFJUPHabmGDGEPXvfqEIU2EOnDQ0QsxbuwUKx8i909YPnWC23kj6MMzk7M/W8HPQOgnNNqu0EagrtZKGMhZUJXYf2e/3KAaC442O8oVBsvmC6mTi1SsZTsSgSQUho4yklvl3USMg28= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) by DB8PR08MB3964.eurprd08.prod.outlook.com (2603:10a6:10:a4::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.17; Wed, 22 Dec 2021 17:40:47 +0000 Received: from DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e]) by DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e%6]) with mapi id 15.20.4823.019; Wed, 22 Dec 2021 17:40:47 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v3 18/19] qapi: backup: add immutable-source parameter Date: Wed, 22 Dec 2021 18:40:17 +0100 Message-Id: <20211222174018.257550-19-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211222174018.257550-1-vsementsov@virtuozzo.com> References: <20211222174018.257550-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8P250CA0017.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:330::22) To DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c7168303-b35c-4161-f08e-08d9c5722fce X-MS-TrafficTypeDiagnostic: DB8PR08MB3964:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KaEXaioI1MfXmLIn5Qy4OIM+IkfUisBxCOAo9O6UXQnEAR8v+mFeK9ujyBlZE8N2qH/VB8jNCneplMNEqWivHy+jKvTWSeapyrAL8IXUTUH90xXYZAebhBr5bwbKgPN8UFLcUWWErrjDOXGibyIRM9GysFlNLwtx7AJP0sN8l/tvMUaEoj2PfSDb59XY2YLl4K5SIPbbmdBiRvoYHQ9gbk9sfBCNULo+Nk6KXhgZ4r2Z9mEsXDTxGrksfpyLyYqOz9CwlrndbvrgrghVZEzVqdz0DjGaREOvExS7iXC1v5tAKtkCB0jKayEeJhW1WLDPqUrI6UTXisMrDWr69OrUgh3lpi9lkRE76nS6qxOngrPnlX502TVsEkYCelcREG1mYjxl1CqHBPuJ2iQ8UtE8VPtyDig23UygfSOYlqgTbvwJ7Xwz6O1fVR86J62zaNX+pukHle4t5CQz1FkmDr6HH4t+G7olHnKqa5RW+v9KSLu4I1dA9bawQ7sa3QDioWECenxEkK1ckvHnqt6RkZ+rhzeuFoXiuGnRylS6ElJg5yszr5nFpdag5KU4JDSr0xi8atq28H2qgUhCIq6LyjIezWi1tJCaLdHV4vlKYB5KQIJn4D4uC0VL+HIy7pMFCraLXuoyumoH3L6Dj59xBIv59ly74hcTypmFJ5TDIKrbbx3qc43soiEo4EgHIJUNPtDYwGy0WdNTQ/FyfohruBytoQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB9PR08MB6748.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(107886003)(6512007)(6506007)(26005)(316002)(52116002)(2906002)(186003)(508600001)(6486002)(6916009)(4326008)(2616005)(8936002)(5660300002)(6666004)(8676002)(1076003)(38100700002)(38350700002)(86362001)(83380400001)(66946007)(66476007)(66556008)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4sjROHG9e8JtfAVyikDGBei12Axins/j1lEF16Dobm/AwCkxEYC4F5wzZXacGxktcFelH2mc7EFIdALLmOqxygo72y8mfo5/FKMsM84G/Zk8VZtkt4Ddq5oYFC0E7XRje36xENzeuwNkjGj15KsFO0fmHoWW8e9Nx/SzvAkct8gyoRxN6CVuVRJ7jDETJVwwGb4D/V4CdgVbBoyznZHnaPtZUfJjqVF+EFk/UqP3PJs3rwVUNaeD04cWB0762F2QfBICH4gAYudyDHuPKO7ot9BE/YPwTp6B3/dcw1lDkscCY1oaAn3ZmoSIxJLUNMrKDpEgLZd6bdyg8g6ncvSMW2+PmEIt9j7yP9hNpnobT2eFQcYkV9S/j0i9hfUwJemhPqad5gd2SFriyeYwoRuS1jRpbXYDCiIAFeUS1Jm1YMPRggyTY119HMiY18dqCo1RjyLShUcl3EOiXdJpkWzXmFh9fZm78hksxBoX0blFKowSOrO41tBfFmheVDbFarsIc0bymh4Q0RKueAbLKmtzEhjY9ZoGfiwy05WPsVt/qjATOd31j94mDFDfbNiioqwNMMlA3YQglSb+p+4Xtks4qXb7k5yNdh6W/S8mkCRCEE3XmQVyP16iCdFmqKjnx3KTfMiQ8NXoDaq13bhOqxDk/1S0PcxW/Z4cw6gqs4KD9lhK9jdIoLkthOjKW3LDGG5HPcf4nlVkuwBbNNwqHYjMCLUm2bS7drE99cU6cg2swylNq0swBTFGMTgd/aMATg70zEDso3L6rrvpa3SRj8U381K7q4o8/7Dn4DCL0+JUl3Oz0v+zVZqP/5ZrhH6mA6DZW8AiRUrY91XPQ6WaweYY5FfVGMbV7k+5oh77cOFbHDbmUIfN/u2+m6hzcEri5XOXp/WRhnr1KHtJSDYcot0W1p3pWcbKc2Qxa6+703v9cdX/HICmHgGgq33qtw1iI20a3st+dRxjiRY+O4SlfTQcrVb2cQmxYZouvRHNHr/P6DqsPixUisSD6CiiBNqo+hN24Qb/X37Yi1bRWToOltMJbf9kIzIJAZAluxJCnVFyL5L0lKvI5q9RaGNc37koBpG4Nh942I9p3WuG5RdJwsvnk3bYoK683Z67PNj1QzjFtmRZ7uU8zSrzsas8QCxN5PdZ3BNNUTudUb2J2MCFF7Q+ucy1Roe2GL35O+zrjA+N0Z0u8CaJQ4hRZFyJCfmB9EMom2aNSEbKbIDIQjRg26yWxsmtmLBADN/5p9WI+56gBmmaSfe16dclwtzSjMb56FwAJTkquQ3TsCbSpNb3E008IssGtTJtb7MyrU7ANTedsvz3KDjXT5Ho8slX0/+dBwizdeOw5O1xEycLBtqwfsX4CzPRAOeRhda45caBKDMDuVmsjZv7wRJuoT9YbDB2mnKF6rcU2A5ywwk8LCx2YRvP8f5Te3EoUckm8KpEe+fg7f6TFeH3QybsqL24ZXQn2BW+KJlw2QLWdFaPDWLe561whlakQvAfyaGQd6yQM5HwcPp6oa7YDZUd1ielQGtbly8cVSKAs7sodftmvoDl346PIJxP9iUPB+a5zZqN1pCY/uXsdtvjG0PLWnqB8fdXnXHWT4gWx4m4NgPpT2YR7l9SKDDuphtvctMT7h7Kolc8V5CqvHI2ZulVXMzYqTSbCMIrp6bahwenowWyMV7QadVo0w== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: c7168303-b35c-4161-f08e-08d9c5722fce X-MS-Exchange-CrossTenant-AuthSource: DB9PR08MB6748.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Dec 2021 17:40:47.1170 (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: /fLZ0ssYIIuEDh9U/GXqoJPsobKyzLXeWB1uoZm5fBBDTadC9OZnxy+8Fr3HYRZs0mb60fjeDYjZHaY+5eGkC5MbM7ZUaqzmSNrDDfoc14s= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB3964 Received-SPF: pass client-ip=40.107.21.133; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com 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, 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.29 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 on the way to implement internal-backup with fleecing scheme, which includes backup job copying from fleecing block driver node (which is target of copy-before-write filter) to final target of backup. This job doesn't need own filter, as fleecing block driver node is a kind of snapshot, it's immutable from reader point of view. Let's add a parameter for backup to not insert filter but instead unshare writes on source. This way backup job becomes a simple copying process. Signed-off-by: Vladimir Sementsov-Ogievskiy --- qapi/block-core.json | 11 ++++++- include/block/block_int.h | 1 + block/backup.c | 61 +++++++++++++++++++++++++++++++++++---- block/replication.c | 2 +- blockdev.c | 1 + 5 files changed, 69 insertions(+), 7 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index b47351dbac..6bac3b53fb 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1436,6 +1436,15 @@ # above node specified by @drive. If this option is not given, # a node name is autogenerated. (Since: 4.2) # +# @immutable-source: If true, assume source is immutable, and don't insert filter +# as no copy-before-write operations are needed. It will +# fail if there are existing writers on source node. +# Any attempt to add writer to source node during backup will +# also fail. @filter-node-name must not be set. +# If false, insert copy-before-write filter above source node +# (see also @filter-node-name parameter). +# Default is false. (Since 6.2) +# # @x-perf: Performance options. (Since 6.0) # # Features: @@ -1455,7 +1464,7 @@ '*on-source-error': 'BlockdevOnError', '*on-target-error': 'BlockdevOnError', '*auto-finalize': 'bool', '*auto-dismiss': 'bool', - '*filter-node-name': 'str', + '*filter-node-name': 'str', '*immutable-source': 'bool', '*x-perf': { 'type': 'BackupPerf', 'features': [ 'unstable' ] } } } diff --git a/include/block/block_int.h b/include/block/block_int.h index f4c75e8ba9..efb85c41de 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -1324,6 +1324,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, BitmapSyncMode bitmap_mode, bool compress, const char *filter_node_name, + bool immutable_source, BackupPerf *perf, BlockdevOnError on_source_error, BlockdevOnError on_target_error, diff --git a/block/backup.c b/block/backup.c index 21d5983779..9b4b35b21b 100644 --- a/block/backup.c +++ b/block/backup.c @@ -34,6 +34,14 @@ typedef struct BackupBlockJob { BlockDriverState *cbw; BlockDriverState *source_bs; BlockDriverState *target_bs; + BlockBackend *source_blk; + BlockBackend *target_blk; + /* + * Note that if backup runs with filter (immutable-source parameter is + * false), @cbw is set but @source_blk and @target_blk are NULL. + * Otherwise if backup runs without filter (immutable-source paramter is + * true), @cbw is NULL but @source_blk and @target_blk are set. + */ BdrvDirtyBitmap *sync_bitmap; @@ -102,7 +110,17 @@ static void backup_clean(Job *job) { BackupBlockJob *s = container_of(job, BackupBlockJob, common.job); block_job_remove_all_bdrv(&s->common); - bdrv_cbw_drop(s->cbw); + if (s->cbw) { + assert(!s->source_blk && !s->target_blk); + bdrv_cbw_drop(s->cbw); + } else { + block_copy_state_free(s->bcs); + s->bcs = NULL; + blk_unref(s->source_blk); + s->source_blk = NULL; + blk_unref(s->target_blk); + s->target_blk = NULL; + } } void backup_do_checkpoint(BlockJob *job, Error **errp) @@ -357,6 +375,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, BitmapSyncMode bitmap_mode, bool compress, const char *filter_node_name, + bool immutable_source, BackupPerf *perf, BlockdevOnError on_source_error, BlockdevOnError on_target_error, @@ -369,6 +388,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, int64_t cluster_size; BlockDriverState *cbw = NULL; BlockCopyState *bcs = NULL; + BlockBackend *source_blk = NULL, *target_blk = NULL; assert(bs); assert(target); @@ -377,6 +397,12 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, assert(sync_mode != MIRROR_SYNC_MODE_INCREMENTAL); assert(sync_bitmap || sync_mode != MIRROR_SYNC_MODE_BITMAP); + if (immutable_source && filter_node_name) { + error_setg(errp, "immutable-source and filter-node-name should not " + "be set simultaneously"); + return NULL; + } + if (bs == target) { error_setg(errp, "Source and target cannot be the same"); return NULL; @@ -451,9 +477,30 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, goto error; } - cbw = bdrv_cbw_append(bs, target, filter_node_name, &bcs, errp); - if (!cbw) { - goto error; + if (immutable_source) { + source_blk = blk_new_with_bs(bs, BLK_PERM_CONSISTENT_READ, + BLK_PERM_WRITE_UNCHANGED | + BLK_PERM_CONSISTENT_READ, errp); + if (!source_blk) { + goto error; + } + + target_blk = blk_new_with_bs(target, BLK_PERM_WRITE, + BLK_PERM_CONSISTENT_READ, errp); + if (!target_blk) { + goto error; + } + + bcs = block_copy_state_new(blk_root(source_blk), blk_root(target_blk), + NULL, false, errp); + if (!bcs) { + goto error; + } + } else { + cbw = bdrv_cbw_append(bs, target, filter_node_name, &bcs, errp); + if (!cbw) { + goto error; + } } cluster_size = block_copy_cluster_size(bcs); @@ -465,7 +512,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, } /* job->len is fixed, so we can't allow resize */ - job = block_job_create(job_id, &backup_job_driver, txn, cbw, + job = block_job_create(job_id, &backup_job_driver, txn, cbw ?: bs, 0, BLK_PERM_ALL, speed, creation_flags, cb, opaque, errp); if (!job) { @@ -475,6 +522,8 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, job->cbw = cbw; job->source_bs = bs; job->target_bs = target; + job->source_blk = source_blk; + job->target_blk = target_blk; job->on_source_error = on_source_error; job->on_target_error = on_target_error; job->sync_mode = sync_mode; @@ -502,6 +551,8 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, if (cbw) { bdrv_cbw_drop(cbw); } + blk_unref(source_blk); + blk_unref(target_blk); return NULL; } diff --git a/block/replication.c b/block/replication.c index 55c8f894aa..c6c4d3af85 100644 --- a/block/replication.c +++ b/block/replication.c @@ -590,7 +590,7 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode, s->backup_job = backup_job_create( NULL, s->secondary_disk->bs, s->hidden_disk->bs, 0, MIRROR_SYNC_MODE_NONE, NULL, 0, false, NULL, - &perf, + false, &perf, BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT, JOB_INTERNAL, backup_job_completed, bs, NULL, &local_err); diff --git a/blockdev.c b/blockdev.c index 0eb2823b1b..b6effd481d 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2900,6 +2900,7 @@ static BlockJob *do_backup_common(BackupCommon *backup, backup->sync, bmap, backup->bitmap_mode, backup->compress, backup->filter_node_name, + backup->immutable_source, &perf, backup->on_source_error, backup->on_target_error, From patchwork Wed Dec 22 17:40:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12697177 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id A3BFCC433EF for ; Wed, 22 Dec 2021 18:09:28 +0000 (UTC) Received: from localhost ([::1]:37802 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n063L-0006WX-Hl for qemu-devel@archiver.kernel.org; Wed, 22 Dec 2021 13:09:27 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52764) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n05by-0001lT-04; Wed, 22 Dec 2021 12:41:10 -0500 Received: from mail-eopbgr60133.outbound.protection.outlook.com ([40.107.6.133]:36163 helo=EUR04-DB3-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 1n05bv-0002Zq-N9; Wed, 22 Dec 2021 12:41:09 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BFJhPEqj9nL27xXv8cc2yiJgJefNR5tpWRLksywlaIqEMcTDVJPPe8ZwSYgTlJIwcK2QyUIV5YJzBYTNjI9H7VB/LHXRZGE6Zr+rM+fFNXTK7Kau/o1Ytm95QngtzFEG7x6noXDz2zT9pE20MmDfeBrjZyJmGJ7uraSYk/otz+XKzIafx4+ySQgGGNmMDsXQGFFrBPVm/KAS08v4nPkn6CD3d2P6v5hIdaEau6alM+ZuxXtJZ9Jav+U9xZYW5mIJKcl+tKtX7H1HDbelBaEL8MHRrapmQ6Y5YdfTfnXF5+cMfpH0aYUZLAa+6+GZDuQZq2ixlQZinzA5o7II0sc23Q== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QPwjRIVYM8sjXHMAQLSFxonXy5LKd26KIRqLHNniaMM=; b=iWIte64niKSm5HXqgnRT/+1You7BVTdmiJHlRPS8EJbkfM3RSGzylbj4FGFU2EzC0SDQNPVkZ4s+xEHequ5kBdkdYxx0UMcoYpyPrFrDDbdjrslRP6VFY2WbyTvRkMLOK+PatDZPOqrQrb/tpaEoTWQehExNc+Wsq1lKxK0OSEoheZOMFHXKTfSGKLHiHG2jqrZQ8xHX+/WpMemnDFHYZw/km0FF1L0mYYGKPJWdUs3YtX9QanhPpSMhS42LJPdO6Wc/hw7rEokvwBGz1N1DbQja8islMPNl4QPzf8j1sR6OoVlLV9Ao5fpKwh79WiQAw7q3c34OHtvu0a+OahSIRA== 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=QPwjRIVYM8sjXHMAQLSFxonXy5LKd26KIRqLHNniaMM=; b=owdvmkUAGik/nvyAT+OIff4Z3mmuICLtaP36FQYIOWtlENiN2haP3r1cYQa3t3yjMSHhHN4vkrR3nXMibjLWxW1INlO2QKdnrehP3dqf+dDrcSrA5IySwGApWi4IQK0wIFMSvlztSyjPj1LzoDJNhmrkdWzJ1Kd0UzcGhZywly0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) by DB8PR08MB3964.eurprd08.prod.outlook.com (2603:10a6:10:a4::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.17; Wed, 22 Dec 2021 17:40:48 +0000 Received: from DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e]) by DB9PR08MB6748.eurprd08.prod.outlook.com ([fe80::a89f:c7bc:b9f8:fc3e%6]) with mapi id 15.20.4823.019; Wed, 22 Dec 2021 17:40:48 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, nikita.lapshin@virtuozzo.com Subject: [PATCH v3 19/19] iotests/image-fleecing: test push backup with fleecing Date: Wed, 22 Dec 2021 18:40:18 +0100 Message-Id: <20211222174018.257550-20-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211222174018.257550-1-vsementsov@virtuozzo.com> References: <20211222174018.257550-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS8P250CA0017.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:330::22) To DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bea803cc-b2f8-4ce7-3249-08d9c5723059 X-MS-TrafficTypeDiagnostic: DB8PR08MB3964:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:580; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 925fUrvJbXEVxPi4nGdnh97Qe5az+OGdnQkR1hiwtOa/n+h1rGkBIzRWPsSAIUlG8IAwwIMHt6v7xJyOw2djKY6DpunLmuh6lVEsKi/8/x4N2hcVUnaXKMx3T1gaw/1ZAYAOYFdLgtRupmhKuDJTxInW2mDMszZw5fq6R/l+dzuwBkursy90r01H7bnnqVHTZoNdj/GDtSsCbeOZMBiWGt6TEilF1C1libLCBYXA2Kgp1fGYWlN8KAevana0j9lSFPXhktCLr8xYJhUk5fnU+mpFF8W1PGQ66IpCWhe3NtLGLbKGra8jtVmjUJhqUsaRpTbyMLvlnsh3m491g3wGqQ/1BOmXAwwFXcJ48YGNLf+es6rMnZIxoB0oNqfKUwoNhm6tVvsda9/i2RnKudIGHI31rAVm+8qmWRfHL/bEbL1tRlZJ4DIA1GhH0QjCvu9th28yV8SuOUJevLyNyHGvLUFJJL3KmoKyzsWDr6iB6sfH4w77yfOeRW/OKy38ELtgOJR2QcNPzTKM+CY5x1N7qz+yGSERhymOjJMOhIfnQDaxCm2JqEUgs/Vkipf+axNZQ3EzgWfVA5P4USN2cFyhr2ERtT+GdvCxPiHn25F88TmSPx8XdzbeKcwJpFvO0ZMT7s5QzsCC8FM/+fYOpwP1sFrDjdYSGnIUd85Kttrepov/Kki9nCM2eMlBvwVW+BrWVq7X82RRZkwq8T+NtRQowA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB9PR08MB6748.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(107886003)(6512007)(6506007)(26005)(316002)(52116002)(2906002)(186003)(508600001)(6486002)(6916009)(4326008)(2616005)(8936002)(5660300002)(6666004)(8676002)(1076003)(38100700002)(38350700002)(86362001)(83380400001)(66946007)(66476007)(66556008)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RvPrhMW3Qw/IVMYpdrjg6PlkEZ9W+Qtuzqyn1hhaGbtR7jpKVPjOruCmp1sMVkWsmSZIlIz9AeRVu9fwA9lkYXmvJoGX2rANagaf6zQI5BDNbBNdna6dw9/x4DhnqVLKz6CImm/Au7ykrHxeauS3R4o7cCKmGlH0wt82p3KXRxDsGDD60wUq15YZc29q+D11EM4AfF5OORijEhcOtaw9w0BmgSVvmB/WtZPL7TBTZYD5CzR/YOFD5E6IfyO1drbHHmDUKIsRlUpsH2hSMLoFn0pnRSWKPnFoxGV6p3LF8kgG8dyTrv1OVyfggjL4PH6b092Ne7KRDhkOJeHvbV7gTbAi+yBmHzMqHNefxFARq8YLYVV18K7b+Iw1xUU0Ao6mGERNTEgnwRDjyzJctHjeGxd+LgvzzqoVZzWLGP8ejYpsWCU/w+sUrxSxqi5/YTPkzzRw+WgyWuky+cQ4g6cpn7K2gdLo80bVRjG+RQSsdqYfPPD8zNTPBhR/99w9vyuqGk0ujC8wcXUwzFwz0/vd7Xg/KC8gkyO6VnU3uzg3Y5euFtHg8iz5CDf031cm4p7VWzJk2sV9JRXKTwcGnrZ0dR4YI1Z7QF1pONvIQrPeqLIhQwDju9LEcfmwHvRM4R0UVcV0JN7H0qNySR4m8nDTHLvfv526fJO//Gq5IAebb1DVozKc8V6ubz6v99Z4xxGBgpqzgqfI1hdRORxUb7I7dG5rQ5SGOvgMjIhTCQ42vh0Sb+CA1R7b1jRKdIAV6ak45c3/czAKZ/u+X5g0Mqv/5ki7Hu+ZRf2YZ6pKMtQnQMlYJqqSH3+/jjCxMEx2wglf85yMaL0iir80dbDrdlS2rrYbEH6hFo3A+FA2zWfBXsRpc252e3tDWvzBwgvB+RzRHcjkHkeRxb9FxhWNOw26EmG87uKEvtKpi2h0ha2YLBadB4MG6jtQPdZeJ/giXvtpD5ZGPj2CiutPe2N0O8YkDy8HbfDCIvryHAaklAwepp3iew+kkiGCtx+IRFyoCuj8BKFBab9Oab5o0L5ztZDSUOaJ6rIOkL8v7eJzCnsuuySfPVzs3kAW5mWU36ctuKmdYXu/aHNH0VBwBh9mCe3Ac42U723ue+RikfRe7scAxgTqJeGqBwBF94cGnkx1Qk/WbRsGLTBK+vXSiYYZV4QNAqFm5AawfmfFHCCUYAN6kNP9aCL5YtpbNJmFiJ/upJXWdNB84E97iWpKc3bH4Hj7gXvw0luz+PqRU1z6ty0hFIpcNj0/gsA+1THDrv8KadL+uYqCVOKvX7cpsMLFX/2qSS/UJA07HUUZIsH9QcmCZabycjw1T1wsXnBZHNFFG+3HTK17fHW/8Ysy+DFz+PuMGaA2gKpJq0Cj/zvsxLhFoBvIQnb2+RJtVNAYofXWu2fbA/oKIV6qhsMQ7dfKTb/vstjLx0EuEwWM44S7v8CGk6dFTbu1lUu8v2krGQwXDC+6XHecSWHmBUgtoKQrUlUU2w0VcL1rgotOUH5PBFpvfZcbOod2e8FnYK6pubyjWciRgGjhtDUQLEEFRn3TYH1VnxEEqUIabBETBEkIvTXt8Jfxa1vpDAhqIRcH1GwfC8RrU1963uBPmDxokNpEdGtLWSmrW2a7bikxa9xxA00YCjM/521iYgSMHvao9SoOnzPefPpMoyahPo4auMugnX47KA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: bea803cc-b2f8-4ce7-3249-08d9c5723059 X-MS-Exchange-CrossTenant-AuthSource: DB9PR08MB6748.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Dec 2021 17:40:48.0699 (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: wxXyq3+5Pz4OR9yY5b6NIJEchmAGIAvJ3JY+NP/vezAFU617fMRtVmf4zanGypWIWbjPwQ7vMB07ucht0e7O0oHQ2QMYQ114A68Icrxb5Nw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB3964 Received-SPF: pass client-ip=40.107.6.133; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com 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, 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.29 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" Add test for push backup with fleecing: - start fleecing with copy-before-write filter - start a backup job from temporary fleecing node to actual backup target Signed-off-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/tests/image-fleecing | 121 ++++++++++++++------ tests/qemu-iotests/tests/image-fleecing.out | 63 ++++++++++ 2 files changed, 152 insertions(+), 32 deletions(-) diff --git a/tests/qemu-iotests/tests/image-fleecing b/tests/qemu-iotests/tests/image-fleecing index 279047b19c..c72cfc70f2 100755 --- a/tests/qemu-iotests/tests/image-fleecing +++ b/tests/qemu-iotests/tests/image-fleecing @@ -49,9 +49,15 @@ remainder = [('0xd5', '0x108000', '32k'), # Right-end of partial-left [1] ('0xdc', '32M', '32k'), # Left-end of partial-right [2] ('0xcd', '0x3ff0000', '64k')] # patterns[3] -def do_test(use_cbw, use_fleecing_filter, base_img_path, - fleece_img_path, nbd_sock_path, vm, +def do_test(vm, use_cbw, use_fleecing_filter, base_img_path, + fleece_img_path, nbd_sock_path=None, + target_img_path=None, bitmap=False): + push_backup = target_img_path is not None + assert (nbd_sock_path is not None) != push_backup + if push_backup: + assert use_cbw + log('--- Setting up images ---') log('') @@ -65,6 +71,9 @@ def do_test(use_cbw, use_fleecing_filter, base_img_path, else: assert qemu_img('create', '-f', 'qcow2', fleece_img_path, '64M') == 0 + if push_backup: + assert qemu_img('create', '-f', 'qcow2', target_img_path, '64M') == 0 + for p in patterns: qemu_io('-f', iotests.imgfmt, '-c', 'write -P%s %s %s' % p, base_img_path) @@ -140,27 +149,45 @@ def do_test(use_cbw, use_fleecing_filter, base_img_path, export_node = 'fl-fleecing' if use_fleecing_filter else tmp_node - log('') - log('--- Setting up NBD Export ---') - log('') + if push_backup: + log('') + log('--- Starting actual backup ---') + log('') - nbd_uri = 'nbd+unix:///%s?socket=%s' % (export_node, nbd_sock_path) - log(vm.qmp('nbd-server-start', - {'addr': {'type': 'unix', - 'data': {'path': nbd_sock_path}}})) + log(vm.qmp('blockdev-add', **{ + 'driver': iotests.imgfmt, + 'node-name': 'target', + 'file': { + 'driver': 'file', + 'filename': target_img_path + } + })) + log(vm.qmp('blockdev-backup', device=export_node, + sync='full', target='target', + immutable_source=True, + job_id='push-backup', speed=1)) + else: + log('') + log('--- Setting up NBD Export ---') + log('') - log(vm.qmp('nbd-server-add', device=export_node)) + nbd_uri = 'nbd+unix:///%s?socket=%s' % (export_node, nbd_sock_path) + log(vm.qmp('nbd-server-start', + {'addr': { 'type': 'unix', + 'data': { 'path': nbd_sock_path } } })) - log('') - log('--- Sanity Check ---') - log('') + log(vm.qmp('nbd-server-add', device=export_node)) - for p in patterns + zeroes: - cmd = 'read -P%s %s %s' % p - log(cmd) - out, ret = qemu_io_pipe_and_status('-r', '-f', 'raw', '-c', cmd, nbd_uri) - if ret != 0: - print(out) + log('') + log('--- Sanity Check ---') + log('') + + for p in patterns + zeroes: + cmd = 'read -P%s %s %s' % p + log(cmd) + out, ret = qemu_io_pipe_and_status('-r', '-f', 'raw', '-c', cmd, nbd_uri) + if ret != 0: + print(out) log('') log('--- Testing COW ---') @@ -171,6 +198,20 @@ def do_test(use_cbw, use_fleecing_filter, base_img_path, log(cmd) log(vm.hmp_qemu_io(qom_path, cmd, qdev=True)) + if push_backup: + # Check that previous operations were done during backup, not after + result = vm.qmp('query-block-jobs') + if len(result['return']) != 1: + log('Backup finished too fast, COW is not tested') + + result = vm.qmp('block-job-set-speed', device='push-backup', speed=0) + assert result == {'return': {}} + + log(vm.event_wait(name='BLOCK_JOB_COMPLETED', + match={'data': {'device': 'push-backup'}}), + filters=[iotests.filter_qmp_event]) + log(vm.qmp('blockdev-del', node_name='target')) + log('') log('--- Verifying Data ---') log('') @@ -178,15 +219,19 @@ def do_test(use_cbw, use_fleecing_filter, base_img_path, for p in patterns + zeroes: cmd = 'read -P%s %s %s' % p log(cmd) - out, ret = qemu_io_pipe_and_status('-r', '-f', 'raw', '-c', cmd, nbd_uri) - if ret != 0: - print(out) + if push_backup: + assert qemu_io_silent('-r', '-c', cmd, target_img_path) == 0 + else: + out, ret = qemu_io_pipe_and_status('-r', '-f', 'raw', '-c', cmd, nbd_uri) + if ret != 0: + print(out) log('') log('--- Cleanup ---') log('') - log(vm.qmp('nbd-server-stop')) + if not push_backup: + log(vm.qmp('nbd-server-stop')) if use_cbw: log(vm.qmp('qom-set', path=qom_path, property='drive', value=src_node)) @@ -215,24 +260,36 @@ def do_test(use_cbw, use_fleecing_filter, base_img_path, log('Done') -def test(use_cbw, use_fleecing_filter, bitmap=False): +def test(use_cbw, use_fleecing_filter, + nbd_sock_path=None, target_img_path=None, bitmap=False): with iotests.FilePath('base.img') as base_img_path, \ iotests.FilePath('fleece.img') as fleece_img_path, \ - iotests.FilePath('nbd.sock', - base_dir=iotests.sock_dir) as nbd_sock_path, \ iotests.VM() as vm: - do_test(use_cbw, use_fleecing_filter, base_img_path, - fleece_img_path, nbd_sock_path, vm, bitmap=bitmap) + do_test(vm, use_cbw, use_fleecing_filter, base_img_path, + fleece_img_path, nbd_sock_path, target_img_path, + bitmap=bitmap) + +def test_pull(use_cbw, use_fleecing_filter, bitmap=False): + with iotests.FilePath('nbd.sock', + base_dir=iotests.sock_dir) as nbd_sock_path: + test(use_cbw, use_fleecing_filter, nbd_sock_path, None, bitmap=bitmap) + +def test_push(): + with iotests.FilePath('target.img') as target_img_path: + test(True, True, None, target_img_path) log('=== Test backup(sync=none) based fleecing ===\n') -test(False, False) +test_pull(False, False) log('=== Test cbw-filter based fleecing ===\n') -test(True, False) +test_pull(True, False) log('=== Test fleecing-format based fleecing ===\n') -test(True, True) +test_pull(True, True) log('=== Test fleecing-format based fleecing with bitmap ===\n') -test(True, True, bitmap=True) +test_pull(True, True, bitmap=True) + +log('=== Test push backup with fleecing ===\n') +test_push() diff --git a/tests/qemu-iotests/tests/image-fleecing.out b/tests/qemu-iotests/tests/image-fleecing.out index 62e1c1fe42..acfc89ff0e 100644 --- a/tests/qemu-iotests/tests/image-fleecing.out +++ b/tests/qemu-iotests/tests/image-fleecing.out @@ -293,3 +293,66 @@ read -P0xdc 32M 32k read -P0xcd 0x3ff0000 64k Done +=== Test push backup with fleecing === + +--- Setting up images --- + +Done + +--- Launching VM --- + +Done + +--- Setting up Fleecing Graph --- + +{"return": {}} +{"return": {}} +{"return": {}} +{"return": {}} + +--- Starting actual backup --- + +{"return": {}} +{"return": {}} + +--- Testing COW --- + +write -P0xab 0 64k +{"return": ""} +write -P0xad 0x00f8000 64k +{"return": ""} +write -P0x1d 0x2008000 64k +{"return": ""} +write -P0xea 0x3fe0000 64k +{"return": ""} +{"data": {"device": "push-backup", "len": 67108864, "offset": 67108864, "speed": 0, "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} +{"return": {}} + +--- Verifying Data --- + +read -P0x5d 0 64k +read -P0xd5 1M 64k +read -P0xdc 32M 64k +read -P0xcd 0x3ff0000 64k +read -P0 0x00f8000 32k +read -P0 0x2010000 32k +read -P0 0x3fe0000 64k + +--- Cleanup --- + +{"return": {}} +{"return": {}} +{"return": {}} +{"return": {}} + +--- Confirming writes --- + +read -P0xab 0 64k +read -P0xad 0x00f8000 64k +read -P0x1d 0x2008000 64k +read -P0xea 0x3fe0000 64k +read -P0xd5 0x108000 32k +read -P0xdc 32M 32k +read -P0xcd 0x3ff0000 64k + +Done