git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v3] fsmonitor: option to allow fsmonitor to run against network-mounted repos

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 11, 2022, 19:33 UTC
Message-ID
<xmqqh72iefsn.fsf@gitster.g>
In-Reply-To
<pull.1317.v3.git.1660242752495.gitgitgadget@gmail.com>
"Eric DeCosta via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 35 quoted lines
> From: Eric DeCosta <edecosta@mathworks.com>
>
> Though perhaps not common, there are uses cases where users have large,
> network-mounted repos. Having the ability to run fsmonitor against
> network paths would benefit those users.
>
> Most modern Samba-based filers have the necessary support to enable
> fsmonitor on network-mounted repos. As a first step towards enabling
> fsmonitor to work against network-mounted repos, introduce a
> configuration option, 'fsmonitor.allowRemote'. Setting this option to
> true will override the default behavior (erroring-out) when a
> network-mounted repo is detected by fsmonitor.
>
> Signed-off-by: Eric DeCosta <edecosta@mathworks.com>
> ---
> ...
>  compat/fsmonitor/fsm-settings-win32.c | 66 +++++++++++++++++++++++++++
>  1 file changed, 66 insertions(+)
>
> diff --git a/compat/fsmonitor/fsm-settings-win32.c b/compat/fsmonitor/fsm-settings-win32.c
> index 907655720bb..32c0695c6c1 100644
> --- a/compat/fsmonitor/fsm-settings-win32.c
> +++ b/compat/fsmonitor/fsm-settings-win32.c
> @@ -24,6 +24,60 @@ static enum fsmonitor_reason check_vfs4git(struct repository *r)
>  	return FSMONITOR_REASON_OK;
>  }
>  
> +/*
> + * Check if monitoring remote working directories is allowed.
> + *
> + * By default, monitoring remote working directories is
> + * disabled unless on a network filesystem that is known to
> + * behave well.  Users may override this behavior in enviroments where
> + * they have proper support.
> + */

After applying this patch, "unless on a network filesystem ..." part is not exactly in effect yet; we could say that we start with no known-to-behave-well network filesystems, but we can then update the above comment when we start to know of at least one good one.

Show 5 quoted lines
> +/*
> + * Check remote working directory protocol.
> + *
> + * Error if client machine cannot get remote protocol information.
> + */

Good, but void means that the caller of this function does not know when we detected an error. Perhaps return -1 on error, return 0 on "not error", so that we can return 1 when we learn to recognize "known to behave well" network filesystem to tell the caller?

That is,
> +static void check_remote_protocol(wchar_t *wpath)
"void" -> "int"
Show 11 quoted lines
> +{
> +	HANDLE h;
> +	FILE_REMOTE_PROTOCOL_INFO proto_info;
> +
> +	h = CreateFileW(wpath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
> +			FILE_FLAG_BACKUP_SEMANTICS, NULL);
> +
> +	if (h == INVALID_HANDLE_VALUE) {
> +		error(_("[GLE %ld] unable to open for read '%ls'"),
> +		      GetLastError(), wpath);
> +		return;
"return" -> "return -1"
Show 8 quoted lines
> +	}
> +
> +	if (!GetFileInformationByHandleEx(h, FileRemoteProtocolInfo,
> +		&proto_info, sizeof(proto_info))) {
> +		error(_("[GLE %ld] unable to get protocol information for '%ls'"),
> +		      GetLastError(), wpath);
> +		CloseHandle(h);
> +		return;
"return" -> "return -1"
Show 9 quoted lines
> +	}
> +
> +	CloseHandle(h);
> +
> +	trace_printf_key(&trace_fsmonitor,
> +				"check_remote_protocol('%ls') remote protocol %#8.8lx",
> +				wpath, proto_info.Protocol);
> +
> +	return;
"return" -> "return 0" (or "-1")
Show 11 quoted lines
> +}
> +
>  /*
>   * Remote working directories are problematic for FSMonitor.
>   *
> @@ -115,6 +169,18 @@ static enum fsmonitor_reason check_remote(struct repository *r)
>  		trace_printf_key(&trace_fsmonitor,
>  				 "check_remote('%s') true",
>  				 r->worktree);
> +
> +		check_remote_protocol(wfullpath);
And here
		ret = check_remote_protocol(wfullpath);
		if (ret < 0)
			/* definitely an error */
			return FSMONITOR_REASON_ERROR;

and then we can fall thru the non-error case below. We'd of course need to declare "int ret" at the beginning of the function.

Show 11 quoted lines
> +		switch (check_config_allowremote(r)) {
> +		case 0: /* config overrides and disables */
> +			return FSMONITOR_REASON_REMOTE;
> +		case 1: /* config overrides and enables */
> +			return FSMONITOR_REASON_OK;
> +		default:
> +			break; /* config has no opinion */
> +		}
> +
>  		return FSMONITOR_REASON_REMOTE;
>  	}

In the future, when this "first step" graduates to the upcoming release, we may want to have a follow-up enhancement patch that changes the code like so:

 * we recognize ones like SMB in check_remote_protocol() as "known
   to be good", and return 1 from there
 * after the "switch" above determies that the configuration file
   does not have any opinion, instead of unconditionally returning
   REASON_REMOTE to refuse the request, pay attention to "ret", e.g.
   something like

- return FSMONITOR_REASON_REMOTE; + if (!ret) + return FSMONITOR_REASON_REMOTE; + else /* known to be good ones */ + return FSMONITOR_REASON_OK;

When we do so, we'd resurrect the "unless on a network filesystem that is known to behave well" comment. What this last part does is exactly that.

Thanks.
Previous: Eric DeCosta via GitGitGadgetNext: Eric DeCosta via GitGitGadget
Message 16 of 20 in “fsmonitor: option to allow fsmonitor to run against network-mounted repos”
  1. fsmonitor: option to allow fsmonitor to run against network-mounted reposEric DeCosta via GitGitGadget, Aug 9, 2022
  2. Junio C HamanoAug 10, 2022
  3. Eric DAug 10, 2022
  4. Junio C HamanoAug 10, 2022
  5. Eric DAug 10, 2022
  6. Eric DAug 10, 2022
  7. Junio C HamanoAug 10, 2022
  8. 0/2 Option to allow fsmonitor to run against repos on network file systemsEric DeCosta via GitGitGadget, Aug 11, 2022
  9. 1/2 fsmonitor: option to allow fsmonitor to run against network-mounted reposEric DeCosta via GitGitGadget, Aug 11, 2022
  10. 2/2 fsmonitor.allowRemote now overrides default behaviorEric DeCosta via GitGitGadget, Aug 11, 2022
  11. Junio C HamanoAug 11, 2022
  12. Eric DAug 11, 2022
  13. Junio C HamanoAug 11, 2022
  14. Eric DAug 11, 2022
  15. fsmonitor: option to allow fsmonitor to run against network-mounted reposEric DeCosta via GitGitGadget, Aug 11, 2022
  16. Junio C HamanoAug 11, 2022
  17. fsmonitor: option to allow fsmonitor to run against network-mounted reposEric DeCosta via GitGitGadget, Aug 11, 2022
  18. Junio C HamanoAug 12, 2022
  19. Jeff HostetlerAug 15, 2022
  20. Junio C HamanoAug 15, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.