anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone

Blame SOURCES/0544-shutdown-don-t-remount-ro-network-filesystems.-6588.patch

923a60
From f70113f32c25b8d1c7d87eb812556c91b4b9b5c6 Mon Sep 17 00:00:00 2001
923a60
From: NeilBrown <neil@brown.name>
923a60
Date: Thu, 31 Aug 2017 02:48:25 +1000
923a60
Subject: [PATCH] shutdown: don't remount,ro network filesystems. (#6588)
923a60
923a60
systemd-shutdown is run after the network is stopped,
923a60
so remounting a network filesystem read-only can hang.
923a60
A simple umount is the most useful thing that can
923a60
be done for a network filesystem once the network is down.
923a60
923a60
(cherry picked from commit 9cbc4547702aac28466c497f720038b9e2dc510c)
923a60
923a60
Resolves: #1312002
923a60
---
923a60
 src/core/umount.c | 17 ++++++++++++-----
923a60
 1 file changed, 12 insertions(+), 5 deletions(-)
923a60
923a60
diff --git a/src/core/umount.c b/src/core/umount.c
923a60
index bfd8aa5f88..6e8ccc794f 100644
923a60
--- a/src/core/umount.c
923a60
+++ b/src/core/umount.c
923a60
@@ -41,6 +41,7 @@
923a60
 typedef struct MountPoint {
923a60
         char *path;
923a60
         char *options;
923a60
+        char *type;
923a60
         dev_t devnum;
923a60
         LIST_FIELDS(struct MountPoint, mount_point);
923a60
 } MountPoint;
923a60
@@ -73,7 +74,7 @@ static int mount_points_list_get(MountPoint **head) {
923a60
                 return -errno;
923a60
 
923a60
         for (i = 1;; i++) {
923a60
-                _cleanup_free_ char *path = NULL, *options = NULL;
923a60
+                _cleanup_free_ char *path = NULL, *options = NULL, *type = NULL;
923a60
                 char *p = NULL;
923a60
                 MountPoint *m;
923a60
                 int k;
923a60
@@ -87,11 +88,11 @@ static int mount_points_list_get(MountPoint **head) {
923a60
                            "%*s"        /* (6) mount flags */
923a60
                            "%*[^-]"     /* (7) optional fields */
923a60
                            "- "         /* (8) separator */
923a60
-                           "%*s "       /* (9) file system type */
923a60
+                           "%ms "       /* (9) file system type */
923a60
                            "%*s"        /* (10) mount source */
923a60
                            "%ms"        /* (11) mount options */
923a60
                            "%*[^\n]",   /* some rubbish at the end */
923a60
-                           &path, &options);
923a60
+                           &path, &type, &options);
923a60
                 if (k != 2) {
923a60
                         if (k == EOF)
923a60
                                 break;
923a60
@@ -129,6 +130,8 @@ static int mount_points_list_get(MountPoint **head) {
923a60
                 m->path = p;
923a60
                 m->options = options;
923a60
                 options = NULL;
923a60
+                m->type = type;
923a60
+                type = NULL;
923a60
 
923a60
                 LIST_PREPEND(mount_point, *head, m);
923a60
         }
923a60
@@ -371,8 +374,12 @@ static int mount_points_list_umount(MountPoint **head, bool *changed, bool log_e
923a60
                 /* If we are in a container, don't attempt to
923a60
                    read-only mount anything as that brings no real
923a60
                    benefits, but might confuse the host, as we remount
923a60
-                   the superblock here, not the bind mound. */
923a60
-                if (detect_container(NULL) <= 0)  {
923a60
+                   the superblock here, not the bind mount.
923a60
+                   If the filesystem is a network fs, also skip the
923a60
+                   remount.  It brings no value (we cannot leave
923a60
+                   a "dirty fs") and could hang if the network is down.  */
923a60
+                if (detect_container(NULL) <= 0 &&
923a60
+                    !fstype_is_network(m->type)) {
923a60
                         _cleanup_free_ char *options = NULL;
923a60
                         /* MS_REMOUNT requires that the data parameter
923a60
                          * should be the same from the original mount