[pbs-devel] [PATCH proxmox-backup] tape: fix encryption on certain tape drives

Dominik Csapak d.csapak at proxmox.com
Mon Dec 15 14:59:44 CET 2025


For most SCSI commands, we have to preallocate a buffer for sg_utils to
write into, and the SCSI commands get the buffer size as parameter so
that the tape know how much data it can send.

It seems that some tape drives only allow aligned buffer sizes, though
it's not clear if it has to aligned to 512 or 4096 bytes.

In case of the tape encryption pages, we used 8192 + 4 bytes for some
reason, which tripped those tape drives up and they returned an error
instead of valid data.

Every other instance of our commands use aligned buffer sizes, so use
them here too to increase compatibility.

Tested on our LTO9 tape changer, which works with both values correctly.

This was encountered by a customer in an enterprise ticket.

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 pbs-tape/src/sg_tape/encryption.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pbs-tape/src/sg_tape/encryption.rs b/pbs-tape/src/sg_tape/encryption.rs
index c24a6c658..9390dff7d 100644
--- a/pbs-tape/src/sg_tape/encryption.rs
+++ b/pbs-tape/src/sg_tape/encryption.rs
@@ -134,7 +134,7 @@ fn sg_spout_set_encryption<F: AsRawFd>(
 // Warning: this blocks and fails if there is no media loaded
 #[allow(clippy::vec_init_then_push)]
 fn sg_spin_data_encryption_status<F: AsRawFd>(file: &mut F) -> Result<Vec<u8>, Error> {
-    let allocation_len: u32 = 8192 + 4;
+    let allocation_len: u32 = 8192;
 
     let mut sg_raw = SgRaw::new(file, allocation_len as usize)?;
 
@@ -163,7 +163,7 @@ fn sg_spin_data_encryption_status<F: AsRawFd>(file: &mut F) -> Result<Vec<u8>, E
 // Warning: this blocks and fails if there is no media loaded
 #[allow(clippy::vec_init_then_push)]
 fn sg_spin_data_encryption_caps<F: AsRawFd>(file: &mut F) -> Result<Vec<u8>, Error> {
-    let allocation_len: u32 = 8192 + 4;
+    let allocation_len: u32 = 8192;
 
     let mut sg_raw = SgRaw::new(file, allocation_len as usize)?;
 
-- 
2.47.3





More information about the pbs-devel mailing list