]> git.proxmox.com Git - pve-storage.git/blobdiff - PVE/Storage/CephFSPlugin.pm
btrfs: do not reuse DirPlugins activate_storage directrly
[pve-storage.git] / PVE / Storage / CephFSPlugin.pm
index 843af88adfddb0c150a5f7a08eead01c2b48362a..2aaa45083be54f944566667b8950cf7c342355db 100644 (file)
@@ -7,11 +7,12 @@ use IO::File;
 use Net::IP;
 use File::Path;
 
-use PVE::Tools qw(run_command file_set_contents);
+use PVE::CephConfig;
+use PVE::JSONSchema qw(get_standard_option);
 use PVE::ProcFSTools;
 use PVE::Storage::Plugin;
-use PVE::JSONSchema qw(get_standard_option);
-use PVE::CephConfig;
+use PVE::Systemd;
+use PVE::Tools qw(run_command file_set_contents);
 
 use base qw(PVE::Storage::Plugin);
 
@@ -37,33 +38,13 @@ sub cephfs_is_mounted {
     return undef;
 }
 
-
-# FIXME: duplicate of api/diskmanage one, move to common helper (pve-common's
-#        Tools or Systemd ?)
-sub systemd_escape {
-    my ($val, $is_path) = @_;
-
-    # NOTE: this is not complete, but enough for our needs. normally all
-    # characters which are not alpha-numerical, '.' or '_' would need escaping
-    $val =~ s/\-/\\x2d/g;
-
-    if ($is_path) {
-       $val =~ s/^\///g;
-       $val =~ s/\/$//g;
-    }
-    $val =~ s/\//-/g;
-
-    return $val;
-}
-
-# FIXME: remove in PVE 7.0 where systemd is recent enough to not have those
-#        local-fs/remote-fs dependency cycles generated for _netdev mounts...
+# FIXME: remove once it's possible to specify _netdev for fuse.ceph mounts
 sub systemd_netmount {
     my ($where, $type, $what, $opts) = @_;
 
 # don't do default deps, systemd v241 generator produces ordering deps on both
 # local-fs(-pre) and remote-fs(-pre) targets if we use the required _netdev
-# option. Over thre corners this gets us an ordering cycle on shutdown, which
+# option. Over three corners this gets us an ordering cycle on shutdown, which
 # may make shutdown hang if the random cycle breaking hits the "wrong" unit to
 # delete.
     my $unit =  <<"EOF";
@@ -83,10 +64,14 @@ Type=${type}
 Options=${opts}
 EOF
 
-    my $unit_fn = systemd_escape($where, 1) . ".mount";
+    my $unit_fn = PVE::Systemd::escape_unit($where, 1) . ".mount";
     my $unit_path = "/run/systemd/system/$unit_fn";
+    my $daemon_needs_reload = -e $unit_path;
 
     file_set_contents($unit_path, $unit);
+
+    run_command(['systemctl', 'daemon-reload'], errmsg => "daemon-reload error")
+       if $daemon_needs_reload;
     run_command(['systemctl', 'start', $unit_fn], errmsg => "mount error");
 
 }
@@ -161,6 +146,7 @@ sub options {
        fuse => { optional => 1 },
        bwlimit => { optional => 1 },
        maxfiles => { optional => 1 },
+       'prune-backups' => { optional => 1 },
     };
 }
 
@@ -180,6 +166,8 @@ sub on_add_hook {
     return if defined($scfg->{monhost}); # nothing to do if not pve managed ceph
 
     PVE::CephConfig::ceph_create_keyfile($scfg->{type}, $storeid);
+
+    return;
 }
 
 sub on_delete_hook {
@@ -188,6 +176,8 @@ sub on_delete_hook {
     return if defined($scfg->{monhost}); # nothing to do if not pve managed ceph
 
     PVE::CephConfig::ceph_remove_keyfile($scfg->{type}, $storeid);
+
+    return;
 }
 
 sub status {
@@ -232,4 +222,14 @@ sub deactivate_storage {
     }
 }
 
+sub get_volume_notes {
+    my $class = shift;
+    PVE::Storage::DirPlugin::get_volume_notes($class, @_);
+}
+
+sub update_volume_notes {
+    my $class = shift;
+    PVE::Storage::DirPlugin::update_volume_notes($class, @_);
+}
+
 1;