pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Patches for Win32 locking, clang warnings, tests+misc, 2025-10-02
Posted by Anonymous on Thu 2nd Oct 2025 18:08
raw | new post

  1. From 1597a14238533358ba9fed4679e452dcc9eac93d Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Wed, 1 Oct 2025 18:18:50 +0200
  4. Subject: [PATCH 01/10] cygwin: Fix lockincfile1-related build failure
  5.  
  6. Fix lockincfile1-related build failure - Makefile entries were
  7. missing.
  8.  
  9. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  10. ---
  11. cygwin/Makefile | 2 ++
  12.  1 file changed, 2 insertions(+)
  13.  
  14. diff --git a/cygwin/Makefile b/cygwin/Makefile
  15. index 3e55f1c..06d808a 100644
  16. --- a/cygwin/Makefile
  17. +++ b/cygwin/Makefile
  18. @@ -80,6 +80,7 @@ build_testutils:
  19.         (cd "$(PROJECT_BASEDIR_DIR)/tests/lssparse" && make all)
  20.         (cd "$(PROJECT_BASEDIR_DIR)/tests/winfsinfo1" && make all)
  21.         (cd "$(PROJECT_BASEDIR_DIR)/tests/filemmaptests" && make all)
  22. +       (cd "$(PROJECT_BASEDIR_DIR)/tests/lockincfile1" && make all)
  23.         (cd "$(PROJECT_BASEDIR_DIR)/tests/winclonefile" && make all)
  24.         (cd "$(PROJECT_BASEDIR_DIR)/tests/winoffloadcopyfile" && make all)
  25.         (cd "$(PROJECT_BASEDIR_DIR)/tests/winrunassystem" && make all)
  26. @@ -120,6 +121,7 @@ clean:
  27.         (cd "$(PROJECT_BASEDIR_DIR)/tests/lssparse" && make clean)
  28.         (cd "$(PROJECT_BASEDIR_DIR)/tests/winfsinfo1" && make clean)
  29.         (cd "$(PROJECT_BASEDIR_DIR)/tests/filemmaptests" && make clean)
  30. +       (cd "$(PROJECT_BASEDIR_DIR)/tests/lockincfile1" && make clean)
  31.         (cd "$(PROJECT_BASEDIR_DIR)/tests/winclonefile" && make clean)
  32.         (cd "$(PROJECT_BASEDIR_DIR)/tests/winoffloadcopyfile" && make clean)
  33.         (cd "$(PROJECT_BASEDIR_DIR)/tests/winrunassystem" && make clean)
  34. --
  35. 2.51.0
  36.  
  37. From 149bef668ec3b54578603ef2b077e68dc03d41ac Mon Sep 17 00:00:00 2001
  38. From: Roland Mainz <roland.mainz@nrubsig.org>
  39. Date: Wed, 1 Oct 2025 18:20:15 +0200
  40. Subject: [PATCH 02/10] tests: lockincfile1 should use
  41.  |FILE_FLAG_WRITE_THROUGH|
  42.  
  43. lockincfile1 should use |FILE_FLAG_WRITE_THROUGH|.
  44.  
  45. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  46. ---
  47. tests/lockincfile1/lockincfile1.c | 2 +-
  48.  1 file changed, 1 insertion(+), 1 deletion(-)
  49.  
  50. diff --git a/tests/lockincfile1/lockincfile1.c b/tests/lockincfile1/lockincfile1.c
  51. index cde5822..cae0339 100644
  52. --- a/tests/lockincfile1/lockincfile1.c
  53. +++ b/tests/lockincfile1/lockincfile1.c
  54. @@ -67,7 +67,7 @@ int main(int argc, char *av[])
  55.          FILE_SHARE_READ | FILE_SHARE_WRITE,
  56.          NULL,
  57.          OPEN_EXISTING,
  58. -        /*FILE_ATTRIBUTE_NORMAL*/FILE_FLAG_NO_BUFFERING,
  59. +        /*FILE_ATTRIBUTE_NORMAL*/FILE_FLAG_NO_BUFFERING|FILE_FLAG_WRITE_THROUGH,
  60.          NULL);
  61.      if (h == INVALID_HANDLE_VALUE) {
  62.          (void)fprintf(stderr, "%s: Cannot open file '%s', lasterr=%ld\n",
  63. --
  64. 2.51.0
  65.  
  66. From 5ebe0d70c7a3854e43bf081e2c9acae1baf77dee Mon Sep 17 00:00:00 2001
  67. From: Roland Mainz <roland.mainz@nrubsig.org>
  68. Date: Wed, 1 Oct 2025 19:39:53 +0200
  69. Subject: [PATCH 03/10] daemon,sys: Move retry loop for blocking locks to the
  70.  userland daemon
  71.  
  72. Move retry loop for blocking locks to the userland daemon.
  73. This makes the kernel module simpler, and allows us to implement
  74. support for |CB_NOTIFY_LOCK| later.
  75.  
  76. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  77. ---
  78. daemon/lock.c       | 50 +++++++++++++++++++++++++++++++++++++++++++--
  79.  sys/nfs41sys_lock.c | 32 -----------------------------
  80.  2 files changed, 48 insertions(+), 34 deletions(-)
  81.  
  82. diff --git a/daemon/lock.c b/daemon/lock.c
  83. index d41ef2c..e5d9b4e 100644
  84. --- a/daemon/lock.c
  85. +++ b/daemon/lock.c
  86. @@ -1,5 +1,6 @@
  87.  /* NFSv4.1 client for Windows
  88. - * Copyright (C) 2012 The Regents of the University of Michigan
  89. + * Copyright (C) 2012 The Regents of the University of Michigan
  90. + * Copyright (C) 2023-2025 Roland Mainz <roland.mainz@nrubsig.org>
  91.   *
  92.   * Olga Kornievskaia <aglo@umich.edu>
  93.   * Casey Bodley <cbodley@umich.edu>
  94. @@ -197,7 +198,7 @@ static __inline uint32_t get_lock_type(BOOLEAN exclusive, BOOLEAN blocking)
  95.          : ( exclusive == 0 ? READW_LT : WRITEW_LT );
  96.  }
  97.  
  98. -static int handle_lock(void *deamon_context, nfs41_upcall *upcall)
  99. +static int handle_lock_retry(void *deamon_context, nfs41_upcall *upcall)
  100.  {
  101.      stateid_arg stateid;
  102.      lock_upcall_args *args = &upcall->args.lock;
  103. @@ -266,6 +267,51 @@ out_free:
  104.      goto out;
  105.  }
  106.  
  107. +#define LOCK_POLL_MIN_WAIT_MS   (100UL)     /* 100ms */
  108. +#define LOCK_POLL_MAX_WAIT_MS   (15000UL)   /* 15s */
  109. +
  110. +static int handle_lock(void *deamon_context, nfs41_upcall *upcall)
  111. +{
  112. +    int status;
  113. +    lock_upcall_args *args = &upcall->args.lock;
  114. +    nfs41_open_state *state = upcall->state_ref;
  115. +    DWORD poll_delay = 0UL;
  116. +
  117. +retry_lock:
  118. +    status = handle_lock_retry(deamon_context, upcall);
  119. +    if ((status == ERROR_LOCK_FAILED) && (args->blocking)) {
  120. +        /*
  121. +         * Use exponential backoff between polls for blocking locks, but
  122. +         * limit it to |LOCK_POLL_MAX_WAIT_MS| milliseconds
  123. +         */
  124. +        if (poll_delay == 0L)
  125. +            poll_delay = LOCK_POLL_MIN_WAIT_MS;
  126. +        else
  127. +            poll_delay *= 2L;
  128. +        if (poll_delay > LOCK_POLL_MAX_WAIT_MS)
  129. +            poll_delay = LOCK_POLL_MAX_WAIT_MS;
  130. +
  131. +        /*
  132. +         * Make sure the kernel waits for us, and then go to sleep
  133. +         *
  134. +         * ToDO:
  135. +         * - Turn this into an Win32 event, wait via
  136. +         * |WaitForSingleObject(..., poll_delay)|, and signal the event if
  137. +         * a matching |CB_NOTIFY_LOCK| is received
  138. +         */
  139. +        DPRINTF(1,
  140. +            ("handle_lock(state->path.path='%s'): retry in %ldms\n",
  141. +            state->path.path, (long)poll_delay));
  142. +        (void)delayxid(upcall->xid, 30+(poll_delay/1000));
  143. +        Sleep(poll_delay);
  144. +
  145. +        goto retry_lock;
  146. +    }
  147. +
  148. +    return status;
  149. +}
  150. +
  151. +
  152.  static void cancel_lock(IN nfs41_upcall *upcall)
  153.  {
  154.      stateid_arg stateid;
  155. diff --git a/sys/nfs41sys_lock.c b/sys/nfs41sys_lock.c
  156. index a729ada..b73821d 100644
  157. --- a/sys/nfs41sys_lock.c
  158. +++ b/sys/nfs41sys_lock.c
  159. @@ -218,24 +218,6 @@ static void print_lock_args(
  160.          !BooleanFlagOn(flags, SL_FAIL_IMMEDIATELY));
  161.  }
  162.  
  163. -
  164. -/* use exponential backoff between polls for blocking locks */
  165. -#define MSEC_TO_RELATIVE_WAIT   (-10000LL)
  166. -#define MIN_LOCK_POLL_WAIT      (100 * MSEC_TO_RELATIVE_WAIT) /* 100ms */
  167. -#define MAX_LOCK_POLL_WAIT      (15000 * MSEC_TO_RELATIVE_WAIT) /* 15s */
  168. -
  169. -static void denied_lock_backoff(
  170. -    IN OUT PLARGE_INTEGER delay)
  171. -{
  172. -    if (delay->QuadPart == 0LL)
  173. -        delay->QuadPart = MIN_LOCK_POLL_WAIT;
  174. -    else
  175. -        delay->QuadPart *= 2LL;
  176. -
  177. -    if (delay->QuadPart > MAX_LOCK_POLL_WAIT)
  178. -        delay->QuadPart = MAX_LOCK_POLL_WAIT;
  179. -}
  180. -
  181.  #ifdef NFS41_DRIVER_HACK_LOCKING_STORAGE32_RANGELOCK_PROBING
  182.  static
  183.  bool rangelock_hack_skiplock(
  184. @@ -276,14 +258,11 @@ NTSTATUS nfs41_Lock(
  185.      __notnull PNFS41_FCB nfs41_fcb = NFS41GetFcbExtension(Fcb);
  186.  #endif /* NFS41_DRIVER_HACK_LOCKING_STORAGE32_RANGELOCK_PROBING */
  187.      const ULONG flags = LowIoContext->ParamsFor.Locks.Flags;
  188. -    LARGE_INTEGER poll_delay = {0};
  189.  #ifdef ENABLE_TIMINGS
  190.      LARGE_INTEGER t1, t2;
  191.      t1 = KeQueryPerformanceCounter(NULL);
  192.  #endif
  193.  
  194. -    poll_delay.QuadPart = 0;
  195. -
  196.  #ifdef DEBUG_LOCK
  197.      DbgEn();
  198.      print_lock_args(RxContext);
  199. @@ -312,7 +291,6 @@ NTSTATUS nfs41_Lock(
  200.      entry->u.Lock.exclusive = BooleanFlagOn(flags, SL_EXCLUSIVE_LOCK);
  201.      entry->u.Lock.blocking = !BooleanFlagOn(flags, SL_FAIL_IMMEDIATELY);
  202.  
  203. -retry_upcall:
  204.      status = nfs41_UpcallWaitForReply(entry, pVNetRootContext->timeout);
  205.      if (status) {
  206.          /* Timeout - |nfs41_downcall()| will free |entry|+contents */
  207. @@ -320,16 +298,6 @@ retry_upcall:
  208.          goto out;
  209.      }
  210.  
  211. -    /* blocking locks keep trying until it succeeds */
  212. -    if (entry->status == ERROR_LOCK_FAILED && entry->u.Lock.blocking) {
  213. -        denied_lock_backoff(&poll_delay);
  214. -        DbgP("returned ERROR_LOCK_FAILED; retrying in %llums\n",
  215. -            poll_delay.QuadPart / MSEC_TO_RELATIVE_WAIT);
  216. -        KeDelayExecutionThread(KernelMode, FALSE, &poll_delay);
  217. -        entry->state = NFS41_WAITING_FOR_UPCALL;
  218. -        goto retry_upcall;
  219. -    }
  220. -
  221.      status = map_lock_errors(entry->status);
  222.      RxContext->CurrentIrp->IoStatus.Status = status;
  223.  
  224. --
  225. 2.51.0
  226.  
  227. From 82c1ed0b02d51a4941f93285301e4bfbaf309e43 Mon Sep 17 00:00:00 2001
  228. From: Roland Mainz <roland.mainz@nrubsig.org>
  229. Date: Wed, 1 Oct 2025 19:45:08 +0200
  230. Subject: [PATCH 04/10] README.md,docs: Cygwin 3.3 (32bit) does not have a
  231.  "bmake" package
  232.  
  233. Cygwin 3.3 (32bit) does not have a "bmake" package, we therefore
  234. remove it from the Cygwin 3.3 package list.
  235.  
  236. Reported-by: Cedric Blancher <cedric.blancher@gmail.com>
  237. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  238. ---
  239. README.md       | 2 +-
  240.  docs/README.xml | 2 +-
  241.  2 files changed, 2 insertions(+), 2 deletions(-)
  242.  
  243. diff --git a/README.md b/README.md
  244. index bc07283..8c28eec 100644
  245. --- a/README.md
  246. +++ b/README.md
  247. @@ -346,7 +346,7 @@ Cygwin 32bit can be installed like this:
  248.  
  249.  3.  Run installer with these arguments:
  250.  
  251. -        setup-x86.exe --allow-unsupported-windows -q --no-verify --site "http://ctm.crouchingtigerhiddenfruitbat.org/pub/cygwin/circa/2022/11/23/063457" -P cygwin,cygwin-devel,cygrunsrv,cygutils,cygutils-extra,bash,bzip2,coreutils,getent,gdb,grep,hostname,less,libiconv,libiconv2,pax,pbzip2,procps-ng,sed,tar,time,util-linux,wget,libnfs-utils,make,bmake,git,dos2unix,unzip
  252. +        setup-x86.exe --allow-unsupported-windows -q --no-verify --site "http://ctm.crouchingtigerhiddenfruitbat.org/pub/cygwin/circa/2022/11/23/063457" -P cygwin,cygwin-devel,cygrunsrv,cygutils,cygutils-extra,bash,bzip2,coreutils,getent,gdb,grep,hostname,less,libiconv,libiconv2,pax,pbzip2,procps-ng,sed,tar,time,util-linux,wget,libnfs-utils,make,git,dos2unix,unzip
  253.  
  254.  ## Download and install MSYS2/64bit \[OPTIONAL\]
  255.  
  256. diff --git a/docs/README.xml b/docs/README.xml
  257. index 7666be1..f994545 100644
  258. --- a/docs/README.xml
  259. +++ b/docs/README.xml
  260. @@ -475,7 +475,7 @@ cd download</programlisting>
  261.        </listitem>
  262.        <listitem>
  263.          <para>Run installer with these arguments:</para>
  264. -        <programlisting>setup-x86.exe --allow-unsupported-windows -q --no-verify --site "http://ctm.crouchingtigerhiddenfruitbat.org/pub/cygwin/circa/2022/11/23/063457" -P cygwin,cygwin-devel,cygrunsrv,cygutils,cygutils-extra,bash,bzip2,coreutils,getent,gdb,grep,hostname,less,libiconv,libiconv2,pax,pbzip2,procps-ng,sed,tar,time,util-linux,wget,libnfs-utils,make,bmake,git,dos2unix,unzip</programlisting>
  265. +        <programlisting>setup-x86.exe --allow-unsupported-windows -q --no-verify --site "http://ctm.crouchingtigerhiddenfruitbat.org/pub/cygwin/circa/2022/11/23/063457" -P cygwin,cygwin-devel,cygrunsrv,cygutils,cygutils-extra,bash,bzip2,coreutils,getent,gdb,grep,hostname,less,libiconv,libiconv2,pax,pbzip2,procps-ng,sed,tar,time,util-linux,wget,libnfs-utils,make,git,dos2unix,unzip</programlisting>
  266.        </listitem>
  267.      </orderedlist>
  268.    </section>
  269. --
  270. 2.51.0
  271.  
  272. From c7520e90e74f302fa1e7d25049f7c573550ef911 Mon Sep 17 00:00:00 2001
  273. From: Roland Mainz <roland.mainz@nrubsig.org>
  274. Date: Wed, 1 Oct 2025 19:49:56 +0200
  275. Subject: [PATCH 05/10] daemon: CriticalSections |state->locks.lock| should not
  276.  use a spin count
  277.  
  278. CriticalSections |state->locks.lock| should not use a spin count,
  279. as they are locked for longer time spans, and spinning is then just
  280. wasted CPU time.
  281.  
  282. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  283. ---
  284. daemon/open.c | 6 +++++-
  285.  1 file changed, 5 insertions(+), 1 deletion(-)
  286.  
  287. diff --git a/daemon/open.c b/daemon/open.c
  288. index 953fa49..3972a81 100644
  289. --- a/daemon/open.c
  290. +++ b/daemon/open.c
  291. @@ -81,7 +81,11 @@ static int create_open_state(
  292.      state->ref_count = 1; /* will be released in |cleanup_close()| */
  293.      list_init(&state->locks.list);
  294.      list_init(&state->client_entry);
  295. -    InitializeCriticalSection(&state->locks.lock);
  296. +    /*
  297. +     * Disable spin count as |state->locks.lock| is typically used to
  298. +     * protect list searches, which takes a long time
  299. +     */
  300. +    (void)InitializeCriticalSectionAndSpinCount(&state->locks.lock, 0);
  301.  
  302.      state->ea.list = INVALID_HANDLE_VALUE;
  303.      InitializeCriticalSection(&state->ea.lock);
  304. --
  305. 2.51.0
  306.  
  307. From c8e705e95d898bbcb9f143e6781b0569fac2407a Mon Sep 17 00:00:00 2001
  308. From: Roland Mainz <roland.mainz@nrubsig.org>
  309. Date: Thu, 2 Oct 2025 13:28:20 +0200
  310. Subject: [PATCH 06/10] tests: manual tests: Add "DISKSPD" for async I/O
  311.  testing
  312.  
  313. manual tests: Add "DISKSPD" (storage load generator / performance test tool)
  314. for async read/write testing.
  315.  
  316. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  317. ---
  318. tests/manual_testing.txt | 32 +++++++++++++++++++++++++++++++-
  319.  1 file changed, 31 insertions(+), 1 deletion(-)
  320.  
  321. diff --git a/tests/manual_testing.txt b/tests/manual_testing.txt
  322. index 98ee849..ee1cb7f 100644
  323. --- a/tests/manual_testing.txt
  324. +++ b/tests/manual_testing.txt
  325. @@ -1,5 +1,5 @@
  326.  #
  327. -# ms-nfs41-client manual testing sequence, 2025-09-19
  328. +# ms-nfs41-client manual testing sequence, 2025-10-02
  329.  #
  330.  # Draft version, needs to be turned into automated tests
  331.  # if possible
  332. @@ -1089,5 +1089,35 @@ $ /usr/lib/csih/getVolInfo.exe . | fgrep FILE_CASE_SENSITIVE_SEARCH # must be "F
  333.  1. https://learn.microsoft.com/en-us/windows/compatibility/ntvdm-and-16-bit-app-support
  334.  
  335.  
  336. +#
  337. +# DISKSPD storage load generator / performance test tool
  338. +# (https://github.com/microsoft/diskspd/)
  339. +# Mainly used to test Win32 async read/write
  340. +#
  341. +
  342. +#
  343. +# Download&&unpack
  344. +#
  345. +wget 'https://github.com/microsoft/diskspd/releases/download/v2.2/DiskSpd.ZIP'
  346. +mkdir DiskSpd && cd DiskSpd
  347. +unzip ../DiskSpd.ZIP
  348. +
  349. +#
  350. +# run tests
  351. +#
  352. +
  353. +# prep
  354. +mkdir testruns && cd testruns
  355. +
  356. +# async IO tests
  357. +../DiskSpd/amd64/diskspd.exe -c512M -b4K -t32 -r -o64 -d120 -Sh -w50 testfile1.dat testfile2.dat
  358. +../DiskSpd/amd64/diskspd.exe -c512M -b8K -t32 -r -o64 -d120 -Sh -w50 testfile1.dat testfile2.dat
  359. +../DiskSpd/amd64/diskspd.exe -c512M -b32K -t32 -r -o64 -d120 -Sh -w50 testfile1.dat testfile2.dat
  360. +../DiskSpd/amd64/diskspd.exe -c512M -b32K -t32 -r -o64 -d120 -Sb -w50 testfile1.dat testfile2.dat
  361. +../DiskSpd/amd64/diskspd.exe -c512M -b1M -t32 -r -o64 -d120 -Sh -w50 testfile1.dat testfile2.dat
  362. +# memory-mapped IO (not async)
  363. +../DiskSpd/amd64/diskspd.exe -c512M -b1M -t32 -r -o64 -d120 -Sm -Nv -w50 testfile1.dat
  364. +
  365. +
  366.  #
  367.  # EOF.
  368. --
  369. 2.51.0
  370.  
  371. From ae191fe5dc724822f565c9e5bf1280a9be9e8c94 Mon Sep 17 00:00:00 2001
  372. From: Dan Shelton <dan.f.shelton@gmail.com>
  373. Date: Thu, 2 Oct 2025 15:17:23 +0200
  374. Subject: [PATCH 07/10] daemon: Fix clang/ReactOS pointer mismatch warnings
  375.  
  376. Fix clang/ReactOS pointer mismatch warnings.
  377.  
  378. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  379. ---
  380. daemon/acl.c     | 2 +-
  381.  daemon/ea.c      | 6 ++++--
  382.  daemon/lock.c    | 3 ++-
  383.  daemon/open.c    | 2 +-
  384.  daemon/setattr.c | 3 ++-
  385.  daemon/symlink.c | 2 +-
  386.  6 files changed, 11 insertions(+), 7 deletions(-)
  387.  
  388. diff --git a/daemon/acl.c b/daemon/acl.c
  389. index 24f225f..c37a7c8 100644
  390. --- a/daemon/acl.c
  391. +++ b/daemon/acl.c
  392. @@ -1267,7 +1267,7 @@ static int map_dacl_2_nfs4acl(PACL acl, PSID sid, PSID gsid, nfsacl41 *nfs4_acl,
  393.              nfsace4 *curr_nfsace = &nfs4_acl->aces[nfs_i];
  394.              PSID ace_sid;
  395.  
  396. -            status = GetAce(acl, win_i, &ace);
  397. +            status = GetAce(acl, win_i, (LPVOID *)&ace);
  398.              if (!status) {
  399.                  status = GetLastError();
  400.                  eprintf("map_dacl_2_nfs4acl: GetAce failed with %d\n", status);
  401. diff --git a/daemon/ea.c b/daemon/ea.c
  402. index e5b012a..b6f1613 100644
  403. --- a/daemon/ea.c
  404. +++ b/daemon/ea.c
  405. @@ -198,7 +198,8 @@ static int parse_setexattr(unsigned char *buffer, uint32_t length, nfs41_upcall
  406.      if (status) goto out;
  407.      status = safe_read(&buffer, &length, &args->buf_len, sizeof(args->buf_len));
  408.      if (status) goto out;
  409. -    status = get_safe_read_bufferpos(&buffer, &length, args->buf_len, &args->buf);
  410. +    status = get_safe_read_bufferpos(&buffer, &length,
  411. +        args->buf_len, (void **)&args->buf);
  412.      if (status) goto out;
  413.  
  414.      EASSERT(length == 0);
  415. @@ -280,7 +281,8 @@ static int parse_getexattr(unsigned char *buffer, uint32_t length, nfs41_upcall
  416.      if (status) goto out;
  417.      status = safe_read(&buffer, &length, &args->ealist_len, sizeof(args->ealist_len));
  418.      if (status) goto out;
  419. -    status = get_safe_read_bufferpos(&buffer, &length, args->ealist_len, &args->ealist);
  420. +    status = get_safe_read_bufferpos(&buffer, &length,
  421. +        args->ealist_len, (void **)&args->ealist);
  422.      if (status) goto out;
  423.  
  424.      EASSERT(length == 0);
  425. diff --git a/daemon/lock.c b/daemon/lock.c
  426. index e5d9b4e..b5e1f29 100644
  427. --- a/daemon/lock.c
  428. +++ b/daemon/lock.c
  429. @@ -359,7 +359,8 @@ static int parse_unlock(unsigned char *buffer, uint32_t length, nfs41_upcall *up
  430.      status = safe_read(&buffer, &length, &args->count, sizeof(ULONG));
  431.      if (status) goto out;
  432.      args->buf_len = args->count*2L*sizeof(LONGLONG);
  433. -    status = get_safe_read_bufferpos(&buffer, &length, args->buf_len, &args->buf);
  434. +    status = get_safe_read_bufferpos(&buffer, &length,
  435. +        args->buf_len, (void **)&args->buf);
  436.      if (status) goto out;
  437.  
  438.      EASSERT(length == 0);
  439. diff --git a/daemon/open.c b/daemon/open.c
  440. index 3972a81..d86b836 100644
  441. --- a/daemon/open.c
  442. +++ b/daemon/open.c
  443. @@ -1265,7 +1265,7 @@ static int marshall_open(unsigned char *buffer, uint32_t *length, nfs41_upcall *
  444.           */
  445.          unsigned short *wc_len_out;
  446.          status = get_safe_write_bufferpos(&buffer, length,
  447. -            sizeof(unsigned short), &wc_len_out);
  448. +            sizeof(unsigned short), (void **)&wc_len_out);
  449.          if (status) goto out;
  450.          EASSERT(wc_len_out != NULL);
  451.  
  452. diff --git a/daemon/setattr.c b/daemon/setattr.c
  453. index 6a877ac..fe920a2 100644
  454. --- a/daemon/setattr.c
  455. +++ b/daemon/setattr.c
  456. @@ -53,7 +53,8 @@ static int parse_setattr(unsigned char *buffer, uint32_t length, nfs41_upcall *u
  457.      if (status) goto out;
  458.      status = safe_read(&buffer, &length, &args->buf_len, sizeof(args->buf_len));
  459.      if (status) goto out;
  460. -    status = get_safe_read_bufferpos(&buffer, &length, args->buf_len, &args->buf);
  461. +    status = get_safe_read_bufferpos(&buffer, &length,
  462. +        args->buf_len, (void **)&args->buf);
  463.      if (status) goto out;
  464.  
  465.      args->root = upcall->root_ref;
  466. diff --git a/daemon/symlink.c b/daemon/symlink.c
  467. index 5722b72..2eb947b 100644
  468. --- a/daemon/symlink.c
  469. +++ b/daemon/symlink.c
  470. @@ -295,7 +295,7 @@ static int marshall_symlink_get(unsigned char *buffer, uint32_t *length,
  471.  
  472.      unsigned short *wc_len_out;
  473.      status = get_safe_write_bufferpos(&buffer, length,
  474. -        sizeof(unsigned short), &wc_len_out);
  475. +        sizeof(unsigned short), (void **)&wc_len_out);
  476.      if (status) goto out;
  477.      EASSERT(wc_len_out != NULL);
  478.  
  479. --
  480. 2.51.0
  481.  
  482. From 7f658e69e8c2dc1a763802de2abee03b37fd7c10 Mon Sep 17 00:00:00 2001
  483. From: Dan Shelton <dan.f.shelton@gmail.com>
  484. Date: Thu, 2 Oct 2025 15:24:13 +0200
  485. Subject: [PATCH 08/10] daemon: Fix clang warning "comparison of integers of
  486.  different signs: 'int' and 'unsigned long long'" in handle_readdir()
  487.  
  488. Fix clang warning "comparison of integers of different signs: 'int'
  489. and 'unsigned long long'" in handle_readdir()
  490.  
  491. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  492. ---
  493. daemon/readdir.c | 4 ++--
  494.  1 file changed, 2 insertions(+), 2 deletions(-)
  495.  
  496. diff --git a/daemon/readdir.c b/daemon/readdir.c
  497. index 5496e23..407bcfb 100644
  498. --- a/daemon/readdir.c
  499. +++ b/daemon/readdir.c
  500. @@ -759,8 +759,8 @@ static int handle_readdir(void *deamon_context, nfs41_upcall *upcall)
  501.      bitmap4 attr_request;
  502.      bool_t eof;
  503.      /* make sure we allocate enough space for one nfs41_readdir_entry */
  504. -    const uint32_t max_buf_len = max(args->buf_len,
  505. -        sizeof(nfs41_readdir_entry) + NFS41_MAX_COMPONENT_LEN+1);
  506. +    const uint32_t max_buf_len = max((uint32_t)args->buf_len,
  507. +        (uint32_t)(sizeof(nfs41_readdir_entry) + NFS41_MAX_COMPONENT_LEN+1));
  508.  
  509.      DPRINTF(1, ("--> handle_nfs41_dirquery(filter='%s',initial=%d,restart=%d,single=%d)\n",
  510.          args->filter, (int)args->initial, (int)args->restart, (int)args->single));
  511. --
  512. 2.51.0
  513.  
  514. From 81b9155a79416443740be5c664535d66d4c1d1db Mon Sep 17 00:00:00 2001
  515. From: Roland Mainz <roland.mainz@nrubsig.org>
  516. Date: Thu, 2 Oct 2025 18:00:44 +0200
  517. Subject: [PATCH 09/10] daemon: Fix uninitialised variable in
  518.  |nfs41_open_stateid_arg()|
  519.  
  520. Fix uninitialised variable in |nfs41_open_stateid_arg()|.
  521.  
  522. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  523. ---
  524. daemon/nfs41_ops.h | 1 +
  525.  daemon/open.c      | 3 +++
  526.  2 files changed, 4 insertions(+)
  527.  
  528. diff --git a/daemon/nfs41_ops.h b/daemon/nfs41_ops.h
  529. index b3b70fb..f1bf145 100644
  530. --- a/daemon/nfs41_ops.h
  531. +++ b/daemon/nfs41_ops.h
  532. @@ -305,6 +305,7 @@ typedef struct __nfs41_reclaim_complete_res {
  533.  
  534.  /* recoverable stateid argument */
  535.  enum stateid_type {
  536. +    STATEID_UNINITIALISED = 0,
  537.      STATEID_OPEN,
  538.      STATEID_LOCK,
  539.      STATEID_DELEG_FILE,
  540. diff --git a/daemon/open.c b/daemon/open.c
  541. index d86b836..d93ec60 100644
  542. --- a/daemon/open.c
  543. +++ b/daemon/open.c
  544. @@ -165,6 +165,7 @@ void nfs41_open_stateid_arg(
  545.      IN nfs41_open_state *state,
  546.      OUT stateid_arg *arg)
  547.  {
  548. +    arg->type = STATEID_UNINITIALISED;
  549.      arg->open = state;
  550.      arg->delegation = NULL;
  551.  
  552. @@ -202,6 +203,8 @@ void nfs41_open_stateid_arg(
  553.      }
  554.  out:
  555.      ReleaseSRWLockShared(&state->lock);
  556. +
  557. +    EASSERT(arg->type != STATEID_UNINITIALISED);
  558.  }
  559.  
  560.  /* client list of associated open state */
  561. --
  562. 2.51.0
  563.  
  564. From 4de73098e54abf4c8d85285aaf533c06e39ddc0b Mon Sep 17 00:00:00 2001
  565. From: Roland Mainz <roland.mainz@nrubsig.org>
  566. Date: Thu, 2 Oct 2025 18:56:06 +0200
  567. Subject: [PATCH 10/10] sys: Fix race conditions with
  568.  |updowncall_entry.timeout_secs| usage
  569.  
  570. Fix race conditions with |updowncall_entry.timeout_secs| usage.
  571.  
  572. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  573. ---
  574. sys/nfs41sys_driver.h     |  2 +-
  575.  sys/nfs41sys_updowncall.c | 21 ++++++++++-----------
  576.  2 files changed, 11 insertions(+), 12 deletions(-)
  577.  
  578. diff --git a/sys/nfs41sys_driver.h b/sys/nfs41sys_driver.h
  579. index 913288f..fa019f4 100644
  580. --- a/sys/nfs41sys_driver.h
  581. +++ b/sys/nfs41sys_driver.h
  582. @@ -169,7 +169,7 @@ typedef struct _updowncall_entry {
  583.      LONGLONG xid;
  584.      nfs41_opcodes opcode;
  585.      NTSTATUS status;
  586. -    volatile LONGLONG timeout_secs;
  587. +    volatile LONG timeout_secs;
  588.      nfs41_updowncall_state state;
  589.      FAST_MUTEX lock;
  590.      LIST_ENTRY next;
  591. diff --git a/sys/nfs41sys_updowncall.c b/sys/nfs41sys_updowncall.c
  592. index 08d9165..7afc19f 100644
  593. --- a/sys/nfs41sys_updowncall.c
  594. +++ b/sys/nfs41sys_updowncall.c
  595. @@ -468,6 +468,12 @@ NTSTATUS nfs41_UpcallWaitForReply(
  596.  
  597.      FsRtlEnterFileSystem();
  598.  
  599. +    /*
  600. +     * |entry->timeout_secs| can be increased by |nfs41_delayxid()| from
  601. +     * another userland thread!
  602. +     */
  603. +    entry->timeout_secs = (LONG)secs;
  604. +
  605.      nfs41_AddEntry(upcalllist.lock, upcalllist, entry);
  606.      (void)KeSetEvent(&upcallEvent, IO_NFS41FS_INCREMENT, FALSE);
  607.  
  608. @@ -476,17 +482,12 @@ NTSTATUS nfs41_UpcallWaitForReply(
  609.  
  610.      const ULONG tickIncrement = KeQueryTimeIncrement();
  611.  
  612. -    /*
  613. -     * |entry->timeout_secs| can be increased by |nfs41_delayxid()| from
  614. -     * another userland thread!
  615. -     */
  616. -    entry->timeout_secs = secs;
  617. -
  618.      LARGE_INTEGER startTicks, currTicks;
  619.      KeQueryTickCount(&startTicks);
  620.  
  621.      LARGE_INTEGER timeout;
  622. -    timeout.QuadPart = RELATIVE(SECONDS(entry->timeout_secs));
  623. +    timeout.QuadPart =
  624. +        RELATIVE(SECONDS(InterlockedAdd(&entry->timeout_secs, 0)));
  625.  
  626.  retry_wait:
  627.      status = KeWaitForSingleObject(&entry->cond, Executive,
  628. @@ -512,7 +513,7 @@ retry_wait:
  629.           */
  630.          KeQueryTickCount(&currTicks);
  631.          if (((currTicks.QuadPart - startTicks.QuadPart) * tickIncrement) <=
  632. -            SECONDS(entry->timeout_secs)) {
  633. +            SECONDS(InterlockedAdd(&entry->timeout_secs, 0))) {
  634.              DbgP("nfs41_UpcallWaitForReply: KeWaitForSingleObject() "
  635.                  "returned status(=0x%lx), "
  636.                  "retry waiting for '%s' entry=0x%p xid=%lld\n",
  637. @@ -859,9 +860,7 @@ NTSTATUS nfs41_delayxid(
  638.      DbgP("nfs41_delayxid: Adding moredelay=%llu xid=%lld entry\n",
  639.          moredelay, delayxid);
  640.  
  641. -    ExAcquireFastMutexUnsafe(&cur->lock);
  642. -    cur->timeout_secs += moredelay;
  643. -    ExReleaseFastMutexUnsafe(&cur->lock);
  644. +    (void)InterlockedAdd(&cur->timeout_secs, (LONG)moredelay);
  645.  
  646.  out:
  647.      FsRtlExitFileSystem();
  648. --
  649. 2.51.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