From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id AC77A1FF0AF for ; Fri, 06 Nov 2026 10:42:51 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 6642C21536; Fri, 06 Nov 2026 10:42:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stuttgart.de; s=s1022; t=1793957702; bh=3SNXn9uO3P4DHrAvoQ2hiSgqQLQmCy5rgbJBX2sTvIY=; h=From:To:Cc:Subject:Date:From; b=ierkYMIahydbM9v4OIuy/ziJKv+eTP/FNY9nLRAv94FROYd21qq7zIyHT1GchPU+C Cl3wtMasrtrr7RuZL6T0nPESYpXGTU5Fp6r5xT/qyo5JOfEGMxQk15Uiivc8rn01Be qBZo369glfMPrNtqrlSlbYYtDj0i+wQGrTnTkzimWiVpUuta7id/duT2IOrrFfv/OP VVhVr0diUzmX5/9xoroEFK4z8G2edB3WG/eW9rimNj0Cwg9T8GJVcOHSmoH8yyoFqo weTHGQdA1MdnEpntDADrUnB/TZtRDMOPuo6vPHBzqhL5rcZ18cRaR3JQZOB98Uf0Md 8fS+RODSsqzfQ== From: Jakob-Tobias Winter To: pbs-devel@lists.proxmox.com Subject: [PATCH proxmox-backup] fix #7964: tape: make barcode-label task abortable Date: Fri, 6 Nov 2026 10:33:22 +0100 Message-ID: <20261106093422.1637066-2-tobias@stuttgart.de> X-Mailer: git-send-email 2.53.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain DMARC_PASS -0.1 DMARC pass policy RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_PASS -0.001 SPF: HELO matches SPF record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: XFF75IFYYOGUORBE5Y2AOVK33I3XLQE2 X-Message-ID-Hash: XFF75IFYYOGUORBE5Y2AOVK33I3XLQE2 X-MailFrom: prvs=957be33b11=tobias@stuttgart.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Jakob-Tobias Winter X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The barcode-label-media worker never checked whether an abort was requested, so pressing stop in the GUI had no effect and the task kept loading and labeling every unlabeled tape in the changer. Check for an abort request before each tape is loaded, and again before the label is written, since loading the media can take a while. A load or label write that is already running cannot be interrupted, so those operations still run to completion. Signed-off-by: Jakob-Tobias Winter --- Tested on PBS 4.2.8 (patch applied on top of 4.2.8-1) with a real tape library: stopping the barcode-label task now aborts after the current load, without labeling the loaded tape or loading the next one. src/api2/tape/drive.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/api2/tape/drive.rs b/src/api2/tape/drive.rs index 79b3b269c..3d8cca128 100644 --- a/src/api2/tape/drive.rs +++ b/src/api2/tape/drive.rs @@ -30,6 +30,7 @@ use pbs_tape::{ sg_tape::tape_alert_flags_critical, }; use proxmox_rest_server::WorkerTask; +use proxmox_worker_task::WorkerTaskContext; use crate::{ api2::tape::restore::{fast_catalog_restore, restore_media}, @@ -1040,13 +1041,14 @@ pub fn barcode_label_media( drive.clone(), "barcode-label-media", Some(drive.clone()), - move |_worker, config| barcode_label_media_worker(drive, &config, pool), + move |worker, config| barcode_label_media_worker(&worker, drive, &config, pool), )?; Ok(upid_str.into()) } fn barcode_label_media_worker( + worker: &WorkerTask, drive: String, drive_config: &SectionConfigData, pool: Option, @@ -1076,6 +1078,10 @@ fn barcode_label_media_worker( continue; } + // loading and labeling a tape cannot be interrupted, so check + // before starting with the next one + worker.check_abort()?; + inventory.reload()?; match inventory.find_media_by_label_text(&label_text) { Ok(Some(_)) => { @@ -1112,6 +1118,9 @@ fn barcode_label_media_worker( } } + // loading the media can take a while, so check again before writing the label + worker.check_abort()?; + let ctime = proxmox_time::epoch_i64(); let label = MediaLabel { label_text: label_text.to_string(), -- 2.53.0