From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id DE3F190DF4 for ; Thu, 25 Jan 2024 15:42:25 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id BE8CC1B961 for ; Thu, 25 Jan 2024 15:41:55 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Thu, 25 Jan 2024 15:41:55 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id C88FA492A6 for ; Thu, 25 Jan 2024 15:41:54 +0100 (CET) From: Fiona Ebner To: pve-devel@lists.proxmox.com Date: Thu, 25 Jan 2024 15:41:42 +0100 Message-Id: <20240125144149.216064-7-f.ebner@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240125144149.216064-1-f.ebner@proxmox.com> References: <20240125144149.216064-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.075 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [HACK qemu 06/13] block/{copy-before-write, snapshot-access}: implement bdrv_co_get_info driver callback X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Jan 2024 14:42:25 -0000 In preparation to fix an issue for backup fleecing where discarding the source would lead to an assertion failure when the fleecing image has larger granularity than the backup target. Signed-off-by: Fiona Ebner --- Still need to wait on a response from upstream. For now this hack, so that the RFC as a whole doesn't have to wait. block/copy-before-write.c | 30 ++++++++++++++++++++++++++++++ block/snapshot-access.c | 7 +++++++ 2 files changed, 37 insertions(+) diff --git a/block/copy-before-write.c b/block/copy-before-write.c index 87f047ad5f..961e7439ad 100644 --- a/block/copy-before-write.c +++ b/block/copy-before-write.c @@ -322,6 +322,35 @@ cbw_co_snapshot_block_status(BlockDriverState *bs, return ret; } +static int coroutine_fn +cbw_co_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) +{ + BDRVCopyBeforeWriteState *s = bs->opaque; + + BlockDriverInfo local_bdi; + int64_t cluster_size = 0; + + int ret, ret2; + + ret = bdrv_co_get_info(bs->file->bs, &local_bdi); + if (ret == 0) { + cluster_size = MAX(cluster_size, local_bdi.cluster_size); + } + + ret2 = bdrv_co_get_info(s->target->bs, &local_bdi); + if (ret2 == 0) { + cluster_size = MAX(cluster_size, local_bdi.cluster_size); + } + + if (ret != 0 && ret2 != 0) { + return ret; + } + + bdi->cluster_size = cluster_size; + + return 0; +} + static int coroutine_fn GRAPH_RDLOCK cbw_co_pdiscard_snapshot(BlockDriverState *bs, int64_t offset, int64_t bytes) { @@ -531,6 +560,7 @@ BlockDriver bdrv_cbw_filter = { .bdrv_co_preadv_snapshot = cbw_co_preadv_snapshot, .bdrv_co_pdiscard_snapshot = cbw_co_pdiscard_snapshot, .bdrv_co_snapshot_block_status = cbw_co_snapshot_block_status, + .bdrv_co_get_info = cbw_co_get_info, .bdrv_refresh_filename = cbw_refresh_filename, diff --git a/block/snapshot-access.c b/block/snapshot-access.c index 67ea339da9..5aa20aaa1f 100644 --- a/block/snapshot-access.c +++ b/block/snapshot-access.c @@ -25,6 +25,7 @@ #include "sysemu/block-backend.h" #include "qemu/cutils.h" #include "block/block_int.h" +#include "block/copy-before-write.h" static int coroutine_fn GRAPH_RDLOCK snapshot_access_co_preadv_part(BlockDriverState *bs, @@ -72,6 +73,11 @@ snapshot_access_co_pwritev_part(BlockDriverState *bs, return -ENOTSUP; } +static int coroutine_fn +snapshot_access_co_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) +{ + return bdrv_co_get_info(bs->file->bs, bdi); +} static void snapshot_access_refresh_filename(BlockDriverState *bs) { @@ -118,6 +124,7 @@ BlockDriver bdrv_snapshot_access_drv = { .bdrv_co_pwrite_zeroes = snapshot_access_co_pwrite_zeroes, .bdrv_co_pdiscard = snapshot_access_co_pdiscard, .bdrv_co_block_status = snapshot_access_co_block_status, + .bdrv_co_get_info = snapshot_access_co_get_info, .bdrv_refresh_filename = snapshot_access_refresh_filename, -- 2.39.2