- From 96a82c801ddfe4657a12f62fb10edddb97d8b732 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Fri, 22 Aug 2025 15:17:58 +0200
- Subject: [PATCH 1/3] sys:
- |FSCTL_DUPLICATE_EXTENTS_TO_FILE|+|FSCTL_OFFLOAD_READ| should reject dirs
- early
- |FSCTL_DUPLICATE_EXTENTS_TO_FILE|+|FSCTL_OFFLOAD_READ| should reject
- directories early. The NFS layer will reject them anyway, but it is
- faster to do that early in the kernel.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- sys/nfs41sys_fileinfo.c | 1 +
- sys/nfs41sys_fsctl.c | 23 +++++++++++++++++++++++
- 2 files changed, 24 insertions(+)
- diff --git a/sys/nfs41sys_fileinfo.c b/sys/nfs41sys_fileinfo.c
- index cea57ad..90f14e5 100644
- --- a/sys/nfs41sys_fileinfo.c
- +++ b/sys/nfs41sys_fileinfo.c
- @@ -520,6 +520,7 @@ NTSTATUS map_setfile_error(
- case ERROR_FILE_NOT_FOUND: return STATUS_OBJECT_NAME_NOT_FOUND;
- case ERROR_PATH_NOT_FOUND: return STATUS_OBJECT_PATH_NOT_FOUND;
- case ERROR_ACCESS_DENIED: return STATUS_ACCESS_DENIED;
- + case ERROR_DIRECTORY_NOT_SUPPORTED: return STATUS_FILE_IS_A_DIRECTORY;
- case ERROR_FILE_INVALID: return STATUS_FILE_INVALID;
- case ERROR_NOT_SAME_DEVICE: return STATUS_NOT_SAME_DEVICE;
- case ERROR_NOT_SUPPORTED: return STATUS_NOT_IMPLEMENTED;
- diff --git a/sys/nfs41sys_fsctl.c b/sys/nfs41sys_fsctl.c
- index 0d7da28..275bc22 100644
- --- a/sys/nfs41sys_fsctl.c
- +++ b/sys/nfs41sys_fsctl.c
- @@ -586,6 +586,7 @@ NTSTATUS check_nfs41_duplicatedata_args(
- __notnull PMRX_SRV_OPEN SrvOpen = RxContext->pRelevantSrvOpen;
- __notnull PNFS41_V_NET_ROOT_EXTENSION VNetRootContext =
- NFS41GetVNetRootExtension(SrvOpen->pVNetRoot);
- + __notnull PNFS41_FCB nfs41_fcb = NFS41GetFcbExtension(RxContext->pFcb);
- /* access checks */
- if (VNetRootContext->read_only) {
- @@ -597,6 +598,11 @@ NTSTATUS check_nfs41_duplicatedata_args(
- status = STATUS_ACCESS_DENIED;
- goto out;
- }
- +
- + if (nfs41_fcb->StandardInfo.Directory) {
- + status = STATUS_FILE_IS_A_DIRECTORY;
- + goto out;
- + }
- out:
- return status;
- }
- @@ -742,6 +748,12 @@ NTSTATUS nfs41_DuplicateData(
- goto out;
- }
- + if (nfs41_src_fcb->StandardInfo.Directory) {
- + DbgP("nfs41_DuplicateData: src is a dir\n");
- + status = STATUS_FILE_IS_A_DIRECTORY;
- + goto out;
- + }
- +
- /*
- * Disable caching because NFSv4.2 DEALLOCATE is basically a
- * "write" operation. AFAIK we should flush the cache and wait
- @@ -991,6 +1003,7 @@ NTSTATUS nfs41_OffloadRead(
- NTSTATUS status = STATUS_INVALID_DEVICE_REQUEST;
- __notnull XXCTL_LOWIO_COMPONENT *FsCtl =
- &RxContext->LowIoContext.ParamsFor.FsCtl;
- + __notnull PNFS41_FCB nfs41_fcb = NFS41GetFcbExtension(RxContext->pFcb);
- __notnull PNFS41_FOBX nfs41_fobx = NFS41GetFobxExtension(RxContext->pFobx);
- DbgEn();
- @@ -1020,6 +1033,11 @@ NTSTATUS nfs41_OffloadRead(
- goto out;
- }
- + if (nfs41_fcb->StandardInfo.Directory) {
- + status = STATUS_FILE_IS_A_DIRECTORY;
- + goto out;
- + }
- +
- PFSCTL_OFFLOAD_READ_INPUT ori =
- (PFSCTL_OFFLOAD_READ_INPUT)FsCtl->pInputBuffer;
- PFSCTL_OFFLOAD_READ_OUTPUT oro =
- @@ -1084,6 +1102,7 @@ NTSTATUS check_nfs41_offload_write_args(
- __notnull PMRX_SRV_OPEN SrvOpen = RxContext->pRelevantSrvOpen;
- __notnull PNFS41_V_NET_ROOT_EXTENSION VNetRootContext =
- NFS41GetVNetRootExtension(SrvOpen->pVNetRoot);
- + __notnull PNFS41_FCB nfs41_fcb = NFS41GetFcbExtension(RxContext->pFcb);
- /* access checks */
- if (VNetRootContext->read_only) {
- @@ -1096,6 +1115,10 @@ NTSTATUS check_nfs41_offload_write_args(
- goto out;
- }
- + if (nfs41_fcb->StandardInfo.Directory) {
- + status = STATUS_FILE_IS_A_DIRECTORY;
- + goto out;
- + }
- out:
- return status;
- }
- --
- 2.45.1
- From edc8a2eb753364001e7c15ed5bb9763b03e9e842 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Fri, 22 Aug 2025 15:37:33 +0200
- Subject: [PATCH 2/3] daemon: |read_from_mds()| should handle READ_PLUS failing
- with |NFS4ERR_NOTSUPP|
- |read_from_mds()| should handle READ_PLUS failing with |NFS4ERR_NOTSUPP|,
- like FreeBSD 14.3 does.
- Reported-by: Cedric Blancher <cedric.blancher@gmail.com>
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/readwrite.c | 6 +++++-
- 1 file changed, 5 insertions(+), 1 deletion(-)
- diff --git a/daemon/readwrite.c b/daemon/readwrite.c
- index d865c23..3c52049 100644
- --- a/daemon/readwrite.c
- +++ b/daemon/readwrite.c
- @@ -82,7 +82,11 @@ static int read_from_mds(
- status = nfs42_read_plus(session, file, stateid,
- args->offset + reloffset, chunk,
- p, &bytes_read, &eof);
- - if (status == NFS4ERR_IO) {
- + /*
- + * Linux returns |NFS4ERR_IO| if not supported, FreeBSD 14.3
- + * returns |NFS4ERR_NOTSUPP| if not supported
- + */
- + if ((status == NFS4ERR_IO) || (status == NFS4ERR_NOTSUPP)) {
- DPRINTF(0,
- ("read_from_mds: "
- "nfs42_read_plus() failed, error '%s', "
- --
- 2.45.1
- From 0479da9e5d8933248563b4601ad99c44a7dd8dc6 Mon Sep 17 00:00:00 2001
- From: Cedric Blancher <cedric.blancher@gmail.com>
- Date: Fri, 22 Aug 2025 15:43:10 +0200
- Subject: [PATCH 3/3] tests: Add FreeBSD NFSv4.2 server setup
- Add FreeBSD NFSv4.2 server setup, tested with
- FreeBSD 14.3.
- Signed-off-by: Roland Mainz <roland.mainz@nrubsig.org>
- ---
- tests/nfs_server_setup.txt | 41 ++++++++++++++++++++++++++++++++------
- 1 file changed, 35 insertions(+), 6 deletions(-)
- diff --git a/tests/nfs_server_setup.txt b/tests/nfs_server_setup.txt
- index 0e7393f..2a5e7af 100644
- --- a/tests/nfs_server_setup.txt
- +++ b/tests/nfs_server_setup.txt
- @@ -2,12 +2,6 @@
- # NFSv4.2/NFSv4.1 server setup for testing
- #
- -#
- -# TODO:
- -# - FreeBSD NFSv4.1 server setup
- -#
- -
- -
- #
- # Debian Linux "Bullseye" NFSv4.2 server setup
- #
- @@ -179,4 +173,39 @@ chmod A... # to edit ACLs
- See https://docs.oracle.com/en/operating-systems/solaris/oracle-solaris/11.4/manage-nfs/troubleshooting-network-file-systems1.html
- +#
- +# FreeBSD NFSv4.2 server setup
- +# (tested with FreeBSD 14.3)
- +#
- +
- +##### 1. Server setup
- +
- +# Install FreeBSD (14.3) with NTP enabled
- +
- +# configure NFSv4.2 server with idmapping enabled
- +sysrc rpcbind_enable="YES"
- +sysrc mountd_enable="YES"
- +sysrc nfs_server_enable=YES
- +sysrc nfsv4_server_enable=YES
- +sysrc nfsuserd_flags="-domain GLOBAL.LOC"
- +sysrc nfsuserd_enable=YES
- +sysrc nfscbd_enable=YES
- +sysctl vfs.nfs.enable_uidtostring=1
- +sysctl vfs.nfsd.enable_stringtouid=1
- +sysctl vfs.nfsd.issue_delegations=1
- +
- +mkdir /nfsdata
- +chmod a+rwxt /nfsdata
- +
- +# NFSv4.1 exports must come after the 'V4: /' line,
- +# otherwise you get a NFS4ERR_NOFILEHANDLE
- +printf 'V4: /\n' >'/etc/exports'
- +printf '/nfsdata -network=10.49.202.0 -mask=255.255.255.0 -sec=sys\n' >>'/etc/exports'
- +service nfsd start
- +
- +##### 2. Misc commands:
- +pw groupadd group -n None -g 197121
- +pw groupadd group -n ced -g 197608
- +pw useradd -n ced -u 197608 -g None -G None,ced -m -s /bin/sh
- +
- # EOF.
- --
- 2.45.1
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
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.