Blame SOURCES/ovt-Avoid-freezing-mount-points-for-same-device.patch

5fa55c
From 4952e22663c8e00c913a007a5e59e47e3b3b02c0 Mon Sep 17 00:00:00 2001
5fa55c
From: Cathy Avery <cavery@redhat.com>
5fa55c
Date: Wed, 11 Mar 2020 14:59:21 +0100
5fa55c
Subject: [PATCH 1/2] Avoid freezing mount points for same device.
5fa55c
5fa55c
Message-id: <20200311145921.11689-1-cavery@redhat.com>
5fa55c
Patchwork-id: 94230
5fa55c
O-Subject: [RHEL-7.8.z/RHEL-7.7.z/RHEL-7.6.z open-vm-tools PATCH] Avoid freezing mount points for same device.
5fa55c
Bugzilla: 1812934
5fa55c
RH-Acked-by: Eduardo Otubo <eterrell@redhat.com>
5fa55c
RH-Acked-by: Mohammed Gamal <mgamal@redhat.com>
5fa55c
RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
5fa55c
5fa55c
commit d58847b497e212737007958c945af1df22a8ab58
5fa55c
Author: Oliver Kurth <okurth@vmware.com>
5fa55c
Date:   Fri Aug 2 11:07:21 2019 -0700
5fa55c
5fa55c
    Avoid freezing mount points for same device.
5fa55c
5fa55c
    Loopback device setup could cause a cyclic dependency
5fa55c
    between 2 mount points. In order to break the cycle,
5fa55c
    avoid freezing the mount points to the same device.
5fa55c
5fa55c
    This change also skips some system mount points for 'tmpfs'
5fa55c
    and 'cgroup' etc as those share the same device/FS name.
5fa55c
    This is fine because we can't quiese those mount points
5fa55c
    anyway (system mount points don't support quiescing).
5fa55c
5fa55c
Signed-off-by: Cathy Avery <cavery@redhat.com>
5fa55c
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
5fa55c
---
5fa55c
 lib/syncDriver/syncDriverPosix.c | 32 ++++++++++++++++++++++----
5fa55c
 1 file changed, 27 insertions(+), 5 deletions(-)
5fa55c
5fa55c
diff --git a/lib/syncDriver/syncDriverPosix.c b/lib/syncDriver/syncDriverPosix.c
5fa55c
index 839cb6d..7b6132b 100644
5fa55c
--- a/lib/syncDriver/syncDriverPosix.c
5fa55c
+++ b/lib/syncDriver/syncDriverPosix.c
5fa55c
@@ -1,5 +1,5 @@
5fa55c
 /*********************************************************
5fa55c
- * Copyright (C) 2005-2018 VMware, Inc. All rights reserved.
5fa55c
+ * Copyright (C) 2005-2019 VMware, Inc. All rights reserved.
5fa55c
  *
5fa55c
  * This program is free software; you can redistribute it and/or modify it
5fa55c
  * under the terms of the GNU Lesser General Public License as published
5fa55c
@@ -140,6 +140,7 @@ static GSList *
5fa55c
 SyncDriverLocalMounts(void)
5fa55c
 {
5fa55c
    GSList *paths = NULL;
5fa55c
+   GHashTable *devices;
5fa55c
    MNTHANDLE mounts;
5fa55c
    DECLARE_MNTINFO(mntinfo);
5fa55c
 
5fa55c
@@ -148,19 +149,39 @@ SyncDriverLocalMounts(void)
5fa55c
       return NULL;
5fa55c
    }
5fa55c
 
5fa55c
+   devices = g_hash_table_new_full(g_str_hash, g_str_equal, free, free);
5fa55c
+
5fa55c
    while (GETNEXT_MNTINFO(mounts, mntinfo)) {
5fa55c
-      char *path;
5fa55c
+      const char *device;
5fa55c
+      const char *path;
5fa55c
+      const char *prevDevicePath;
5fa55c
+
5fa55c
+      device = MNTINFO_NAME(mntinfo);
5fa55c
+      path = MNTINFO_MNTPT(mntinfo);
5fa55c
+
5fa55c
       /*
5fa55c
        * Skip remote mounts because they are not freezable and opening them
5fa55c
        * could lead to hangs. See PR 1196785.
5fa55c
        */
5fa55c
       if (SyncDriverIsRemoteFS(mntinfo)) {
5fa55c
          Debug(LGPFX "Skipping remote file system, name=%s, mntpt=%s.\n",
5fa55c
-               MNTINFO_NAME(mntinfo), MNTINFO_MNTPT(mntinfo));
5fa55c
+               device, path);
5fa55c
+         continue;
5fa55c
+      }
5fa55c
+
5fa55c
+      /*
5fa55c
+       * Avoid adding a path to the list, if we have already got
5fa55c
+       * a path mounting the same device path.
5fa55c
+       */
5fa55c
+      prevDevicePath = g_hash_table_lookup(devices, device);
5fa55c
+      if (prevDevicePath != NULL) {
5fa55c
+         Debug(LGPFX "Skipping duplicate file system, name=%s, mntpt=%s "
5fa55c
+               "(existing path=%s).\n", device, path, prevDevicePath);
5fa55c
          continue;
5fa55c
       }
5fa55c
 
5fa55c
-      path = Util_SafeStrdup(MNTINFO_MNTPT(mntinfo));
5fa55c
+      g_hash_table_insert(devices, Util_SafeStrdup(device),
5fa55c
+                          Util_SafeStrdup(path));
5fa55c
 
5fa55c
       /*
5fa55c
        * A mount point could depend on existence of a previous mount
5fa55c
@@ -172,9 +193,10 @@ SyncDriverLocalMounts(void)
5fa55c
        * dependency. So, we need to keep them in reverse order of
5fa55c
        * mount points to achieve the dependency order.
5fa55c
        */
5fa55c
-      paths = g_slist_prepend(paths, path);
5fa55c
+      paths = g_slist_prepend(paths, Util_SafeStrdup(path));
5fa55c
    }
5fa55c
 
5fa55c
+   g_hash_table_destroy(devices);
5fa55c
    (void) CLOSE_MNTFILE(mounts);
5fa55c
    return paths;
5fa55c
 }
5fa55c
-- 
5fa55c
1.8.3.1
5fa55c