1
0
mirror of https://github.com/git/git synced 2024-06-30 22:54:27 +00:00

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>
This commit is contained in:
Jeff Hostetler 2024-02-26 21:39:24 +00:00 committed by Junio C Hamano
parent 84d441f2f0
commit b0dba507fe

View File

@ -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++;
}