]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mount-util: handle remount failures gracefully if flags already match
authorLennart Poettering <lennart@poettering.net>
Wed, 24 Mar 2021 13:17:20 +0000 (14:17 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 7 May 2021 09:58:47 +0000 (11:58 +0200)
In bind_remount_one_with_mountinfo() let's handle mount failures
gracefully if the flags already match anyway. This isn't perfect, since
it mixes up superblock and mount point flags, but it's close enough.

(cherry picked from commit b23c6a6411fd58ac281642bcae915a7ea55db5c7)

src/shared/mount-util.c

index ab2f62c32fce5af2a91d583fed6da4ea1e097aff..f226dc1aa682e3a264c26615d47788ca8d268fec 100644 (file)
@@ -387,8 +387,16 @@ int bind_remount_one_with_mountinfo(
         }
 
         r = mount_nofollow(NULL, path, NULL, ((flags & ~flags_mask)|MS_BIND|MS_REMOUNT|new_flags) & ~MS_RELATIME, NULL);
-        if (r < 0)
-                return r;
+        if (r < 0) {
+                if (((flags ^ new_flags) & flags_mask & ~MS_RELATIME) != 0) /* Ignore MS_RELATIME again,
+                                                                             * since kernel adds it in
+                                                                             * everywhere, because it's the
+                                                                             * default. */
+                        return r;
+
+                /* Let's handle redundant remounts gracefully */
+                log_debug_errno(r, "Failed to remount '%s' but flags already match what we want, ignoring: %m", path);
+        }
 
         return 0;
 }