pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Patches for kernel file flushing, catdbgprint.exe, docs+misc, 2025-12-03
Posted by Anonymous on Wed 3rd Dec 2025 20:45
raw | new post

  1. From 1fb6631ecd9a75e4aeb592f250c3a9bb0f9a9687 Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Wed, 3 Dec 2025 11:41:42 +0100
  4. Subject: [PATCH 1/8] sys: |nfs41_Create()|: Switch from
  5.  |RxChangeBufferingState()|+|DISABLE_CACHING| to |RxFlushFcbInSystemCache(fcb,
  6.  TRUE)|
  7.  
  8. |nfs41_Create()|: Switch from |RxChangeBufferingState()|+|DISABLE_CACHING|
  9. to |RxFlushFcbInSystemCache(fcb, TRUE)| if the file is opened
  10. for data access.
  11.  
  12. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  13. ---
  14. sys/nfs41sys_openclose.c | 10 +++++++---
  15.  1 file changed, 7 insertions(+), 3 deletions(-)
  16.  
  17. diff --git a/sys/nfs41sys_openclose.c b/sys/nfs41sys_openclose.c
  18. index 7a4d4ed..57b10d5 100644
  19. --- a/sys/nfs41sys_openclose.c
  20. +++ b/sys/nfs41sys_openclose.c
  21. @@ -1189,21 +1189,25 @@ retry_on_link:
  22.      print_std_info(1, &nfs41_fcb->StandardInfo);
  23.  #endif
  24.  
  25. -    /* aglo: 05/10/2012. it seems like always have to invalid the cache if the
  26. +    /*
  27. +     * aglo: 05/10/2012: it seems like always have to invalid the cache if the
  28.       * file has been opened before and being opened again for data access.
  29.       * If the file was opened before, RDBSS might have cached (unflushed) data
  30.       * and by opening it again, we will not have the correct representation of
  31.       * the file size and data content. fileio tests 208, 219, 221.
  32. +     * gisburn 2025-12-02: Switching from |RxChangeBufferingState()| with
  33. +     * |DISABLE_CACHING| to |RxFlushFcbInSystemCache(fcb, TRUE)| incl.
  34. +     * syncing with lazywriter (testing with parallel gcc build shows that
  35. +     * just waiting for the lazy writer is not sufficient).
  36.       */
  37.      if (Fcb->OpenCount > 0 && (isDataAccess(params->DesiredAccess) ||
  38.              nfs41_fcb->changeattr != entry->ChangeTime) &&
  39.                  !nfs41_fcb->StandardInfo.Directory) {
  40. -        ULONG flag = DISABLE_CACHING;
  41.  #ifdef DEBUG_OPEN
  42.          DbgP("nfs41_Create: reopening (changed) file '%wZ'\n",
  43.              SrvOpen->pAlreadyPrefixedName);
  44.  #endif
  45. -        RxChangeBufferingState((PSRV_OPEN)SrvOpen, ULongToPtr(flag), 1);
  46. +        (void)RxFlushFcbInSystemCache((PFCB)RxContext->pFcb, TRUE);
  47.      }
  48.  
  49.      if (!nfs41_fcb->StandardInfo.Directory &&
  50. --
  51. 2.51.0
  52.  
  53. From 7cdf7984afb1a48386c45aac9307f3e1c52875f3 Mon Sep 17 00:00:00 2001
  54. From: Roland Mainz <roland.mainz@nrubsig.org>
  55. Date: Wed, 3 Dec 2025 12:37:37 +0100
  56. Subject: [PATCH 2/8] cygwin,tests: Add new /sbin/catdbgprint.exe utilty to
  57.  print kernel |DbgPrint*()| messages to stdout
  58.  
  59. Add new /sbin/catdbgprint.exe utilty to print kernel |DbgPrint*()|
  60. messages to stdout.
  61. This tool can also run multiple instances in parallel, allowing for
  62. automated tests to examine the kernel debug output.
  63.  
  64. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  65. ---
  66. cygwin/Makefile                 |   4 +
  67.  cygwin/Makefile.install         |   2 +
  68.  cygwin/devel/msnfs41client.bash |  31 +----
  69.  tests/catdbgprint/Makefile      |  26 ++++
  70.  tests/catdbgprint/catdbgprint.c | 205 ++++++++++++++++++++++++++++++++
  71.  5 files changed, 240 insertions(+), 28 deletions(-)
  72.  create mode 100644 tests/catdbgprint/Makefile
  73.  create mode 100644 tests/catdbgprint/catdbgprint.c
  74.  
  75. diff --git a/cygwin/Makefile b/cygwin/Makefile
  76. index cf2b036..5d058a9 100644
  77. --- a/cygwin/Makefile
  78. +++ b/cygwin/Makefile
  79. @@ -23,6 +23,7 @@ VS_BUILD_DIR_ARM64:=$(PROJECT_BASEDIR_DIR)/build.vc19/ARM64/Debug/
  80.  
  81.  # trigger "build_testutils" target when these binaries are needed
  82.  $(PROJECT_BASEDIR_DIR)/tests/ea/nfs_ea.exe \
  83. +       $(PROJECT_BASEDIR_DIR)/tests/catdbgprint/catdbgprint.exe \
  84.         $(PROJECT_BASEDIR_DIR)/tests/lssparse/lssparse.exe \
  85.         $(PROJECT_BASEDIR_DIR)/tests/winfsinfo1/winfsinfo.exe \
  86.         $(PROJECT_BASEDIR_DIR)/tests/filemmaptests/qsortonmmapedfile1.exe \
  87. @@ -76,6 +77,7 @@ build_arm_64bit_debug:
  88.         MSBuild.exe '$(shell cygpath -w "$(PROJECT_BASEDIR_DIR)/build.vc19/nfs41-client.sln")' -t:Build  -p:Configuration=Debug -p:Platform=ARM64 /p:CERTIFICATE_THUMBPRINT=$$CERTIFICATE_THUMBPRINT
  89.  
  90.  build_testutils:
  91. +       (cd "$(PROJECT_BASEDIR_DIR)/tests/catdbgprint" && make all)
  92.         (cd "$(PROJECT_BASEDIR_DIR)/tests/ea" && make all)
  93.         (cd "$(PROJECT_BASEDIR_DIR)/tests/lssparse" && make all)
  94.         (cd "$(PROJECT_BASEDIR_DIR)/tests/winfsinfo1" && make all)
  95. @@ -117,6 +119,7 @@ build64: \
  96.  #
  97.  clean:
  98.         rm -vRf $$(find "$(PROJECT_BASEDIR_DIR)/build.vc19" -name Debug -o -name Release)
  99. +       (cd "$(PROJECT_BASEDIR_DIR)/tests/catdbgprint" && make clean)
  100.         (cd "$(PROJECT_BASEDIR_DIR)/tests/ea" && make clean)
  101.         (cd "$(PROJECT_BASEDIR_DIR)/tests/lssparse" && make clean)
  102.         (cd "$(PROJECT_BASEDIR_DIR)/tests/winfsinfo1" && make clean)
  103. @@ -131,6 +134,7 @@ installdest_util: \
  104.         $(PROJECT_BASEDIR_DIR)/nfs41rdr.inf \
  105.         $(PROJECT_BASEDIR_DIR)/etc_netconfig \
  106.         $(PROJECT_BASEDIR_DIR)/ms-nfs41-idmap.conf \
  107. +       $(PROJECT_BASEDIR_DIR)/tests/catdbgprint/catdbgprint.exe \
  108.         $(PROJECT_BASEDIR_DIR)/tests/ea/nfs_ea.exe \
  109.         $(PROJECT_BASEDIR_DIR)/tests/lssparse/lssparse.exe \
  110.         $(PROJECT_BASEDIR_DIR)/tests/winfsinfo1/winfsinfo.exe \
  111. diff --git a/cygwin/Makefile.install b/cygwin/Makefile.install
  112. index efb327d..1db56fc 100644
  113. --- a/cygwin/Makefile.install
  114. +++ b/cygwin/Makefile.install
  115. @@ -167,6 +167,8 @@ installdest:
  116.         cp "$(PROJECT_BASEDIR_DIR)/tests/winclonefile/winclonefile.i686.exe" $(DESTDIR)/bin/winclonefile.i686.exe
  117.         cp "$(PROJECT_BASEDIR_DIR)/tests/winoffloadcopyfile/winoffloadcopyfile.x86_64.exe" $(DESTDIR)/bin/winoffloadcopyfile.x86_64.exe
  118.         cp "$(PROJECT_BASEDIR_DIR)/tests/winoffloadcopyfile/winoffloadcopyfile.i686.exe" $(DESTDIR)/bin/winoffloadcopyfile.i686.exe
  119. +       cp "$(PROJECT_BASEDIR_DIR)/tests/catdbgprint/catdbgprint.x86_64.exe" $(DESTDIR)/sbin/catdbgprint.x86_64.exe
  120. +       cp "$(PROJECT_BASEDIR_DIR)/tests/catdbgprint/catdbgprint.i686.exe" $(DESTDIR)/sbin/catdbgprint.i686.exe
  121.         cp "$(PROJECT_BASEDIR_DIR)/tests/winrunassystem/winrunassystem.x86_64.exe" $(DESTDIR)/sbin/winrunassystem.x86_64.exe
  122.         cp "$(PROJECT_BASEDIR_DIR)/tests/winrunassystem/winrunassystem.i686.exe" $(DESTDIR)/sbin/winrunassystem.i686.exe
  123.         cp "$(PROJECT_BASEDIR_DIR)/tests/winrunassystem/nfs_globalmount.x86_64.exe" $(DESTDIR)/sbin/nfs_globalmount.x86_64.exe
  124. diff --git a/cygwin/devel/msnfs41client.bash b/cygwin/devel/msnfs41client.bash
  125. index 4e44571..4b769c7 100755
  126. --- a/cygwin/devel/msnfs41client.bash
  127. +++ b/cygwin/devel/msnfs41client.bash
  128. @@ -249,6 +249,7 @@ function nfsclient_install
  129.                 'bin/winoffloadcopyfile'
  130.                 'bin/winsg'
  131.                 'bin/nfs_ea'
  132. +               'sbin/catdbgprint'
  133.                 'sbin/winrunassystem'
  134.                 'sbin/nfs_globalmount'
  135.                 'usr/share/msnfs41client/tests/misc/qsortonmmapedfile1'
  136. @@ -939,29 +940,10 @@ function attach_debugger_to_daemon
  137.  
  138.  function watch_kernel_debuglog
  139.  {
  140. -       typeset dbgview_cmd
  141. -
  142.         printf "# logging start...\n" 1>&2
  143.  
  144. -       case "$(uname -m)" in
  145. -               'x86_64') dbgview_cmd='dbgview64' ;;
  146. -               'i686')   dbgview_cmd='dbgview' ;;
  147. -               *)
  148. -                       printf $"%s: Unknown machine type\n" "$0" 1>&2
  149. -                       return 1
  150. -                       ;;
  151. -       esac
  152. +       catdbgprint
  153.  
  154. -       # seperate process so SIGINT works
  155. -       # use DebugView (https://learn.microsoft.com/en-gb/sysinternals/downloads/debugview) to print kernel log
  156. -       dbgview_cmd="${dbgview_cmd}" bash -c '
  157. -               klogname="msnfs41client_watch_kernel_debuglog$$.log"
  158. -               $dbgview_cmd /t /k /l "$klogname" &
  159. -               (( dbgview_pid=$! ))
  160. -               trap "(( dbgview_pid != 0)) && kill $dbgview_pid && wait ; (( dbgview_pid=0 ))" INT TERM EXIT
  161. -               sleep 2
  162. -               printf "# logging %s ...\n" "$klogname" 1>&2
  163. -               tail -n0 -f "$klogname"'
  164.         printf '# logging done\n' 1>&2
  165.         return 0
  166.  }
  167. @@ -1302,14 +1284,7 @@ function main
  168.                         ;;
  169.                 'watch_kernel_debuglog')
  170.                         check_machine_arch || (( numerr++ ))
  171. -                       case "$(uname -m)" in
  172. -                               'x86_64') require_cmd 'dbgview64' || (( numerr++ )) ;;
  173. -                               'i686')   require_cmd 'dbgview' || (( numerr++ )) ;;
  174. -                               *)
  175. -                                       printf $"%s: Unknown machine type\n" "$0" 1>&2
  176. -                                       (( numerr++ ))
  177. -                                       ;;
  178. -                       esac
  179. +                       require_cmd 'catdbgprint' || (( numerr++ ))
  180.                         if ! is_windows_admin_account ; then
  181.                                 printf $"%s: %q requires Windows Adminstator permissions.\n" "$0" "$cmd"
  182.                                 (( numerr++ ))
  183. diff --git a/tests/catdbgprint/Makefile b/tests/catdbgprint/Makefile
  184. new file mode 100644
  185. index 0000000..ea75bd7
  186. --- /dev/null
  187. +++ b/tests/catdbgprint/Makefile
  188. @@ -0,0 +1,26 @@
  189. +#
  190. +# Makefile for catdbgprint
  191. +#
  192. +
  193. +# signtool.exe can be in either '/cygdrive/c/Program Files/' or '/cygdrive/c/Program Files (x86)/'
  194. +SIGNTOOL := $(shell ls -1 '/cygdrive/c/Program Files'*'/Microsoft SDKs/ClickOnce/SignTool/signtool.exe' | head -n 1)
  195. +
  196. +all: catdbgprint.i686.exe catdbgprint.x86_64.exe catdbgprint.exe
  197. +
  198. +catdbgprint.i686.exe: catdbgprint.c
  199. +       clang -target i686-pc-windows-gnu -std=gnu17 -Wall -Wextra -DUNICODE=1 -D_UNICODE=1 -I../../include -g catdbgprint.c -lntdll -o $@
  200. +       bash -x -c '"$(SIGNTOOL)" sign /ph /fd "sha256" /sha1 "$${CERTIFICATE_THUMBPRINT%$$(printf "\r")}" $@'
  201. +
  202. +catdbgprint.x86_64.exe: catdbgprint.c
  203. +       clang -target x86_64-pc-windows-gnu -std=gnu17 -Wall -Wextra -DUNICODE=1 -D_UNICODE=1 -I../../include -g catdbgprint.c -lntdll -o $@
  204. +       bash -x -c '"$(SIGNTOOL)" sign /ph /fd "sha256" /sha1 "$${CERTIFICATE_THUMBPRINT%$$(printf "\r")}" $@'
  205. +
  206. +catdbgprint.exe: catdbgprint.x86_64.exe
  207. +       ln -s catdbgprint.x86_64.exe catdbgprint.exe
  208. +
  209. +clean:
  210. +       rm -fv \
  211. +               catdbgprint.i686.exe \
  212. +               catdbgprint.x86_64.exe \
  213. +               catdbgprint.exe
  214. +# EOF.
  215. diff --git a/tests/catdbgprint/catdbgprint.c b/tests/catdbgprint/catdbgprint.c
  216. new file mode 100644
  217. index 0000000..7f053e1
  218. --- /dev/null
  219. +++ b/tests/catdbgprint/catdbgprint.c
  220. @@ -0,0 +1,205 @@
  221. +/*
  222. + * MIT License
  223. + *
  224. + * Copyright (c) 2024-2025 Roland Mainz <roland.mainz@nrubsig.org>
  225. + *
  226. + * Permission is hereby granted, free of charge, to any person obtaining a copy
  227. + * of this software and associated documentation files (the "Software"), to deal
  228. + * in the Software without restriction, including without limitation the rights
  229. + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  230. + * copies of the Software, and to permit persons to whom the Software is
  231. + * furnished to do so, subject to the following conditions:
  232. + *
  233. + * The above copyright notice and this permission notice shall be included in
  234. + * all copies or substantial portions of the Software.
  235. + *
  236. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  237. + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  238. + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  239. + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  240. + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  241. + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  242. + * SOFTWARE.
  243. + */
  244. +
  245. +/*
  246. + * catdbgprint.c - print Windows kernel |DbgPrint()| messages
  247. + *
  248. + * Written by Roland Mainz <roland.mainz@nrubsig.org>
  249. + */
  250. +
  251. +/*
  252. + * Compile with:
  253. + * $ clang -target x86_64-pc-windows-gnu \
  254. + *      -Wall -Wextra -DUNICODE=1 -D_UNICODE=1 -g catdbgprint.c -o catdbgprint.exe #
  255. + */
  256. +
  257. +#include <windows.h>
  258. +#include <evntrace.h>
  259. +#include <evntcons.h>
  260. +#include <stdio.h>
  261. +#include <stdlib.h>
  262. +#include <stddef.h>
  263. +#include <ctype.h>
  264. +
  265. +typedef struct _DBGPRINT_EVENT {
  266. +    ULONG ComponentId;   /* DPFLTR_xxx_ID */
  267. +    ULONG Level;         /* DPFLTR_LEVEL_xxx */
  268. +    CHAR  Message[];     /* '\0'-terminated ANSI string */
  269. +} DBGPRINT_EVENT;
  270. +
  271. +static
  272. +void int_to_octal3(int value, unsigned char *restrict out)
  273. +{
  274. +    if (value < 0)
  275. +        value = 0;
  276. +    if (value > 0777)
  277. +        value = 0777; /* clamp to max 0777/511 */
  278. +
  279. +    out[2] = (char)('0' + (value & 7));
  280. +    out[1] = (char)('0' + ((value >> 3) & 7));
  281. +    out[0] = (char)('0' + ((value >> 6) & 7));
  282. +}
  283. +
  284. +static
  285. +VOID WINAPI EventCallback(PEVENT_RECORD ev)
  286. +{
  287. +    unsigned char buffer[2048];
  288. +    unsigned char *b = buffer;
  289. +
  290. +    if (ev->UserDataLength >= offsetof(DBGPRINT_EVENT, Message)) {
  291. +        size_t i;
  292. +        unsigned char c;
  293. +        const DBGPRINT_EVENT *dpe = (const DBGPRINT_EVENT *)ev->UserData;
  294. +        const unsigned char *msg = (const unsigned char *)dpe->Message;
  295. +        ssize_t msg_len = ev->UserDataLength - offsetof(DBGPRINT_EVENT, Message);
  296. +
  297. +        for (i=0 ; i < msg_len ; i++) {
  298. +            if ((msg[i] == '\0') ||
  299. +                ((msg[i] == '\n') && (msg[i+1] == '\0')))
  300. +                break;
  301. +
  302. +            c = msg[i];
  303. +
  304. +            if (c == '\n') {
  305. +                *b++ = '\\';
  306. +                *b++ = 'n';
  307. +            }
  308. +            else if (c == '\v') {
  309. +                *b++ = '\\';
  310. +                *b++ = 'v';
  311. +            }
  312. +            else if (c == '\f') {
  313. +                *b++ = '\\';
  314. +                *b++ = 'f';
  315. +            }
  316. +            else if (c == '\r') {
  317. +                *b++ = '\\';
  318. +                *b++ = 'r';
  319. +            }
  320. +            else if (c == '\t') {
  321. +                *b++ = '\\';
  322. +                *b++ = 't';
  323. +            }
  324. +            else if (c == '\b') {
  325. +                *b++ = '\\';
  326. +                *b++ = 'b';
  327. +            }
  328. +            else if (c == '\a') {
  329. +                *b++ = '\\';
  330. +                *b++ = 'a';
  331. +            }
  332. +            else if (c == '\\') {
  333. +                /*
  334. +                 * We only print one backslash, otherwise we cause problems
  335. +                 * with the user expectation that they can copy&&paste Windows
  336. +                 * paths.
  337. +                 * FIXME: There should be a command-line argument to define
  338. +                 * how to handle non-printable+backslash characters (e.g.
  339. +                 * "human readable", "always octal escaped",
  340. +                 * "ksh93 compound variable array", ...)
  341. +                 */
  342. +                *b++ = '\\';
  343. +            }
  344. +            else if ((c > 127) || isprint((int)c)) {
  345. +                *b++ = c;
  346. +            }
  347. +            else {
  348. +                *b++ = '\\';
  349. +                int_to_octal3(c, b);
  350. +                b+=3;
  351. +            }
  352. +        }
  353. +
  354. +        *b++ = '\0';
  355. +        (void)fprintf(stdout, "%s\n", buffer);
  356. +    }
  357. +}
  358. +
  359. +int main(int ac, char *av[])
  360. +{
  361. +    TRACEHANDLE hSession = 0;
  362. +    TRACEHANDLE hTrace = 0;
  363. +    ULONG status;
  364. +    int retval = EXIT_SUCCESS;
  365. +
  366. +    (void)ac;
  367. +
  368. +    size_t propsSize = sizeof(EVENT_TRACE_PROPERTIES) + 1024;
  369. +    EVENT_TRACE_PROPERTIES *props = (EVENT_TRACE_PROPERTIES*)calloc(1, propsSize);
  370. +    if (props == NULL) {
  371. +        (void)fprintf(stderr, "%s: Malloc failed\n", av[0]);
  372. +        retval = EXIT_FAILURE;
  373. +        goto done;
  374. +    }
  375. +
  376. +    props->Wnode.BufferSize = (ULONG)propsSize;
  377. +    props->Wnode.Flags = WNODE_FLAG_TRACED_GUID;
  378. +    props->LogFileMode = EVENT_TRACE_REAL_TIME_MODE;
  379. +    props->EnableFlags = EVENT_TRACE_FLAG_DBGPRINT;
  380. +    props->LoggerNameOffset = sizeof(EVENT_TRACE_PROPERTIES);
  381. +#if 1
  382. +    /* Increase buffer size to 32MB */
  383. +    props->BufferSize = 64;             /* Buffer size in KB (64KB per buffer) */
  384. +    props->MinimumBuffers = 512;        /* Minimum buffers */
  385. +    props->MaximumBuffers = 512;        /* Maximum buffers */
  386. +#endif
  387. +
  388. +    status = StartTraceW(&hSession, KERNEL_LOGGER_NAME, props);
  389. +    if (status == ERROR_ALREADY_EXISTS) {
  390. +        (void)fprintf(stderr,
  391. +            "#### Kernel Logger already running, attaching...\n");
  392. +        hSession = 0;
  393. +    } else if (status != ERROR_SUCCESS) {
  394. +        (void)fprintf(stderr, "%s: StartTraceA() failed with error=%d\n",
  395. +            av[0], (int)status);
  396. +        retval = EXIT_FAILURE;
  397. +        goto done;
  398. +    } else {
  399. +        (void)fprintf(stderr,
  400. +            "#### Started Kernel Logger session.\n");
  401. +    }
  402. +
  403. +    EVENT_TRACE_LOGFILE log = {
  404. +        .LoggerName = KERNEL_LOGGER_NAME,
  405. +        .ProcessTraceMode =
  406. +            PROCESS_TRACE_MODE_REAL_TIME |
  407. +            PROCESS_TRACE_MODE_EVENT_RECORD,
  408. +        .EventRecordCallback = EventCallback
  409. +    };
  410. +
  411. +    hTrace = OpenTrace(&log);
  412. +    if (hTrace == INVALID_PROCESSTRACE_HANDLE) {
  413. +        (void)fprintf(stderr, "%s: OpenTrace() failed with error=%d\n",
  414. +            av[0], (int)GetLastError());
  415. +        retval = EXIT_FAILURE;
  416. +        goto done;
  417. +    }
  418. +
  419. +    (void)fprintf(stderr,
  420. +        "#### Listening for |DbgPrint*()| messages...\n");
  421. +    status = ProcessTrace(&hTrace, 1, NULL, NULL);
  422. +
  423. +done:
  424. +    return retval;
  425. +}
  426. --
  427. 2.51.0
  428.  
  429. From ad7800c72c5922105fc307073154c099069c15d1 Mon Sep 17 00:00:00 2001
  430. From: =?UTF-8?q?Aur=C3=A9lien=20Couderc?= <aurelien.couderc2002@gmail.com>
  431. Date: Wed, 3 Dec 2025 12:50:19 +0100
  432. Subject: [PATCH 3/8] README.md,docs: Improve comment about using NFS as MSYS2
  433.  root filesystem
  434.  
  435. Improve comment about using NFS as MSYS2 root filesystem.
  436.  
  437. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  438. ---
  439. README.md       | 4 ++--
  440.  docs/README.xml | 2 +-
  441.  2 files changed, 3 insertions(+), 3 deletions(-)
  442.  
  443. diff --git a/README.md b/README.md
  444. index df8c22b..589ab63 100644
  445. --- a/README.md
  446. +++ b/README.md
  447. @@ -367,8 +367,8 @@ Cygwin 32bit can be installed like this:
  448.          pacman -S --noconfirm base-devel gcc clang sed time coreutils util-linux grep sed emacs gdb make autoconf automake gettext gettext-devel git subversion flex bison unzip pax tar libiconv-devel ncurses-devel gmp-devel mpfr-devel mpc-devel isl-devel procps-ng libiconv-devel
  449.  
  450.  > [!NOTE]
  451. -> NFS filesystem used the MSYS root filesystem must be mounted as global
  452. -> filesystem
  453. +> NFS filesystem used as MSYS root filesystem (`/`) must be mounted as
  454. +> global filesystem (e.g. use `nfs_globalmount.exe`)
  455.  >
  456.  > <div>
  457.  >
  458. diff --git a/docs/README.xml b/docs/README.xml
  459. index 5c0d941..1d34228 100644
  460. --- a/docs/README.xml
  461. +++ b/docs/README.xml
  462. @@ -500,7 +500,7 @@ chmod a+x 'msys2-x86_64-20250830.exe'
  463.      </orderedlist>
  464.      <note>
  465.          <title>Installing MSYS on NFS filesystem</title>
  466. -        <para>NFS filesystem used the MSYS root filesystem must be mounted as global filesystem</para>
  467. +        <para>NFS filesystem used as MSYS root filesystem (<filename>/</filename>) must be mounted as global filesystem (e.g. use <command>nfs_globalmount.exe</command>)</para>
  468.          <orderedlist>
  469.              <title>Known issues</title>
  470.              <listitem><para>Edit <filename>/etc/pacman.conf</filename> and set <programlisting>SigLevel = Never</programlisting>, because due to a Cygwin/MSYS2 bug there is a mismatch between Cygwin/MSYS2 POSIX uid/gid and Win32 owner/owner_group SIDs</para></listitem>
  471. --
  472. 2.51.0
  473.  
  474. From 17c63ca23b066574bbc21932b6815407949cdb43 Mon Sep 17 00:00:00 2001
  475. From: =?UTF-8?q?Aur=C3=A9lien=20Couderc?= <aurelien.couderc2002@gmail.com>
  476. Date: Wed, 3 Dec 2025 13:09:57 +0100
  477. Subject: [PATCH 4/8] README.md,docs: Improve Windows requirement documentation
  478.  
  479. Improve Windows requirement documentation.
  480.  
  481. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  482. ---
  483. README.md       | 14 ++++++++++++--
  484.  docs/README.xml | 17 ++++++++++++++++-
  485.  2 files changed, 28 insertions(+), 3 deletions(-)
  486.  
  487. diff --git a/README.md b/README.md
  488. index 589ab63..aea5dcd 100644
  489. --- a/README.md
  490. +++ b/README.md
  491. @@ -260,8 +260,18 @@ NFSv4.2/NFSv4.1 filesystem driver for Windows 10/11 & Windows Server
  492.  
  493.  # Requirements
  494.  
  495. -- Windows 10 (32bit or 64bit), Windows 11 or Windows Server
  496. -  2019+2022+2025
  497. +- Operarting system:
  498. +
  499. +  - Windows 10 (32bit or 64bit)
  500. +  - Windows 11 (64bit)
  501. +  - Windows Server 2019 (64bit)
  502. +  - Windows Server 2022 (64bit)
  503. +  - Windows Server 2025 (64bit)
  504. +
  505. +  (Requires `NTFS`, `ReFS` or
  506. +  [`WinBTRFS`](https://github.com/maharmstone/btrfs) for System Volume
  507. +  (`C:`); the installer requires hardlink support, which `FAT` does not
  508. +  support)
  509.  
  510.  - Cygwin:
  511.  
  512. diff --git a/docs/README.xml b/docs/README.xml
  513. index 1d34228..c264cac 100644
  514. --- a/docs/README.xml
  515. +++ b/docs/README.xml
  516. @@ -301,7 +301,22 @@
  517.      <title>Requirements</title>
  518.      <itemizedlist>
  519.        <listitem>
  520. -        <para>Windows 10 (32bit or 64bit), Windows 11 or Windows Server 2019+2022+2025</para>
  521. +        <para>Operarting system:
  522. +          <itemizedlist>
  523. +            <listitem>Windows 10 (32bit or 64bit)</listitem>
  524. +            <listitem>Windows 11 (64bit)</listitem>
  525. +            <listitem>Windows Server 2019 (64bit)</listitem>
  526. +            <listitem>Windows Server 2022 (64bit)</listitem>
  527. +            <listitem>Windows Server 2025 (64bit)</listitem>
  528. +          </itemizedlist>
  529. +        </para>
  530. +        <para>(Requires <literal>NTFS</literal>,
  531. +          <literal>ReFS</literal> or
  532. +          <link xl:href="https://github.com/maharmstone/btrfs"><literal>WinBTRFS</literal></link>
  533. +          for System Volume (<filename>C:</filename>); the installer
  534. +          requires hardlink support, which <literal>FAT</literal>
  535. +          does not support)
  536. +        </para>
  537.        </listitem>
  538.        <listitem>
  539.          <para>Cygwin:
  540. --
  541. 2.51.0
  542.  
  543. From 23eb1d6f076ddeaeedbaa7e1c3395990c9811d00 Mon Sep 17 00:00:00 2001
  544. From: =?UTF-8?q?Aur=C3=A9lien=20Couderc?= <aurelien.couderc2002@gmail.com>
  545. Date: Wed, 3 Dec 2025 14:35:51 +0100
  546. Subject: [PATCH 5/8] tests: Fix Win11/2022 build failure in winfsinfo.c
  547.  
  548. Fix Win11/2022 build failure in winfsinfo.c.
  549.  
  550. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  551. ---
  552. tests/winfsinfo1/winfsinfo.c | 5 +++++
  553.  1 file changed, 5 insertions(+)
  554.  
  555. diff --git a/tests/winfsinfo1/winfsinfo.c b/tests/winfsinfo1/winfsinfo.c
  556. index dc103e1..e81e0b4 100644
  557. --- a/tests/winfsinfo1/winfsinfo.c
  558. +++ b/tests/winfsinfo1/winfsinfo.c
  559. @@ -1187,8 +1187,13 @@ int get_file_remote_protocol_info(const char *progname, const char *filename)
  560.          (void)printf("\t\t\tcompound Share=(\n");
  561.          (void)printf("\t\t\t\tCapabilities=0x%lx\n",
  562.              (unsigned long)frpi.ProtocolSpecific.Smb2.Share.Capabilities);
  563. +#if NTDDI_VERSION >= NTDDI_WIN10_NI
  564.          (void)printf("\t\t\t\tShareFlags=0x%lx\n",
  565.              (unsigned long)frpi.ProtocolSpecific.Smb2.Share.ShareFlags);
  566. +#else
  567. +        (void)printf("\t\t\t\tCachingFlags=0x%lx\n",
  568. +            (unsigned long)frpi.ProtocolSpecific.Smb2.Share.CachingFlags);
  569. +#endif /* NTDDI_VERSION >= NTDDI_WIN10_NI */
  570.  #if 0 /* MinGW header do not have these fields yet */
  571.          (void)printf("\t\t\t\tCachingFlags=0x%lx\n",
  572.              (unsigned long)frpi.ProtocolSpecific.Smb2.Share.CachingFlags);
  573. --
  574. 2.51.0
  575.  
  576. From 02c643c308023741da84d90922cc93cc1ddd8aa7 Mon Sep 17 00:00:00 2001
  577. From: Roland Mainz <roland.mainz@nrubsig.org>
  578. Date: Wed, 3 Dec 2025 15:41:17 +0100
  579. Subject: [PATCH 6/8] README.md,docs: Document status of create-file-with-ACL
  580.  NFS server support
  581.  
  582. Document status of create-file-with-ACL NFS server support.
  583.  
  584. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  585. ---
  586. README.md       | 22 +++++++++++++++++++---
  587.  docs/README.xml | 12 +++++++++---
  588.  2 files changed, 28 insertions(+), 6 deletions(-)
  589.  
  590. diff --git a/README.md b/README.md
  591. index aea5dcd..0b9c4a0 100644
  592. --- a/README.md
  593. +++ b/README.md
  594. @@ -807,9 +807,25 @@ Within WSL mount UNC path returned by `/sbin/nfs_mount`
  595.    which support `FATTR4_ACL`/`FATTR4_DACL` for `OPEN`/`CREATE`
  596.    operations.
  597.  
  598. -  So far FreeBSD 14.3 and the NFS-Ganesha NFS servers are known to
  599. -  support this, while Linux 6.12.\*, Solaris 11.4 and Illumos NFS
  600. -  servers ignore the ACL on `OPEN`/`CREATE` operations.
  601. +  Status:
  602. +
  603. +  - FreeBSD 14.3 nfsd: Works
  604. +
  605. +  - NFS-Ganesha NFS server: Works
  606. +
  607. +  - Linux kernel server: Requires patch
  608. +
  609. +    ([f9a48423f6ff5198257e508c5ef1ff0ec1be4465 - "NFSD: NFSv4 file
  610. +    creation neglects setting
  611. +    ACL"](https://git.kernel.org/pub/scm/linux/kernel/git/cel/linux.git/commit/?h=nfsd-testing&id=f9a48423f6ff5198257e508c5ef1ff0ec1be4465))
  612. +
  613. +  - Solaris 11.4 nfsd: Does not work
  614. +
  615. +    (ignores the ACL on `OPEN`/`CREATE` operations)
  616. +
  617. +  - Illumos NFSv4.2 nfsd: Does not work
  618. +
  619. +    (ignores the ACL on `OPEN`/`CREATE` operations)
  620.  
  621.  # Troubleshooting && finding bugs/debugging
  622.  
  623. diff --git a/docs/README.xml b/docs/README.xml
  624. index c264cac..4821cf9 100644
  625. --- a/docs/README.xml
  626. +++ b/docs/README.xml
  627. @@ -907,9 +907,15 @@ Datei befindet. Versuchen Sie, die Datei woanders zu speichern.</programlisting>
  628.          <literal>FATTR4_ACL</literal>/<literal>FATTR4_DACL</literal> for
  629.          <literal>OPEN</literal>/<literal>CREATE</literal>
  630.          operations.</para>
  631. -        <para>So far FreeBSD 14.3 and the NFS-Ganesha NFS servers are known to support this,
  632. -        while Linux 6.12.*, Solaris 11.4 and Illumos NFS servers ignore the ACL on
  633. -        <literal>OPEN</literal>/<literal>CREATE</literal> operations.</para>
  634. +        <para>Status:
  635. +          <itemizedlist>
  636. +            <listitem><para>FreeBSD 14.3 nfsd: Works</para></listitem>
  637. +            <listitem><para>NFS-Ganesha NFS server: Works</para></listitem>
  638. +            <listitem><para>Linux kernel server: Requires patch</para><para>(<link xl:href="https://git.kernel.org/pub/scm/linux/kernel/git/cel/linux.git/commit/?h=nfsd-testing&amp;id=f9a48423f6ff5198257e508c5ef1ff0ec1be4465">f9a48423f6ff5198257e508c5ef1ff0ec1be4465 - "NFSD: NFSv4 file creation neglects setting ACL"</link>)</para></listitem>
  639. +            <listitem><para>Solaris 11.4 nfsd: Does not work</para><para>(ignores the ACL on <literal>OPEN</literal>/<literal>CREATE</literal> operations)</para></listitem>
  640. +            <listitem><para>Illumos NFSv4.2 nfsd: Does not work</para><para>(ignores the ACL on <literal>OPEN</literal>/<literal>CREATE</literal> operations)</para></listitem>
  641. +          </itemizedlist>
  642. +        </para>
  643.        </listitem>
  644.      </itemizedlist>
  645.    </section>
  646. --
  647. 2.51.0
  648.  
  649. From 15f00908f394ed7b1f37651e4934bab0cfbc3aea Mon Sep 17 00:00:00 2001
  650. From: Roland Mainz <roland.mainz@nrubsig.org>
  651. Date: Wed, 3 Dec 2025 19:58:39 +0100
  652. Subject: [PATCH 7/8] sys: Use |RxFlushFcbInSystemCache(fcb,TRUE)| to flush
  653.  {src,dest} files for
  654.  |FSCTL_SET_ZERO_DATA|,|FSCTL_DUPLICATE_EXTENTS_TO_FILE|,|FSCTL_OFFLOAD_WRITE|
  655.  
  656. Use |RxFlushFcbInSystemCache(fcb,TRUE)| to flush {src,dest} files for
  657. |FSCTL_SET_ZERO_DATA|, |FSCTL_DUPLICATE_EXTENTS_TO_FILE| and
  658. |FSCTL_OFFLOAD_WRITE|.
  659.  
  660. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  661. ---
  662. sys/nfs41sys_fsctl.c | 155 +++++++++++++++++++++++++++++--------------
  663.  1 file changed, 105 insertions(+), 50 deletions(-)
  664.  
  665. diff --git a/sys/nfs41sys_fsctl.c b/sys/nfs41sys_fsctl.c
  666. index 25c1290..696f9c8 100644
  667. --- a/sys/nfs41sys_fsctl.c
  668. +++ b/sys/nfs41sys_fsctl.c
  669. @@ -459,6 +459,7 @@ NTSTATUS nfs41_SetZeroData(
  670.      __notnull const PFILE_ZERO_DATA_INFORMATION setzerodatabuffer =
  671.          (const PFILE_ZERO_DATA_INFORMATION)FsCtl->pInputBuffer;
  672.      __notnull PNFS41_FOBX nfs41_fobx = NFS41GetFobxExtension(RxContext->pFobx);
  673. +    bool fcb_locked_exclusive = false;
  674.  
  675.      DbgEn();
  676.  
  677. @@ -482,23 +483,29 @@ NTSTATUS nfs41_SetZeroData(
  678.          goto out;
  679.      }
  680.  
  681. +    status = RxAcquireExclusiveFcbResourceInMRx(RxContext->pFcb);
  682. +    if (!NT_SUCCESS(status)) {
  683. +        DbgP("nfs41_SetZeroData: "
  684. +            "RxAcquireExclusiveFcbResourceInMRx() failed, status=0x%lx\n",
  685. +            status);
  686. +        goto out;
  687. +    }
  688. +    fcb_locked_exclusive = true;
  689. +
  690.      DbgP("nfs41_SetZeroData: "
  691.          "setzerodatabuffer=(FileOffset=%lld,BeyondFinalZero=%lld)\n",
  692.          (long long)setzerodatabuffer->FileOffset.QuadPart,
  693.          (long long)setzerodatabuffer->BeyondFinalZero.QuadPart);
  694.  
  695.      /*
  696. -     * Disable caching because NFSv4.2 DEALLOCATE is basically a
  697. -     * "write" operation. AFAIK we should flush the cache and wait
  698. -     * for the kernel lazy writer (which |RxChangeBufferingState()|
  699. -     * AFAIK does) before doing the DEALLOCATE, to avoid that we
  700. -     * have outstanding writes in the kernel cache at the same
  701. -     * location where the DEALLOCATE should do it's work
  702. +     * NFSv4.2 DEALLOCATE is basically a "write" operation, but happens
  703. +     * only on the NFS server side. We need to flush our NFS client
  704. +     * cache and wait for the kernel lazy writer before doing the
  705. +     * DEALLOCATE, to avoid that we have outstanding writes in the
  706. +     * kernel cache at the same location where the DEALLOCATE should
  707. +     * do it's work.
  708.       */
  709. -    ULONG flag = DISABLE_CACHING;
  710. -    DbgP("nfs41_SetZeroData: disableing caching for file '%wZ'\n",
  711. -        SrvOpen->pAlreadyPrefixedName);
  712. -    RxChangeBufferingState((PSRV_OPEN)SrvOpen, ULongToPtr(flag), 1);
  713. +    (void)RxFlushFcbInSystemCache((PFCB)RxContext->pFcb, TRUE);
  714.  
  715.      status = nfs41_UpcallCreate(NFS41_SYSOP_FSCTL_SET_ZERO_DATA,
  716.          &nfs41_fobx->sec_ctx,
  717. @@ -534,6 +541,10 @@ NTSTATUS nfs41_SetZeroData(
  718.      }
  719.  
  720.  out:
  721. +    if (fcb_locked_exclusive) {
  722. +        RxReleaseFcbResourceInMRx(RxContext->pFcb);
  723. +    }
  724. +
  725.      if (entry) {
  726.          nfs41_UpcallDestroy(entry);
  727.      }
  728. @@ -639,6 +650,10 @@ NTSTATUS nfs41_DuplicateData(
  729.      __notnull XXCTL_LOWIO_COMPONENT *FsCtl =
  730.          &RxContext->LowIoContext.ParamsFor.FsCtl;
  731.      __notnull PNFS41_FOBX nfs41_fobx = NFS41GetFobxExtension(RxContext->pFobx);
  732. +    PFCB srcfcb = NULL;
  733. +    PFOBX srcfox = NULL;
  734. +    bool src_fcb_locked_exclusive = false;
  735. +    bool dest_fcb_locked_exclusive = false;
  736.  
  737.      /*
  738.       * Temporary store |FSCTL_DUPLICATE_EXTENTS_TO_FILE| data here, which
  739. @@ -751,8 +766,8 @@ NTSTATUS nfs41_DuplicateData(
  740.          goto out;
  741.      }
  742.  
  743. -    PFCB srcfcb = srcfo->FsContext;
  744. -    PFOBX srcfox = srcfo->FsContext2;
  745. +    srcfcb = srcfo->FsContext;
  746. +    srcfox = srcfo->FsContext2;
  747.      PNFS41_FCB nfs41_src_fcb = NFS41GetFcbExtension(srcfcb);
  748.      PNFS41_SRV_OPEN src_nfs41_srvopen = NFS41GetSrvOpenExtension(srcfox->SrvOpen);
  749.  
  750. @@ -768,38 +783,39 @@ NTSTATUS nfs41_DuplicateData(
  751.          goto out;
  752.      }
  753.  
  754. -    IO_STATUS_BLOCK flushIoStatus;
  755. -    DbgP("nfs41_DuplicateData: flushing src file buffers\n");
  756. -    status = ZwFlushBuffersFile(dd.handle, &flushIoStatus);
  757. -    if (status) {
  758. -        if (status == STATUS_ACCESS_DENIED) {
  759. -            /*
  760. -             * |ZwFlushBuffersFile()| can fail if |dd.handle| was not opened
  761. -             * for write access
  762. -             */
  763. -            DbgP("nfs41_DuplicateData: "
  764. -                "ZwFlushBuffersFile() failed with STATUS_ACCESS_DENIED\n");
  765. -        }
  766. -        else {
  767. -            DbgP("nfs41_DuplicateData: "
  768. -                "ZwFlushBuffersFile() failed, status=0x%lx\n",
  769. -                (long)status);
  770. -            goto out;
  771. -        }
  772. +    status = RxAcquireExclusiveFcbResourceInMRx((PMRX_FCB)srcfcb);
  773. +    if (!NT_SUCCESS(status)) {
  774. +        DbgP("nfs41_DuplicateData: "
  775. +            "RxAcquireExclusiveFcbResourceInMRx() failed, status=0x%lx\n",
  776. +            status);
  777. +        goto out;
  778. +    }
  779. +    src_fcb_locked_exclusive = true;
  780. +
  781. +    status = RxAcquireExclusiveFcbResourceInMRx(RxContext->pFcb);
  782. +    if (!NT_SUCCESS(status)) {
  783. +        DbgP("nfs41_DuplicateData: "
  784. +            "RxAcquireExclusiveFcbResourceInMRx() failed, status=0x%lx\n",
  785. +            status);
  786. +        goto out;
  787.      }
  788. +    dest_fcb_locked_exclusive = true;
  789.  
  790.      /*
  791. -     * Disable caching because NFSv4.2 CLONE is basically a
  792. -     * "write" operation. AFAIK we should flush the cache and wait
  793. -     * for the kernel lazy writer (which |RxChangeBufferingState()|
  794. -     * AFAIK does) before doing the CLONE, to avoid that we
  795. -     * have outstanding writes in the kernel cache at the same
  796. -     * location where the CLONE should do it's work
  797. +     * NFSv4.2 CLONE is basically a "write" operation, but happens
  798. +     * only on the NFS server side. We need to flush our NFS client
  799. +     * cache (for both src and dest files!!) and wait in both cases
  800. +     * for the kernel lazy writer before doing the CLONE, to avoid
  801. +     * that we have outstanding writes in the kernel cache at the
  802. +     * same location where the CLONE should do it's work.
  803.       */
  804. -    ULONG flag = DISABLE_CACHING;
  805. -    DbgP("nfs41_DuplicateData: disableing caching for file '%wZ'\n",
  806. -        SrvOpen->pAlreadyPrefixedName);
  807. -    RxChangeBufferingState((PSRV_OPEN)SrvOpen, ULongToPtr(flag), 1);
  808. +    DbgP("nfs41_DuplicateData: flushing src file '%wZ'\n",
  809. +        srcfox->SrvOpen->pAlreadyPrefixedName);
  810. +    (void)RxFlushFcbInSystemCache((PFCB)srcfcb, TRUE);
  811. +
  812. +    DbgP("nfs41_DuplicateData: flushing dest file '%wZ'\n",
  813. +        RxContext->pRelevantSrvOpen->pAlreadyPrefixedName);
  814. +    (void)RxFlushFcbInSystemCache((PFCB)RxContext->pFcb, TRUE);
  815.  
  816.      status = nfs41_UpcallCreate(NFS41_SYSOP_FSCTL_DUPLICATE_DATA,
  817.          &nfs41_fobx->sec_ctx,
  818. @@ -842,6 +858,14 @@ NTSTATUS nfs41_DuplicateData(
  819.      }
  820.  
  821.  out:
  822. +    if (src_fcb_locked_exclusive) {
  823. +        RxReleaseFcbResourceInMRx((PMRX_FCB)srcfcb);
  824. +    }
  825. +
  826. +    if (dest_fcb_locked_exclusive) {
  827. +        RxReleaseFcbResourceInMRx(RxContext->pFcb);
  828. +    }
  829. +
  830.      if (entry) {
  831.          nfs41_UpcallDestroy(entry);
  832.      }
  833. @@ -1185,6 +1209,8 @@ NTSTATUS nfs41_OffloadWrite(
  834.          &RxContext->LowIoContext.ParamsFor.FsCtl;
  835.      __notnull PNFS41_FOBX nfs41_fobx = NFS41GetFobxExtension(RxContext->pFobx);
  836.      offloadcontext_entry *src_oce = NULL;
  837. +    bool src_fcb_locked_exclusive = false;
  838. +    bool dest_fcb_locked_exclusive = false;
  839.  
  840.      struct {
  841.          LONGLONG    srcfileoffset;
  842. @@ -1291,18 +1317,39 @@ NTSTATUS nfs41_OffloadWrite(
  843.      PNFS41_SRV_OPEN src_nfs41_srvopen =
  844.          NFS41GetSrvOpenExtension(src_oce->src_srvopen);
  845.  
  846. +    status = RxAcquireExclusiveFcbResourceInMRx(src_oce->src_srvopen->pFcb);
  847. +    if (!NT_SUCCESS(status)) {
  848. +        DbgP("nfs41_OffloadWrite: "
  849. +            "RxAcquireExclusiveFcbResourceInMRx() failed, status=0x%lx\n",
  850. +            status);
  851. +        goto out;
  852. +    }
  853. +    src_fcb_locked_exclusive = true;
  854. +
  855. +    status = RxAcquireExclusiveFcbResourceInMRx(RxContext->pFcb);
  856. +    if (!NT_SUCCESS(status)) {
  857. +        DbgP("nfs41_OffloadWrite: "
  858. +            "RxAcquireExclusiveFcbResourceInMRx() failed, status=0x%lx\n",
  859. +            status);
  860. +        goto out;
  861. +    }
  862. +    dest_fcb_locked_exclusive = true;
  863. +
  864.      /*
  865. -     * Disable caching because NFSv4.2 COPY is basically a
  866. -     * "write" operation. AFAIK we should flush the cache and wait
  867. -     * for the kernel lazy writer (which |RxChangeBufferingState()|
  868. -     * AFAIK does) before doing the COPY, to avoid that we
  869. -     * have outstanding writes in the kernel cache at the same
  870. -     * location where the COPY should do it's work
  871. +     * NFSv4.2 COPY is basically a "write" operation, but happens
  872. +     * only on the NFS server side. We need to flush our NFS client
  873. +     * cache (for both src and dest files!!) and wait in both cases
  874. +     * for the kernel lazy writer before doing the COPY, to avoid
  875. +     * that we have outstanding writes in the kernel cache at the
  876. +     * same location where the COPY should do it's work.
  877.       */
  878. -    ULONG flag = DISABLE_CACHING;
  879. -    DbgP("nfs41_OffloadWrite: disableing caching for file '%wZ'\n",
  880. -        SrvOpen->pAlreadyPrefixedName);
  881. -    RxChangeBufferingState((PSRV_OPEN)SrvOpen, ULongToPtr(flag), 1);
  882. +    DbgP("nfs41_OffloadWrite: flushing src file '%wZ'\n",
  883. +        src_oce->src_srvopen->pAlreadyPrefixedName);
  884. +    (void)RxFlushFcbInSystemCache((PFCB)src_oce->src_srvopen->pFcb, TRUE);
  885. +
  886. +    DbgP("nfs41_OffloadWrite: flushing dest file '%wZ'\n",
  887. +        RxContext->pRelevantSrvOpen->pAlreadyPrefixedName);
  888. +    (void)RxFlushFcbInSystemCache((PFCB)RxContext->pFcb, TRUE);
  889.  
  890.      status = nfs41_UpcallCreate(NFS41_SYSOP_FSCTL_OFFLOAD_DATACOPY,
  891.          &nfs41_fobx->sec_ctx,
  892. @@ -1350,6 +1397,14 @@ NTSTATUS nfs41_OffloadWrite(
  893.      }
  894.  
  895.  out:
  896. +    if (src_fcb_locked_exclusive) {
  897. +        RxReleaseFcbResourceInMRx(src_oce->src_srvopen->pFcb);
  898. +    }
  899. +
  900. +    if (dest_fcb_locked_exclusive) {
  901. +        RxReleaseFcbResourceInMRx(RxContext->pFcb);
  902. +    }
  903. +
  904.      if (src_oce) {
  905.          /* Release resource we obtained in shared mode */
  906.          ExReleaseResourceLite(&src_oce->resource);
  907. --
  908. 2.51.0
  909.  
  910. From b79a9ea32708261cf292d31a957a2fad8d420803 Mon Sep 17 00:00:00 2001
  911. From: Roland Mainz <roland.mainz@nrubsig.org>
  912. Date: Wed, 3 Dec 2025 21:36:44 +0100
  913. Subject: [PATCH 8/8] sys: Fix |nfs41_DuplicateData()| crash on Windows/32bit
  914.  with faulty string pointer
  915.  
  916. Fix |nfs41_DuplicateData()| crash on Windows/32bit with faulty
  917. string pointer.
  918.  
  919. Reported-by: Cedric Blancher <cedric.blancher@gmail.com>
  920. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  921. ---
  922. sys/nfs41sys_fsctl.c | 2 +-
  923.  1 file changed, 1 insertion(+), 1 deletion(-)
  924.  
  925. diff --git a/sys/nfs41sys_fsctl.c b/sys/nfs41sys_fsctl.c
  926. index 696f9c8..686b139 100644
  927. --- a/sys/nfs41sys_fsctl.c
  928. +++ b/sys/nfs41sys_fsctl.c
  929. @@ -756,7 +756,7 @@ NTSTATUS nfs41_DuplicateData(
  930.      DbgP("nfs41_DuplicateData: "
  931.          "srcfo=0x%p srcfo->FileName='%wZ'\n",
  932.          srcfo,
  933. -        srcfo->FileName);
  934. +        &srcfo->FileName);
  935.  
  936.      if (srcfo->DeviceObject !=
  937.          RxContext->CurrentIrpSp->FileObject->DeviceObject) {
  938. --
  939. 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