pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: WinNT-Version+hostname in "niiname", fixed-size libtirpc buffers+misc, 2024-03-21
Posted by Anonymous on Thu 21st Mar 2024 13:56
raw | new post

  1. From ff60d93e2556e8ff61a526735979a6c33bc2d7ee Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Thu, 21 Mar 2024 12:26:45 +0100
  4. Subject: [PATCH 1/3] tests: Document workaround for sporadic gcc build
  5.  failures (gcc bugzilla #114381)
  6.  
  7. Document workaround (configure option "--disable-libstdcxx-pch") for
  8. sporadic gcc build failures when building
  9. "x86_64-pc-cygwin/bits/extc++.h.gch/O2g.gch".
  10.  
  11. See also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114381
  12. ("(Sporadic) crash generating x86_64-pc-cygwin/bits/extc++.h.gch/O2g.gch")
  13.  
  14. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  15. ---
  16. tests/manual_testing.txt | 5 ++++-
  17.  1 file changed, 4 insertions(+), 1 deletion(-)
  18.  
  19. diff --git a/tests/manual_testing.txt b/tests/manual_testing.txt
  20. index 8ebe9a6..f8fc3b8 100644
  21. --- a/tests/manual_testing.txt
  22. +++ b/tests/manual_testing.txt
  23. @@ -204,6 +204,9 @@ MSBuild.exe build.vc19/nfs41-client.sln -t:Build  -p:Configuration=Release -p:Pl
  24.  #   max_path_length=131
  25.  #   ---- snip ----
  26.  # - Full build can easily take ~~16 hours minutes
  27. +# - Option "--disable-libstdcxx-pch" is used due to bug
  28. +#   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114381 ("(Sporadic)
  29. +#   crash generating x86_64-pc-cygwin/bits/extc++.h.gch/O2g.gch")
  30.  #
  31.  git clone -b 'releases/gcc-13.2.0' git://gcc.gnu.org/git/gcc.git
  32.  cd gcc/
  33. @@ -212,7 +215,7 @@ cd gcc/
  34.  # ancient workarounds for issues which no longer exists)
  35.  (set -o xtrace ; sed -i "s/as_ln_s='cp -pR'/as_ln_s='ln -s'/g" $(find . -name configure) )
  36.  # run configure
  37. -./configure
  38. +./configure --disable-libstdcxx-pch
  39.  # repeat:
  40.  make -j4 clean
  41.  (yes | make -j32 all)
  42. --
  43. 2.43.0
  44.  
  45. From 201309492f1c8a14bbb2b8f2d3ee3080530bee83 Mon Sep 17 00:00:00 2001
  46. From: Roland Mainz <roland.mainz@nrubsig.org>
  47. Date: Thu, 21 Mar 2024 12:36:53 +0100
  48. Subject: [PATCH 2/3] daemon: Add WinNT major/minor/buildnumber+hostname to
  49.  |nii_name|
  50.  
  51. Add WinNT major/minor/buildnumber+hostname to |nii_name|.
  52.  
  53. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  54. ---
  55. build.vc19/nfsd/nfsd.vcxproj |  8 ++--
  56.  daemon/nfs41_daemon.c        | 92 +++++++++++++++++++++++-------------
  57.  daemon/util.c                | 24 ++++++++++
  58.  daemon/util.h                |  4 ++
  59.  4 files changed, 91 insertions(+), 37 deletions(-)
  60.  
  61. diff --git a/build.vc19/nfsd/nfsd.vcxproj b/build.vc19/nfsd/nfsd.vcxproj
  62. index ea755d1..ee7a8be 100644
  63. --- a/build.vc19/nfsd/nfsd.vcxproj
  64. +++ b/build.vc19/nfsd/nfsd.vcxproj
  65. @@ -97,7 +97,7 @@
  66.      <Link>
  67.        <SubSystem>Console</SubSystem>
  68.        <GenerateDebugInformation>true</GenerateDebugInformation>
  69. -      <AdditionalDependencies>iphlpapi.lib;ws2_32.lib;wldap32.lib;..\$(Configuration)\libtirpc.lib;%(AdditionalDependencies)</AdditionalDependencies>
  70. +      <AdditionalDependencies>iphlpapi.lib;ws2_32.lib;wldap32.lib;ntdll.lib;..\$(Configuration)\libtirpc.lib;%(AdditionalDependencies)</AdditionalDependencies>
  71.      </Link>
  72.    </ItemDefinitionGroup>
  73.    <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
  74. @@ -116,7 +116,7 @@
  75.      <Link>
  76.        <SubSystem>Console</SubSystem>
  77.        <GenerateDebugInformation>true</GenerateDebugInformation>
  78. -      <AdditionalDependencies>iphlpapi.lib;ws2_32.lib;wldap32.lib;..\$(Platform)\$(Configuration)\libtirpc.lib;%(AdditionalDependencies)</AdditionalDependencies>
  79. +      <AdditionalDependencies>iphlpapi.lib;ws2_32.lib;wldap32.lib;ntdll.lib;..\$(Platform)\$(Configuration)\libtirpc.lib;%(AdditionalDependencies)</AdditionalDependencies>
  80.      </Link>
  81.    </ItemDefinitionGroup>
  82.    <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
  83. @@ -138,7 +138,7 @@
  84.        <GenerateDebugInformation>true</GenerateDebugInformation>
  85.        <EnableCOMDATFolding>true</EnableCOMDATFolding>
  86.        <OptimizeReferences>true</OptimizeReferences>
  87. -      <AdditionalDependencies>iphlpapi.lib;ws2_32.lib;wldap32.lib;..\$(Configuration)\libtirpc.lib;%(AdditionalDependencies)</AdditionalDependencies>
  88. +      <AdditionalDependencies>iphlpapi.lib;ws2_32.lib;wldap32.lib;ntdll.lib;..\$(Configuration)\libtirpc.lib;%(AdditionalDependencies)</AdditionalDependencies>
  89.      </Link>
  90.    </ItemDefinitionGroup>
  91.    <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
  92. @@ -160,7 +160,7 @@
  93.        <GenerateDebugInformation>true</GenerateDebugInformation>
  94.        <EnableCOMDATFolding>true</EnableCOMDATFolding>
  95.        <OptimizeReferences>true</OptimizeReferences>
  96. -      <AdditionalDependencies>iphlpapi.lib;ws2_32.lib;wldap32.lib;..\$(Platform)\$(Configuration)\libtirpc.lib;%(AdditionalDependencies)</AdditionalDependencies>
  97. +      <AdditionalDependencies>iphlpapi.lib;ws2_32.lib;wldap32.lib;ntdll.lib;..\$(Platform)\$(Configuration)\libtirpc.lib;%(AdditionalDependencies)</AdditionalDependencies>
  98.      </Link>
  99.    </ItemDefinitionGroup>
  100.    <ItemGroup>
  101. diff --git a/daemon/nfs41_daemon.c b/daemon/nfs41_daemon.c
  102. index 9ba7885..5b9c48d 100644
  103. --- a/daemon/nfs41_daemon.c
  104. +++ b/daemon/nfs41_daemon.c
  105. @@ -523,59 +523,85 @@ void nfsd_crt_debug_init(void)
  106.  static
  107.  void init_version_string(void)
  108.  {
  109. -    char uname_buff[256];
  110. -    char *s;
  111. -    DWORD buff_read;
  112. +    DWORD WinNT_MajorVersion = 0;
  113. +    DWORD WinNT_MinorVersion = 0;
  114. +    DWORD WinNT_BuildNumber = 0;
  115. +    char *niin_ptr = nfs41_dg.nfs41_nii_name;
  116. +    char hostnamebuf[128];
  117. +
  118. +#define IVS_REMAINING_NIINAME_BYTES \
  119. +    (sizeof(nfs41_dg.nfs41_nii_name) - (niin_ptr-nfs41_dg.nfs41_nii_name))
  120. +
  121. +    /*
  122. +     * Add our own name
  123. +     */
  124. +    niin_ptr += snprintf(niin_ptr, IVS_REMAINING_NIINAME_BYTES,
  125. +        "msnfs41client 0.1");
  126. +
  127. +    /* FIXME: Add git tag */
  128.  
  129.      /*
  130. -     * gisburn: fixme:
  131. -     * We should get the Windows version numbers from the
  132. -     * Windows registry, unfortunately this is going to be a
  133. -     * another variantion of vesion hell, as |GetVersionEx()|
  134. -     * is depreciated
  135. +     * Add Windows version numbers
  136.       */
  137. -    subcmd_popen_context *scmd_uname = subcmd_popen("C:\\cygwin64\\bin\\uname.exe -a");
  138. +    if (getwinntversionnnumbers(&WinNT_MajorVersion,
  139. +        &WinNT_MinorVersion, &WinNT_BuildNumber)) {
  140. +        niin_ptr += snprintf(niin_ptr, IVS_REMAINING_NIINAME_BYTES,
  141. +            ", WinNT %u.%u-%u",
  142. +            (unsigned int)WinNT_MajorVersion,
  143. +            (unsigned int)WinNT_MinorVersion,
  144. +            (unsigned int)WinNT_BuildNumber);
  145. +    }
  146. +
  147. +    /*
  148. +     * Add hostname
  149. +     */
  150. +    if (!gethostname(hostnamebuf, sizeof(hostnamebuf))) {
  151. +        niin_ptr += snprintf(niin_ptr, IVS_REMAINING_NIINAME_BYTES,
  152. +            ", hostname='%s'", hostnamebuf);
  153. +    }
  154. +
  155. +#ifdef NFS41_DRIVER_FEATURE_IDMAPPER_CYGWIN
  156. +    /*
  157. +     * Add cygwin version, if Cygwin idmapper is enabled
  158. +     */
  159. +    subcmd_popen_context *scmd_uname =
  160. +        subcmd_popen("C:\\cygwin64\\bin\\uname.exe -a");
  161.      if (scmd_uname) {
  162. +        char unamebuf[256];
  163. +        char *s;
  164. +        DWORD buff_read;
  165. +
  166.          buff_read = 0;
  167. -        if (subcmd_readcmdoutput(scmd_uname, uname_buff, sizeof(uname_buff), &buff_read)) {
  168. +        if (subcmd_readcmdoutput(scmd_uname, unamebuf,
  169. +            sizeof(unamebuf)-1, &buff_read)) {
  170.              /* Remove trailing newline */
  171. -            if ((buff_read > 0) && (uname_buff[buff_read-1] == '\n'))
  172. -                uname_buff[buff_read-1] = '\0';
  173. +            if ((buff_read > 0) && (unamebuf[buff_read-1] == '\n'))
  174. +                unamebuf[buff_read-1] = '\0';
  175.              else
  176. -                uname_buff[buff_read] = '\0';
  177. +                unamebuf[buff_read] = '\0';
  178.  
  179.              /* Stomp newline&co. */
  180. -            for (s = uname_buff ; *s != '\0' ; s++) {
  181. +            for (s = unamebuf ; *s != '\0' ; s++) {
  182.                  if ((*s == '\n') || (*s == '\r'))
  183.                      *s = ' ';
  184.              }
  185. +
  186. +            niin_ptr += snprintf(niin_ptr, IVS_REMAINING_NIINAME_BYTES,
  187. +                ", cygwin_vers='%s'", unamebuf);
  188.          }
  189.          else {
  190. -            eprintf("init_version_string: subcmd_readcmdoutput() for 'uname -a' failed\n");
  191. -            uname_buff[0] = '\0';
  192. +            eprintf("init_version_string: subcmd_readcmdoutput() "
  193. +                "for 'uname -a' failed\n");
  194. +            unamebuf[0] = '\0';
  195.          }
  196.          subcmd_pclose(scmd_uname);
  197.      }
  198.      else {
  199. -        eprintf("init_version_string: subcmd_popen() for 'uname -a' failed\n");
  200. -        uname_buff[0] = '\0';
  201. +        eprintf("init_version_string: subcmd_popen() for "
  202. +            "'uname -a' failed\n");
  203.      }
  204. +#endif /* NFS41_DRIVER_FEATURE_IDMAPPER_CYGWIN */
  205.  
  206. -    /*
  207. -     * gisburn: fixme:
  208. -     * 1. We should include cygwin uname output only in Cygwin mode
  209. -     * 2. We should determinate the Windows version numvber ourselves
  210. -     * 3. We should include our own version and git tag
  211. -     * 4. We should honor RFC5661: "... it is RECOMMENDED
  212. -     *   that the nii_name be used to distinguish machine architecture,
  213. -     *   machine platforms, revisions, versions, and patch levels. The
  214. -     *   nii_date field is the timestamp of when the software instance
  215. -     *   was published or built..."
  216. -     */
  217. -    (void)snprintf(nfs41_dg.nfs41_nii_name,
  218. -        sizeof(nfs41_dg.nfs41_nii_name),
  219. -        "msnfs41client 0.1 WinNT NFSv4.1 client, cygwin_vers='%s'",
  220. -        uname_buff);
  221.      DPRINTF(1, ("init_version_string: versionstring='%s'\n",
  222.          nfs41_dg.nfs41_nii_name));
  223.  }
  224. diff --git a/daemon/util.c b/daemon/util.c
  225. index e2774d0..382944a 100644
  226. --- a/daemon/util.c
  227. +++ b/daemon/util.c
  228. @@ -628,3 +628,27 @@ bool_t waitcriticalsection(LPCRITICAL_SECTION cs)
  229.      }
  230.      return cs_locked;
  231.  }
  232. +
  233. +/*
  234. + * Get WinNT version numbers
  235. + *
  236. + * We use this wrapper function because |RtlGetNtVersionNumbers()|
  237. + * is a private API, but it should be safe to use as Cygwin and
  238. + * other software relies on it
  239. + */
  240. +bool getwinntversionnnumbers(
  241. +    DWORD *MajorVersionPtr,
  242. +    DWORD *MinorVersionPtr,
  243. +    DWORD *BuildNumberPtr)
  244. +{
  245. +    NTSTATUS RtlGetNtVersionNumbers(LPDWORD, LPDWORD, LPDWORD);
  246. +
  247. +    /*
  248. +     * Reference:
  249. +     * https://cygwin.com/git/?p=newlib-cygwin.git;a=blob;f=winsup/cygwin/wincap.cc
  250. +     */
  251. +    (void)RtlGetNtVersionNumbers(MajorVersionPtr, MinorVersionPtr, BuildNumberPtr);
  252. +    *BuildNumberPtr &= 0xffff;
  253. +
  254. +    return true;
  255. +}
  256. diff --git a/daemon/util.h b/daemon/util.h
  257. index 2bc2ec9..73bfc54 100644
  258. --- a/daemon/util.h
  259. +++ b/daemon/util.h
  260. @@ -22,6 +22,8 @@
  261.  #ifndef __NFS41_DAEMON_UTIL_H__
  262.  #define __NFS41_DAEMON_UTIL_H__
  263.  
  264. +#include <stdbool.h>
  265. +
  266.  #include "nfs41_types.h"
  267.  #include "from_kernel.h"
  268.  
  269. @@ -269,4 +271,6 @@ BOOL subcmd_readcmdoutput(subcmd_popen_context *pinfo, char *buff, size_t buff_s
  270.  bool_t waitSRWlock(PSRWLOCK srwlock);
  271.  bool_t waitcriticalsection(LPCRITICAL_SECTION cs);
  272.  
  273. +bool getwinntversionnnumbers(DWORD *MajorVersionPtr, DWORD *MinorVersionPtr, DWORD *BuildNumberPtr);
  274. +
  275.  #endif /* !__NFS41_DAEMON_UTIL_H__ */
  276. --
  277. 2.43.0
  278.  
  279. From 3736f9402c213c2929fce4d1d46241d2e87f2fde Mon Sep 17 00:00:00 2001
  280. From: Roland Mainz <roland.mainz@nrubsig.org>
  281. Date: Thu, 21 Mar 2024 14:20:01 +0100
  282. Subject: [PATCH 3/3] libtirpc: Add new build option
  283.  "NFS41_DRIVER_USE_LARGE_SOCKET_RCVSND_BUFFERS"
  284.  
  285. Add new build option "NFS41_DRIVER_USE_LARGE_SOCKET_RCVSND_BUFFERS".
  286. It enables the use of fixed-size large buffers for socket receive and
  287. send buffers.
  288.  
  289. Using a large fixed-size buffer avoids the erratic behaviour
  290. caused by automatic scaling, and avoids that the code
  291. spends lots of time waiting for the data to be split into
  292. smaller chunks - this results in much reduced LATENCY.
  293.  
  294. Another benefit is that this gives a larger TCP window
  295. (as Windows has no public API to set the TCP window size
  296. per socket), resulting in better performance over WLAN
  297. connections.
  298.  
  299. This still needs detailed testing for performace (and more important)
  300. reduced latency.
  301.  
  302. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  303. ---
  304. libtirpc/src/clnt_generic.c |   4 +-
  305.  libtirpc/src/svc_vc.c       |  19 ++++--
  306.  libtirpc/src/wintirpc.c     | 132 ++++++++++++++++++++++++++++++++++++
  307.  libtirpc/tirpc/wintirpc.h   |   1 +
  308.  nfs41_build_features.h      |  16 +++++
  309.  5 files changed, 165 insertions(+), 7 deletions(-)
  310.  
  311. diff --git a/libtirpc/src/clnt_generic.c b/libtirpc/src/clnt_generic.c
  312. index 2e64b11..fca8707 100644
  313. --- a/libtirpc/src/clnt_generic.c
  314. +++ b/libtirpc/src/clnt_generic.c
  315. @@ -356,7 +356,6 @@ clnt_tli_create(const int fd_in, const struct netconfig *nconf,
  316.         CLIENT *cl;                     /* client handle */
  317.         bool_t madefd = FALSE;          /* whether fd opened here */
  318.         long servtype;
  319. -       BOOL one = TRUE;
  320.         struct __rpc_sockinfo si;
  321.         extern int __rpc_minfd;
  322.         int fd = fd_in;
  323. @@ -404,8 +403,7 @@ clnt_tli_create(const int fd_in, const struct netconfig *nconf,
  324.                 if (nconf &&
  325.                     ((strcmp(nconf->nc_protofmly, "inet") == 0) ||
  326.                      (strcmp(nconf->nc_protofmly, "inet6") == 0))) {
  327. -                       wintirpc_setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (const char *)&one,
  328. -                           sizeof (one));
  329. +                       wintirpc_setnfsclientsockopts(fd);
  330.                 }
  331.                 cl = clnt_vc_create(fd, svcaddr, prog, vers, sendsz, recvsz,
  332.              callback_xdr, callback_function, callback_args);
  333. diff --git a/libtirpc/src/svc_vc.c b/libtirpc/src/svc_vc.c
  334. index 83c58fe..9ea907f 100644
  335. --- a/libtirpc/src/svc_vc.c
  336. +++ b/libtirpc/src/svc_vc.c
  337. @@ -356,10 +356,21 @@ again:
  338.  
  339.         __xprt_set_raddr(newxprt, &addr);
  340.  
  341. -       if (__rpc_fd2sockinfo(sock, &si) && si.si_proto == IPPROTO_TCP) {
  342. -               len = 1;
  343. -               /* XXX fvdl - is this useful? */
  344. -               wintirpc_setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (const char *)&len, sizeof (len));
  345. +       if (__rpc_fd2sockinfo(sock, &si)) {
  346. +               if (si.si_proto == IPPROTO_TCP) {
  347. +                       wintirpc_setnfsclientsockopts(sock);
  348. +               }
  349. +               else {
  350. +                       wintirpc_warnx("rendezvous_request: "
  351. +                               "Unexpected sock=%d, si.si_proto=%d\n",
  352. +                               sock,
  353. +                               (int)si.si_proto);
  354. +               }
  355. +       }
  356. +       else {
  357. +               wintirpc_warnx("rendezvous_request: "
  358. +                       "__rpc_fd2sockinfo(sock=%d) failed\n",
  359. +                       sock);
  360.         }
  361.  
  362.         cd = (struct cf_conn *)newxprt->xp_p1;
  363. diff --git a/libtirpc/src/wintirpc.c b/libtirpc/src/wintirpc.c
  364. index 003958a..88fac01 100644
  365. --- a/libtirpc/src/wintirpc.c
  366. +++ b/libtirpc/src/wintirpc.c
  367. @@ -25,6 +25,8 @@
  368.  #include <stdio.h>
  369.  #include <winsock.h>
  370.  
  371. +#include "../../nfs41_build_features.h"
  372. +
  373.  WSADATA WSAData;
  374.  
  375.  static int init = 0;
  376. @@ -396,6 +398,136 @@ int wintirpc_setsockopt(int socket, int level, int option_name,
  377.                 option_value, option_len);
  378.  }
  379.  
  380. +void wintirpc_setnfsclientsockopts(int sock)
  381. +{
  382. +       DWORD one;
  383. +       int rcvbufvalue;
  384. +       int sndbufvalue;
  385. +       socklen_t bufsize;
  386. +
  387. +       one = 1;
  388. +       /* XXX fvdl - is this useful? */
  389. +       if (wintirpc_setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
  390. +               (const char *)&one, sizeof(one)))
  391. +               wintirpc_warnx("wintirpc_setnfsclientsockopts(sock=%d):"
  392. +                       " Error setting TCP_NODELAY\n", sock);
  393. +
  394. +       /* gisburn: Is this useful ? */
  395. +       one = 1;
  396. +       if (wintirpc_setsockopt(sock, IPPROTO_TCP, TCP_TIMESTAMPS,
  397. +               (const char *)&one, sizeof(one)))
  398. +               wintirpc_warnx("wintirpc_setnfsclientsockopts(sock=%d):"
  399. +                       " Error setting TCP_TIMESTAMPS\n", sock);
  400. +
  401. +#ifdef NFS41_DRIVER_USE_LARGE_SOCKET_RCVSND_BUFFERS
  402. +       /*
  403. +        * Print default values
  404. +        */
  405. +       rcvbufvalue = 0;
  406. +       bufsize = sizeof(rcvbufvalue);
  407. +       if (wintirpc_getsockopt(sock, SOL_SOCKET, SO_RCVBUF,
  408. +               (char *)&rcvbufvalue, &bufsize))
  409. +               wintirpc_warnx("wintirpc_setnfsclientsockopts(sock=%d):"
  410. +                       " Error getting SO_RCVBUF\n", sock);
  411. +
  412. +       sndbufvalue = 0;
  413. +       bufsize = sizeof(sndbufvalue);
  414. +       if (wintirpc_getsockopt(sock, SOL_SOCKET, SO_SNDBUF,
  415. +               (char *)&sndbufvalue, &bufsize))
  416. +               wintirpc_warnx("wintirpc_setnfsclientsockopts(sock=%d):"
  417. +                       " Error getting SO_SNDBUF\n", sock);
  418. +
  419. +#ifdef _DEBUG
  420. +       (void)printf("wintirpc_setnfsclientsockopts(sock=%d): "
  421. +               "SO_RCVBUF=%d\n", sock, (int)rcvbufvalue);
  422. +       (void)printf("wintirpc_setnfsclientsockopts(sock=%d): "
  423. +               "SO_SNDBUF=%d\n", sock, (int)sndbufvalue);
  424. +#endif
  425. +
  426. +       /*
  427. +        * Set socket rcv and snd buffer sizes to 8M if the current
  428. +        * value is smaller
  429. +        *
  430. +        * Windows 10 defaults to 64k, which is far too small for most
  431. +        * NFS read&&write requests, which causes significant delays
  432. +        * for each request
  433. +        *
  434. +        * Using a large static buffer avoids the erratic behaviour
  435. +        * caused by automatic scaling, and avoids that the code
  436. +        * spends lots of time waiting for the data to be split into
  437. +        * smaller chunks - this results in much reduced latency.
  438. +        *
  439. +        * Another benefit is that this gives a larger TCP window
  440. +        * (as Windows has no public API to set the TCP window size
  441. +        * per socket), resulting in better performance over WLAN
  442. +        * connections.
  443. +        */
  444. +#define NFSRV_TCPSOCKBUF (8 * 1024 * 1024)
  445. +
  446. +       if (rcvbufvalue < NFSRV_TCPSOCKBUF) {
  447. +               rcvbufvalue = NFSRV_TCPSOCKBUF;
  448. +               bufsize = sizeof(rcvbufvalue);
  449. +               if (wintirpc_setsockopt(sock, SOL_SOCKET, SO_RCVBUF,
  450. +                       (const char *)&rcvbufvalue, sizeof(bufsize)))
  451. +                       wintirpc_warnx(
  452. +                               "wintirpc_setnfsclientsockopts(sock=%d): "
  453. +                               "Error setting SO_RCVBUF\n", sock);
  454. +
  455. +               rcvbufvalue = 0;
  456. +               bufsize = sizeof(rcvbufvalue);
  457. +               if (wintirpc_getsockopt(sock, SOL_SOCKET, SO_RCVBUF,
  458. +                       (char *)&rcvbufvalue, &bufsize))
  459. +                       wintirpc_warnx(
  460. +                               "wintirpc_setnfsclientsockopts(sock=%d): "
  461. +                               "Error getting SO_RCVBUF\n", sock);
  462. +
  463. +               if (rcvbufvalue != NFSRV_TCPSOCKBUF) {
  464. +                       wintirpc_warnx(
  465. +                               "wintirpc_setnfsclientsockopts(sock=%d): "
  466. +                               "SO_RCVBUF expected size=%d, got size=%d\n",
  467. +                               sock,
  468. +                               (int)NFSRV_TCPSOCKBUF, (int)rcvbufvalue);
  469. +               }
  470. +
  471. +#ifdef _DEBUG
  472. +               (void)printf("wintirpc_setnfsclientsockopts(sock=%d): "
  473. +                       "set SO_RCVBUF to %d\n", sock, (int)rcvbufvalue);
  474. +#endif
  475. +       }
  476. +
  477. +
  478. +       if (sndbufvalue < NFSRV_TCPSOCKBUF) {
  479. +               sndbufvalue = NFSRV_TCPSOCKBUF;
  480. +               bufsize = sizeof(sndbufvalue);
  481. +               if (wintirpc_setsockopt(sock, SOL_SOCKET, SO_SNDBUF,
  482. +                       (const char *)&sndbufvalue, sizeof(bufsize)))
  483. +                       wintirpc_warnx(
  484. +                               "wintirpc_setnfsclientsockopts(sock=%d): "
  485. +                               "Error setting SO_SNDBUF\n", sock);
  486. +
  487. +               sndbufvalue = 0;
  488. +               bufsize = sizeof(sndbufvalue);
  489. +               if (wintirpc_getsockopt(sock, SOL_SOCKET, SO_SNDBUF,
  490. +                       (char *)&sndbufvalue, &bufsize))
  491. +                       wintirpc_warnx(
  492. +                               "wintirpc_setnfsclientsockopts(sock=%d): "
  493. +                               "Error getting SO_SNDBUF\n", sock);
  494. +
  495. +               if (sndbufvalue != NFSRV_TCPSOCKBUF) {
  496. +                       wintirpc_warnx(
  497. +                               "wintirpc_setnfsclientsockopts(sock=%d): "
  498. +                               "SO_SNDBUF expected size=%d, got size=%d\n",
  499. +                               sock, (int)NFSRV_TCPSOCKBUF, (int)sndbufvalue);
  500. +               }
  501. +
  502. +#ifdef _DEBUG
  503. +               (void)printf("wintirpc_setnfsclientsockopts(sock=%d): "
  504. +                       "set SO_SNDBUF to %d\n", sock, (int)sndbufvalue);
  505. +#endif
  506. +       }
  507. +#endif /* NFS41_DRIVER_USE_LARGE_SOCKET_RCVSND_BUFFERS */
  508. +}
  509. +
  510.  void wintirpc_syslog(int prio, const char *format, ...)
  511.  {
  512.         const char *prio_s;
  513. diff --git a/libtirpc/tirpc/wintirpc.h b/libtirpc/tirpc/wintirpc.h
  514. index c1f7f22..4d70be4 100644
  515. --- a/libtirpc/tirpc/wintirpc.h
  516. +++ b/libtirpc/tirpc/wintirpc.h
  517. @@ -157,6 +157,7 @@ int wintirpc_getsockopt(int socket, int level, int option_name,
  518.      void *restrict option_value, socklen_t *restrict option_len);
  519.  int wintirpc_setsockopt(int socket, int level, int option_name,
  520.      const void *option_value, socklen_t option_len);
  521. +void wintirpc_setnfsclientsockopts(int sock);
  522.  void wintirpc_syslog(int prio, const char *format, ...);
  523.  void wintirpc_warnx(const char *format, ...);
  524.  void wintirpc_register_osfhandle_fd(SOCKET handle, int fd);
  525. diff --git a/nfs41_build_features.h b/nfs41_build_features.h
  526. index 61a37dd..2e18150 100644
  527. --- a/nfs41_build_features.h
  528. +++ b/nfs41_build_features.h
  529. @@ -77,4 +77,20 @@
  530.   */
  531.  #define NFS41_DRIVER_WORKAROUND_FOR_GETATTR_AFTER_CLOSE_HACKS 1
  532.  
  533. +/*
  534. + * NFS41_DRIVER_USE_LARGE_SOCKET_RCVSND_BUFFERS - use
  535. + * static, large buffer size for socket receive and send buffers
  536. + *
  537. + * Using a large static buffer avoids the erratic behaviour
  538. + * caused by automatic scaling, and avoids that the code
  539. + * spends lots of time waiting for the data to be split into
  540. + * smaller chunks - this results in much reduced latency.
  541. + *
  542. + * Another benefit is that this gives a larger TCP window
  543. + * (as Windows has no public API to set the TCP window size
  544. + * per socket), resulting in better performance over WLAN
  545. + * connections.
  546. + */
  547. +#define NFS41_DRIVER_USE_LARGE_SOCKET_RCVSND_BUFFERS 1
  548. +
  549.  #endif /* !_NFS41_DRIVER_BUILDFEATURES_ */
  550. --
  551. 2.43.0

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