|
|
17b0f1 |
From d9df4d0ed03f56036b04e19a8e6be2c028c4a72e Mon Sep 17 00:00:00 2001
|
|
|
17b0f1 |
From: Jan Synacek <jsynacek@redhat.com>
|
|
|
17b0f1 |
Date: Wed, 17 Jan 2018 09:13:24 +0100
|
|
|
17b0f1 |
Subject: [PATCH] automount: ack automount requests even when already mounted
|
|
|
17b0f1 |
|
|
|
17b0f1 |
If a process accesses an autofs filesystem while systemd is in the
|
|
|
17b0f1 |
middle of starting the mount unit on top of it, it is possible for the
|
|
|
17b0f1 |
autofs_ptype_missing_direct request from the kernel to be received after
|
|
|
17b0f1 |
the mount unit has been fully started:
|
|
|
17b0f1 |
|
|
|
17b0f1 |
systemd forks and execs mount ...
|
|
|
17b0f1 |
... access autofs, blocks
|
|
|
17b0f1 |
mount exits ...
|
|
|
17b0f1 |
systemd receives SIGCHLD ...
|
|
|
17b0f1 |
... kernel sends request
|
|
|
17b0f1 |
systemd receives request ...
|
|
|
17b0f1 |
|
|
|
17b0f1 |
systemd needs to respond to this request, otherwise the kernel will
|
|
|
17b0f1 |
continue to block access to the mount point.
|
|
|
17b0f1 |
|
|
|
17b0f1 |
(cherry picked from commit e7d54bf58789545a9eb0b3964233defa0b007318)
|
|
|
17b0f1 |
|
|
|
17b0f1 |
Resolves: #1535135
|
|
|
17b0f1 |
---
|
|
|
17b0f1 |
src/core/automount.c | 28 ++++++++++++++++------------
|
|
|
17b0f1 |
1 file changed, 16 insertions(+), 12 deletions(-)
|
|
|
17b0f1 |
|
|
|
17b0f1 |
diff --git a/src/core/automount.c b/src/core/automount.c
|
|
|
17b0f1 |
index 20a5de8cae..182ba5240f 100644
|
|
|
17b0f1 |
--- a/src/core/automount.c
|
|
|
17b0f1 |
+++ b/src/core/automount.c
|
|
|
17b0f1 |
@@ -712,7 +712,7 @@ static int automount_start_expire(Automount *a) {
|
|
|
17b0f1 |
automount_dispatch_expire, a);
|
|
|
17b0f1 |
}
|
|
|
17b0f1 |
|
|
|
17b0f1 |
-static void automount_enter_runnning(Automount *a) {
|
|
|
17b0f1 |
+static void automount_enter_running(Automount *a) {
|
|
|
17b0f1 |
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
|
|
|
17b0f1 |
struct stat st;
|
|
|
17b0f1 |
int r;
|
|
|
17b0f1 |
@@ -744,18 +744,22 @@ static void automount_enter_runnning(Automount *a) {
|
|
|
17b0f1 |
goto fail;
|
|
|
17b0f1 |
}
|
|
|
17b0f1 |
|
|
|
17b0f1 |
- if (!S_ISDIR(st.st_mode) || st.st_dev != a->dev_id)
|
|
|
17b0f1 |
+ /* The mount unit may have been explicitly started before we got the
|
|
|
17b0f1 |
+ * autofs request. Ack it to unblock anything waiting on the mount point. */
|
|
|
17b0f1 |
+ if (!S_ISDIR(st.st_mode) || st.st_dev != a->dev_id) {
|
|
|
17b0f1 |
log_unit_info(UNIT(a)->id,
|
|
|
17b0f1 |
"%s's automount point already active?", UNIT(a)->id);
|
|
|
17b0f1 |
- else {
|
|
|
17b0f1 |
- r = manager_add_job(UNIT(a)->manager, JOB_START, UNIT_TRIGGER(UNIT(a)),
|
|
|
17b0f1 |
- JOB_REPLACE, true, &error, NULL);
|
|
|
17b0f1 |
- if (r < 0) {
|
|
|
17b0f1 |
- log_unit_warning(UNIT(a)->id,
|
|
|
17b0f1 |
- "%s failed to queue mount startup job: %s",
|
|
|
17b0f1 |
- UNIT(a)->id, bus_error_message(&error, r));
|
|
|
17b0f1 |
- goto fail;
|
|
|
17b0f1 |
- }
|
|
|
17b0f1 |
+ automount_send_ready(a, a->tokens, 0);
|
|
|
17b0f1 |
+ return;
|
|
|
17b0f1 |
+ }
|
|
|
17b0f1 |
+
|
|
|
17b0f1 |
+ r = manager_add_job(UNIT(a)->manager, JOB_START, UNIT_TRIGGER(UNIT(a)),
|
|
|
17b0f1 |
+ JOB_REPLACE, true, &error, NULL);
|
|
|
17b0f1 |
+ if (r < 0) {
|
|
|
17b0f1 |
+ log_unit_warning(UNIT(a)->id,
|
|
|
17b0f1 |
+ "%s failed to queue mount startup job: %s",
|
|
|
17b0f1 |
+ UNIT(a)->id, bus_error_message(&error, r));
|
|
|
17b0f1 |
+ goto fail;
|
|
|
17b0f1 |
}
|
|
|
17b0f1 |
|
|
|
17b0f1 |
r = automount_start_expire(a);
|
|
|
17b0f1 |
@@ -979,7 +983,7 @@ static int automount_dispatch_io(sd_event_source *s, int fd, uint32_t events, vo
|
|
|
17b0f1 |
goto fail;
|
|
|
17b0f1 |
}
|
|
|
17b0f1 |
|
|
|
17b0f1 |
- automount_enter_runnning(a);
|
|
|
17b0f1 |
+ automount_enter_running(a);
|
|
|
17b0f1 |
break;
|
|
|
17b0f1 |
|
|
|
17b0f1 |
case autofs_ptype_expire_direct:
|