- From 7efa56c2f9a1825f5483879459e8460e553eeb85 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Fri, 18 Oct 2024 14:00:34 +0200
- Subject: [PATCH 1/4] daemon: Fix drmemory hits when processing NFSv4 referrals
- Fix two drmemory hits when processing NFSv4 referrals:
- ---- snip ----
- Error #1: UNINITIALIZED READ: reading 8 byte(s)
- 0 path_fh_copy [ms-nfs41-client\daemon\util.c:468]
- 1 server_lookup [ms-nfs41-client\daemon\lookup.c:259]
- 2 server_lookup_loop [ms-nfs41-client\daemon\lookup.c:360]
- 3 nfs41_lookup [ms-nfs41-client\daemon\lookup.c:512]
- 4 lookup_entry [ms-nfs41-client\daemon\readdir.c:468]
- 5 readdir_copy_entry [ms-nfs41-client\daemon\readdir.c:534]
- 6 handle_readdir [ms-nfs41-client\daemon\readdir.c:800]
- 7 upcall_handle [ms-nfs41-client\daemon\upcall.c:220]
- 8 nfsd_worker_thread_main [ms-nfs41-client\daemon\nfs41_daemon.c:201]
- 9 nfsd_thread_main [ms-nfs41-client\daemon\nfs41_daemon.c:239]
- 10 KERNEL32.dll!BaseThreadInitThunk +0x13 (0x00007ffadccb7374 <KERNEL32.dll+0x17374>)
- Error #2: UNINITIALIZED READ: reading 8 byte(s)
- 0 path_fh_copy [ms-nfs41-client\daemon\util.c:470]
- 1 server_lookup [ms-nfs41-client\daemon\lookup.c:259]
- 2 server_lookup_loop [ms-nfs41-client\daemon\lookup.c:360]
- 3 nfs41_lookup [ms-nfs41-client\daemon\lookup.c:512]
- 8 readdir_copy_entry [ms-nfs41-client\daemon\readdir.c:534]
- 9 handle_readdir [ms-nfs41-client\daemon\readdir.c:800]
- 10 upcall_handle [ms-nfs41-client\daemon\upcall.c:220]
- 11 nfsd_worker_thread_main [ms-nfs41-client\daemon\nfs41_daemon.c:201]
- 12 nfsd_thread_main [ms-nfs41-client\daemon\nfs41_daemon.c:239]
- ---- snip ----
- Reported-by: Cedric Blancher <cedric.blancher@gmail.com>
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/lookup.c | 4 ++--
- daemon/namespace.c | 2 +-
- 2 files changed, 3 insertions(+), 3 deletions(-)
- diff --git a/daemon/lookup.c b/daemon/lookup.c
- index 0c971e7..8dad916 100644
- --- a/daemon/lookup.c
- +++ b/daemon/lookup.c
- @@ -466,9 +466,9 @@ int nfs41_lookup(
- {
- nfs41_abs_path path;
- struct nfs41_name_cache *cache = session_name_cache(session);
- - nfs41_path_fh parent, target, *server_start;
- + nfs41_path_fh parent = { 0 }, target = { 0 }, *server_start;
- const char *path_pos, *path_end;
- - struct lookup_referral referral;
- + struct lookup_referral referral = { 0 };
- bool_t negative = 0;
- int status;
- diff --git a/daemon/namespace.c b/daemon/namespace.c
- index fd2e364..b5328a9 100644
- --- a/daemon/namespace.c
- +++ b/daemon/namespace.c
- @@ -445,7 +445,7 @@ static int referral_mount_location(
- IN const fs_location4 *loc,
- OUT nfs41_client **client_out)
- {
- - multi_addr4 addrs;
- + multi_addr4 addrs = { 0 };
- int status = ERROR_BAD_NET_NAME;
- uint32_t i;
- --
- 2.45.1
- From 13a1662788a6b78b4e5fa0f937d1b00d54caffc0 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Sat, 19 Oct 2024 11:53:56 +0200
- Subject: [PATCH 2/4] libtirpc: |bindresvport_sa()| should start allocating
- reserved ports where it left off last time
- |bindresvport_sa()| should start allocating reserved ports where
- it left off last time, otherwise it can reuse a port reservation
- which is already in use, leading to a |connect()| failure.
- This fixes NFSv4 referrals not working if they refer to the same
- host which did the referral.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- libtirpc/src/bindresvport.c | 14 ++++++--------
- 1 file changed, 6 insertions(+), 8 deletions(-)
- diff --git a/libtirpc/src/bindresvport.c b/libtirpc/src/bindresvport.c
- index 50e1669..5868df8 100644
- --- a/libtirpc/src/bindresvport.c
- +++ b/libtirpc/src/bindresvport.c
- @@ -164,7 +164,7 @@ bindresvport_sa(sd, sa)
- #endif
- /* fixme: not threadsafe, we should use |portnum_lock| */
- -static int bindresvport_sa_last_n = 0;
- +static unsigned int bindresvport_sa_n = 0;
- int
- bindresvport_sa(int sd, struct sockaddr *sa)
- @@ -182,13 +182,13 @@ bindresvport_sa(int sd, struct sockaddr *sa)
- BRP_D((void)fprintf(stdout,
- "--> bindresvport_sa(sd=%d,sa=0x%p): "
- - "bindresvport_sa_last_n=%d\n",
- - sd, sa, bindresvport_sa_last_n));
- + "bindresvport_sa_n=%u\n",
- + sd, sa, bindresvport_sa_n));
- sd_sock = wintirpc_fd2sockethandle(sd);
- for (n = 0 ; n < NPORTS ; n++) {
- - currport = ((n+bindresvport_sa_last_n)%NPORTS)+STARTPORT;
- + currport = ((bindresvport_sa_n++)%NPORTS)+STARTPORT;
- portRange.StartPort = htons((unsigned short)currport);
- portRange.NumberOfPorts = 1;
- @@ -198,8 +198,8 @@ bindresvport_sa(int sd, struct sockaddr *sa)
- BRP_D((void)fprintf(stdout,
- "bindresvport_sa(sd=%d,sa=0x%p): "
- - "trying n=%d, bindresvport_sa_last_n=%d, port=%d ...\n",
- - sd, sa, n, bindresvport_sa_last_n,
- + "trying n=%d, bindresvport_sa_n=%u, port=%d ...\n",
- + sd, sa, n, bindresvport_sa_n,
- (int)ntohs(portRange.StartPort)));
- ioctlres = WSAIoctl(sd_sock,
- SIO_ACQUIRE_PORT_RESERVATION,
- @@ -224,12 +224,10 @@ bindresvport_sa(int sd, struct sockaddr *sa)
- "with error = %d\n",
- sd, sa, lasterr);
- res = 1;
- - bindresvport_sa_last_n = n+1;
- goto out;
- }
- /* Success */
- - bindresvport_sa_last_n = n+1;
- break;
- }
- --
- 2.45.1
- From 164582131c466acefaba1768b1b7238cf9ac5b98 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Sat, 19 Oct 2024 13:31:54 +0200
- Subject: [PATCH 3/4] daemon: Add some NFSv4 referral debugging code
- Add some NFSv4 referral debugging code.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/namespace.c | 9 +++++++--
- 1 file changed, 7 insertions(+), 2 deletions(-)
- diff --git a/daemon/namespace.c b/daemon/namespace.c
- index b5328a9..3d90b81 100644
- --- a/daemon/namespace.c
- +++ b/daemon/namespace.c
- @@ -449,10 +449,15 @@ static int referral_mount_location(
- int status = ERROR_BAD_NET_NAME;
- uint32_t i;
- - DPRINTF(NSLVL, ("--> referral_mount_location()\n"));
- + DPRINTF(1, ("--> referral_mount_location()\n"));
- /* create a client and session for the first available server */
- for (i = 0; i < loc->server_count; i++) {
- + DPRINTF(1,
- + ("referral_mount_location: "
- + "trying loc->servers[%d].address='%s'\n",
- + (int)i, loc->servers[i].address));
- +
- /* XXX: only deals with 'address' as a hostname with default port */
- status = nfs41_server_resolve(loc->servers[i].address, 2049, &addrs);
- if (status) continue;
- @@ -462,7 +467,7 @@ static int referral_mount_location(
- break;
- }
- - DPRINTF(NSLVL, ("<-- referral_mount_location() returning %d\n", status));
- + DPRINTF(1, ("<-- referral_mount_location() returning %d\n", status));
- return status;
- }
- --
- 2.45.1
- From f168296e3d49bc5f6709bcb447d38d48591f6170 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Sat, 19 Oct 2024 14:28:29 +0200
- Subject: [PATCH 4/4] cygwin: Add NFSv4.1 referral support to
- README.bintarball.txt
- Add NFSv4.1 referral support to README.bintarball.txt
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- cygwin/README.bintarball.txt | 4 ++++
- 1 file changed, 4 insertions(+)
- diff --git a/cygwin/README.bintarball.txt b/cygwin/README.bintarball.txt
- index 8fb6966..2613d29 100644
- --- a/cygwin/README.bintarball.txt
- +++ b/cygwin/README.bintarball.txt
- @@ -61,6 +61,10 @@ NFSv4.1 filesystem driver for Windows 10/11&Windows Server 2019
- - Support for NFSv4 public mounts (i.e. use the NFSv4 public file handle
- lookup protocol via $ nfs_mount -o public ... #)
- +- Support for NFSv4 referrals
- + - See Linux export(5) refer= option, nfsref(5) or
- + https://docs.oracle.com/cd/E86824_01/html/E54764/nfsref-1m.html
- +
- - SFU/Cygwin support, including:
- - uid/gid
- - Cygwin symlinks
- --
- 2.45.1
msnfs41client: Fixes for NFSv4 referrals+misc, 2024-10-19
Posted by Anonymous on Sat 19th Oct 2024 15:43
raw | new post
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.