[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.