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 51DDE1FF163 for ; Thu, 7 Nov 2024 17:52:11 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 9F50134AE5; Thu, 7 Nov 2024 17:51:55 +0100 (CET) From: Fiona Ebner To: pve-devel@lists.proxmox.com Date: Thu, 7 Nov 2024 17:51:16 +0100 Message-Id: <20241107165146.125935-5-f.ebner@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241107165146.125935-1-f.ebner@proxmox.com> References: <20241107165146.125935-1-f.ebner@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.058 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 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH qemu v3 04/34] PVE backup: save device name in device info structure 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 device name needs to be queried while holding the graph read lock and since it doesn't change during the whole operation, just get it once during setup and avoid the need to query it again in different places. Also in preparation to use it more often in error messages and for the upcoming external backup access API. Signed-off-by: Fiona Ebner --- No changes in v3. pve-backup.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/pve-backup.c b/pve-backup.c index 051ebffe48..33c23e53c2 100644 --- a/pve-backup.c +++ b/pve-backup.c @@ -94,6 +94,7 @@ typedef struct PVEBackupDevInfo { size_t size; uint64_t block_size; uint8_t dev_id; + char* device_name; int completed_ret; // INT_MAX if not completed BdrvDirtyBitmap *bitmap; BlockDriverState *target; @@ -327,6 +328,8 @@ static void coroutine_fn pvebackup_co_complete_stream(void *opaque) } di->bs = NULL; + g_free(di->device_name); + di->device_name = NULL; assert(di->target == NULL); @@ -621,9 +624,6 @@ static void create_backup_jobs_bh(void *opaque) { BlockDriverState *source_bs = di->bs; bool discard_source = false; - bdrv_graph_co_rdlock(); - const char *job_id = bdrv_get_device_name(di->bs); - bdrv_graph_co_rdunlock(); if (di->fleecing.bs) { if (setup_snapshot_access(di, &local_err) < 0) { error_setg(errp, "setting up snapshot access for fleecing failed: %s", @@ -654,7 +654,7 @@ static void create_backup_jobs_bh(void *opaque) { } BlockJob *job = backup_job_create( - job_id, source_bs, di->target, backup_state.speed, sync_mode, di->bitmap, + di->device_name, source_bs, di->target, backup_state.speed, sync_mode, di->bitmap, bitmap_mode, false, discard_source, NULL, &perf, BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT, JOB_DEFAULT, pvebackup_complete_cb, di, backup_state.txn, &local_err); @@ -751,6 +751,7 @@ static GList coroutine_fn GRAPH_RDLOCK *get_device_info( } PVEBackupDevInfo *di = g_new0(PVEBackupDevInfo, 1); di->bs = bs; + di->device_name = g_strdup(bdrv_get_device_name(bs)); if (fleecing && device_uses_fleecing(*d)) { g_autofree gchar *fleecing_devid = g_strconcat(*d, "-fleecing", NULL); @@ -789,6 +790,7 @@ static GList coroutine_fn GRAPH_RDLOCK *get_device_info( PVEBackupDevInfo *di = g_new0(PVEBackupDevInfo, 1); di->bs = bs; + di->device_name = g_strdup(bdrv_get_device_name(bs)); di_list = g_list_append(di_list, di); } } @@ -956,9 +958,6 @@ UuidInfo coroutine_fn *qmp_backup( di->block_size = dump_cb_block_size; - bdrv_graph_co_rdlock(); - const char *devname = bdrv_get_device_name(di->bs); - bdrv_graph_co_rdunlock(); PBSBitmapAction action = PBS_BITMAP_ACTION_NOT_USED; size_t dirty = di->size; @@ -973,7 +972,8 @@ UuidInfo coroutine_fn *qmp_backup( } action = PBS_BITMAP_ACTION_NEW; } else { - expect_only_dirty = proxmox_backup_check_incremental(pbs, devname, di->size) != 0; + expect_only_dirty = + proxmox_backup_check_incremental(pbs, di->device_name, di->size) != 0; } if (expect_only_dirty) { @@ -997,7 +997,8 @@ UuidInfo coroutine_fn *qmp_backup( } } - int dev_id = proxmox_backup_co_register_image(pbs, devname, di->size, expect_only_dirty, errp); + int dev_id = proxmox_backup_co_register_image(pbs, di->device_name, di->size, + expect_only_dirty, errp); if (dev_id < 0) { goto err_mutex; } @@ -1009,7 +1010,7 @@ UuidInfo coroutine_fn *qmp_backup( di->dev_id = dev_id; PBSBitmapInfo *info = g_malloc(sizeof(*info)); - info->drive = g_strdup(devname); + info->drive = g_strdup(di->device_name); info->action = action; info->size = di->size; info->dirty = dirty; @@ -1034,10 +1035,7 @@ UuidInfo coroutine_fn *qmp_backup( goto err_mutex; } - bdrv_graph_co_rdlock(); - const char *devname = bdrv_get_device_name(di->bs); - bdrv_graph_co_rdunlock(); - di->dev_id = vma_writer_register_stream(vmaw, devname, di->size); + di->dev_id = vma_writer_register_stream(vmaw, di->device_name, di->size); if (di->dev_id <= 0) { error_set(errp, ERROR_CLASS_GENERIC_ERROR, "register_stream failed"); @@ -1148,6 +1146,9 @@ err: bdrv_co_unref(di->target); } + g_free(di->device_name); + di->device_name = NULL; + g_free(di); } g_list_free(di_list); -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel