]> git.proxmox.com Git - proxmox-backup.git/commitdiff
api2/node/disks/zfs: instantiate import service
authorStoiko Ivanov <s.ivanov@proxmox.com>
Wed, 16 Sep 2020 12:14:18 +0000 (14:14 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 30 Sep 2020 06:43:38 +0000 (08:43 +0200)
When creating a new zpool for a datastore, also instantiate an
import-unit for it. This helps in cases where '/etc/zfs/zool.cache'
get corrupted and thus the pool is not imported upon boot.

This patch needs the corresponding addition of 'zfs-import@.service' in
the zfsonlinux repository.

Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
src/api2/node/disks/zfs.rs

index c5d6f6a60dab9e63bab680cc1c4785408999191c..0f0e4220d57e064984037d0db71e56df6e41f9d3 100644 (file)
@@ -25,6 +25,8 @@ use crate::server::WorkerTask;
 
 use crate::api2::types::*;
 
+use crate::tools::systemd;
+
 pub const DISK_ARRAY_SCHEMA: Schema = ArraySchema::new(
     "Disk name list.", &BLOCKDEVICE_NAME_SCHEMA)
     .schema();
@@ -355,6 +357,9 @@ pub fn create_zpool(
             let output = crate::tools::run_command(command, None)?;
             worker.log(output);
 
+            let import_unit = format!("zfs-import@{}.service", systemd::escape_unit(&name, false));
+            systemd::enable_unit(&import_unit)?;
+
             if let Some(compression) = compression {
                 let mut command = std::process::Command::new("zfs");
                 command.args(&["set", &format!("compression={}", compression), &name]);