Skip to content

Commit 1ff68cf

Browse files
authored
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.
1 parent 70776b0 commit 1ff68cf

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

plugins/storage/volume/linstor/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to Linstor CloudStack plugin will be documented in this file
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [2025-01-20]
9+
10+
### Fixed
11+
12+
- Volume snapshots on zfs used the wrong dataset path to hide/unhide snapdev
13+
814
## [2024-12-13]
915

1016
### Fixed

plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LinstorBackupSnapshotCommandWrapper.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,17 @@ public final class LinstorBackupSnapshotCommandWrapper
4545
{
4646
private static final Logger s_logger = Logger.getLogger(LinstorBackupSnapshotCommandWrapper.class);
4747

48+
private static String zfsDatasetName(String zfsFullSnapshotUrl) {
49+
String zfsFullPath = zfsFullSnapshotUrl.substring(6);
50+
int atPos = zfsFullPath.indexOf('@');
51+
return atPos >= 0 ? zfsFullPath.substring(0, atPos) : zfsFullPath;
52+
}
53+
4854
private String zfsSnapdev(boolean hide, String zfsUrl) {
49-
Script script = new Script("/usr/bin/zfs", Duration.millis(5000));
55+
Script script = new Script("zfs", Duration.millis(5000));
5056
script.add("set");
5157
script.add("snapdev=" + (hide ? "hidden" : "visible"));
52-
script.add(zfsUrl.substring(6)); // cutting zfs://
58+
script.add(zfsDatasetName(zfsUrl)); // cutting zfs:// and @snapshotname
5359
return script.execute();
5460
}
5561

@@ -133,10 +139,10 @@ public CopyCmdAnswer execute(LinstorBackupSnapshotCommand cmd, LibvirtComputingR
133139
s_logger.info("Src: " + srcPath + " | " + src.getName());
134140
if (srcPath.startsWith("zfs://")) {
135141
zfsHidden = true;
136-
if (zfsSnapdev(false, srcPath) != null) {
142+
if (zfsSnapdev(false, src.getPath()) != null) {
137143
return new CopyCmdAnswer("Unable to unhide zfs snapshot device.");
138144
}
139-
srcPath = "/dev/" + srcPath.substring(6);
145+
srcPath = "/dev/zvol/" + srcPath.substring(6);
140146
}
141147

142148
secondaryPool = storagePoolMgr.getStoragePoolByURI(dstDataStore.getUrl());

0 commit comments

Comments
 (0)