all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Jakob-Tobias Winter <tobias@stuttgart.de>
To: pbs-devel@lists.proxmox.com
Cc: Jakob-Tobias Winter <tobias@stuttgart.de>
Subject: [PATCH proxmox-backup] fix #7964: tape: make barcode-label task abortable
Date: Fri,  6 Nov 2026 10:33:22 +0100	[thread overview]
Message-ID: <20261106093422.1637066-2-tobias@stuttgart.de> (raw)

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 <tobias@stuttgart.de>
---
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<String>,
@@ -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




                 reply	other threads:[~2026-11-06  9:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261106093422.1637066-2-tobias@stuttgart.de \
    --to=tobias@stuttgart.de \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal