From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <d.csapak@proxmox.com>
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 F2E5490951
 for <pbs-devel@lists.proxmox.com>; Mon, 12 Feb 2024 12:07:27 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id D5C0B17868
 for <pbs-devel@lists.proxmox.com>; Mon, 12 Feb 2024 12:06:57 +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 <pbs-devel@lists.proxmox.com>; Mon, 12 Feb 2024 12:06:57 +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 129794787B
 for <pbs-devel@lists.proxmox.com>; Mon, 12 Feb 2024 12:06:57 +0100 (CET)
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Date: Mon, 12 Feb 2024 12:06:56 +0100
Message-Id: <20240212110656.1333514-1-d.csapak@proxmox.com>
X-Mailer: git-send-email 2.30.2
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.020 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: [pbs-devel] [PATCH proxmox-backup] fix #5229: tape: remove max
 sequence number limit
X-BeenThere: pbs-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox Backup Server development discussion
 <pbs-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pbs-devel/>
List-Post: <mailto:pbs-devel@lists.proxmox.com>
List-Help: <mailto:pbs-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Mon, 12 Feb 2024 11:07:28 -0000

The idea was to limit the number of tapes in a media set, but this was
not enforced when adding a medium to a media set, only on read/parsing
the inventory. With that, it is possible to create media sets greater
than the limit which in turn blocks access to most functions via
api/cli/gui due to the check.

Instead of enforcing an arbitrary limit, simply warn on creation when
the media-set is very large (20).

For LTO-4 this would incur a restore time of at least 38 hours and for
LTO-9 250 hours.

We already have a section in the docs where we tell about the
disadvantages of large media sets.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
We could of course alternatively increase the limit, and really enforce
it on medium allocation, but i honestly don't see a point to that,
because we'd have to set the limit to something higher than 100 to not
break existing media-sets. And at that point it doesn't matter anymore IMO.

 src/tape/media_set.rs       | 10 ----------
 src/tape/pool_writer/mod.rs |  8 ++++++++
 2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/src/tape/media_set.rs b/src/tape/media_set.rs
index 8c08efd9..894c8ae3 100644
--- a/src/tape/media_set.rs
+++ b/src/tape/media_set.rs
@@ -13,8 +13,6 @@ pub struct MediaSet {
 }
 
 impl MediaSet {
-    pub const MEDIA_SET_MAX_SEQ_NR: u64 = 100;
-
     #[allow(clippy::new_without_default)]
     pub fn new() -> Self {
         let uuid = Uuid::generate();
@@ -41,14 +39,6 @@ impl MediaSet {
     }
 
     pub fn insert_media(&mut self, uuid: Uuid, seq_nr: u64) -> Result<(), Error> {
-        if seq_nr > Self::MEDIA_SET_MAX_SEQ_NR {
-            bail!(
-                "media set sequence number to large in media set {} ({} > {})",
-                self.uuid.to_string(),
-                seq_nr,
-                Self::MEDIA_SET_MAX_SEQ_NR
-            );
-        }
         let seq_nr = seq_nr as usize;
         if self.media_list.len() > seq_nr {
             if self.media_list[seq_nr].is_some() {
diff --git a/src/tape/pool_writer/mod.rs b/src/tape/pool_writer/mod.rs
index f1224bdd..b6cd5027 100644
--- a/src/tape/pool_writer/mod.rs
+++ b/src/tape/pool_writer/mod.rs
@@ -272,6 +272,14 @@ impl PoolWriter {
 
         let media_set = media.media_set_label().unwrap();
 
+        if is_new_media && media_set.seq_nr >= 20 {
+            task_warn!(
+                worker,
+                "large media-set detected ({}), consider using a different allocation policy",
+                media_set.seq_nr
+            );
+        }
+
         drive.assert_encryption_mode(media_set.encryption_key_fingerprint.is_some())?;
 
         self.status = Some(PoolWriterState {
-- 
2.30.2