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