diff options
author | Jeff Hostetler <jeffhostetler@github.com> | 2024-02-26 22:39:24 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-03-06 18:10:06 +0100 |
commit | b0dba507fe3bb12836100f44e2fcfdf69091fd4d (patch) | |
tree | 55401b6ceeb84c7cac231d7632d77700253556f0 /fsmonitor.c | |
parent | fsmonitor: trace the new invalidated cache-entry count (diff) | |
download | git-b0dba507fe3bb12836100f44e2fcfdf69091fd4d.tar.xz git-b0dba507fe3bb12836100f44e2fcfdf69091fd4d.zip |
fsmonitor: refactor bit invalidation in refresh callback
Refactor code in the fsmonitor_refresh_callback() call chain dealing
with invalidating the CE_FSMONITOR_VALID bit and add a trace message.
During the refresh, we clear the CE_FSMONITOR_VALID bit in response to
data from the FSMonitor daemon (so that a later phase will lstat() and
verify the true state of the file).
Create a new function to clear the bit and add some unique tracing for
it to help debug edge cases.
This is similar to the existing `mark_fsmonitor_invalid()` function,
but it also does untracked-cache invalidation and we've already
handled that in the refresh-callback handlers, so but we don't need
to repeat that.
Signed-off-by: Jeff Hostetler <jeffhostetler@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'fsmonitor.c')
-rw-r--r-- | fsmonitor.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/fsmonitor.c b/fsmonitor.c index 739ddbf7ac..3c87449be8 100644 --- a/fsmonitor.c +++ b/fsmonitor.c @@ -183,6 +183,22 @@ static int query_fsmonitor_hook(struct repository *r, return result; } +/* + * Invalidate the FSM bit on this CE. This is like mark_fsmonitor_invalid() + * but we've already handled the untracked-cache, so let's not repeat that + * work. This also lets us have a different trace message so that we can + * see everything that was done as part of the refresh-callback. + */ +static void invalidate_ce_fsm(struct cache_entry *ce) +{ + if (ce->ce_flags & CE_FSMONITOR_VALID) { + trace_printf_key(&trace_fsmonitor, + "fsmonitor_refresh_callback INV: '%s'", + ce->name); + ce->ce_flags &= ~CE_FSMONITOR_VALID; + } +} + static size_t handle_path_with_trailing_slash( struct index_state *istate, const char *name, int pos); @@ -219,7 +235,7 @@ static size_t handle_path_without_trailing_slash( * cache-entry with the same pathname, nor for a cone * at that directory. (That is, assume no D/F conflicts.) */ - istate->cache[pos]->ce_flags &= ~CE_FSMONITOR_VALID; + invalidate_ce_fsm(istate->cache[pos]); return 1; } else { size_t nr_in_cone; @@ -297,7 +313,7 @@ static size_t handle_path_with_trailing_slash( for (i = pos; i < istate->cache_nr; i++) { if (!starts_with(istate->cache[i]->name, name)) break; - istate->cache[i]->ce_flags &= ~CE_FSMONITOR_VALID; + invalidate_ce_fsm(istate->cache[i]); nr_in_cone++; } |