pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Patches for kernel performance improvements+cleanup+misc, 2025-08-12
Posted by Anonymous on Tue 12th Aug 2025 17:53
raw | new post

  1. From 05730ef9dd72acbad774e10f108a01a10eba9daf Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Mon, 11 Aug 2025 11:15:05 +0200
  4. Subject: [PATCH 1/7] sys: |nfs41_downcall()| does not need to clear temporary
  5.  |nfs41_updowncall_entry|
  6.  
  7. |nfs41_downcall()| does not need to clear temporary |nfs41_updowncall_entry|.
  8.  
  9. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  10. ---
  11. sys/nfs41sys_updowncall.c | 5 +----
  12.  1 file changed, 1 insertion(+), 4 deletions(-)
  13.  
  14. diff --git a/sys/nfs41sys_updowncall.c b/sys/nfs41sys_updowncall.c
  15. index 0b3b39c..3a1c135 100644
  16. --- a/sys/nfs41sys_updowncall.c
  17. +++ b/sys/nfs41sys_updowncall.c
  18. @@ -144,8 +144,6 @@ static void unmarshal_nfs41_header(
  19.      nfs41_updowncall_entry *tmp,
  20.      unsigned char **buf)
  21.  {
  22. -    RtlZeroMemory(tmp, sizeof(nfs41_updowncall_entry));
  23. -
  24.      RtlCopyMemory(&tmp->xid, *buf, sizeof(tmp->xid));
  25.      *buf += sizeof(tmp->xid);
  26.      RtlCopyMemory(&tmp->opcode, *buf, sizeof(tmp->opcode));
  27. @@ -646,9 +644,8 @@ NTSTATUS nfs41_downcall(
  28.  #endif /* DEBUG_PRINT_DOWNCALL_HEXBUF */
  29.  
  30.  #ifdef USE_STACK_FOR_DOWNCALL_UPDOWNCALLENTRY_MEM
  31. -    nfs41_updowncall_entry stacktmp;
  32. +    nfs41_updowncall_entry stacktmp; /* rename this to |header_tmp| */
  33.  
  34. -    (void)memset(&stacktmp, 0, sizeof(stacktmp));
  35.      tmp = &stacktmp;
  36.  #else
  37.      tmp = nfs41_downcall_allocate_updowncall_entry();
  38. --
  39. 2.45.1
  40.  
  41. From 8ba45eaf5cdc22d9006976e448b4ca28d3e5bda1 Mon Sep 17 00:00:00 2001
  42. From: Roland Mainz <roland.mainz@nrubsig.org>
  43. Date: Mon, 11 Aug 2025 11:18:23 +0200
  44. Subject: [PATCH 2/7] daemon: downcall should use the actual bytes written back
  45.  to kernel for |DeviceIoControl()|
  46.  
  47. Downcall should use the actual bytes written back to kernel for
  48. |DeviceIoControl()|, and not the maximum buffer size.
  49.  
  50. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  51. ---
  52. daemon/nfs41_daemon.c | 12 +++++++++---
  53.  daemon/open.c         |  7 ++++++-
  54.  daemon/symlink.c      |  4 ++++
  55.  daemon/upcall.c       |  9 ++++++++-
  56.  4 files changed, 27 insertions(+), 5 deletions(-)
  57.  
  58. diff --git a/daemon/nfs41_daemon.c b/daemon/nfs41_daemon.c
  59. index 12d18b0..c798c28 100644
  60. --- a/daemon/nfs41_daemon.c
  61. +++ b/daemon/nfs41_daemon.c
  62. @@ -138,7 +138,7 @@ static unsigned int nfsd_worker_thread_main(void *args)
  63.      // buffer used to process upcall, assumed to be fixed size.
  64.      // if we ever need to handle non-cached IO, need to make it dynamic
  65.      unsigned char outbuf[UPCALL_BUF_SIZE], inbuf[UPCALL_BUF_SIZE];
  66. -    DWORD inbuf_len = UPCALL_BUF_SIZE, outbuf_len;
  67. +    DWORD inbuf_len, outbuf_len;
  68.      nfs41_upcall upcall;
  69.  
  70.      /*
  71. @@ -213,7 +213,7 @@ write_downcall:
  72.              "get_last_error=%d\n", upcall.xid, opcode2string(upcall.opcode),
  73.              upcall.status, upcall.last_error));
  74.  
  75. -        upcall_marshall(&upcall, inbuf, (uint32_t)inbuf_len, (uint32_t*)&outbuf_len);
  76. +        upcall_marshall(&upcall, inbuf, UPCALL_BUF_SIZE, (uint32_t*)&inbuf_len);
  77.  
  78.          /*
  79.           * Note: Caller impersonation ends with |IOCTL_NFS41_WRITE| -
  80. @@ -223,7 +223,13 @@ write_downcall:
  81.          (void)CloseHandle(upcall.currentthread_token);
  82.          upcall.currentthread_token = INVALID_HANDLE_VALUE;
  83.  
  84. -        DPRINTF(2, ("making a downcall: outbuf_len %ld\n\n", outbuf_len));
  85. +        DPRINTF(2,
  86. +            ("making a downcall: "
  87. +            "xid=%lld inbuf_len=%ld opcode='%s' status=%d\n",
  88. +            upcall.xid,
  89. +            (long)inbuf_len,
  90. +            opcode2string(upcall.opcode),
  91. +            upcall.status));
  92.          status = DeviceIoControl(pipe, IOCTL_NFS41_WRITE,
  93.              inbuf, inbuf_len, NULL, 0, (LPDWORD)&outbuf_len, NULL);
  94.          if (!status) {
  95. diff --git a/daemon/open.c b/daemon/open.c
  96. index d2c8bf3..ae1540c 100644
  97. --- a/daemon/open.c
  98. +++ b/daemon/open.c
  99. @@ -1227,7 +1227,10 @@ static int marshall_open(unsigned char *buffer, uint32_t *length, nfs41_upcall *
  100.          if (status) goto out;
  101.          status = safe_write(&buffer, length, &len, sizeof(len));
  102.          if (status) goto out;
  103. -        /* convert args->symlink to wchar */
  104. +        /*
  105. +         * convert args->symlink to wchar
  106. +         * FIXME: What about |len| if we have characters outside the BMP ?
  107. +         */
  108.          if (*length <= len || !MultiByteToWideChar(CP_UTF8,
  109.              MB_ERR_INVALID_CHARS,
  110.              args->symlink.path, args->symlink.len,
  111. @@ -1235,6 +1238,8 @@ static int marshall_open(unsigned char *buffer, uint32_t *length, nfs41_upcall *
  112.              status = ERROR_BUFFER_OVERFLOW;
  113.              goto out;
  114.          }
  115. +
  116. +        *length -= len;
  117.      }
  118.      DPRINTF(2, ("NFS41_SYSOP_OPEN: downcall "
  119.          "open_state=0x%p "
  120. diff --git a/daemon/symlink.c b/daemon/symlink.c
  121. index 8ddd70e..0a53de4 100644
  122. --- a/daemon/symlink.c
  123. +++ b/daemon/symlink.c
  124. @@ -297,6 +297,7 @@ static int marshall_symlink_get(unsigned char *buffer, uint32_t *length,
  125.          goto out;
  126.      }
  127.  
  128. +    /* FIXME: What about |len| if we have characters outside the BMP ? */
  129.      if (!MultiByteToWideChar(CP_UTF8,
  130.              MB_ERR_INVALID_CHARS,
  131.              args->target_get.path, args->target_get.len,
  132. @@ -307,6 +308,9 @@ static int marshall_symlink_get(unsigned char *buffer, uint32_t *length,
  133.          status = ERROR_BUFFER_OVERFLOW;
  134.          goto out;
  135.      }
  136. +
  137. +    *length -= len;
  138. +
  139.  out:
  140.      return status;
  141.  }
  142. diff --git a/daemon/upcall.c b/daemon/upcall.c
  143. index 93fc329..45e0729 100644
  144. --- a/daemon/upcall.c
  145. +++ b/daemon/upcall.c
  146. @@ -232,8 +232,15 @@ write_downcall:
  147.      /* marshall the operation's results */
  148.      op = g_upcall_op_table[upcall->opcode];
  149.      if (op && op->marshall) {
  150. -        if ((upcall->status = op->marshall(buffer, &length, upcall)))
  151. +        if ((upcall->status = op->marshall(buffer, &length, upcall))) {
  152. +            DPRINTF(0,
  153. +                ("upcall_marshall: "
  154. +                "marshall failed, op='%s' *length=%ld, status=0x%lx\n",
  155. +                opcode2string(upcall->opcode),
  156. +                (long)length,
  157. +                (long)upcall->status));
  158.              goto write_downcall;
  159. +        }
  160.      }
  161.  out:
  162.      *length_out = total - length;
  163. --
  164. 2.45.1
  165.  
  166. From fba8c60743e5eb0dfe70bc16c42c528bb61fa8b9 Mon Sep 17 00:00:00 2001
  167. From: Roland Mainz <roland.mainz@nrubsig.org>
  168. Date: Mon, 11 Aug 2025 11:41:24 +0200
  169. Subject: [PATCH 3/7] sys: |IoCompleteRequest()| and |KeSetEvent()| should use
  170.  priority boost
  171.  
  172. |IoCompleteRequest()| and |KeSetEvent()| should use priority boost like
  173. the Windows SMB driver does.
  174.  
  175. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  176. ---
  177. sys/nfs41sys_driver.c     |  2 +-
  178.  sys/nfs41sys_driver.h     |  3 +++
  179.  sys/nfs41sys_mount.c      |  4 ++--
  180.  sys/nfs41sys_updowncall.c | 11 ++++++-----
  181.  4 files changed, 12 insertions(+), 8 deletions(-)
  182.  
  183. diff --git a/sys/nfs41sys_driver.c b/sys/nfs41sys_driver.c
  184. index 628789f..7cf2445 100644
  185. --- a/sys/nfs41sys_driver.c
  186. +++ b/sys/nfs41sys_driver.c
  187. @@ -976,7 +976,7 @@ NTSTATUS nfs41_FsdDispatch(
  188.          print_error("*** not ours ***\n");
  189.          Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST;
  190.          Irp->IoStatus.Information = 0;
  191. -        IoCompleteRequest(Irp, IO_NO_INCREMENT );
  192. +        IoCompleteRequest(Irp, IO_NFS41FS_INCREMENT);
  193.          status = STATUS_INVALID_DEVICE_REQUEST;
  194.          goto out;
  195.      }
  196. diff --git a/sys/nfs41sys_driver.h b/sys/nfs41sys_driver.h
  197. index 6f57818..17965a7 100644
  198. --- a/sys/nfs41sys_driver.h
  199. +++ b/sys/nfs41sys_driver.h
  200. @@ -92,6 +92,9 @@ typedef struct __nfs41_timings {
  201.  } nfs41_timings;
  202.  #endif /* ENABLE_TIMINGS */
  203.  
  204. +/* Windows SMB driver also uses |IO_NFS41FS_INCREMENT| */
  205. +#define IO_NFS41FS_INCREMENT IO_NETWORK_INCREMENT
  206. +
  207.  #define DISABLE_CACHING 0
  208.  #define ENABLE_READ_CACHING 1
  209.  #define ENABLE_WRITE_CACHING 2
  210. diff --git a/sys/nfs41sys_mount.c b/sys/nfs41sys_mount.c
  211. index f2d7d81..9fa2ccd 100644
  212. --- a/sys/nfs41sys_mount.c
  213. +++ b/sys/nfs41sys_mount.c
  214. @@ -1414,7 +1414,7 @@ NTSTATUS nfs41_FinalizeNetRoot(
  215.              DbgP("Removing entry from upcall list\n");
  216.              nfs41_RemoveEntry(upcallLock, tmp);
  217.              tmp->status = STATUS_INSUFFICIENT_RESOURCES;
  218. -            KeSetEvent(&tmp->cond, 0, FALSE);
  219. +            (void)KeSetEvent(&tmp->cond, IO_NFS41FS_INCREMENT, FALSE);
  220.          } else
  221.              break;
  222.      } while (1);
  223. @@ -1425,7 +1425,7 @@ NTSTATUS nfs41_FinalizeNetRoot(
  224.              DbgP("Removing entry from downcall list\n");
  225.              nfs41_RemoveEntry(downcallLock, tmp);
  226.              tmp->status = STATUS_INSUFFICIENT_RESOURCES;
  227. -            KeSetEvent(&tmp->cond, 0, FALSE);
  228. +            (void)KeSetEvent(&tmp->cond, IO_NFS41FS_INCREMENT, FALSE);
  229.          } else
  230.              break;
  231.      } while (1);
  232. diff --git a/sys/nfs41sys_updowncall.c b/sys/nfs41sys_updowncall.c
  233. index 3a1c135..deba9d6 100644
  234. --- a/sys/nfs41sys_updowncall.c
  235. +++ b/sys/nfs41sys_updowncall.c
  236. @@ -257,7 +257,7 @@ NTSTATUS handle_upcall(
  237.      switch(entry->opcode) {
  238.      case NFS41_SYSOP_SHUTDOWN:
  239.          status = marshal_nfs41_shutdown(entry, pbOut, cbOut, len);
  240. -        KeSetEvent(&entry->cond, 0, FALSE);
  241. +        (void)KeSetEvent(&entry->cond, IO_NFS41FS_INCREMENT, FALSE);
  242.          break;
  243.      case NFS41_SYSOP_MOUNT:
  244.          status = marshal_nfs41_mount(entry, pbOut, cbOut, len);
  245. @@ -518,7 +518,7 @@ NTSTATUS nfs41_UpcallWaitForReply(
  246.      FsRtlEnterFileSystem();
  247.  
  248.      nfs41_AddEntry(upcallLock, upcall, entry);
  249. -    KeSetEvent(&upcallEvent, 0, FALSE);
  250. +    (void)KeSetEvent(&upcallEvent, IO_NFS41FS_INCREMENT, FALSE);
  251.  
  252.      if (entry->async_op)
  253.          goto out;
  254. @@ -597,7 +597,7 @@ process_upcall:
  255.          ExReleaseFastMutex(&entry->lock);
  256.          if (status) {
  257.              entry->status = status;
  258. -            KeSetEvent(&entry->cond, 0, FALSE);
  259. +            (void)KeSetEvent(&entry->cond, IO_NFS41FS_INCREMENT, FALSE);
  260.              RxContext->InformationToReturn = 0;
  261.          } else
  262.              RxContext->InformationToReturn = len;
  263. @@ -807,8 +807,9 @@ NTSTATUS nfs41_downcall(
  264.                      (int)cur->opcode);
  265.                  break;
  266.          }
  267. -    } else
  268. -        KeSetEvent(&cur->cond, 0, FALSE);
  269. +    } else {
  270. +        (void)KeSetEvent(&cur->cond, IO_NFS41FS_INCREMENT, FALSE);
  271. +    }
  272.  
  273.  out_free:
  274.  #ifdef USE_STACK_FOR_DOWNCALL_UPDOWNCALLENTRY_MEM
  275. --
  276. 2.45.1
  277.  
  278. From f336f52a31acef508fd54bfbd1bb4263c876f5a4 Mon Sep 17 00:00:00 2001
  279. From: Dan Shelton <dan.f.shelton@gmail.com>
  280. Date: Mon, 11 Aug 2025 12:04:57 +0200
  281. Subject: [PATCH 4/7] sys: Driver should use ExAcquireFastMutexUnsafe() and
  282.  ExReleaseFastMutexUnsafe()
  283.  
  284. ExAcquireFastMutexUnsafe() and ExReleaseFastMutexUnsafe() inside
  285. FsRtlEnterFileSystem()/FsRtlExitFileSystem().
  286.  
  287. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  288. ---
  289. sys/nfs41sys_driver.c     | 20 ++++++++++----------
  290.  sys/nfs41sys_driver.h     | 24 ++++++++++++------------
  291.  sys/nfs41sys_mount.c      |  8 ++++----
  292.  sys/nfs41sys_updowncall.c | 29 +++++++++++++++++++----------
  293.  4 files changed, 45 insertions(+), 36 deletions(-)
  294.  
  295. diff --git a/sys/nfs41sys_driver.c b/sys/nfs41sys_driver.c
  296. index 7cf2445..bfde496 100644
  297. --- a/sys/nfs41sys_driver.c
  298. +++ b/sys/nfs41sys_driver.c
  299. @@ -686,7 +686,7 @@ VOID nfs41_remove_fcb_entry(
  300.  {
  301.      PLIST_ENTRY pEntry;
  302.      nfs41_fcb_list_entry *cur;
  303. -    ExAcquireFastMutex(&fcblistLock);
  304. +    ExAcquireFastMutexUnsafe(&fcblistLock);
  305.  
  306.      pEntry = openlist.head.Flink;
  307.      while (!IsListEmpty(&openlist.head)) {
  308. @@ -709,7 +709,7 @@ VOID nfs41_remove_fcb_entry(
  309.          }
  310.          pEntry = pEntry->Flink;
  311.      }
  312. -    ExReleaseFastMutex(&fcblistLock);
  313. +    ExReleaseFastMutexUnsafe(&fcblistLock);
  314.  }
  315.  
  316.  static
  317. @@ -720,7 +720,7 @@ VOID nfs41_invalidate_fobx_entry(
  318.      nfs41_fcb_list_entry *cur;
  319.      __notnull PNFS41_FOBX nfs41_fobx = NFS41GetFobxExtension(pFobx);
  320.  
  321. -    ExAcquireFastMutex(&fcblistLock);
  322. +    ExAcquireFastMutexUnsafe(&fcblistLock);
  323.  
  324.      pEntry = openlist.head.Flink;
  325.      while (!IsListEmpty(&openlist.head)) {
  326. @@ -743,7 +743,7 @@ VOID nfs41_invalidate_fobx_entry(
  327.          }
  328.          pEntry = pEntry->Flink;
  329.      }
  330. -    ExReleaseFastMutex(&fcblistLock);
  331. +    ExReleaseFastMutexUnsafe(&fcblistLock);
  332.  }
  333.  
  334.  NTSTATUS nfs41_Flush(
  335. @@ -788,7 +788,7 @@ VOID nfs41_update_fcb_list(
  336.  {
  337.      PLIST_ENTRY pEntry;
  338.      nfs41_fcb_list_entry *cur;
  339. -    ExAcquireFastMutex(&fcblistLock);
  340. +    ExAcquireFastMutexUnsafe(&fcblistLock);
  341.      pEntry = openlist.head.Flink;
  342.      while (!IsListEmpty(&openlist.head)) {
  343.          cur = (nfs41_fcb_list_entry *)CONTAINING_RECORD(pEntry,
  344. @@ -815,7 +815,7 @@ VOID nfs41_update_fcb_list(
  345.          }
  346.          pEntry = pEntry->Flink;
  347.      }
  348. -    ExReleaseFastMutex(&fcblistLock);
  349. +    ExReleaseFastMutexUnsafe(&fcblistLock);
  350.  }
  351.  
  352.  NTSTATUS nfs41_IsValidDirectory (
  353. @@ -903,7 +903,7 @@ void enable_caching(
  354.  
  355.      RxChangeBufferingState((PSRV_OPEN)SrvOpen, ULongToPtr(flag), 1);
  356.  
  357. -    ExAcquireFastMutex(&fcblistLock);
  358. +    ExAcquireFastMutexUnsafe(&fcblistLock);
  359.      pEntry = openlist.head.Flink;
  360.      while (!IsListEmpty(&openlist.head)) {
  361.          cur = (nfs41_fcb_list_entry *)CONTAINING_RECORD(pEntry,
  362. @@ -943,7 +943,7 @@ void enable_caching(
  363.          nfs41_fobx->deleg_type = 0;
  364.      }
  365.  out_release_fcblistlock:
  366. -    ExReleaseFastMutex(&fcblistLock);
  367. +    ExReleaseFastMutexUnsafe(&fcblistLock);
  368.  }
  369.  
  370.  NTSTATUS nfs41_CompleteBufferingStateChangeRequest(
  371. @@ -1231,7 +1231,7 @@ VOID fcbopen_main(PVOID ctx)
  372.          PLIST_ENTRY pEntry;
  373.          nfs41_fcb_list_entry *cur;
  374.          status = KeDelayExecutionThread(KernelMode, TRUE, &timeout);
  375. -        ExAcquireFastMutex(&fcblistLock);
  376. +        ExAcquireFastMutexUnsafe(&fcblistLock);
  377.          pEntry = openlist.head.Flink;
  378.          while (!IsListEmpty(&openlist.head)) {
  379.              PNFS41_NETROOT_EXTENSION pNetRootContext;
  380. @@ -1328,7 +1328,7 @@ out:
  381.              }
  382.              pEntry = pEntry->Flink;
  383.          }
  384. -        ExReleaseFastMutex(&fcblistLock);
  385. +        ExReleaseFastMutexUnsafe(&fcblistLock);
  386.      }
  387.  //    DbgEx();
  388.  }
  389. diff --git a/sys/nfs41sys_driver.h b/sys/nfs41sys_driver.h
  390. index 17965a7..a2d5ed6 100644
  391. --- a/sys/nfs41sys_driver.h
  392. +++ b/sys/nfs41sys_driver.h
  393. @@ -354,41 +354,41 @@ typedef struct _nfs41_mount_list {
  394.  } nfs41_mount_list;
  395.  
  396.  #define nfs41_AddEntry(lock,list,pEntry)                    \
  397. -            ExAcquireFastMutex(&lock);                      \
  398. +            ExAcquireFastMutexUnsafe(&lock);                \
  399.              InsertTailList(&(list).head, &(pEntry)->next);  \
  400. -            ExReleaseFastMutex(&lock);
  401. +            ExReleaseFastMutexUnsafe(&lock);
  402.  #define nfs41_RemoveFirst(lock,list,pEntry)                 \
  403. -            ExAcquireFastMutex(&lock);                      \
  404. +            ExAcquireFastMutexUnsafe(&lock);                \
  405.              pEntry = (IsListEmpty(&(list).head)             \
  406.              ? NULL                                          \
  407.              : RemoveHeadList(&(list).head));                \
  408. -            ExReleaseFastMutex(&lock);
  409. +            ExReleaseFastMutexUnsafe(&lock);
  410.  #define nfs41_RemoveEntry(lock,pEntry)                      \
  411. -            ExAcquireFastMutex(&lock);                      \
  412. +            ExAcquireFastMutexUnsafe(&lock);                \
  413.              RemoveEntryList(&pEntry->next);                 \
  414. -            ExReleaseFastMutex(&lock);
  415. +            ExReleaseFastMutexUnsafe(&lock);
  416.  #define nfs41_IsListEmpty(lock,list,flag)                   \
  417. -            ExAcquireFastMutex(&lock);                      \
  418. +            ExAcquireFastMutexUnsafe(&lock);                \
  419.              flag = IsListEmpty(&(list).head);               \
  420. -            ExReleaseFastMutex(&lock);
  421. +            ExReleaseFastMutexUnsafe(&lock);
  422.  #define nfs41_GetFirstEntry(lock,list,pEntry)               \
  423. -            ExAcquireFastMutex(&lock);                      \
  424. +            ExAcquireFastMutexUnsafe(&lock);                \
  425.              pEntry = (IsListEmpty(&(list).head)             \
  426.               ? NULL                                         \
  427.               : (nfs41_updowncall_entry *)                   \
  428.                 (CONTAINING_RECORD((list).head.Flink,        \
  429.                                    nfs41_updowncall_entry,   \
  430.                                    next)));                  \
  431. -            ExReleaseFastMutex(&lock);
  432. +            ExReleaseFastMutexUnsafe(&lock);
  433.  #define nfs41_GetFirstMountEntry(lock,list,pEntry)          \
  434. -            ExAcquireFastMutex(&lock);                      \
  435. +            ExAcquireFastMutexUnsafe(&lock);                \
  436.              pEntry = (IsListEmpty(&(list).head)             \
  437.               ? NULL                                         \
  438.               : (nfs41_mount_entry *)                        \
  439.                 (CONTAINING_RECORD((list).head.Flink,        \
  440.                                    nfs41_mount_entry,        \
  441.                                    next)));                  \
  442. -            ExReleaseFastMutex(&lock);
  443. +            ExReleaseFastMutexUnsafe(&lock);
  444.  
  445.  
  446.  typedef struct _NFS41_NETROOT_EXTENSION {
  447. diff --git a/sys/nfs41sys_mount.c b/sys/nfs41sys_mount.c
  448. index 9fa2ccd..4ed1e1c 100644
  449. --- a/sys/nfs41sys_mount.c
  450. +++ b/sys/nfs41sys_mount.c
  451. @@ -954,7 +954,7 @@ NTSTATUS nfs41_CreateVNetRoot(
  452.  
  453.          status = STATUS_NFS_SHARE_NOT_MOUNTED;
  454.  
  455. -        ExAcquireFastMutex(&pNetRootContext->mountLock);
  456. +        ExAcquireFastMutexUnsafe(&pNetRootContext->mountLock);
  457.          pEntry = &pNetRootContext->mounts.head;
  458.          pEntry = pEntry->Flink;
  459.          while (pEntry != NULL) {
  460. @@ -1007,7 +1007,7 @@ NTSTATUS nfs41_CreateVNetRoot(
  461.              status = STATUS_SUCCESS;
  462.          }
  463.  #endif /* NFS41_DRIVER_SYSTEM_LUID_MOUNTS_ARE_GLOBAL */
  464. -        ExReleaseFastMutex(&pNetRootContext->mountLock);
  465. +        ExReleaseFastMutexUnsafe(&pNetRootContext->mountLock);
  466.  
  467.          if (status != STATUS_SUCCESS) {
  468.              DbgP("No existing mount found, "
  469. @@ -1085,7 +1085,7 @@ NTSTATUS nfs41_CreateVNetRoot(
  470.      } else {
  471.          PLIST_ENTRY pEntry;
  472.  
  473. -        ExAcquireFastMutex(&pNetRootContext->mountLock);
  474. +        ExAcquireFastMutexUnsafe(&pNetRootContext->mountLock);
  475.          pEntry = &pNetRootContext->mounts.head;
  476.          pEntry = pEntry->Flink;
  477.          while (pEntry != NULL) {
  478. @@ -1135,7 +1135,7 @@ NTSTATUS nfs41_CreateVNetRoot(
  479.                  break;
  480.              pEntry = pEntry->Flink;
  481.          }
  482. -        ExReleaseFastMutex(&pNetRootContext->mountLock);
  483. +        ExReleaseFastMutexUnsafe(&pNetRootContext->mountLock);
  484.  #ifdef DEBUG_MOUNT
  485.          if (!found_matching_flavor)
  486.              DbgP("Didn't find matching security flavor\n");
  487. diff --git a/sys/nfs41sys_updowncall.c b/sys/nfs41sys_updowncall.c
  488. index deba9d6..cf5be35 100644
  489. --- a/sys/nfs41sys_updowncall.c
  490. +++ b/sys/nfs41sys_updowncall.c
  491. @@ -553,9 +553,9 @@ retry_wait:
  492.          }
  493.          /* fall-through */
  494.      default:
  495. -        ExAcquireFastMutex(&entry->lock);
  496. +        ExAcquireFastMutexUnsafe(&entry->lock);
  497.          if (entry->state == NFS41_DONE_PROCESSING) {
  498. -            ExReleaseFastMutex(&entry->lock);
  499. +            ExReleaseFastMutexUnsafe(&entry->lock);
  500.              break;
  501.          }
  502.          DbgP("[upcall] abandoning '%s' entry=0x%p xid=%lld\n",
  503. @@ -563,7 +563,7 @@ retry_wait:
  504.              entry,
  505.              (entry?entry->xid:-1LL));
  506.          entry->state = NFS41_NOT_WAITING;
  507. -        ExReleaseFastMutex(&entry->lock);
  508. +        ExReleaseFastMutexUnsafe(&entry->lock);
  509.          goto out;
  510.      }
  511.      nfs41_RemoveEntry(downcallLock, entry);
  512. @@ -581,6 +581,8 @@ NTSTATUS nfs41_upcall(
  513.      ULONG len = 0;
  514.      PLIST_ENTRY pEntry = NULL;
  515.  
  516. +    FsRtlEnterFileSystem();
  517. +
  518.  process_upcall:
  519.      nfs41_RemoveFirst(upcallLock, upcall, pEntry);
  520.      if (pEntry) {
  521. @@ -588,13 +590,13 @@ process_upcall:
  522.  
  523.          entry = (nfs41_updowncall_entry *)CONTAINING_RECORD(pEntry,
  524.                      nfs41_updowncall_entry, next);
  525. -        ExAcquireFastMutex(&entry->lock);
  526. +        ExAcquireFastMutexUnsafe(&entry->lock);
  527.          nfs41_AddEntry(downcallLock, downcall, entry);
  528.          status = handle_upcall(RxContext, entry, &len);
  529.          if (status == STATUS_SUCCESS &&
  530.                  entry->state == NFS41_WAITING_FOR_UPCALL)
  531.              entry->state = NFS41_WAITING_FOR_DOWNCALL;
  532. -        ExReleaseFastMutex(&entry->lock);
  533. +        ExReleaseFastMutexUnsafe(&entry->lock);
  534.          if (status) {
  535.              entry->status = status;
  536.              (void)KeSetEvent(&entry->cond, IO_NFS41FS_INCREMENT, FALSE);
  537. @@ -622,7 +624,10 @@ process_upcall:
  538.                  goto out;
  539.          }
  540.      }
  541. +
  542.  out:
  543. +    FsRtlExitFileSystem();
  544. +
  545.      return status;
  546.  }
  547.  
  548. @@ -639,6 +644,8 @@ NTSTATUS nfs41_downcall(
  549.      nfs41_updowncall_entry *tmp, *cur= NULL;
  550.      BOOLEAN found = 0;
  551.  
  552. +    FsRtlEnterFileSystem();
  553. +
  554.  #ifdef DEBUG_PRINT_DOWNCALL_HEXBUF
  555.      print_hexbuf("downcall buffer", buf, in_len);
  556.  #endif /* DEBUG_PRINT_DOWNCALL_HEXBUF */
  557. @@ -657,7 +664,7 @@ NTSTATUS nfs41_downcall(
  558.  
  559.      unmarshal_nfs41_header(tmp, &buf);
  560.  
  561. -    ExAcquireFastMutex(&downcallLock);
  562. +    ExAcquireFastMutexUnsafe(&downcallLock);
  563.      pEntry = &downcall.head;
  564.      pEntry = pEntry->Flink;
  565.      while (pEntry != NULL) {
  566. @@ -671,7 +678,7 @@ NTSTATUS nfs41_downcall(
  567.              break;
  568.          pEntry = pEntry->Flink;
  569.      }
  570. -    ExReleaseFastMutex(&downcallLock);
  571. +    ExReleaseFastMutexUnsafe(&downcallLock);
  572.      SeStopImpersonatingClient();
  573.      if (!found) {
  574.          print_error("Didn't find xid=%lld entry\n", tmp->xid);
  575. @@ -679,7 +686,7 @@ NTSTATUS nfs41_downcall(
  576.          goto out_free;
  577.      }
  578.  
  579. -    ExAcquireFastMutex(&cur->lock);
  580. +    ExAcquireFastMutexUnsafe(&cur->lock);
  581.      if (cur->state == NFS41_NOT_WAITING) {
  582.          DbgP("[downcall] Nobody is waiting for this request!!!\n");
  583.          switch(cur->opcode) {
  584. @@ -719,7 +726,7 @@ NTSTATUS nfs41_downcall(
  585.              }
  586.              break;
  587.          }
  588. -        ExReleaseFastMutex(&cur->lock);
  589. +        ExReleaseFastMutexUnsafe(&cur->lock);
  590.          nfs41_RemoveEntry(downcallLock, cur);
  591.          nfs41_UpcallDestroy(cur);
  592.          status = STATUS_UNSUCCESSFUL;
  593. @@ -782,7 +789,7 @@ NTSTATUS nfs41_downcall(
  594.              break;
  595.          }
  596.      }
  597. -    ExReleaseFastMutex(&cur->lock);
  598. +    ExReleaseFastMutexUnsafe(&cur->lock);
  599.      if (cur->async_op) {
  600.          switch (cur->opcode) {
  601.              case NFS41_SYSOP_WRITE:
  602. @@ -819,5 +826,7 @@ out_free:
  603.  out:
  604.  #endif /* USE_STACK_FOR_DOWNCALL_UPDOWNCALLENTRY_MEM */
  605.  
  606. +    FsRtlExitFileSystem();
  607. +
  608.      return status;
  609.  }
  610. --
  611. 2.45.1
  612.  
  613. From d22f8522de9b6b33248d263be8cb3b6a65143b0e Mon Sep 17 00:00:00 2001
  614. From: Dan Shelton <dan.f.shelton@gmail.com>
  615. Date: Mon, 11 Aug 2025 12:24:12 +0200
  616. Subject: [PATCH 5/7] include,sys: Cleanup kernel module C preprocessor macros
  617.  for ReactOS/clang
  618.  
  619. Cleanup kernel module C preprocessor macros for ReactOS/clang.
  620.  
  621. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  622. ---
  623. include/nfs41_driver.h |  5 +++-
  624.  sys/nfs41sys_driver.h  | 54 ++++++++++++++++++++++++++----------------
  625.  2 files changed, 37 insertions(+), 22 deletions(-)
  626.  
  627. diff --git a/include/nfs41_driver.h b/include/nfs41_driver.h
  628. index 31dd4c8..bf956f4 100644
  629. --- a/include/nfs41_driver.h
  630. +++ b/include/nfs41_driver.h
  631. @@ -38,7 +38,10 @@
  632.  
  633.  // See "Defining I/O Control Codes" in WDK docs
  634.  #define _RDR_CTL_CODE(code, method) \
  635. -    CTL_CODE(FILE_DEVICE_NETWORK_REDIRECTOR, 0x800 | (code), method, FILE_ANY_ACCESS)
  636. +    CTL_CODE(FILE_DEVICE_NETWORK_REDIRECTOR, \
  637. +    (0x800 | (code)), \
  638. +    (method), \
  639. +    FILE_ANY_ACCESS)
  640.  
  641.  #define IOCTL_NFS41_START       _RDR_CTL_CODE(0, METHOD_BUFFERED)
  642.  #define IOCTL_NFS41_STOP        _RDR_CTL_CODE(1, METHOD_NEITHER)
  643. diff --git a/sys/nfs41sys_driver.h b/sys/nfs41sys_driver.h
  644. index a2d5ed6..b1db3f5 100644
  645. --- a/sys/nfs41sys_driver.h
  646. +++ b/sys/nfs41sys_driver.h
  647. @@ -354,41 +354,53 @@ typedef struct _nfs41_mount_list {
  648.  } nfs41_mount_list;
  649.  
  650.  #define nfs41_AddEntry(lock,list,pEntry)                    \
  651. -            ExAcquireFastMutexUnsafe(&lock);                \
  652. +            { \
  653. +            ExAcquireFastMutexUnsafe(&(lock));              \
  654.              InsertTailList(&(list).head, &(pEntry)->next);  \
  655. -            ExReleaseFastMutexUnsafe(&lock);
  656. +            ExReleaseFastMutexUnsafe(&(lock));              \
  657. +            }
  658.  #define nfs41_RemoveFirst(lock,list,pEntry)                 \
  659. -            ExAcquireFastMutexUnsafe(&lock);                \
  660. -            pEntry = (IsListEmpty(&(list).head)             \
  661. +            { \
  662. +            ExAcquireFastMutexUnsafe(&(lock));              \
  663. +            (pEntry) = (IsListEmpty(&(list).head)           \
  664.              ? NULL                                          \
  665.              : RemoveHeadList(&(list).head));                \
  666. -            ExReleaseFastMutexUnsafe(&lock);
  667. +            ExReleaseFastMutexUnsafe(&(lock));              \
  668. +            }
  669.  #define nfs41_RemoveEntry(lock,pEntry)                      \
  670. -            ExAcquireFastMutexUnsafe(&lock);                \
  671. -            RemoveEntryList(&pEntry->next);                 \
  672. -            ExReleaseFastMutexUnsafe(&lock);
  673. +            { \
  674. +            ExAcquireFastMutexUnsafe(&(lock));              \
  675. +            RemoveEntryList(&(pEntry)->next);               \
  676. +            ExReleaseFastMutexUnsafe(&(lock));              \
  677. +            }
  678.  #define nfs41_IsListEmpty(lock,list,flag)                   \
  679. -            ExAcquireFastMutexUnsafe(&lock);                \
  680. -            flag = IsListEmpty(&(list).head);               \
  681. -            ExReleaseFastMutexUnsafe(&lock);
  682. +            { \
  683. +            ExAcquireFastMutexUnsafe(&(lock));              \
  684. +            (flag) = IsListEmpty(&(list).head);             \
  685. +            ExReleaseFastMutexUnsafe(&(lock));              \
  686. +            }
  687.  #define nfs41_GetFirstEntry(lock,list,pEntry)               \
  688. -            ExAcquireFastMutexUnsafe(&lock);                \
  689. -            pEntry = (IsListEmpty(&(list).head)             \
  690. +            { \
  691. +            ExAcquireFastMutexUnsafe(&(lock));              \
  692. +            (pEntry) = (IsListEmpty(&(list).head)           \
  693.               ? NULL                                         \
  694.               : (nfs41_updowncall_entry *)                   \
  695.                 (CONTAINING_RECORD((list).head.Flink,        \
  696.                                    nfs41_updowncall_entry,   \
  697.                                    next)));                  \
  698. -            ExReleaseFastMutexUnsafe(&lock);
  699. +            ExReleaseFastMutexUnsafe(&(lock));              \
  700. +            }
  701.  #define nfs41_GetFirstMountEntry(lock,list,pEntry)          \
  702. -            ExAcquireFastMutexUnsafe(&lock);                \
  703. -            pEntry = (IsListEmpty(&(list).head)             \
  704. +            { \
  705. +            ExAcquireFastMutexUnsafe(&(lock));              \
  706. +            (pEntry) = (IsListEmpty(&(list).head)           \
  707.               ? NULL                                         \
  708.               : (nfs41_mount_entry *)                        \
  709.                 (CONTAINING_RECORD((list).head.Flink,        \
  710.                                    nfs41_mount_entry,        \
  711.                                    next)));                  \
  712. -            ExReleaseFastMutexUnsafe(&lock);
  713. +            ExReleaseFastMutexUnsafe(&(lock));              \
  714. +            }
  715.  
  716.  
  717.  typedef struct _NFS41_NETROOT_EXTENSION {
  718. @@ -477,8 +489,8 @@ typedef struct _NFS41_DEVICE_EXTENSION {
  719.  } NFS41_DEVICE_EXTENSION, *PNFS41_DEVICE_EXTENSION;
  720.  
  721.  #define NFS41GetDeviceExtension(RxContext,pExt)        \
  722. -        PNFS41_DEVICE_EXTENSION pExt = (PNFS41_DEVICE_EXTENSION) \
  723. -        ((PBYTE)(RxContext->RxDeviceObject) + sizeof(RDBSS_DEVICE_OBJECT))
  724. +        PNFS41_DEVICE_EXTENSION (pExt) = (PNFS41_DEVICE_EXTENSION) \
  725. +        ((PBYTE)((RxContext)->RxDeviceObject) + sizeof(RDBSS_DEVICE_OBJECT))
  726.  
  727.  typedef struct _nfs41_fcb_list_entry {
  728.      LIST_ENTRY next;
  729. @@ -498,8 +510,8 @@ typedef enum _NULMRX_STORAGE_TYPE_CODES {
  730.      NTC_NFS41_DEVICE_EXTENSION      =   (NODE_TYPE_CODE)0xFC00,
  731.  } NFS41_STORAGE_TYPE_CODES;
  732.  #define RxDefineNode( node, type )          \
  733. -        node->NodeTypeCode = NTC_##type;    \
  734. -        node->NodeByteSize = sizeof(type);
  735. +        (node)->NodeTypeCode = NTC_##type;  \
  736. +        (node)->NodeByteSize = sizeof(type);
  737.  
  738.  #define RDR_NULL_STATE  0
  739.  #define RDR_UNLOADED    1
  740. --
  741. 2.45.1
  742.  
  743. From 9b32fbd7dec343051d6bcbf54506aa2ce90d438b Mon Sep 17 00:00:00 2001
  744. From: Dan Shelton <dan.f.shelton@gmail.com>
  745. Date: Mon, 11 Aug 2025 13:12:21 +0200
  746. Subject: [PATCH 6/7] daemon: Add {...} brackets to debug macros
  747.  
  748. Add {...} brackets to debug macros to avoid confusion in nested
  749. if()/else statements.
  750.  
  751. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  752. ---
  753. daemon/daemon_debug.h | 88 ++++++++++++++++++++++++-------------------
  754.  1 file changed, 49 insertions(+), 39 deletions(-)
  755.  
  756. diff --git a/daemon/daemon_debug.h b/daemon/daemon_debug.h
  757. index 16e450b..896481b 100644
  758. --- a/daemon/daemon_debug.h
  759. +++ b/daemon/daemon_debug.h
  760. @@ -56,55 +56,65 @@
  761.  #endif /* _WIN64 */
  762.  
  763.  #define EASSERT(exp) \
  764. -    if (!(exp)) { \
  765. -        DWORD d_saved_lasterr = GetLastError(); \
  766. -        eprintf("ASSERTION '%s' in '%s'/%ld failed.\n", \
  767. -            ""#exp"", __FILE__, (long)__LINE__); \
  768. -        SetLastError(d_saved_lasterr); \
  769. +    { \
  770. +        if (!(exp)) { \
  771. +            DWORD d_saved_lasterr = GetLastError(); \
  772. +            eprintf("ASSERTION '%s' in '%s'/%ld failed.\n", \
  773. +                ""#exp"", __FILE__, (long)__LINE__); \
  774. +            SetLastError(d_saved_lasterr); \
  775. +        } \
  776.      }
  777.  #define EASSERT_MSG(exp, msg) \
  778. -    if (!(exp)) { \
  779. -        DWORD d_saved_lasterr = GetLastError(); \
  780. -        eprintf("ASSERTION '%s' in '%s'/%ld failed, msg=", \
  781. -            ""#exp"", __FILE__, (long)__LINE__); \
  782. -        eprintf_out msg ; \
  783. -        SetLastError(d_saved_lasterr); \
  784. +    { \
  785. +        if (!(exp)) { \
  786. +            DWORD d_saved_lasterr = GetLastError(); \
  787. +            eprintf("ASSERTION '%s' in '%s'/%ld failed, msg=", \
  788. +                ""#exp"", __FILE__, (long)__LINE__); \
  789. +            eprintf_out msg ; \
  790. +            SetLastError(d_saved_lasterr); \
  791. +        } \
  792.      }
  793.  #define DASSERT(exp, level) \
  794. -    if (!(exp) && DPRINTF_LEVEL_ENABLED(level)) { \
  795. -        DWORD d_saved_lasterr = GetLastError(); \
  796. -        dprintf_out("ASSERTION '%s' in '%s'/%ld failed.\n", \
  797. -            ""#exp"", __FILE__, (long)__LINE__); \
  798. -        SetLastError(d_saved_lasterr); \
  799. +    { \
  800. +        if ((!(exp)) && DPRINTF_LEVEL_ENABLED(level)) { \
  801. +            DWORD d_saved_lasterr = GetLastError(); \
  802. +            dprintf_out("ASSERTION '%s' in '%s'/%ld failed.\n", \
  803. +                ""#exp"", __FILE__, (long)__LINE__); \
  804. +            SetLastError(d_saved_lasterr); \
  805. +        } \
  806.      }
  807.  #define DASSERT_MSG(exp, level, msg) \
  808. -    if (!(exp) && DPRINTF_LEVEL_ENABLED(level)) { \
  809. -        DWORD d_saved_lasterr = GetLastError(); \
  810. -        dprintf_out("ASSERTION '%s' in '%s'/%ld failed, msg=", \
  811. -            ""#exp"", __FILE__, (long)__LINE__); \
  812. -        dprintf_out msg ; \
  813. -        SetLastError(d_saved_lasterr); \
  814. +    { \
  815. +        if (!(exp) && DPRINTF_LEVEL_ENABLED(level)) { \
  816. +            DWORD d_saved_lasterr = GetLastError(); \
  817. +            dprintf_out("ASSERTION '%s' in '%s'/%ld failed, msg=", \
  818. +                ""#exp"", __FILE__, (long)__LINE__); \
  819. +            dprintf_out msg ; \
  820. +            SetLastError(d_saved_lasterr); \
  821. +        } \
  822.      }
  823. -
  824.  #define DASSERT_IS_VALID_NON_NULL_PTR(exp, level) \
  825. -    if (!DEBUG_IS_VALID_NON_NULL_PTR(exp) && \
  826. -        DPRINTF_LEVEL_ENABLED(level)) { \
  827. -        DWORD d_saved_lasterr = GetLastError(); \
  828. -        dprintf_out("ASSERTION " \
  829. -            "!DEBUG_IS_VALID_NON_NULL_PTR('%s'=0x%p) " \
  830. -            "in '%s'/%ld failed.\n", \
  831. -            ""#exp"", (void *)(exp), __FILE__, (long)__LINE__); \
  832. -        SetLastError(d_saved_lasterr); \
  833. +    { \
  834. +        if (!DEBUG_IS_VALID_NON_NULL_PTR(exp) && \
  835. +            DPRINTF_LEVEL_ENABLED(level)) { \
  836. +            DWORD d_saved_lasterr = GetLastError(); \
  837. +            dprintf_out("ASSERTION " \
  838. +                "!DEBUG_IS_VALID_NON_NULL_PTR('%s'=0x%p) " \
  839. +                "in '%s'/%ld failed.\n", \
  840. +                ""#exp"", (void *)(exp), __FILE__, (long)__LINE__); \
  841. +            SetLastError(d_saved_lasterr); \
  842. +        } \
  843.      }
  844. -
  845.  #define EASSERT_IS_VALID_NON_NULL_PTR(exp) \
  846. -    if (!DEBUG_IS_VALID_NON_NULL_PTR(exp)) { \
  847. -        DWORD d_saved_lasterr = GetLastError(); \
  848. -        eprintf("ASSERTION " \
  849. -            "!DEBUG_IS_VALID_NON_NULL_PTR('%s'=0x%p) " \
  850. -            "in '%s'/%ld failed.\n", \
  851. -            ""#exp"", (void *)(exp), __FILE__, (long)__LINE__); \
  852. -        SetLastError(d_saved_lasterr); \
  853. +    { \
  854. +        if (!DEBUG_IS_VALID_NON_NULL_PTR(exp)) { \
  855. +            DWORD d_saved_lasterr = GetLastError(); \
  856. +            eprintf("ASSERTION " \
  857. +                "!DEBUG_IS_VALID_NON_NULL_PTR('%s'=0x%p) " \
  858. +                "in '%s'/%ld failed.\n", \
  859. +                ""#exp"", (void *)(exp), __FILE__, (long)__LINE__); \
  860. +            SetLastError(d_saved_lasterr); \
  861. +        } \
  862.      }
  863.  
  864.  extern int g_debug_level;
  865. --
  866. 2.45.1
  867.  
  868. From 9afa46207675fcbfb7a68b93de5e08f365bd6bd5 Mon Sep 17 00:00:00 2001
  869. From: Dan Shelton <dan.f.shelton@gmail.com>
  870. Date: Mon, 11 Aug 2025 15:47:38 +0200
  871. Subject: [PATCH 7/7] sys: Cleanup NFS41GetDeviceExtension() macro
  872.  
  873. Cleanup NFS41GetDeviceExtension() macro.
  874.  
  875. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  876. ---
  877. sys/nfs41sys_driver.c |  9 ++++++---
  878.  sys/nfs41sys_driver.h |  6 +++---
  879.  sys/nfs41sys_mount.c  | 14 ++++++++------
  880.  3 files changed, 17 insertions(+), 12 deletions(-)
  881.  
  882. diff --git a/sys/nfs41sys_driver.c b/sys/nfs41sys_driver.c
  883. index bfde496..c312ce2 100644
  884. --- a/sys/nfs41sys_driver.c
  885. +++ b/sys/nfs41sys_driver.c
  886. @@ -387,7 +387,8 @@ NTSTATUS nfs41_Start(
  887.      IN OUT PRDBSS_DEVICE_OBJECT dev)
  888.  {
  889.      NTSTATUS status;
  890. -    NFS41GetDeviceExtension(RxContext, DevExt);
  891. +    PNFS41_DEVICE_EXTENSION DevExt =
  892. +        NFS41GetDeviceExtension(RxContext->RxDeviceObject);
  893.  
  894.      DbgEn();
  895.  
  896. @@ -411,7 +412,8 @@ NTSTATUS nfs41_Stop(
  897.      IN OUT PRDBSS_DEVICE_OBJECT dev)
  898.  {
  899.      NTSTATUS status;
  900. -    NFS41GetDeviceExtension(RxContext, DevExt);
  901. +    PNFS41_DEVICE_EXTENSION DevExt =
  902. +        NFS41GetDeviceExtension(RxContext->RxDeviceObject);
  903.      DbgEn();
  904.      status = SharedMemoryFree(DevExt->SharedMemorySection);
  905.      DbgEx();
  906. @@ -444,7 +446,8 @@ NTSTATUS nfs41_DevFcbXXXControlFile(
  907.      ULONG fsop = io_ctx->ParamsFor.FsCtl.FsControlCode, state;
  908.      ULONG in_len = io_ctx->ParamsFor.IoCtl.InputBufferLength;
  909.      DWORD *buf = io_ctx->ParamsFor.IoCtl.pInputBuffer;
  910. -    NFS41GetDeviceExtension(RxContext, DevExt);
  911. +    PNFS41_DEVICE_EXTENSION DevExt =
  912. +        NFS41GetDeviceExtension(RxContext->RxDeviceObject);
  913.      DWORD nfs41d_version = 0;
  914.  
  915.      //DbgEn();
  916. diff --git a/sys/nfs41sys_driver.h b/sys/nfs41sys_driver.h
  917. index b1db3f5..6c6db57 100644
  918. --- a/sys/nfs41sys_driver.h
  919. +++ b/sys/nfs41sys_driver.h
  920. @@ -488,9 +488,9 @@ typedef struct _NFS41_DEVICE_EXTENSION {
  921.      HANDLE                  openlistHandle;
  922.  } NFS41_DEVICE_EXTENSION, *PNFS41_DEVICE_EXTENSION;
  923.  
  924. -#define NFS41GetDeviceExtension(RxContext,pExt)        \
  925. -        PNFS41_DEVICE_EXTENSION (pExt) = (PNFS41_DEVICE_EXTENSION) \
  926. -        ((PBYTE)((RxContext)->RxDeviceObject) + sizeof(RDBSS_DEVICE_OBJECT))
  927. +#define NFS41GetDeviceExtension(DeviceObject)        \
  928. +    ((PNFS41_DEVICE_EXTENSION) \
  929. +        (((PBYTE)(DeviceObject)) + sizeof(RDBSS_DEVICE_OBJECT)))
  930.  
  931.  typedef struct _nfs41_fcb_list_entry {
  932.      LIST_ENTRY next;
  933. diff --git a/sys/nfs41sys_mount.c b/sys/nfs41sys_mount.c
  934. index 4ed1e1c..a1e7f61 100644
  935. --- a/sys/nfs41sys_mount.c
  936. +++ b/sys/nfs41sys_mount.c
  937. @@ -819,7 +819,9 @@ NTSTATUS nfs41_CreateVNetRoot(
  938.          NFS41GetVNetRootExtension(pVNetRoot);
  939.      __notnull PNFS41_NETROOT_EXTENSION pNetRootContext =
  940.          NFS41GetNetRootExtension(pNetRoot);
  941. -    NFS41GetDeviceExtension(pCreateNetRootContext->RxContext,DevExt);
  942. +    PRX_CONTEXT RxContext = pCreateNetRootContext->RxContext;
  943. +    PNFS41_DEVICE_EXTENSION DevExt =
  944. +        NFS41GetDeviceExtension(RxContext->RxDeviceObject);
  945.      DWORD nfs41d_version = DevExt->nfs41d_version;
  946.      nfs41_mount_entry *existing_mount = NULL;
  947.      LUID luid;
  948. @@ -875,17 +877,17 @@ NTSTATUS nfs41_CreateVNetRoot(
  949.      }
  950.      nfs41_MountConfig_InitDefaults(Config);
  951.  
  952. -    if (pCreateNetRootContext->RxContext->Create.EaLength) {
  953. +    if (RxContext->Create.EaLength) {
  954.          /* Codepath for nfs_mount.exe */
  955.          DbgP("Codepath for nfs_mount.exe, "
  956.              "Create->{ EaBuffer=0x%p, EaLength=%ld }\n",
  957. -            pCreateNetRootContext->RxContext->Create.EaBuffer,
  958. -            (long)pCreateNetRootContext->RxContext->Create.EaLength);
  959. +            RxContext->Create.EaBuffer,
  960. +            (long)RxContext->Create.EaLength);
  961.  
  962.          /* parse the extended attributes for mount options */
  963.          status = nfs41_MountConfig_ParseOptions(
  964. -            pCreateNetRootContext->RxContext->Create.EaBuffer,
  965. -            pCreateNetRootContext->RxContext->Create.EaLength,
  966. +            RxContext->Create.EaBuffer,
  967. +            RxContext->Create.EaLength,
  968.              Config);
  969.          if (status != STATUS_SUCCESS) {
  970.              DbgP("nfs41_MountConfig_ParseOptions() failed\n");
  971. --
  972. 2.45.1

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

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




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