From 1ff68cf9b10d9064dbdb10b840000ad161f734bd Mon Sep 17 00:00:00 2001 From: Rene Peinthor Date: Tue, 21 Jan 2025 11:10:17 +0100 Subject: [PATCH] linstor: Fix ZFS snapshot backup (#10219) Linstor plugin used the wrong zfs dataset path to hide/unhide the snapshot device. Also don't use the full path to the zfs binary. --- plugins/storage/volume/linstor/CHANGELOG.md | 6 ++++++ .../LinstorBackupSnapshotCommandWrapper.java | 14 ++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/plugins/storage/volume/linstor/CHANGELOG.md b/plugins/storage/volume/linstor/CHANGELOG.md index 957377e2978..419a7f983ee 100644 --- a/plugins/storage/volume/linstor/CHANGELOG.md +++ b/plugins/storage/volume/linstor/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to Linstor CloudStack plugin will be documented in this file The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2025-01-20] + +### Fixed + +- Volume snapshots on zfs used the wrong dataset path to hide/unhide snapdev + ## [2024-12-13] ### Fixed diff --git a/plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LinstorBackupSnapshotCommandWrapper.java b/plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LinstorBackupSnapshotCommandWrapper.java index a210d53d7e7..a572759c35a 100644 --- a/plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LinstorBackupSnapshotCommandWrapper.java +++ b/plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LinstorBackupSnapshotCommandWrapper.java @@ -45,11 +45,17 @@ public final class LinstorBackupSnapshotCommandWrapper { private static final Logger s_logger = Logger.getLogger(LinstorBackupSnapshotCommandWrapper.class); + private static String zfsDatasetName(String zfsFullSnapshotUrl) { + String zfsFullPath = zfsFullSnapshotUrl.substring(6); + int atPos = zfsFullPath.indexOf('@'); + return atPos >= 0 ? zfsFullPath.substring(0, atPos) : zfsFullPath; + } + private String zfsSnapdev(boolean hide, String zfsUrl) { - Script script = new Script("/usr/bin/zfs", Duration.millis(5000)); + Script script = new Script("zfs", Duration.millis(5000)); script.add("set"); script.add("snapdev=" + (hide ? "hidden" : "visible")); - script.add(zfsUrl.substring(6)); // cutting zfs:// + script.add(zfsDatasetName(zfsUrl)); // cutting zfs:// and @snapshotname return script.execute(); } @@ -133,10 +139,10 @@ public final class LinstorBackupSnapshotCommandWrapper s_logger.info("Src: " + srcPath + " | " + src.getName()); if (srcPath.startsWith("zfs://")) { zfsHidden = true; - if (zfsSnapdev(false, srcPath) != null) { + if (zfsSnapdev(false, src.getPath()) != null) { return new CopyCmdAnswer("Unable to unhide zfs snapshot device."); } - srcPath = "/dev/" + srcPath.substring(6); + srcPath = "/dev/zvol/" + srcPath.substring(6); } secondaryPool = storagePoolMgr.getStoragePoolByURI(dstDataStore.getUrl());