pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Fixes for NFSv4 referrals+misc, 2024-10-19
Posted by Anonymous on Sat 19th Oct 2024 15:43
raw | new post

  1. From 7efa56c2f9a1825f5483879459e8460e553eeb85 Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Fri, 18 Oct 2024 14:00:34 +0200
  4. Subject: [PATCH 1/4] daemon: Fix drmemory hits when processing NFSv4 referrals
  5.  
  6. Fix two drmemory hits when processing NFSv4 referrals:
  7. ---- snip ----
  8. Error #1: UNINITIALIZED READ: reading 8 byte(s)
  9.  0 path_fh_copy               [ms-nfs41-client\daemon\util.c:468]
  10.  1 server_lookup              [ms-nfs41-client\daemon\lookup.c:259]
  11.  2 server_lookup_loop         [ms-nfs41-client\daemon\lookup.c:360]
  12.  3 nfs41_lookup               [ms-nfs41-client\daemon\lookup.c:512]
  13.  4 lookup_entry               [ms-nfs41-client\daemon\readdir.c:468]
  14.  5 readdir_copy_entry         [ms-nfs41-client\daemon\readdir.c:534]
  15.  6 handle_readdir             [ms-nfs41-client\daemon\readdir.c:800]
  16.  7 upcall_handle              [ms-nfs41-client\daemon\upcall.c:220]
  17.  8 nfsd_worker_thread_main    [ms-nfs41-client\daemon\nfs41_daemon.c:201]
  18.  9 nfsd_thread_main           [ms-nfs41-client\daemon\nfs41_daemon.c:239]
  19. 10 KERNEL32.dll!BaseThreadInitThunk +0x13 (0x00007ffadccb7374 <KERNEL32.dll+0x17374>)
  20.  
  21. Error #2: UNINITIALIZED READ: reading 8 byte(s)
  22.  0 path_fh_copy               [ms-nfs41-client\daemon\util.c:470]
  23.  1 server_lookup              [ms-nfs41-client\daemon\lookup.c:259]
  24.  2 server_lookup_loop         [ms-nfs41-client\daemon\lookup.c:360]
  25.  3 nfs41_lookup               [ms-nfs41-client\daemon\lookup.c:512]
  26.  8 readdir_copy_entry         [ms-nfs41-client\daemon\readdir.c:534]
  27.  9 handle_readdir             [ms-nfs41-client\daemon\readdir.c:800]
  28. 10 upcall_handle              [ms-nfs41-client\daemon\upcall.c:220]
  29. 11 nfsd_worker_thread_main    [ms-nfs41-client\daemon\nfs41_daemon.c:201]
  30. 12 nfsd_thread_main           [ms-nfs41-client\daemon\nfs41_daemon.c:239]
  31. ---- snip ----
  32.  
  33. Reported-by: Cedric Blancher <cedric.blancher@gmail.com>
  34. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  35. ---
  36. daemon/lookup.c    | 4 ++--
  37.  daemon/namespace.c | 2 +-
  38.  2 files changed, 3 insertions(+), 3 deletions(-)
  39.  
  40. diff --git a/daemon/lookup.c b/daemon/lookup.c
  41. index 0c971e7..8dad916 100644
  42. --- a/daemon/lookup.c
  43. +++ b/daemon/lookup.c
  44. @@ -466,9 +466,9 @@ int nfs41_lookup(
  45.  {
  46.      nfs41_abs_path path;
  47.      struct nfs41_name_cache *cache = session_name_cache(session);
  48. -    nfs41_path_fh parent, target, *server_start;
  49. +    nfs41_path_fh parent = { 0 }, target = { 0 }, *server_start;
  50.      const char *path_pos, *path_end;
  51. -    struct lookup_referral referral;
  52. +    struct lookup_referral referral = { 0 };
  53.      bool_t negative = 0;
  54.      int status;
  55.  
  56. diff --git a/daemon/namespace.c b/daemon/namespace.c
  57. index fd2e364..b5328a9 100644
  58. --- a/daemon/namespace.c
  59. +++ b/daemon/namespace.c
  60. @@ -445,7 +445,7 @@ static int referral_mount_location(
  61.      IN const fs_location4 *loc,
  62.      OUT nfs41_client **client_out)
  63.  {
  64. -    multi_addr4 addrs;
  65. +    multi_addr4 addrs = { 0 };
  66.      int status = ERROR_BAD_NET_NAME;
  67.      uint32_t i;
  68.  
  69. --
  70. 2.45.1
  71.  
  72. From 13a1662788a6b78b4e5fa0f937d1b00d54caffc0 Mon Sep 17 00:00:00 2001
  73. From: Roland Mainz <roland.mainz@nrubsig.org>
  74. Date: Sat, 19 Oct 2024 11:53:56 +0200
  75. Subject: [PATCH 2/4] libtirpc: |bindresvport_sa()| should start allocating
  76.  reserved ports where it left off last time
  77.  
  78. |bindresvport_sa()| should start allocating reserved ports where
  79. it left off last time, otherwise it can reuse a port reservation
  80. which is already in use, leading to a |connect()| failure.
  81.  
  82. This fixes NFSv4 referrals not working if they refer to the same
  83. host which did the referral.
  84.  
  85. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  86. ---
  87. libtirpc/src/bindresvport.c | 14 ++++++--------
  88.  1 file changed, 6 insertions(+), 8 deletions(-)
  89.  
  90. diff --git a/libtirpc/src/bindresvport.c b/libtirpc/src/bindresvport.c
  91. index 50e1669..5868df8 100644
  92. --- a/libtirpc/src/bindresvport.c
  93. +++ b/libtirpc/src/bindresvport.c
  94. @@ -164,7 +164,7 @@ bindresvport_sa(sd, sa)
  95.  #endif
  96.  
  97.  /* fixme: not threadsafe, we should use |portnum_lock| */
  98. -static int bindresvport_sa_last_n = 0;
  99. +static unsigned int bindresvport_sa_n = 0;
  100.  
  101.  int
  102.  bindresvport_sa(int sd, struct sockaddr *sa)
  103. @@ -182,13 +182,13 @@ bindresvport_sa(int sd, struct sockaddr *sa)
  104.  
  105.         BRP_D((void)fprintf(stdout,
  106.                 "--> bindresvport_sa(sd=%d,sa=0x%p): "
  107. -               "bindresvport_sa_last_n=%d\n",
  108. -               sd, sa, bindresvport_sa_last_n));
  109. +               "bindresvport_sa_n=%u\n",
  110. +               sd, sa, bindresvport_sa_n));
  111.  
  112.         sd_sock = wintirpc_fd2sockethandle(sd);
  113.  
  114.         for (n = 0 ; n < NPORTS ; n++) {
  115. -               currport = ((n+bindresvport_sa_last_n)%NPORTS)+STARTPORT;
  116. +               currport = ((bindresvport_sa_n++)%NPORTS)+STARTPORT;
  117.  
  118.                 portRange.StartPort = htons((unsigned short)currport);
  119.                 portRange.NumberOfPorts = 1;
  120. @@ -198,8 +198,8 @@ bindresvport_sa(int sd, struct sockaddr *sa)
  121.  
  122.                 BRP_D((void)fprintf(stdout,
  123.                         "bindresvport_sa(sd=%d,sa=0x%p): "
  124. -                       "trying n=%d, bindresvport_sa_last_n=%d, port=%d ...\n",
  125. -                       sd, sa, n, bindresvport_sa_last_n,
  126. +                       "trying n=%d, bindresvport_sa_n=%u, port=%d ...\n",
  127. +                       sd, sa, n, bindresvport_sa_n,
  128.                         (int)ntohs(portRange.StartPort)));
  129.                 ioctlres = WSAIoctl(sd_sock,
  130.                         SIO_ACQUIRE_PORT_RESERVATION,
  131. @@ -224,12 +224,10 @@ bindresvport_sa(int sd, struct sockaddr *sa)
  132.                                 "with error = %d\n",
  133.                                 sd, sa, lasterr);
  134.                         res = 1;
  135. -                       bindresvport_sa_last_n = n+1;
  136.                         goto out;
  137.                 }
  138.  
  139.                 /* Success */
  140. -               bindresvport_sa_last_n = n+1;
  141.                 break;
  142.         }
  143.  
  144. --
  145. 2.45.1
  146.  
  147. From 164582131c466acefaba1768b1b7238cf9ac5b98 Mon Sep 17 00:00:00 2001
  148. From: Roland Mainz <roland.mainz@nrubsig.org>
  149. Date: Sat, 19 Oct 2024 13:31:54 +0200
  150. Subject: [PATCH 3/4] daemon: Add some NFSv4 referral debugging code
  151.  
  152. Add some NFSv4 referral debugging code.
  153.  
  154. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  155. ---
  156. daemon/namespace.c | 9 +++++++--
  157.  1 file changed, 7 insertions(+), 2 deletions(-)
  158.  
  159. diff --git a/daemon/namespace.c b/daemon/namespace.c
  160. index b5328a9..3d90b81 100644
  161. --- a/daemon/namespace.c
  162. +++ b/daemon/namespace.c
  163. @@ -449,10 +449,15 @@ static int referral_mount_location(
  164.      int status = ERROR_BAD_NET_NAME;
  165.      uint32_t i;
  166.  
  167. -    DPRINTF(NSLVL, ("--> referral_mount_location()\n"));
  168. +    DPRINTF(1, ("--> referral_mount_location()\n"));
  169.  
  170.      /* create a client and session for the first available server */
  171.      for (i = 0; i < loc->server_count; i++) {
  172. +        DPRINTF(1,
  173. +            ("referral_mount_location: "
  174. +                "trying loc->servers[%d].address='%s'\n",
  175. +                (int)i, loc->servers[i].address));
  176. +
  177.          /* XXX: only deals with 'address' as a hostname with default port */
  178.          status = nfs41_server_resolve(loc->servers[i].address, 2049, &addrs);
  179.          if (status) continue;
  180. @@ -462,7 +467,7 @@ static int referral_mount_location(
  181.              break;
  182.      }
  183.  
  184. -    DPRINTF(NSLVL, ("<-- referral_mount_location() returning %d\n", status));
  185. +    DPRINTF(1, ("<-- referral_mount_location() returning %d\n", status));
  186.  
  187.      return status;
  188.  }
  189. --
  190. 2.45.1
  191.  
  192. From f168296e3d49bc5f6709bcb447d38d48591f6170 Mon Sep 17 00:00:00 2001
  193. From: Roland Mainz <roland.mainz@nrubsig.org>
  194. Date: Sat, 19 Oct 2024 14:28:29 +0200
  195. Subject: [PATCH 4/4] cygwin: Add NFSv4.1 referral support to
  196.  README.bintarball.txt
  197.  
  198. Add NFSv4.1 referral support to README.bintarball.txt
  199.  
  200. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  201. ---
  202. cygwin/README.bintarball.txt | 4 ++++
  203.  1 file changed, 4 insertions(+)
  204.  
  205. diff --git a/cygwin/README.bintarball.txt b/cygwin/README.bintarball.txt
  206. index 8fb6966..2613d29 100644
  207. --- a/cygwin/README.bintarball.txt
  208. +++ b/cygwin/README.bintarball.txt
  209. @@ -61,6 +61,10 @@ NFSv4.1 filesystem driver for Windows 10/11&Windows Server 2019
  210.  - Support for NFSv4 public mounts (i.e. use the NFSv4 public file handle
  211.      lookup protocol via $ nfs_mount -o public ... #)
  212.  
  213. +- Support for NFSv4 referrals
  214. +    - See Linux export(5) refer= option, nfsref(5) or
  215. +        https://docs.oracle.com/cd/E86824_01/html/E54764/nfsref-1m.html
  216. +
  217.  - SFU/Cygwin support, including:
  218.      - uid/gid
  219.      - Cygwin symlinks
  220. --
  221. 2.45.1

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.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at