Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace pre-V4 of FSMonitor with V4 using GFW experimental commits #437

Merged

Conversation

jeffhostetler
Copy link

This replaces #435.

This version merges the existing commits and branch from GFW (and adds 1 additional fixup commit on top)
instead of using cherry-pick versions of the GFW branch. Also, the GFW branch was switched to use "fixup!"
rather than "revert" commits to undo the pre-V4 integration; this will help make them disappear in the future.

This PR will let us test FSMonitor V4 upon the VFS 2.33.0 base.

When we move forward to the v2.34.0 base, we should inherit everything in this series except for
e4dcae6 (fixup! gvfs: disable the built-in FSMonitor, 2021-10-05).

This reverts commit 3bcb1a2.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
This reverts commit 63d2d7b.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Revert the FSMonitor-related portions of 64da6f2

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
…ith FSMonitor

This reverts commit a002e81.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
…h FSMonitor

This reverts commit da396b6.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
…checking on MacOS

This reverts commit 7b8c024.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
…windows

This reverts commit e3fc6ef.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
This reverts commit 7b37f49.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
…checking

This reverts commit 56b6c9a.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
This reverts commit ddab099.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
This reverts commit 751d7c3.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
This reverts commit 0f46db7.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
This reverts commit 207eece.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
This reverts commit 0fadc91.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
This reverts commit 27846cc.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
This reverts commit ec3dfa6.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
This reverts commit 7640844.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
This reverts commit 0de2262.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
This reverts commit 20eea48.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
This reverts commit 8318d7d.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
This reverts commit 41b215e.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
This reverts commit 5ab490f.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
This reverts commit b34d252.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
This reverts commit fd9522a.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
This reverts commit d0ed68b.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
This reverts commit 8657519.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
This reverts commit ccc75e2.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
This reverts commit a25a759.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
jeffhostetler and others added 21 commits October 2, 2021 22:40
…onitor

Teach Git to detect remote working directories on Windows and mark them as
incompatible with FSMonitor.

With this `git fsmonitor--daemon run` will error out with a message like it
does for bare repos.

Client commands, such as `git status`, will not attempt to start the daemon.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Initialize `o->result.fsmonitor_has_run_once` based upon value
in `o->src_index->fsmonitor_has_run_once` to prevent a second
fsmonitor query during the tree traversal and possibly getting
a skewed view of the working directory.

The checkout code has already talked to the fsmonitor and the
traversal is updating the index as it traverses, so there is
no need to query the fsmonitor.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
…hanges on MacOS

Ignore FSEvents resulting from `xattr` changes.  Git does not care about
xattr's or changes to xattr's, so don't waste time collecting these
events in the daemon nor transmitting them to clients.

Various security tools add xattrs to files and/or directories, such as
to mark them as having been downloaded.  We should ignore these events
since it doesn't affect the content of the file/directory or the normal
meta-data that Git cares about.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Teach fsmonitor--daemon to print a startup message only when
`fsmonitor.announceStartup` is true.  This setting is false by default
so that the output of client commands, like `git status`, is not
changed if the daemon is implicitly started.

The message is conditionally printed by "run" and "start" subcommands
and is sent to stderr.  It contains the path to the work tree root.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Teach the fsmonitor--daemon to CD outside of the worktree
before starting up.

The common Git startup mechanism causes the CWD of the daemon process
to be in the root of the worktree.  On Windows, this causes the daemon
process to hold a locked handle on the CWD and prevents other
processes from moving or deleting the worktree while the daemon is
running.

CD to HOME before entering main event loops.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Refactor daemon thread startup to make it easier to start
a third thread class to monitor the health of the daemon.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Rename platform-specific listener thread related variables
and data types as we prepare to add another backend thread
type.

[] `struct fsmonitor_daemon_backend_data` becomes `struct fsm_listen_data`
[] `state->backend_data` becomes `state->listen_data`
[] `state->error_code` becomes `state->listen_error_code`

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Create another thread to watch over the daemon process and
automatically shut it down if necessary.

This commit creates the basic framework for a "health" thread
to monitor the daemon and/or the file system.  Later commits
will add platform-specific code to do the actual work.

The "health" thread is intended to monitor conditions that
would be difficult to track inside the IPC thread pool and/or
the file system listener threads.  For example, when there are
file system events outside of the watched worktree root or if
we want to have an idle-timeout auto-shutdown feature.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
…itoring

Create framework in Win32 version of the "health" thread to
periodically inspect the system and shutdown if warranted.

This version just include the setup for the timeout in
WaitForMultipleObjects() and calls (currently empty) table
of functions.

A later commit will add functions to the table to actually
inspect the system.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
…root moves

Force shutdown fsmonitor daemon if the worktree root directory
is moved, renamed, or deleted.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
…is moved/renamed

Teach the listener thread to shutdown the daemon if the spelling of the
worktree root directory changes.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Teach Git to perform binary search over the cache-entries for a directory
notification and then linearly scan forward to find the immediate children.

Previously, when the FSMonitor reported a modified directory Git would
perform a linear search on the entire cache-entry array for all
entries matching that directory prefix and invalidate them.  Since the
cache-entry array is already sorted, we can use a binary search to
find the first matching entry and then only linearly walk forward and
invalidate entries until the prefix changes.

Also, the original code would invalidate anything having the same
directory prefix.  Since a directory event should only be received for
items that are immediately within the directory (and not within
sub-directories of it), only invalidate those entries and not the
whole subtree.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
If `feature.experimental` and `feature.manyFiles` are set and the user
has not explicitly turned off the builtin FSMonitor, we now start
the built-in FSMonitor by default.

Only forcing it when UNSET matches the behavior of UPDATE_DEFAULT_BOOL()
used for other repo settings.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Update wchar_t buffers to use MAX_LONG_PATH instead of MAX_PATH in
the Win32 backend source files.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
@jeffhostetler jeffhostetler merged commit 041afb4 into microsoft:vfs-2.33.0 Oct 5, 2021
dscho pushed a commit that referenced this pull request Oct 30, 2021
Replace pre-V4 of FSMonitor with V4 using GFW experimental commits
@jeffhostetler jeffhostetler deleted the gvfs-try-v4-fsmonitor-take2 branch June 21, 2023 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants