Skip to content

Commit b0dba50

Browse files
jeffhostetlergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 84d441f commit b0dba50

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

fsmonitor.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,22 @@ static int query_fsmonitor_hook(struct repository *r,
183183
return result;
184184
}
185185

186+
/*
187+
* Invalidate the FSM bit on this CE. This is like mark_fsmonitor_invalid()
188+
* but we've already handled the untracked-cache, so let's not repeat that
189+
* work. This also lets us have a different trace message so that we can
190+
* see everything that was done as part of the refresh-callback.
191+
*/
192+
static void invalidate_ce_fsm(struct cache_entry *ce)
193+
{
194+
if (ce->ce_flags & CE_FSMONITOR_VALID) {
195+
trace_printf_key(&trace_fsmonitor,
196+
"fsmonitor_refresh_callback INV: '%s'",
197+
ce->name);
198+
ce->ce_flags &= ~CE_FSMONITOR_VALID;
199+
}
200+
}
201+
186202
static size_t handle_path_with_trailing_slash(
187203
struct index_state *istate, const char *name, int pos);
188204

@@ -219,7 +235,7 @@ static size_t handle_path_without_trailing_slash(
219235
* cache-entry with the same pathname, nor for a cone
220236
* at that directory. (That is, assume no D/F conflicts.)
221237
*/
222-
istate->cache[pos]->ce_flags &= ~CE_FSMONITOR_VALID;
238+
invalidate_ce_fsm(istate->cache[pos]);
223239
return 1;
224240
} else {
225241
size_t nr_in_cone;
@@ -297,7 +313,7 @@ static size_t handle_path_with_trailing_slash(
297313
for (i = pos; i < istate->cache_nr; i++) {
298314
if (!starts_with(istate->cache[i]->name, name))
299315
break;
300-
istate->cache[i]->ce_flags &= ~CE_FSMONITOR_VALID;
316+
invalidate_ce_fsm(istate->cache[i]);
301317
nr_in_cone++;
302318
}
303319

0 commit comments

Comments
 (0)