Re: [PATCH 11/12] fsmonitor: refactor bit invalidation in refresh callback

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Feb 13, 2024 at 08:52:20PM +0000, Jeff Hostetler via GitGitGadget wrote:
> From: Jeff Hostetler <jeffhostetler@xxxxxxxxxx>
> 
> 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 we don't need the extra stuff that it does.
> 
> Signed-off-by: Jeff Hostetler <jeffhostetler@xxxxxxxxxx>
> ---
>  fsmonitor.c | 20 +++++++++++++++++---
>  1 file changed, 17 insertions(+), 3 deletions(-)
> 
> diff --git a/fsmonitor.c b/fsmonitor.c
> index a7847f07a40..75c7f73f68d 100644
> --- a/fsmonitor.c
> +++ b/fsmonitor.c
> @@ -209,6 +209,20 @@ static void my_invalidate_untracked_cache(
>  	strbuf_release(&work_path);
>  }
>  
> +/*
> + * Invalidate the FSM bit on this CE.  This is like mark_fsmonitor_invalid()
> + * but we've already handled the untracked-cache and I want a different
> + * trace message.
> + */
> +static void my_invalidate_ce_fsm(struct cache_entry *ce)
> +{
> +	if (ce->ce_flags & CE_FSMONITOR_VALID)
> +		trace_printf_key(&trace_fsmonitor,
> +				 "fsmonitor_refresh_cb_invalidate '%s'",
> +				 ce->name);
> +	ce->ce_flags &= ~CE_FSMONITOR_VALID;
> +}

Same comment here regarding the `my_` prefix.

Patrick

> +
>  /*
>   * Use the name-hash to lookup the pathname.
>   *
> @@ -240,7 +254,7 @@ static int my_callback_name_hash(
>  
>  	my_invalidate_untracked_cache(istate, ce->name, ce->ce_namelen);
>  
> -	ce->ce_flags &= ~CE_FSMONITOR_VALID;
> +	my_invalidate_ce_fsm(ce);
>  	return 1;
>  }
>  
> @@ -312,7 +326,7 @@ static int fsmonitor_refresh_callback_unqualified(
>  		 * 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;
> +		my_invalidate_ce_fsm(istate->cache[pos]);
>  		return 1;
>  	} else {
>  		int nr_in_cone;
> @@ -412,7 +426,7 @@ static int fsmonitor_refresh_callback_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;
> +		my_invalidate_ce_fsm(istate->cache[i]);
>  		nr_in_cone++;
>  	}
>  
> -- 
> gitgitgadget
> 
> 

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux