pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS


msnfs41client: Patches for handling READ_PLUS not supported, FreeBSD support, misc, 2025-08-22
Posted by Anonymous on Fri 22nd Aug 2025 16:08
raw | new post

  1. From 96a82c801ddfe4657a12f62fb10edddb97d8b732 Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Fri, 22 Aug 2025 15:17:58 +0200
  4. Subject: [PATCH 1/3] sys:
  5.  |FSCTL_DUPLICATE_EXTENTS_TO_FILE|+|FSCTL_OFFLOAD_READ| should reject dirs
  6.  early
  7.  
  8. |FSCTL_DUPLICATE_EXTENTS_TO_FILE|+|FSCTL_OFFLOAD_READ| should reject
  9. directories early. The NFS layer will reject them anyway, but it is
  10. faster to do that early in the kernel.
  11.  
  12. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  13. ---
  14. sys/nfs41sys_fileinfo.c |  1 +
  15.  sys/nfs41sys_fsctl.c    | 23 +++++++++++++++++++++++
  16.  2 files changed, 24 insertions(+)
  17.  
  18. diff --git a/sys/nfs41sys_fileinfo.c b/sys/nfs41sys_fileinfo.c
  19. index cea57ad..90f14e5 100644
  20. --- a/sys/nfs41sys_fileinfo.c
  21. +++ b/sys/nfs41sys_fileinfo.c
  22. @@ -520,6 +520,7 @@ NTSTATUS map_setfile_error(
  23.      case ERROR_FILE_NOT_FOUND:          return STATUS_OBJECT_NAME_NOT_FOUND;
  24.      case ERROR_PATH_NOT_FOUND:          return STATUS_OBJECT_PATH_NOT_FOUND;
  25.      case ERROR_ACCESS_DENIED:           return STATUS_ACCESS_DENIED;
  26. +    case ERROR_DIRECTORY_NOT_SUPPORTED: return STATUS_FILE_IS_A_DIRECTORY;
  27.      case ERROR_FILE_INVALID:            return STATUS_FILE_INVALID;
  28.      case ERROR_NOT_SAME_DEVICE:         return STATUS_NOT_SAME_DEVICE;
  29.      case ERROR_NOT_SUPPORTED:           return STATUS_NOT_IMPLEMENTED;
  30. diff --git a/sys/nfs41sys_fsctl.c b/sys/nfs41sys_fsctl.c
  31. index 0d7da28..275bc22 100644
  32. --- a/sys/nfs41sys_fsctl.c
  33. +++ b/sys/nfs41sys_fsctl.c
  34. @@ -586,6 +586,7 @@ NTSTATUS check_nfs41_duplicatedata_args(
  35.      __notnull PMRX_SRV_OPEN SrvOpen = RxContext->pRelevantSrvOpen;
  36.      __notnull PNFS41_V_NET_ROOT_EXTENSION VNetRootContext =
  37.          NFS41GetVNetRootExtension(SrvOpen->pVNetRoot);
  38. +    __notnull PNFS41_FCB nfs41_fcb = NFS41GetFcbExtension(RxContext->pFcb);
  39.  
  40.      /* access checks */
  41.      if (VNetRootContext->read_only) {
  42. @@ -597,6 +598,11 @@ NTSTATUS check_nfs41_duplicatedata_args(
  43.          status = STATUS_ACCESS_DENIED;
  44.          goto out;
  45.      }
  46. +
  47. +    if (nfs41_fcb->StandardInfo.Directory) {
  48. +        status = STATUS_FILE_IS_A_DIRECTORY;
  49. +        goto out;
  50. +    }
  51.  out:
  52.      return status;
  53.  }
  54. @@ -742,6 +748,12 @@ NTSTATUS nfs41_DuplicateData(
  55.          goto out;
  56.      }
  57.  
  58. +    if (nfs41_src_fcb->StandardInfo.Directory) {
  59. +        DbgP("nfs41_DuplicateData: src is a dir\n");
  60. +        status = STATUS_FILE_IS_A_DIRECTORY;
  61. +        goto out;
  62. +    }
  63. +
  64.      /*
  65.       * Disable caching because NFSv4.2 DEALLOCATE is basically a
  66.       * "write" operation. AFAIK we should flush the cache and wait
  67. @@ -991,6 +1003,7 @@ NTSTATUS nfs41_OffloadRead(
  68.      NTSTATUS status = STATUS_INVALID_DEVICE_REQUEST;
  69.      __notnull XXCTL_LOWIO_COMPONENT *FsCtl =
  70.          &RxContext->LowIoContext.ParamsFor.FsCtl;
  71. +    __notnull PNFS41_FCB nfs41_fcb = NFS41GetFcbExtension(RxContext->pFcb);
  72.      __notnull PNFS41_FOBX nfs41_fobx = NFS41GetFobxExtension(RxContext->pFobx);
  73.  
  74.      DbgEn();
  75. @@ -1020,6 +1033,11 @@ NTSTATUS nfs41_OffloadRead(
  76.          goto out;
  77.      }
  78.  
  79. +    if (nfs41_fcb->StandardInfo.Directory) {
  80. +        status = STATUS_FILE_IS_A_DIRECTORY;
  81. +        goto out;
  82. +    }
  83. +
  84.      PFSCTL_OFFLOAD_READ_INPUT ori =
  85.          (PFSCTL_OFFLOAD_READ_INPUT)FsCtl->pInputBuffer;
  86.      PFSCTL_OFFLOAD_READ_OUTPUT oro =
  87. @@ -1084,6 +1102,7 @@ NTSTATUS check_nfs41_offload_write_args(
  88.      __notnull PMRX_SRV_OPEN SrvOpen = RxContext->pRelevantSrvOpen;
  89.      __notnull PNFS41_V_NET_ROOT_EXTENSION VNetRootContext =
  90.          NFS41GetVNetRootExtension(SrvOpen->pVNetRoot);
  91. +    __notnull PNFS41_FCB nfs41_fcb = NFS41GetFcbExtension(RxContext->pFcb);
  92.  
  93.      /* access checks */
  94.      if (VNetRootContext->read_only) {
  95. @@ -1096,6 +1115,10 @@ NTSTATUS check_nfs41_offload_write_args(
  96.          goto out;
  97.      }
  98.  
  99. +    if (nfs41_fcb->StandardInfo.Directory) {
  100. +        status = STATUS_FILE_IS_A_DIRECTORY;
  101. +        goto out;
  102. +    }
  103.  out:
  104.      return status;
  105.  }
  106. --
  107. 2.45.1
  108.  
  109. From edc8a2eb753364001e7c15ed5bb9763b03e9e842 Mon Sep 17 00:00:00 2001
  110. From: Roland Mainz <roland.mainz@nrubsig.org>
  111. Date: Fri, 22 Aug 2025 15:37:33 +0200
  112. Subject: [PATCH 2/3] daemon: |read_from_mds()| should handle READ_PLUS failing
  113.  with |NFS4ERR_NOTSUPP|
  114.  
  115. |read_from_mds()| should handle READ_PLUS failing with |NFS4ERR_NOTSUPP|,
  116. like FreeBSD 14.3 does.
  117.  
  118. Reported-by: Cedric Blancher <cedric.blancher@gmail.com>
  119. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  120. ---
  121. daemon/readwrite.c | 6 +++++-
  122.  1 file changed, 5 insertions(+), 1 deletion(-)
  123.  
  124. diff --git a/daemon/readwrite.c b/daemon/readwrite.c
  125. index d865c23..3c52049 100644
  126. --- a/daemon/readwrite.c
  127. +++ b/daemon/readwrite.c
  128. @@ -82,7 +82,11 @@ static int read_from_mds(
  129.              status = nfs42_read_plus(session, file, stateid,
  130.                  args->offset + reloffset, chunk,
  131.                  p, &bytes_read, &eof);
  132. -            if (status == NFS4ERR_IO) {
  133. +            /*
  134. +             * Linux returns |NFS4ERR_IO| if not supported, FreeBSD 14.3
  135. +             * returns |NFS4ERR_NOTSUPP| if not supported
  136. +             */
  137. +            if ((status == NFS4ERR_IO) || (status == NFS4ERR_NOTSUPP)) {
  138.                  DPRINTF(0,
  139.                      ("read_from_mds: "
  140.                      "nfs42_read_plus() failed, error '%s', "
  141. --
  142. 2.45.1
  143.  
  144. From 0479da9e5d8933248563b4601ad99c44a7dd8dc6 Mon Sep 17 00:00:00 2001
  145. From: Cedric Blancher <cedric.blancher@gmail.com>
  146. Date: Fri, 22 Aug 2025 15:43:10 +0200
  147. Subject: [PATCH 3/3] tests: Add FreeBSD NFSv4.2 server setup
  148.  
  149. Add FreeBSD NFSv4.2 server setup, tested with
  150. FreeBSD 14.3.
  151.  
  152. Signed-off-by: Roland Mainz <roland.mainz@nrubsig.org>
  153. ---
  154. tests/nfs_server_setup.txt | 41 ++++++++++++++++++++++++++++++++------
  155.  1 file changed, 35 insertions(+), 6 deletions(-)
  156.  
  157. diff --git a/tests/nfs_server_setup.txt b/tests/nfs_server_setup.txt
  158. index 0e7393f..2a5e7af 100644
  159. --- a/tests/nfs_server_setup.txt
  160. +++ b/tests/nfs_server_setup.txt
  161. @@ -2,12 +2,6 @@
  162.  # NFSv4.2/NFSv4.1 server setup for testing
  163.  #
  164.  
  165. -#
  166. -# TODO:
  167. -# - FreeBSD NFSv4.1 server setup
  168. -#
  169. -
  170. -
  171.  #
  172.  # Debian Linux "Bullseye" NFSv4.2 server setup
  173.  #
  174. @@ -179,4 +173,39 @@ chmod A... # to edit ACLs
  175.  See https://docs.oracle.com/en/operating-systems/solaris/oracle-solaris/11.4/manage-nfs/troubleshooting-network-file-systems1.html
  176.  
  177.  
  178. +#
  179. +# FreeBSD NFSv4.2 server setup
  180. +# (tested with FreeBSD 14.3)
  181. +#
  182. +
  183. +##### 1. Server setup
  184. +
  185. +# Install FreeBSD (14.3) with NTP enabled
  186. +
  187. +# configure NFSv4.2 server with idmapping enabled
  188. +sysrc rpcbind_enable="YES"
  189. +sysrc mountd_enable="YES"
  190. +sysrc nfs_server_enable=YES
  191. +sysrc nfsv4_server_enable=YES
  192. +sysrc nfsuserd_flags="-domain GLOBAL.LOC"
  193. +sysrc nfsuserd_enable=YES
  194. +sysrc nfscbd_enable=YES
  195. +sysctl vfs.nfs.enable_uidtostring=1
  196. +sysctl vfs.nfsd.enable_stringtouid=1
  197. +sysctl vfs.nfsd.issue_delegations=1
  198. +
  199. +mkdir /nfsdata
  200. +chmod a+rwxt /nfsdata
  201. +
  202. +# NFSv4.1 exports must come after the 'V4: /' line,
  203. +# otherwise you get a NFS4ERR_NOFILEHANDLE
  204. +printf 'V4: /\n' >'/etc/exports'
  205. +printf '/nfsdata -network=10.49.202.0 -mask=255.255.255.0  -sec=sys\n' >>'/etc/exports'
  206. +service nfsd start
  207. +
  208. +##### 2. Misc commands:
  209. +pw groupadd group -n None -g 197121
  210. +pw groupadd group -n ced -g 197608
  211. +pw useradd -n ced -u 197608 -g None -G None,ced -m -s /bin/sh
  212. +
  213.  # EOF.
  214. --
  215. 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