[pve-devel] applied: [PATCH storage 3/3] cephfs mount: reload systemd if existing unit gets regenerated

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Jan 29 19:58:24 CET 2020

One the first write bringing the unit file in existence we can just
start it, after that we need to tell systemd that we want to actively
reload it.

While this is slightly shaky due to the fact that we do not check all
paths where such a unit could reside, it is something we can do
because earlier one couldn't have a unit/overwrite anyway (from
procfs mountinfo generated one do not support that) and does adding
such override ones from now on should work.

Also note that we can only get here in the "user does no weird stuff"
case when "cephfs_is_mounted" actively tells that there is no cephfs
mounted at the $mountpoint - at which time we can safely re-write the
potential updated unit file, reload and mount again.

So let's make our life a bit easier here until a user actually
complains about a rational issue for this, maybe we have PVE 7.0 then
and can get rid of that anyway :)

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
 PVE/Storage/CephFSPlugin.pm | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/PVE/Storage/CephFSPlugin.pm b/PVE/Storage/CephFSPlugin.pm
index 843af88..64ca03d 100644
--- a/PVE/Storage/CephFSPlugin.pm
+++ b/PVE/Storage/CephFSPlugin.pm
@@ -85,8 +85,12 @@ EOF
     my $unit_fn = systemd_escape($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");

More information about the pve-devel mailing list