From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 51C721FF39E for ; Mon, 10 Jun 2024 14:59:59 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 54A561760B; Mon, 10 Jun 2024 15:00:21 +0200 (CEST) From: Fiona Ebner To: pve-devel@lists.proxmox.com Date: Mon, 10 Jun 2024 14:59:42 +0200 Message-Id: <20240610125942.116985-8-f.ebner@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240610125942.116985-1-f.ebner@proxmox.com> References: <20240610125942.116985-1-f.ebner@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.059 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] [RFC qemu 7/7] block/backup: set callback for cbw errors 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: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" The callback is invoked when cbw is configured to not break the guest write and will abort a backup job immediately. Currently the backup has to wait for the rest of the block copy operation to finish before checking the cbw error state. Signed-off-by: Fiona Ebner --- Note for testers: if e.g. the PBS is compeletly unreachable, the backup job still will need to wait until the in-flight request is aborted after 15 minutes. But the guest writes should be fast again. block/backup.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/block/backup.c b/block/backup.c index ba153110d3..43d34ce4c2 100644 --- a/block/backup.c +++ b/block/backup.c @@ -32,6 +32,45 @@ static const BlockJobDriver backup_job_driver; +typedef struct { + Job *job; + int ret; +} BackupOnCbwError; + +static void backup_on_cbw_error_cb_bh(void *opaque) +{ + BackupOnCbwError *data = opaque; + if (data->job) { + WITH_JOB_LOCK_GUARD() { + if (!job_is_completed_locked(data->job)) { + error_report("backup was cancelled because of copy-before-write error: %s", + strerror(-data->ret)); + job_cancel_locked(data->job, true); + } + } + } else { + error_report("backup_on_cbw_error_cb_bh: no job! Error: %s", strerror(-data->ret)); + } + + g_free(data); +} + +static void backup_on_cbw_error_cb(void *opaque, int ret) +{ + BackupOnCbwError *data = g_new0(BackupOnCbwError, 1); + data->job = opaque; + data->ret = ret; + + /* + * backup_cancel() cannot run in coroutine context. + */ + if (qemu_in_coroutine()) { + aio_bh_schedule_oneshot(qemu_get_aio_context(), backup_on_cbw_error_cb_bh, data); + } else { + backup_on_cbw_error_cb_bh(data); + } +} + static void backup_cleanup_sync_bitmap(BackupBlockJob *job, int ret) { BdrvDirtyBitmap *bm; @@ -477,6 +516,8 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, goto error; } + bdrv_cbw_set_error_cb(cbw, backup_on_cbw_error_cb, job); + job->cbw = cbw; job->source_bs = bs; job->target_bs = target; -- 2.39.2 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel