From: "Eric DeCosta via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Eric DeCosta <edecosta@mathworks.com>,
Eric DeCosta <edecosta@mathworks.com>
Subject: [PATCH v4] fsmonitor: option to allow fsmonitor to run against network-mounted repos
Date: Thu, 11 Aug 2022 23:57:11 +0000 [thread overview]
Message-ID: <pull.1317.v4.git.1660262231357.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1317.v3.git.1660242752495.gitgitgadget@gmail.com>
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>
---
Option to allow fsmonitor to run against repos on network file systems
cc: Eric D eric.decosta@gmail.com
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1317%2Fedecosta-mw%2Fmaster-v4
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1317/edecosta-mw/master-v4
Pull-Request: https://github.com/gitgitgadget/git/pull/1317
Range-diff vs v3:
1: 6c5f176cbee ! 1: 058dc400c8a fsmonitor: option to allow fsmonitor to run against network-mounted repos
@@ compat/fsmonitor/fsm-settings-win32.c: static enum fsmonitor_reason check_vfs4gi
+ * 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
++ * disabled. Users may override this behavior in enviroments where
+ * they have proper support.
+ */
+static int check_config_allowremote(struct repository *r)
@@ compat/fsmonitor/fsm-settings-win32.c: static enum fsmonitor_reason check_vfs4gi
+ *
+ * Error if client machine cannot get remote protocol information.
+ */
-+static void check_remote_protocol(wchar_t *wpath)
++static int check_remote_protocol(wchar_t *wpath)
+{
+ HANDLE h;
+ FILE_REMOTE_PROTOCOL_INFO proto_info;
@@ compat/fsmonitor/fsm-settings-win32.c: static enum fsmonitor_reason check_vfs4gi
+ if (h == INVALID_HANDLE_VALUE) {
+ error(_("[GLE %ld] unable to open for read '%ls'"),
+ GetLastError(), wpath);
-+ return;
++ return -1;
+ }
+
+ if (!GetFileInformationByHandleEx(h, FileRemoteProtocolInfo,
@@ compat/fsmonitor/fsm-settings-win32.c: static enum fsmonitor_reason check_vfs4gi
+ error(_("[GLE %ld] unable to get protocol information for '%ls'"),
+ GetLastError(), wpath);
+ CloseHandle(h);
-+ return;
++ return -1;
+ }
+
+ CloseHandle(h);
@@ compat/fsmonitor/fsm-settings-win32.c: static enum fsmonitor_reason check_vfs4gi
+ "check_remote_protocol('%ls') remote protocol %#8.8lx",
+ wpath, proto_info.Protocol);
+
-+ return;
++ return 0;
+}
+
/*
* Remote working directories are problematic for FSMonitor.
*
+@@ compat/fsmonitor/fsm-settings-win32.c: static enum fsmonitor_reason check_vfs4git(struct repository *r)
+ */
+ static enum fsmonitor_reason check_remote(struct repository *r)
+ {
++ int ret;
+ wchar_t wpath[MAX_PATH];
+ wchar_t wfullpath[MAX_PATH];
+ size_t wlen;
@@ compat/fsmonitor/fsm-settings-win32.c: static enum fsmonitor_reason check_remote(struct repository *r)
trace_printf_key(&trace_fsmonitor,
"check_remote('%s') true",
r->worktree);
+
-+ check_remote_protocol(wfullpath);
++ ret = check_remote_protocol(wfullpath);
++ if (ret < 0)
++ return FSMONITOR_REASON_ERROR;
+
+ switch (check_config_allowremote(r)) {
+ case 0: /* config overrides and disables */
compat/fsmonitor/fsm-settings-win32.c | 68 +++++++++++++++++++++++++++
1 file changed, 68 insertions(+)
diff --git a/compat/fsmonitor/fsm-settings-win32.c b/compat/fsmonitor/fsm-settings-win32.c
index 907655720bb..e5ec5b0a9f7 100644
--- a/compat/fsmonitor/fsm-settings-win32.c
+++ b/compat/fsmonitor/fsm-settings-win32.c
@@ -24,6 +24,59 @@ 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. Users may override this behavior in enviroments where
+ * they have proper support.
+ */
+static int check_config_allowremote(struct repository *r)
+{
+ int allow;
+
+ if (!repo_config_get_bool(r, "fsmonitor.allowremote", &allow))
+ return allow;
+
+ return -1; /* fsmonitor.allowremote not set */
+}
+
+/*
+ * Check remote working directory protocol.
+ *
+ * Error if client machine cannot get remote protocol information.
+ */
+static int check_remote_protocol(wchar_t *wpath)
+{
+ 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 -1;
+ }
+
+ if (!GetFileInformationByHandleEx(h, FileRemoteProtocolInfo,
+ &proto_info, sizeof(proto_info))) {
+ error(_("[GLE %ld] unable to get protocol information for '%ls'"),
+ GetLastError(), wpath);
+ CloseHandle(h);
+ return -1;
+ }
+
+ CloseHandle(h);
+
+ trace_printf_key(&trace_fsmonitor,
+ "check_remote_protocol('%ls') remote protocol %#8.8lx",
+ wpath, proto_info.Protocol);
+
+ return 0;
+}
+
/*
* Remote working directories are problematic for FSMonitor.
*
@@ -76,6 +129,7 @@ static enum fsmonitor_reason check_vfs4git(struct repository *r)
*/
static enum fsmonitor_reason check_remote(struct repository *r)
{
+ int ret;
wchar_t wpath[MAX_PATH];
wchar_t wfullpath[MAX_PATH];
size_t wlen;
@@ -115,6 +169,20 @@ static enum fsmonitor_reason check_remote(struct repository *r)
trace_printf_key(&trace_fsmonitor,
"check_remote('%s') true",
r->worktree);
+
+ ret = check_remote_protocol(wfullpath);
+ if (ret < 0)
+ return FSMONITOR_REASON_ERROR;
+
+ 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;
}
base-commit: c50926e1f48891e2671e1830dbcd2912a4563450
--
gitgitgadget
next prev parent reply other threads:[~2022-08-11 23:57 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-09 17:44 [PATCH] fsmonitor: option to allow fsmonitor to run against network-mounted repos Eric DeCosta via GitGitGadget
2022-08-10 16:49 ` Junio C Hamano
2022-08-10 18:49 ` Eric D
2022-08-10 19:50 ` Junio C Hamano
2022-08-10 20:36 ` Eric D
2022-08-10 21:30 ` Eric D
2022-08-10 21:41 ` Junio C Hamano
2022-08-11 15:57 ` [PATCH v2 0/2] Option to allow fsmonitor to run against repos on network file systems Eric DeCosta via GitGitGadget
2022-08-11 15:57 ` [PATCH v2 1/2] fsmonitor: option to allow fsmonitor to run against network-mounted repos Eric DeCosta via GitGitGadget
2022-08-11 15:57 ` [PATCH v2 2/2] fsmonitor.allowRemote now overrides default behavior Eric DeCosta via GitGitGadget
2022-08-11 16:53 ` Junio C Hamano
2022-08-11 17:49 ` Eric D
2022-08-11 17:53 ` Junio C Hamano
2022-08-11 17:58 ` Eric D
2022-08-11 18:32 ` [PATCH v3] fsmonitor: option to allow fsmonitor to run against network-mounted repos Eric DeCosta via GitGitGadget
2022-08-11 19:33 ` Junio C Hamano
2022-08-11 23:57 ` Eric DeCosta via GitGitGadget [this message]
2022-08-12 18:23 ` [PATCH v4] " Junio C Hamano
2022-08-15 16:01 ` Jeff Hostetler
2022-08-15 17:33 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=pull.1317.v4.git.1660262231357.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=edecosta@mathworks.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.