]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commit
[HGFS Server] Add file attributes/symlink check status cache using oplock support
authorJohn Wolfe <jwolfe@vmware.com>
Tue, 18 Aug 2020 14:14:12 +0000 (07:14 -0700)
committerJohn Wolfe <jwolfe@vmware.com>
Tue, 18 Aug 2020 14:14:12 +0000 (07:14 -0700)
commit093fcc60b980a6d48e9e3ed2156e79c6a6790f99
tree198857bd20e4cf38ba7900f8d801b05b3c5917af
parente860f4aaaac89aa0043a948ae79ac1b2a8dab6b4
[HGFS Server] Add file attributes/symlink check status cache using oplock support

An investigation found that while copying a group of small files from host
to guest using the shared folder, the HGFS_OP_GETATTR_V3 message was handled
in HGFS server 276,140 times over a period of ~35 seconds.

Caching the file attributes in HGFS on the server-side can reduce the time
significantly (from experimental results, 35s => 8s).

It was also discovered that Posix_RealPath is called repeatedly to check
whether a path is a symlink, since HgfsServerGetLocalNameInfo is called when
handling a series of requests.

Integrate a key-value cache to HGFS server to cache the symlink check results
and file attributes, using the file path as the key.  This task will be divided
into multiple change:

1. Add oplock support
2. Add a customized LRU cache in HGFS server for file attributes and
   symlink check results

-  New files:
   hgfsCache.h/c: implements a customized LRU cache which is built by
                  combining two data structures: a doubly linked list and
                  a hash table.

-  The cache will be allocated only when oplock is enabled.
-  The cache relies on the file change monitor provided by oplock to ensure
   there is no stale data.  When adding an entry into the cache, also
   register the file change callback to oplock.  Upon receiving the file change
   callback, invalidate the cache.  Once the cache is full, remove the LRU
   entry and unregister the file change callback for it.
open-vm-tools/lib/hgfsServer/Makefile.am
open-vm-tools/lib/hgfsServer/hgfsCache.h [new file with mode: 0644]
open-vm-tools/lib/hgfsServer/hgfsCacheStub.c [new file with mode: 0644]
open-vm-tools/lib/hgfsServer/hgfsServer.c
open-vm-tools/lib/hgfsServer/hgfsServerInt.h
open-vm-tools/lib/hgfsServer/hgfsServerOplockInt.h
open-vm-tools/lib/hgfsServer/hgfsServerOplockMonitor.h