]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Hgfs FUSE Client: fix attribute caching of folders
authorOliver Kurth <okurth@vmware.com>
Fri, 2 Nov 2018 22:28:18 +0000 (15:28 -0700)
committerOliver Kurth <okurth@vmware.com>
Fri, 2 Nov 2018 22:28:18 +0000 (15:28 -0700)
When a directory is invalidated from the cache due to any change such as
a rename then any cached children of that parent folder should be
invalidated also.  Otherwise the cache holds stale information leading
to incorrect behavior and failing applications.

open-vm-tools/vmhgfs-fuse/cache.c
open-vm-tools/vmhgfs-fuse/file.c
open-vm-tools/vmhgfs-fuse/vmhgfs_version.h

index 5e3259f6e01cc423c0b987f46b9fc73d0cd29ccc..db89bedc6c58f2e653a216163e69cd1605b52161 100644 (file)
@@ -55,6 +55,7 @@ struct HgfsAttrCache attrList;
 
 /*Lock for accessing the attribute cache*/
 static pthread_mutex_t HgfsAttrCacheLock = PTHREAD_MUTEX_INITIALIZER;
+static void HgfsInvalidateParentsChildren(const char* parent);
 
 /*
  * Lists are used to manage attribute cache in Solaris and FreeBSD,
@@ -414,10 +415,55 @@ HgfsInvalidateAttrCache(const char* path)      //IN: Path to file
    tmp = (HgfsAttrCache *)g_hash_table_lookup(g_hash_table, path);
    if (tmp != NULL) {
       tmp->changeTime = 0;
+      if (tmp->attr.type == HGFS_FILE_TYPE_DIRECTORY) {
+         HgfsInvalidateParentsChildren(tmp->path);
+      }
    }
    pthread_mutex_unlock(&HgfsAttrCacheLock);
 }
 
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * HgfsInvalidateParentsChildren
+ *
+ *    This routine is called by the general function to invalidate a cache
+ *    entry. If the entry is a directory this function is called to invalidate
+ *    any cached children.
+ *
+ * Results:
+ *    None
+ *
+ * Side effects:
+ *    None
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+HgfsInvalidateParentsChildren(const char* parent)      //IN: parent
+{
+   gpointer key, value;
+   GHashTableIter iter;
+   size_t parentLen = Str_Strlen(parent, PATH_MAX);
+
+   LOG(4, ("Invalidating cache children for parent = %s\n",
+           parent));
+
+   g_hash_table_iter_init(&iter, g_hash_table);
+
+   while (g_hash_table_iter_next(&iter, &key, &value)) {
+      HgfsAttrCache *child = (HgfsAttrCache *)value;
+
+      if (Str_Strncasecmp(parent, child->path, parentLen) == 0) {
+         LOG(10, ("Invalidating cache child = %s\n", child->path));
+         child->changeTime = 0;
+      }
+   }
+}
+
+
 /*
  *----------------------------------------------------------------------
  *
index 389ebba888dc52112717775576cabf1b4d1965cd..b0744ff76e827cf10bac81919b638270fa26e4e1 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2013,2017 VMware, Inc. All rights reserved.
+ * Copyright (C) 2013,2018 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
@@ -1068,7 +1068,7 @@ retry:
          }
          break;
       default:
-         LOG(4, ("failed with result %d\n", result));
+         LOG(4, ("Server protocol result %d\n", result));
       }
       break;
    default:
index 4a3dd69729490db1059271d2032a5b4d3dac3b8c..bb3d38bdf7048a058144a7c087582b2855ce0eac 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2013,2017 VMware, Inc. All rights reserved.
+ * Copyright (C) 2013,2018 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
@@ -25,8 +25,8 @@
 #ifndef _VMHGFS_VERSION_H_
 #define _VMHGFS_VERSION_H_
 
-#define VMHGFS_DRIVER_VERSION          1.6.6.0
-#define VMHGFS_DRIVER_VERSION_COMMAS   1,6,6,0
-#define VMHGFS_DRIVER_VERSION_STRING   "1.6.6.0"
+#define VMHGFS_DRIVER_VERSION          1.6.7.0
+#define VMHGFS_DRIVER_VERSION_COMMAS   1,6,7,0
+#define VMHGFS_DRIVER_VERSION_STRING   "1.6.7.0"
 
 #endif /* _VMHGFS_VERSION_H_ */