|
|
923a60 |
From 048ed4b2fecef7003925772740bab651cb08b260 Mon Sep 17 00:00:00 2001
|
|
|
923a60 |
From: brulon <barron@lexmark.com>
|
|
|
923a60 |
Date: Fri, 26 Aug 2016 11:57:22 -0400
|
|
|
923a60 |
Subject: [PATCH] mount: add new LazyUnmount= setting for mount units, mapping
|
|
|
923a60 |
to umount(8)'s "-l" switch (#3827)
|
|
|
923a60 |
|
|
|
923a60 |
(cherry-picked commit from e520950a03419957875034bc27795b0b81d8e793)
|
|
|
923a60 |
|
|
|
923a60 |
Resolves: #1497264
|
|
|
923a60 |
---
|
|
|
923a60 |
man/systemd.mount.xml | 13 +++++++++++++
|
|
|
923a60 |
src/core/dbus-mount.c | 1 +
|
|
|
923a60 |
src/core/load-fragment-gperf.gperf.m4 | 1 +
|
|
|
923a60 |
src/core/mount.c | 8 ++++++--
|
|
|
923a60 |
src/core/mount.h | 2 ++
|
|
|
923a60 |
5 files changed, 23 insertions(+), 2 deletions(-)
|
|
|
923a60 |
|
|
|
923a60 |
diff --git a/man/systemd.mount.xml b/man/systemd.mount.xml
|
|
|
923a60 |
index dfa437b5d2..1590c44cec 100644
|
|
|
923a60 |
--- a/man/systemd.mount.xml
|
|
|
923a60 |
+++ b/man/systemd.mount.xml
|
|
|
923a60 |
@@ -329,6 +329,19 @@
|
|
|
923a60 |
off.</para></listitem>
|
|
|
923a60 |
</varlistentry>
|
|
|
923a60 |
|
|
|
923a60 |
+ <varlistentry>
|
|
|
923a60 |
+ <term><varname>LazyUnmount=</varname></term>
|
|
|
923a60 |
+
|
|
|
923a60 |
+ <listitem><para>Takes a boolean argument. If true, detach the
|
|
|
923a60 |
+ filesystem from the filesystem hierarchy at time of the unmount
|
|
|
923a60 |
+ operation, and clean up all references to the filesystem as
|
|
|
923a60 |
+ soon as they are not busy anymore.
|
|
|
923a60 |
+ This corresponds with
|
|
|
923a60 |
+ <citerefentry project='man-pages'><refentrytitle>umount</refentrytitle><manvolnum>8</manvolnum></citerefentry>'s
|
|
|
923a60 |
+ <parameter>-l</parameter> switch. Defaults to
|
|
|
923a60 |
+ off.</para></listitem>
|
|
|
923a60 |
+ </varlistentry>
|
|
|
923a60 |
+
|
|
|
923a60 |
<varlistentry>
|
|
|
923a60 |
<term><varname>DirectoryMode=</varname></term>
|
|
|
923a60 |
<listitem><para>Directories of mount points (and any parent
|
|
|
923a60 |
diff --git a/src/core/dbus-mount.c b/src/core/dbus-mount.c
|
|
|
923a60 |
index 04beba631b..cbb842f706 100644
|
|
|
923a60 |
--- a/src/core/dbus-mount.c
|
|
|
923a60 |
+++ b/src/core/dbus-mount.c
|
|
|
923a60 |
@@ -110,6 +110,7 @@ const sd_bus_vtable bus_mount_vtable[] = {
|
|
|
923a60 |
SD_BUS_PROPERTY("ControlPID", "u", bus_property_get_pid, offsetof(Mount, control_pid), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
|
|
923a60 |
SD_BUS_PROPERTY("DirectoryMode", "u", bus_property_get_mode, offsetof(Mount, directory_mode), SD_BUS_VTABLE_PROPERTY_CONST),
|
|
|
923a60 |
SD_BUS_PROPERTY("SloppyOptions", "b", bus_property_get_bool, offsetof(Mount, sloppy_options), SD_BUS_VTABLE_PROPERTY_CONST),
|
|
|
923a60 |
+ SD_BUS_PROPERTY("LazyUnmount", "b", bus_property_get_bool, offsetof(Mount, lazy_unmount), SD_BUS_VTABLE_PROPERTY_CONST),
|
|
|
923a60 |
SD_BUS_PROPERTY("Result", "s", property_get_result, offsetof(Mount, result), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
|
|
923a60 |
BUS_EXEC_COMMAND_VTABLE("ExecMount", offsetof(Mount, exec_command[MOUNT_EXEC_MOUNT]), SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION),
|
|
|
923a60 |
BUS_EXEC_COMMAND_VTABLE("ExecUnmount", offsetof(Mount, exec_command[MOUNT_EXEC_UNMOUNT]), SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION),
|
|
|
923a60 |
diff --git a/src/core/load-fragment-gperf.gperf.m4 b/src/core/load-fragment-gperf.gperf.m4
|
|
|
923a60 |
index b2fe627af3..664bba0ef6 100644
|
|
|
923a60 |
--- a/src/core/load-fragment-gperf.gperf.m4
|
|
|
923a60 |
+++ b/src/core/load-fragment-gperf.gperf.m4
|
|
|
923a60 |
@@ -316,6 +316,7 @@ Mount.Type, config_parse_string, 0,
|
|
|
923a60 |
Mount.TimeoutSec, config_parse_sec, 0, offsetof(Mount, timeout_usec)
|
|
|
923a60 |
Mount.DirectoryMode, config_parse_mode, 0, offsetof(Mount, directory_mode)
|
|
|
923a60 |
Mount.SloppyOptions, config_parse_bool, 0, offsetof(Mount, sloppy_options)
|
|
|
923a60 |
+Mount.LazyUnmount, config_parse_bool, 0, offsetof(Mount, lazy_unmount)
|
|
|
923a60 |
EXEC_CONTEXT_CONFIG_ITEMS(Mount)m4_dnl
|
|
|
923a60 |
CGROUP_CONTEXT_CONFIG_ITEMS(Mount)m4_dnl
|
|
|
923a60 |
KILL_CONTEXT_CONFIG_ITEMS(Mount)m4_dnl
|
|
|
923a60 |
diff --git a/src/core/mount.c b/src/core/mount.c
|
|
|
923a60 |
index 0dc67dde69..5fd7a86ddd 100644
|
|
|
923a60 |
--- a/src/core/mount.c
|
|
|
923a60 |
+++ b/src/core/mount.c
|
|
|
923a60 |
@@ -690,7 +690,8 @@ static void mount_dump(Unit *u, FILE *f, const char *prefix) {
|
|
|
923a60 |
"%sOptions: %s\n"
|
|
|
923a60 |
"%sFrom /proc/self/mountinfo: %s\n"
|
|
|
923a60 |
"%sFrom fragment: %s\n"
|
|
|
923a60 |
- "%sDirectoryMode: %04o\n",
|
|
|
923a60 |
+ "%sDirectoryMode: %04o\n"
|
|
|
923a60 |
+ "%sLazyUnmount: %s\n",
|
|
|
923a60 |
prefix, mount_state_to_string(m->state),
|
|
|
923a60 |
prefix, mount_result_to_string(m->result),
|
|
|
923a60 |
prefix, m->where,
|
|
|
923a60 |
@@ -699,7 +700,8 @@ static void mount_dump(Unit *u, FILE *f, const char *prefix) {
|
|
|
923a60 |
prefix, p ? strna(p->options) : "n/a",
|
|
|
923a60 |
prefix, yes_no(m->from_proc_self_mountinfo),
|
|
|
923a60 |
prefix, yes_no(m->from_fragment),
|
|
|
923a60 |
- prefix, m->directory_mode);
|
|
|
923a60 |
+ prefix, m->directory_mode,
|
|
|
923a60 |
+ prefix, yes_no(m->lazy_unmount));
|
|
|
923a60 |
|
|
|
923a60 |
if (m->control_pid > 0)
|
|
|
923a60 |
fprintf(f,
|
|
|
923a60 |
@@ -891,6 +893,8 @@ static void mount_enter_unmounting(Mount *m) {
|
|
|
923a60 |
m->control_command = m->exec_command + MOUNT_EXEC_UNMOUNT;
|
|
|
923a60 |
|
|
|
923a60 |
r = exec_command_set(m->control_command, "/bin/umount", m->where, NULL);
|
|
|
923a60 |
+ if (r >= 0 && m->lazy_unmount)
|
|
|
923a60 |
+ r = exec_command_append(m->control_command, "-l", NULL);
|
|
|
923a60 |
if (r < 0)
|
|
|
923a60 |
goto fail;
|
|
|
923a60 |
|
|
|
923a60 |
diff --git a/src/core/mount.h b/src/core/mount.h
|
|
|
923a60 |
index 353222000f..4e870299cb 100644
|
|
|
923a60 |
--- a/src/core/mount.h
|
|
|
923a60 |
+++ b/src/core/mount.h
|
|
|
923a60 |
@@ -90,6 +90,8 @@ struct Mount {
|
|
|
923a60 |
|
|
|
923a60 |
bool sloppy_options;
|
|
|
923a60 |
|
|
|
923a60 |
+ bool lazy_unmount;
|
|
|
923a60 |
+
|
|
|
923a60 |
MountResult result;
|
|
|
923a60 |
MountResult reload_result;
|
|
|
923a60 |
|