d743bb5
From e0a8e194a2e3ca0a405dadfcbc9b5347e46fe8c0 Mon Sep 17 00:00:00 2001
d743bb5
From: NeilBrown <neil@brown.name>
d743bb5
Date: Wed, 7 Jun 2017 22:28:23 +1000
d743bb5
Subject: [PATCH] core/mount: pass "-c" flag to /bin/umount (#6093)
d743bb5
d743bb5
"-c", which is short for "--no-canonicalize", tells /bin/umount
d743bb5
that the path name is canonical (no .. or symlinks etc).
d743bb5
d743bb5
systemd always uses a canonical name, so this flag is appropriate
d743bb5
for systemd to use.
d743bb5
Knowing that the path is canonical allows umount to avoid
d743bb5
some calls to lstat() on the path.
d743bb5
d743bb5
From v2.30 "-c" goes further and causes umount to avoid all
d743bb5
attempts to 'lstat()' (or similar) the path.  This is important
d743bb5
when automatically unmounting a filesystem, as lstat() can
d743bb5
hang indefinitely in some cases such as when an NFS server
d743bb5
is not accessible.
d743bb5
d743bb5
"-c" has been supported since util-linux 2.17 which is before the
d743bb5
earliest version supported by systemd.
d743bb5
So "-c" is safe to use now, and once util-linux v2.30 is in use,
d743bb5
it will allow mounts from non-responsive NFS servers to be
d743bb5
unmounted.
d743bb5
(cherry picked from commit 83897d5470190a9818df50026cf38cd97114f77d)
d743bb5
---
d743bb5
 src/core/mount.c | 2 +-
d743bb5
 1 file changed, 1 insertion(+), 1 deletion(-)
d743bb5
d743bb5
diff --git a/src/core/mount.c b/src/core/mount.c
d743bb5
index ca0c4b0d5e..214364d87d 100644
d743bb5
--- a/src/core/mount.c
d743bb5
+++ b/src/core/mount.c
d743bb5
@@ -886,7 +886,7 @@ static void mount_enter_unmounting(Mount *m) {
d743bb5
         m->control_command_id = MOUNT_EXEC_UNMOUNT;
d743bb5
         m->control_command = m->exec_command + MOUNT_EXEC_UNMOUNT;
d743bb5
 
d743bb5
-        r = exec_command_set(m->control_command, UMOUNT_PATH, m->where, NULL);
d743bb5
+        r = exec_command_set(m->control_command, UMOUNT_PATH, m->where, "-c", NULL);
d743bb5
         if (r >= 0 && m->lazy_unmount)
d743bb5
                 r = exec_command_append(m->control_command, "-l", NULL);
d743bb5
         if (r >= 0 && m->force_unmount)