Discussion:
[pve-devel] [PATCH storage] cephfs: tell systemd that mount mount requires network
Thomas Lamprecht
2018-11-27 11:02:01 UTC
Permalink
As we mount this manually and thus systemd doesn't know about any
dependency for cephFS mounts, this got umounted only at the last
stage of shutdown, where network wasn't active anymore.

But, CephFS needs to be connected to an active MDS for a clean
unmount so without network this mount would delay shutdown for quite
a bit, until after some minutes systemd gave up and forced unmount.

So tell systemd that this mount requires network, which can be done
with the '_netdev'[0] mount option, that lucky for us can be also
passed to a mount call and isn't only available for fstab.
Wants=network-online.target
Before=umount.target remote-fs.target
After=remote-fs-pre.target system.slice network.target network-online.target -.mount
Which does the trick for us.

[0]: https://www.freedesktop.org/software/systemd/man/systemd.mount.html#_netdev

Signed-off-by: Thomas Lamprecht <***@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 de1499c..1bfdd01 100644
--- a/PVE/Storage/CephFSPlugin.pm
+++ b/PVE/Storage/CephFSPlugin.pm
@@ -66,6 +66,10 @@ sub cephfs_mount {
$cmd = ['/bin/mount', '-t', 'ceph', $source, $mountpoint, '-o', "name=$cmd_option->{userid}"];
push @$cmd, '-o', "secretfile=$secretfile" if defined($secretfile);
}
+ # tell systemd that we're network dependent, else it umounts us to late on
+ # shutdown, when we couldn't connect to the active MDS and thus unmount
+ # hangs and delays shutdown/reboot (man systemd.mount)
+ push @$cmd, '-o', '_netdev';

if ($scfg->{options}) {
push @$cmd, '-o', $scfg->{options};
--
2.19.2
Wolfgang Bumiller
2018-11-27 11:13:24 UTC
Permalink
applied
Post by Thomas Lamprecht
As we mount this manually and thus systemd doesn't know about any
dependency for cephFS mounts, this got umounted only at the last
stage of shutdown, where network wasn't active anymore.
But, CephFS needs to be connected to an active MDS for a clean
unmount so without network this mount would delay shutdown for quite
a bit, until after some minutes systemd gave up and forced unmount.
So tell systemd that this mount requires network, which can be done
with the '_netdev'[0] mount option, that lucky for us can be also
passed to a mount call and isn't only available for fstab.
Wants=network-online.target
Before=umount.target remote-fs.target
After=remote-fs-pre.target system.slice network.target network-online.target -.mount
Which does the trick for us.
[0]: https://www.freedesktop.org/software/systemd/man/systemd.mount.html#_netdev
---
PVE/Storage/CephFSPlugin.pm | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/PVE/Storage/CephFSPlugin.pm b/PVE/Storage/CephFSPlugin.pm
index de1499c..1bfdd01 100644
--- a/PVE/Storage/CephFSPlugin.pm
+++ b/PVE/Storage/CephFSPlugin.pm
@@ -66,6 +66,10 @@ sub cephfs_mount {
$cmd = ['/bin/mount', '-t', 'ceph', $source, $mountpoint, '-o', "name=$cmd_option->{userid}"];
}
+ # tell systemd that we're network dependent, else it umounts us to late on
+ # shutdown, when we couldn't connect to the active MDS and thus unmount
+ # hangs and delays shutdown/reboot (man systemd.mount)
if ($scfg->{options}) {
--
2.19.2
Loading...