100 Commits
Author SHA1 Message Date
Rick Macklem 5bf3e2a141 nfs_clvfsops.c: Set readahead to 15 for RDMA
MFC after:	1 month
Fixes:	884ee8d6c9 ("nfscl: Add some glue for client side NFS over RDMA")
2026-10-18 16:33:45 -07:00
Rick Macklem 02971f2000 clntrdma.h: Add some fields to RDMA structures (glue for nfsclrdma.ko)
This patch adds some fields to NFS client side RDMA
structures and an additional argument to xprt_rdma_release_send().
This patch does not fix any semantics issue.

MFC after:	3 months
Fixes:	884ee8d6c9 ("nfscl: Add some glue for client side NFS over RDMA")
2026-10-17 16:24:00 -07:00
Rick Macklem 81a6514689 clnt_vc.c: Fix handling of backchannel xprt
When clnt_vc_destroy() is called, it might not be the
current connection.  Without this patch, if it is not
the current connection, xp_p2 is set NULL and xprt is released
when it should not be released.

This patch adds a check for "current connection" to fix
the problem.  Found during testing to the client RDMA code,
but could happen for TCP as well.

MFC after:	1 week
2026-10-04 13:29:43 -07:00
Rick Macklem 2050abe804 rpc_generic.c: Initialize "cp" to shut the compiler up
This patch does not fix any semantics issue.

MFC after:	3 months
Fixes:	884ee8d6c9 ("nfscl: Add some glue for client side NFS over RDMA")
2026-10-03 18:54:39 -07:00
Rick Macklem c2089b654a nfscl: Add support for b_pages to be used by RDMA
This patch updates the NFS client RDMA glue so that I/O
can be done directly to/from b_pages for buffer cache
blocks.
It also adds a flag to disable read reduction, that might
be needed against some non-FreeBSD servers and sets readahead
to 8 for RDMA unless the "readahead" option has been
specified.

This commit should not affect non-RDMA behaviour.

MFC after:	3 months
Fixes:	884ee8d6c9 ("nfscl: Add some glue for client side NFS over RDMA")
2026-10-03 17:43:21 -07:00
Rick Macklem b87b15d43e clntrdma.h: Add a field to rpcrdma_xprt
Add a maxsegs field to rpcrdma_xprt, which is used to set
the number of segments allowed for a chunk based on device
attributes.

This commit should not affect non-RDMA behaviour.

MFC after:	3 months
Fixes:	884ee8d6c9 ("nfscl: Add some glue for client side NFS over RDMA")
2026-09-18 17:44:11 -07:00
Rick Macklem ef98d08040 clnt_bck.c: Fix the "glue" for the nfsrdma.ko module
Without this patch, the code failed to acquire the error
return for clnt_bck_rdma_send() and could use "error" uninitialized.

No semantics change for non-RDMA NFS service.

MFC after:	3 months
Fixes:	7144a1d58c ("nfsd: Add glue for the nfsrdma.ko module")
2026-09-18 17:39:27 -07:00
Rick Macklem 274b0d6b11 nfs_nfsdkrpc.c: Fix the "glue" for the nfsrdma.ko modules for NFSv3
Without this patch, nd_xprt is only set for NFSv4.1/4.2.
The nfsrdma.ko needs it to be set for all versions of NFS,
so this one line patch does that.

No semantics change for non-RDMA NFS service.

MFC after:	3 months
Fixes:	7144a1d58c ("nfsd: Add glue for the nfsrdma.ko module")
2026-09-14 16:55:32 -07:00
Rick Macklem 77535f91f6 nfscl: Yet more fixes for the NFS over RDMA client glue
Yet again.  I was trying to make the svc_vc_backchannel()
operations do double duty and be used by the clnt_rdma.c code
as well.  It got too messy, so this reverts svc_vc.c back to
its pre-glue form and adds the small changes needed to support
a separate set of svc_rdma_backchannel_xxx() functions.

This commit should not affect non-RDMA behaviour.

MFC after:	3 months
Fixes:	884ee8d6c9 ("nfscl: Add some glue for client side NFS over RDMA")
2026-09-13 17:12:46 -07:00
Rick Macklem 741cd29526 nfscl: Yet more fixes for the NFS over RDMA client glue
This should be it for a while, but there will be another cycle
of "glue" updates.  I just found out that I'll need to create
an alternate code path that uses a contigmalloc() blob instead
of scatter/gather of pages, since some NICs cannot do the
scatter/gather of pages well.

This commit should not affect non-RDMA behaviour.

MFC after:	3 months
Fixes:	884ee8d6c9 ("nfscl: Add some glue for client side NFS over RDMA")
2026-09-12 15:47:20 -07:00
Rick Macklem fb3875a38e nfsd: Add nfs_extern.h
Oops, forgot to add the new .h file.

MFC after:	3 months
Fixes:	407d717705 ("nfsd: Clean up the "glue" for the nfsrdma.ko module")
2026-09-06 13:51:37 -07:00
Rick Macklem 407d717705 nfsd: Clean up the "glue" for the nfsrdma.ko module
Move svc_reg() calls into a helper function so that the nfsrdma.ko
can call that.  Create a new nfs_extern.h as a place to put the
nfs stuff that server side NFS over RDMA needs to access, with a
prototype for the helper function and a couple of definitions that
probably shouldn't be in svc.h.

No semantics change.

MFC after:	3 months
Fixes:	7144a1d58c ("nfsd: Add glue for the nfsrdma.ko module")
2026-09-06 13:40:34 -07:00
Rick Macklem 799061fc76 nfscl: A few more fixes for the NFS over RDMA client glue
A couple of additional fixes for the NFS client side RDMA glue:
- For Readdirplus, the reply needs to be a large chunk, so set
  M_PROTO9 instead of M_PROTO8.
- The nfsclrdma.ko module now uses xprt_rdma_unmap_chunk()
  instead of xprt_rdma_rekey_chunk().

Hopefully, this is it for the NFS over RDMA client glue changes.

MFC after:	3 months
Fixes:	884ee8d6c9 ("nfscl: Add some glue for client side NFS over RDMA")
2026-09-02 19:20:26 -07:00
Rick Macklem cc352a850f nfs_clvfsops.c: Fix the non-VIMAGE build
The OFED code checks for a vnet argument, but it is
is not defined.

Reported by:	glebius
MFC after:	3 months
Fixes:	884ee8d6c9 ("nfscl: Add some glue for client side NFS over RDMA")
2026-09-01 10:33:08 -07:00
Rick Macklem f41d83578e nfsclient: Fix problems with the NFS over RDMA glue
There were a couple of problems detected w.r.t. the
"glue" for the nfsclrdma.ko module.
- When the NFS server has a small reply for a read,
  it can choose to not use the reduction chunk
  (separate memory area for the read data).  I did
  not realize this was the case.
- There was a bug in rpc_copy_uio_pages() function
  that caused intermittent crashes in memcpy().

This patch fixes the above cases.  It uses M_PROTO6
to mark that an RPC reply has used a reduction chunk,
so that read can handle it correctly.  Read also now
provides a reduction chunk for all read sizes, since
the worst case for the rest of the read RPC reply is
close to the 1024 byte limit.  (NFSv4 uses strings
instead of uid/gid in the attributes and these name
strings can be rather large.)

I wanted to get the "glue" into main so that others
could test the module more easily.  Avaliability of
the module will be announced on freebsd-current@ soon.

It should not affect non-RDMA operation.

I've specified a long MFC, since the module still
requires extensive testing and, hopefully, a review.

MFC after:	3 months
Fixes:	884ee8d6c9 ("nfscl: Add some glue for client side NFS over RDMA")
2026-09-01 07:05:20 -07:00
Rick Macklem 9bec8a959b RELNOTES: Add an entry for the NFS over RDMA "glue" commits 2026-08-30 19:00:45 -07:00
Rick Macklem d8d9f39df5 nfs_clvfsops.c: Silence a compiler warning
MFC after:	3 months
Fixes:	884ee8d6c9 ("nfscl: Add some glue for client side NFS over RDMA")
2026-08-30 17:56:13 -07:00
Rick Macklem 8ee0a615cb nfsclient: Add a new nfs_client_rdma_enable variable
This patch adds a new nfs_client_rdma_enable variable
to /etc/rc.d/nfsclient to enable the client side of
NFS over RDMA.  The client side of NFS over RDMA
requires the nfsclrdma.ko module, which is still under
test/review.

I wanted to get the "glue" into main so that others
could test the module more easily.  Avaliability of
the module will be announced on freebsd-current@ soon.

It should not affect non-RDMA operation.

I've specified a long MFC, since the module still
requires extensive testing and, hopefully, a review.

MFC after:	3 months
2026-08-30 15:11:08 -07:00
Rick Macklem 884ee8d6c9 nfscl: Add some glue for client side NFS over RDMA
This patch adds assorted bits needed by the nfsclrdma.ko
module that implements client side NFS over RDMA.
With this commit, the glue required by the nfsclrdma.ko
module is complete and it should load ok.

It should not affect non-RDMA operation.

I've specified a long MFC, since the module still
requires extensive testing and, hopefully, a review.

MFC after:	3 months
2026-08-30 15:00:27 -07:00
Rick Macklem a311bd18a6 krpc: Add some glue for client side NFS over RDMA
This patch adds assorted bits needed by the nfsclrdma.ko
module that implements client side NFS over RDMA.

It should not affect non-RDMA operation.

Some additional glue is needed for the nfsclrdma.ko
module within the NFS code.  That will be added as
a separate commit.

I've specified a long MFC, since the module still
requires extensive testing and, hopefully, a review.

MFC after:	3 months
2026-08-30 14:32:11 -07:00
Rick Macklem c54fbc9e83 chflags.1: Change dontcache to nocache
Commit 290e563166 changed the flag's name from dontcache
to nocache. This patch fixes the man page.

This is a content change.

Reviewed by:	kib (earlier version)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D58181
Fixes:	4830670a3f ("chflags.1: Document the new UF_DONTCACHE flag")
2026-08-26 15:19:26 -07:00
Rick Macklem 290e563166 chflags: Add a new UF_NOCACHE flag
This internet draft (which is close to being an RFC)
specifies a new NFSv4.2 attribute which tells the NFSv4.2
client to not cache file data. (Similar to O_DIRECT, but
triggered by this attribute set on the file on the NFSv4.2
server and not by the application's open(2).)

https://datatracker.ietf.org/doc/draft-ietf-nfsv4-uncacheable-files/

This patch adds a new chflags(1) flag called UF_NOCACHE to
implement this.

Patches for NFS and ZFS will be done separately.

This is a redo of the patch, with a requested name change
and a #ifdef in strtofflags.c so that it doesn't break some
Linux cross build.  The name change was requested by fuz@.

Reviewed by:	kib (earlier version)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D58181
2026-08-26 14:55:20 -07:00
Rick Macklem 471e14267b nfsd: Update the rc.d script for RDMA for the nfsd service
Commit 7144a1d58c added the hooks for the nfsrdma.ko module.
Once loaded, this module adds RDMA support to the nfsd.

This patch adds a few lines to /etc/rc.d/nfsd, so that
nfs_server_rdma_enable="YES"
in your /etc/rc.conf will load nfsrdma.ko, so that RDMA
service is enabled.
It also supports
nfs_server_rdma_listen="port#"
so that the default of 20490 can be overridden in /etc/rc.conf.

At this available as time, the nfsrdma.ko module is an unofficial port,
since it was developed by Vinicius Ferrao <[email protected]>
using generative AI.
As soon as it is available, it will be announced on
[email protected].

Suggested by:	Vinicius Ferrao <versatushpc.com.br>
MFC after:	1 month
2026-08-14 12:55:54 -07:00
Rick Macklem 7144a1d58c nfsd: Add glue for the nfsrdma.ko module
Thanks to Vinicius Ferrao <versatushpc.com.br>, there
is now a module that implements the server side of RDMA
for the FreeBSD NFS server.

At least for now, it will be maintained as an "unofficial
port" for FreeBSD, since it was built with generative AI
and FreeBSD is working on a policy related to these submissions.

This patch puts the "glue" needed by Vinicius's nfsrdma.ko
module in the system.  This "glue" was written by me without
the use of AI.

The "unofficial port" of nfsrdma.ko will be advertised on
freebsd-current@ as soon as it is available.
(Vinicius's work was sponsored by VersatupHPC.)

Since newnfs_numnfsd is now declared extern in nfs.h,
the extern declaration can be removed from assorted files.
I'll do that as a separate commit.

Suggested by:	Vinicius Ferrao <versatushpc.com.br>
MFC after:	1 month
2026-08-14 07:59:29 -07:00
Rick Macklem 8f20299b47 nfs_commonkrpc.c: Get rid of NFSv4.0 delegation cruft
Delegations in NFSv4.0 never worked well and, since
the NFSv4.0 protocol is now deprecated, use of delegations
for NFSv4.0 is disabled as far as the client can do so.

It turns out that some Illumos NFSv4.0 server issues
delegations anyhow (even when the callback path is
specified as 0.0.0.0) and this can cause use after free
problems.

This patch deleted some cruft that did an nfsrpc_openrpc()
call recursively when an NFSv4.0 server failed to issue
a delegation when it had previously done so.
This code was only meant to be an optimization and
would have been rarely exercised.  Since this recursive
call of nfsrpc_openrpc() is in some of the backtraces
in the bugzilla PR, getting rid of the cruft makes sense.

It is not known if this helps w.r.t. the use after free
problems at this time.

PR:	297233
MFC after:	3 days
2026-08-04 08:55:24 -07:00
Rick Macklem 5ab48fb9f7 nfs_commonkrpc.c: Fix recovery that was broken by 4d80d4913e
Commit 4d80d4913e added a check for nfsess_defunct already
being set.  This was incorrect because, once set, nfsess_defunct
remains set and an additional recovery might be needed.

This patch reverts this part of 4d80d4913e.

PR:	297252
Suggested by:	olivier
MFC after:	3 days
Fixes:	4d80d4913e ("nfs: Fix argument typo to avoid a crash")
2026-08-03 17:02:47 -07:00
Rick Macklem 575af5e2fa RELNOTES: Add an entry for pNFS server improvements
There are expected to be additional improvements and this RELNOTES
entry will be updated accordingly.
2026-07-27 18:52:01 -07:00
Rick Macklem 6901cbbd5a nfs_commonkrpc.c: Handle NFSERR_DELAY for Sequence correctly
Unlike RFC5661 (the original NFSv4.1 RFC), RFC8881 specifies
that a NFS4ERR_DELAY reply to the SEQUENCE operation requires
a reply using the same slot/sequence#.

This patch fixes handling of this case, so it conforms to
RFC8881.

Reported by:	J. David ([email protected])
Tested by:	J. David ([email protected])
MFC after:	1 week
2026-07-27 07:16:29 -07:00
Rick Macklem 88711f1441 Revert "chflags: Add a new UF_DONTCACHE flag"
This reverts commit 74654ba3b1.

Apparently it breaks cross building from Linux for some
reason.  I'll admit I didn't even know we supported cross
building from Linux.
2026-07-12 19:59:26 -07:00
Rick Macklem 4830670a3f chflags.1: Document the new UF_DONTCACHE flag
Commit 74654ba3b1 added and new chflags(1) flag called
"udontcache" or "dontcache".  This patch documents this flag.

This is a content change.

Reviewed by:	kib
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D58181
2026-07-12 15:56:52 -07:00
Rick Macklem 74654ba3b1 chflags: Add a new UF_DONTCACHE flag
This internet draft (which is close to being an RFC)
specifies a new NFSv4.2 attribute which tells the NFSv4.2
client to not cache file data. (Similar to O_DIRECT, but
triggered by this attribute set on the file on the NFSv4.2
server and not by the application's open(2).)

https://datatracker.ietf.org/doc/draft-ietf-nfsv4-uncacheable-files/

This patch adds a new chflags(1) flag called UF_DONTCACHE to
implement this.

Patches for NFS and ZFS will be done separately.

Reviewed by:	kib
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D58181
2026-07-12 15:45:28 -07:00
Rick Macklem 30d4d3db43 nfsd: Commit missing patches for c52bcd09c2
Oops, I missed the other files for the commit.

This should fix the build.

Pointy hat goes on me.

MFC after:	2 weeks
Fixes:	c52bcd09c2 ("nfsd: Garbage collect stray NFSv4 state")
2026-07-11 12:32:46 -07:00
Rick Macklem c52bcd09c2 nfsd: Garbage collect stray NFSv4 state
When a file is deleted on the NFS server by another client,
any NFSv4 state related to that file is left stranded.
This happens because the NFSv4 operations that free the
state use a CFH, which is set by a PutFH operation.
However, the PutFH fails with ESTALE because the file has
been deleted.

This patch adds a function called nfsrv_freestrandedstate()
that frees all the NFSv4 state related to a file and calls
this function when PutFH will be replying ESTALE.

While here, a helper function was defined to handle free'ng
of the nfslockfile structure and replaces the two places
where nearly identical code does this.

Reported by:	Richard Purdie <[email protected]>
Tested by:	Michael Halstead <[email protected]>
MFC after:	2 weeks
2026-07-11 08:49:12 -07:00
Rick Macklem d516e52373 nfsd: Optionally enable use of M_EXTPG mbufs for read replies
A test site determined that, for a Mellanox NIC which can handle
M_EXTPG mbufs, an improvement of 5-15% for read rate could be
achieved if the read reply was in M_EXTPG mbufs.

A patch that tried to determine if the outbound NIC supported
M_EXTPG mbufs (IFCAP_MEXTPG) did not pass review.
However, it does appear that this can be useful for NFS-over-RDMA.
(Which just happen to use NICs that do support M_EXTPG mbufs.)

As such, this patch enables them is xp_extpg is set to true,
which is never for now, but might be set true for RDMA or
when vfs.nfsd.enable_mextpg is set non-zero. (It is 0 by
default, so this is never enabled by default at this time.)

Tested by:	Greg Becker <[email protected]>
MFC after:	2 weeks
2026-07-06 17:10:11 -07:00
Rick Macklem fe6677e7f4 nfs_clstate.c: Fix handling of delegation upgrades
Commit 016570c446 modified the client to handle
the upgrade of a read delegation to a write delegation,
where the server provides the same delegation stateid
to the client.  However, it failed to check if the
delegation structure was currently in use.  Without this
patch, if the structure was in use, a use after free
could occur.

This patch handles the "in use" case by copying the
necessary fields into the current/old structure and
free's the new one instead of the old one that is
"in use".

PR:	296224
MFC after:	2 weeks
2026-07-04 15:00:02 -07:00
Rick Macklem 9e1bbfb88e nfs_clstate.c: Fix CB_RECALL handling for NFSv4.1/4.2
Recent testing with a modified NFSv4.1/4.2 client that
sometimes ignored CB_RECALL callbacks, identified a few
problems when handling the unusual case of CB_RECALL not
be performed by the client.
- The csa_cachethis argument to CB_SEQUENCE was being ignored.
- The CB_SEQUENCE operation would reply NFSERR_DELAY
  after the first CB_RECALL attempt, making retries
  ineffective.
- The code could return NFSERR_RESOURCE, which is a
  NFSv4.0 specific error code.

This patch fixes the above three problems.

The patch only affects the NFSv4.1/4.2 client when
delegations are being issued and the client somehow
fails to handle a CB_RECALL callback of a delegation,
which is an unusual case.

MFC after:	2 weeks
2026-06-27 16:35:20 -07:00
Rick Macklem fe7426b2c9 nfs_nfsdport.c: Fix a typo in a KASSERT
Reported by:	rlibby
2026-06-25 17:55:31 -07:00
Rick Macklem cf523f4beb nfscl: Add support for flexible file layout striping
Commit 72e57bc264 added support for striping to the pNFS
server configuration.  This patch adds support for striping
to the NFS client.

For striped flexible file layouts, an extra structure
must be malloc()d for each stripe, since the number
of stripe servers can vary from one mirror to another.
This new structure is called nfsffs and a single one
of these structures is in the nfsffm structure so that
the non-striped layouts can avoid the additional malloc()'s.

This patch only affects NFSv4.1/4.2 mounts that use the
"pnfs" mount option against servers that support the
flexible file layout.
2026-06-22 18:21:08 -07:00
Rick Macklem 455c354dd4 gss_impl.c: Fix a nfsd hang when the kgssapi.ko is loaded, but no gssd
After the conversion to using netlink, the kgssapi had
no way of knowing if the gssd daemon was running.
As such, a boot where the kgssapi is loaded, but the
gssd is not enabled would hang the nfsd for a very
long time. (Many timeouts at 300sec each.)

This patch adds a Null RPC upcall with a 200msec
timeout to check to see if the gssd is running.
If the gssd is not running, the nfsd starts up
(without Kerberos support) with only a 200msec
delay.)

Also, move the svc_svc_nl_create() and svc_reg() calls in gssd.c
to before the daemon() call, so they are guaranteed to have
been done before the nfsd(8) daemon is started by
the rc scripts.

PR:	295714
Reviewed by:	glebius
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D57455
2026-06-21 16:15:23 -07:00
Rick Macklem c57fab60da nfs_nfsdstate.c: Another unnecessary initialization for gcc
This code hasn't changed in a long time, so I don't know why
this showed up now?
2026-06-21 07:42:19 -07:00
Rick Macklem fa515f60fc nfs_nfsdport.c: One more unnecessary initialization for gcc
Fixes:	d8e8f92519 ("pNFSd: Add a directory of newly created files for the pNFSd")
2026-06-20 19:53:06 -07:00
Rick Macklem 61152df00a nfs_nfsdport.c: Do unnecessary initializations to quiet gcc
Fixes:	d8e8f92519 ("pNFSd: Add a directory of newly created files for the pNFSd")
2026-06-20 17:06:45 -07:00
Rick Macklem d8e8f92519 pNFSd: Add a directory of newly created files for the pNFSd
When an NFSv4.1/4.2 server is configured as a pNFS server,
new file creation (via Open/Create from an NFS client) is
slow, due to the fact that the NFS server (MDS) must do
RPCs against the DS(s).

This patch precreates files in a directory called ".pnfshide/numfiles",
so that the NFS server can just rename them for the Open/Create.
A kernel process called a "replenisher" creates more files in
".pnfshide/numfiles" as required. (At this point, the MDS must
still do Setattr RPC(s) on the DS(s), but that will change when
the pNFS server is converted to the loosely coupled configuration.

This patch only affects the pNFS server and only if the directory
.pnfshide/numfiles exists in the exported file system.

Reviewed by:	kib
Discussed with:	markj
Differential Revision:	https://reviews.freebsd.org/D57554
2026-06-20 11:43:45 -07:00
Rick Macklem b1af05406b nfs_nfsdserv.c: Fix setting of birthtime for some ZFS pools
Some ZFS pools do not support va_birthtime and will return
EINVAL when a VOP_SETATTR() of it is attempted.  The MacOS
NFSv4 client sets va_birthtime (TimeCreate) in the same
Setattr with ctime/mtime and other attributes after a new
file is created.  The EINVAL failure leaves these new files
messed up (mode == 0).

This patch pretends the setting of TimeCreate succeeded if
ctime/mtime were also set in the same Setattr RPC, which
resolves the problem for the MacOS client.

If this fix is not sufficient, a new pathconf name to detect
if a file system supports birthtime may be needed.

PR:	296066
Tested by:	Will <[email protected]>
MFC after:	2 weeks
2026-06-18 08:45:27 -07:00
Rick Macklem 572680712c nfs_clvnops.c: Fix the case where va_flags are being cleared
Commits c5d72d2 and 3b6d4c6 broke the case where the
archive/hidden/system attributes are being set false
(UF_ARCHIVE, UF_HIDDEN or UF_SYSTEM bits being cleared.)
and the NFS server does not support those attributes.
These patches only checked for support if the
archive/hidden/system attributes were non-zero.

This patch fixes the problem.

PR:	296088
Tested by:	Joshua Kinard <[email protected]>
MFC after:	1 week
Fixes:	c5d72d29fe ("nfsv4: Add support for the NFSv4 hidden and system attributes")
2026-06-17 17:34:57 -07:00
Rick Macklem 62e7ac83ae Revert "rpc.tlsservd.c: Pin max threads at 1 for now"
This reverts commit 7a289fe3cd.

Hopefully, commit fc7993cf2d has fixed the underlying
problem reported by PR#289734, so I am reverting this
temporary work-around.

I will delay MFC'ng this for a while, to see if the
problem occurs again.

MFC after:	3 months
2026-06-16 09:15:25 -07:00
Rick Macklem 2e6615b26b netexport: Move struct netexport in a .h file and refcnt it
This patch moves "struct netexport" into a separate
netexport.h file and refcounts the structure, plus adds
a few fields that will be used in a future NFS server
commit.

The patch also includes some helper functions for
handling the netextport structure:
vfs_netexport_alloc(), vfs_netexport_acquire(),
vfs_netexport_release() and vfs_netexport_reset().

Reviewed by:	kib, markj
Differential Revision:	https://reviews.freebsd.org/D57553
2026-06-16 08:35:30 -07:00
Rick Macklem 3dfbbe8586 nfsd: Add per-MDS fs striping configuration
Commit 72e57bc264 added support for striping to the pNFS
server when using the Flexible File layout.
It is configured globally via the following sysctls:
vfs.nfsd.pnfsstripeunit - Size (in bytes) of a stripe
vfs.nfsd.pnfsstripecnt - # of DSs to stripe across

This patch allows the above settings to be overridden
on a per-MDS exported file system basis.  With this
patch, a stripeunit can optionally be specified for
the MDS file system listed when one is listed after
a '#' in the "-p" nfsd argument.  This is done by
appending "@NNN", where NNN is the stripeunit, in bytes.

The current syntax implies that neither a '#' nor '@'
can be in the MDS mount point's directory path.

This patch does not affect current pNFS server
configurations (of which there appears to be very
few, anyhow).
2026-06-05 07:59:42 -07:00
Rick Macklem ea4886f282 nfs_commonkrpc.c: Improve handling of NFSv4.1/4.2 recovery
Commit 4d80d4913e fixed a long standing bug in the recovery
code.  However. glebius@ reported seeing multiple
recovery cycles with this patch during an NFSv4.1/4.2
server reboot.

This commit should minimize the risk of multiple
recovery cycles.

PR:	294925
Reported by:	Jov <[email protected]>
MFC after:	2 weeks
Fixes:	4d80d4913e ("nfs: Fix argument typo to avoid a crash")
2026-06-04 15:02:48 -07:00
Rick Macklem 72e57bc264 nfsd: Add support for striped Flexible File layout
Without this patch, the NFSv4.1/4.2 pNFS server configuration
did not support striping.  This was mainly because the Linux
client driver did not support it either.  The Linux client
driver for Flexible File layout does now support striping.
(Linux kernel version 6.18 or newer)

As such, this patch adds striping support.  The configuration
is currently just two new sysctls called
vfs.nfsd.pnfsstripeunit - Size (in bytes) of a stripe
vfs.nfsd.pnfsstripecnt - # of DSs to stripe across
A setting of 0 for the first sysctl and 1 for the second
disables striping.  A patch that allows use of a different
striping configuration for each exported MDS file system
is planned for the future.

The pnfsdscopymr may be broken by this patch, but since
no one reported that they were actually using a pNFS server
configuration, I do not believe that will be a problem at
this time.

Until the FreeBSD NFSv4.1/4.2 client is patched to handle
striped flexible file layouts, mounts to a striped pNFS
configuration must be done without the "pnfs" mount option.
(Linux systems with a kernel version of 6.18 or newer
should be able to handle a striped pNFS configuration.)

Future patches that convert the pNFS server to a
"loosely coupled" configuration (which allows the use
of non-FreeBSD servers as DSs) are anticipated.
2026-06-03 18:28:56 -07:00
Rick Macklem 07d733963e nfs_clrpcops.c: Change initial layout type to flex files
Since the File 4.1 layout is only supported by some
large configurations of Netapp Filers, switch the client
pNFS code to attempting to use Flexible File Format first.

File 4.1 Layout should still work for any servers that do
no support Flexible File Layout.
2026-06-03 12:04:59 -07:00
Rick Macklem 4d80d4913e nfs: Fix argument typo to avoid a crash
A typo resulted in the wrong argument for a bytewise
comparison that could result in a crash if
the incorrect argument was not a valid pointer.

This patch fixes the argument.

While investigating this, I noticed that the
correct argument was not being filled in as
required, so this patch fixes that, as well.

Somehow, recovery from a NFSv4.1/4.2 server
crash worked during testing, so this was not
detected.  The bug/patch only affects NFS
client mounts using NFSv4.1/4.2.

PR:	294925
Reported by:	Jov <[email protected]>
MFC after:	3 days
2026-05-25 12:22:32 -07:00
Rick Macklem 074c42ade3 RELNOTES: Add an entry for commit b92b9da330 2026-05-14 16:04:26 -07:00
Rick Macklem b92b9da330 nfsd: Allow vfs.nfsd.srvmaxio to be up to 4Mbytes
Without this patch, the maximum setting for
vfs.nfsd.srvmaxio was 1Mbyte.  This patch increases
that to 4Mbytes.

The same as for any setting above 128Kbytes, settings up to
4Mbytes require that kern.ipc.maxsockbuf be increased.
(A message generated after setting vfs.nfsd.srvmaxio via
the /etc/rc.conf variable nfs_server_maxio will indicate
the minimum setting, which will be somewhat greater than
four times the setting of vfs.nfsd.srvmaxio.)

Requested by:	Cedric Blancher <[email protected]>
MFC after:	2 weeks
Fixes:	13d3bd165e ("subr_uio.c: Remove a KASSERT() for large NFS server I/O")
2026-05-14 15:33:23 -07:00
Rick Macklem 13d3bd165e subr_uio.c: Remove a KASSERT() for large NFS server I/O
When the NFS server is set to allow an I/O size greater
than 1Mbyte (not allowed in FreeBSD's main yet), a
KASSERT() in allocuio() can fail when:
zfs_freebsd_write()->zfs_write()->zfs_uiocopy()
->cloneuio()->allocuio()
is called for a large NFS server write.

Since the userland API callers to allocuio() already
check that the size does not exceed UIO_MAXIOV,
there does not seem to be a need to a KASSERT()
here.

Removing the KASSERT() allows NFS server writes
of greater than 1Mbyte to work, once the NFS code
is patched to allow them.

Reviewed by:	kib
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D57005
2026-05-14 15:17:55 -07:00
Rick Macklem 448b4c3f7f nfs_clsubs.c: Fix ncl_getcookie() when "pos" is negative
In ncl_getcookie(), a very large value for "off" for
a directory can result in "pos" being set to a bogus
value (including a negative one), due to truncation.
When "pos" is negative, is can skip past the
while (pos >= NFSNUMCOOKIES) loop and return a
bogus pointer instead of NULL.

This patch changes the type to u_int and also adds
a sanity check for a very large "off" to ensure that
a NULL pointer is returned for this case.

This bug has been in the code for decades and I am
not aware of any report of it causing a problem for
users.

Reviewed by:	markj
Reported by:	Joshua Rogers of AISLE Research Team
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D56779
2026-05-06 07:54:55 -07:00
Rick Macklem 03e9e83f35 nfs_nfsdserv.c: Clip number of callback slots
The client tells the server how many callback slots
it can handle in the callback session.  However, the
NFSv4.1/4.2 server can only handle a maximum of
NFSV4_SLOTS slots.  This patch clips the client's
value to that, to avoid using too high a slot#
for a callback.

Fortunately, I do not know of an extant client that
specifies a value greater than NFSV4_SLOTS, so this
patch is not really needed, as yet.  Also, the client
rarely uses a slot# above 0 when doing callbacks.

MFC after:	2 weeks
2026-05-04 17:04:00 -07:00
Rick Macklem 457c621add nfsd: Disable use of callbacks for NFSv4.0
Commit 71ac1ec5c9 disabled callbacks for the NFS
client for NFSv4.0.  This patch does the same for
the NFSv4.0 server.

The only use for callbacks for NFSv4.0 is delegations
and delegations rarely work well for NFSv4.0 anyhow.

Therefore, this patch disables callbacks for the
NFSv4.0 server.  This is the same behavior as
occurs when vfs.nfsd.issue_delegations is 0.

This change allowed the functions called
nfsrv_getclientipaddr() and nfsrv_getipnumber() to be
removed from the kernel.

MFC after:	2 weeks
2026-05-03 16:25:45 -07:00
Rick Macklem d8d9e1cf5e krpc: Get rid of KRPC_VNET macros
When the krpc was vnet'd, the VNET macros were hidden
behind macros that had the KRPC_ prefix on them.
This was done because, at the time, it was thought
that something other than vnet might be used for this.
That has not happened and probably will not happen,
so this patch replaces these obscuring macros with
the regular vnet ones.

There should be no semantics change caused by
this commit.

Discussed with:	bz, glebius
MFC after:	1 month
2026-05-03 14:25:06 -07:00
Rick Macklem 821976facf nfsd: Get rid of NFSD_VNET macros
When the nfsd was vnet'd, the VNET macros were hidden
behind macros that had the NFSD_ prefix on them.
This was done because, at the time, it was thought
that something other than vnet might be used for this.
That has not happened and probably will not happen,
so this patch replaces these obscuring macros with
the regular vnet ones.

There should be no semantics change caused by
this commit.

Discussed with:	bz, glebius
MFC after:	1 month
2026-05-02 14:36:43 -07:00
Rick Macklem a6e527f893 nfscl: Fix handling of gssd upcalls for the NFS client
Without this patch, all upcalls to the gssd daemon are
done in vnet0 (outside of any vnet jail).  This does
not work well, because a user principal's credential
cache can be within the jail (/tmp/krb5cc_NNN in the
jail's namespace).

This patch modifies the client so that RPCs done
from within vnet jails does an upcall to a gssd
daemon running within the vnet jail.  It required
that the cache of uid->credential shorthands in
the rpcsec_gss be vnet'd.

The situation is still less than ideal and sec=krb5[ip]
mounts that are visible within vnet jails is still
not something I would recommend, but it can work ok
with this patch.

Vnet'ng the NFS client so that mounts can be done
within vnet jails is probably more useful, but that
will require additional work.

Discussed with:	glebius
MFC after:	1 month
2026-05-02 12:36:00 -07:00
Rick Macklem 71ac1ec5c9 nfscl: Disable use of callbacks for NFSv4.0
The only use for callbacks for NFSv4.0 is delegations
and delegations rarely work well for NFSv4.0 anyhow.

Therefore, this patch disables callbacks for the
NFSv4.0 client.  This is the same behavior as
occurred when the nfscbd(8) daemon was not running.

This change allowed a function called nfscl_getmyip()
to be removed from the kernel, which is nice since
maintaining this function was bothersome, due to its
use of routing, etc.

MFC after:	2 weeks
2026-04-30 14:43:04 -07:00
Rick Macklem 6698596cd2 nfsv4.4: Document setup of a NFSv4 root fs
Commit 8b9775912c added support for an NFSv4 mounted
root file system.  This patch documents how to set this
up.  It also includes some minor updates and fixes
some formatting.

This is a content change.

Reviewed by:	kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D56317
Fixes:	8b9775912c ("nfs_diskless: Add support for an NFSv4 root fs")
2026-04-11 12:36:56 -07:00
Rick Macklem cc2f8f3786 RELNOTES: Update the entry for commit 8b9775912c 2026-04-07 13:04:36 -07:00
Rick Macklem dc752c26b7 RELNOTES: Make an entry for supporting an NFSv4 root fs 2026-04-07 12:32:48 -07:00
Rick Macklem 53b4ae3bf0 nfs_diskless: Fix handling of nfsuserd case for NFSv4
Commit 8b9775912c added support for an NFSv4 mounted
root file system, but only if the NFSv4 configuration
used id numbers in the strings.

This patch adds support for the case where the NFSv4
configuration uses name<-->id mappings via nfsuserd(8)
by priming the mapping cache with just enough entries
so that it works until the nfsuserd(8) is running.
They are listed in nfs_prime_userd[] in
sys/fs/nfs/nfs_commonsubs.c.

The entries in nfs_prime_userd[] are also wired into
the kernel's cache for name<-->id mappings when nfsuserd(8)
starts up.  This is necessary, since an upcall to the
nfsuserd(8) daemon for a mapping when looking up the
path to the passwd/group database files (/etc) will
hang the system, due to a vnode lock being held on
the entry in the path which blocks nfsuserd(8) from
accessing files.

To enable this case, the following must be put in the
NFS root file system's /boot/loader.conf:
boot.nfsroot.options="nfsv4"
boot.nfsroot.user_domain="<user.domain>"
where <user.domain> must be the same as nfsuserd
uses (usually set via the -domain flag).
If boot.nfsroot.user_domain does not exist or is
the empty string, ids is strings is configured.

MFC after:	1 week
Requested by:	Dan Shelton <[email protected]>
Fixes:	8b9775912c ("nfs_diskless: Add support for an NFSv4 root fs")
2026-04-07 08:50:21 -07:00
Rick Macklem e6db4dd9d7 nfsid.h: Put the nfsd_idargs structure in a new .h
This patch moves the definition of the nfsd_idargs
structure out of nfs.h and into a new file called
nfsid.h.

This is being done so that it can be included in
nfs_diskless.c in a future commit.

There should be no semantics change from this
commit.

MFC after:	1 week
Fixes:	8b9775912c ("nfs_diskless: Add support for an NFSv4 root fs")
2026-04-06 07:09:01 -07:00
Rick Macklem 8b9775912c nfs_diskless: Add support for an NFSv4 root fs
Without this patch, diskless root NFS file systems
could only be mounted via NFSv3 (or NFSv2).
This patch adds the basic support needed to mount
a root fs via NFSv4.

At this time, the NFSv4 mount will only work if
the following is done on the NFS server configuration:
- The root directory specified in the "V4:" line in
  /etc/exports must be "/".  This is needed since the
  path to mount must be the same for NFSv3 and NFSv4.
- The NFS server must be configured to do both NFSv3
  and NFSv4, since the bootstrap code still uses NFSv3.
- The NFSv4 server must be configured with:
  vfs.nfs.enable_uidtostring=1
  vfs.nfsd.enable_stringtouid=1
  since the NFSv4 root fs cannot be running nfsuserd(8)
  when it is booting.  (This limitation may be removed
  in a future commit by hard-wiring enough id<-->name
  mapping entries to handle things until the nfsuserd(8)
  is running.)

To enable the root fs to be mounted via NFSv4, it needs:
- in the root file system's /boot/loader.conf
  boot.nfsroot.options="nfsv4"
  (Additional options like rsize=65536,wsize=65536 can
   also be specified.)
- in the root file system's /etc/sysctl.conf
  vfs.nfs.enable_uidtostring=1

Requested by:	Dan Shelton <[email protected]>
MFC after:	1 week
2026-04-05 09:02:39 -07:00
Rick Macklem b5815ee99a nfs_nfsdsocket.c: Allow Copy/Clone from a read-only fs
For some server file system types, such as ZFS, a Copy/Clone
operation can be done across file systems of the same file
system type.

However, without this patch, the Copy/Clone will fail with
EROFS if the input file is on a read-only mounted file system.
This happens because Copy/Clone will try to do a VOP_SETATTR()
of atime to set the atime.

This patch pretends the VOP_SETATTR() of atime worked for
read-only file systems.  It fixes a problem when copying
files from a ZFS snapshot.

PR:	294010
MFC after:	2 weeks
2026-03-29 14:41:36 -07:00
Rick Macklem b65e7b4944 nfs_nfsdsocket.c: All Copy and Clone across file systems
For some server file system types, such as ZFS, a Copy/Clone
operation can be done across file systems of the same file
system type.

As such, this patch allows the Copy/Clone to be attempted
when the file handles are for files on different file systems.

This fixes a problem for exported ZFS file systems when a
copy_files on file_range(2) between file systems in the same
NFSv4 mount is attempted.

PR:	294010
MFC after:	2 weeks
2026-03-28 12:39:10 -07:00
Rick Macklem 41b423cc4e clnt_bck.c: Delete a couple of old diagnostic printfs
There were two debug printf()s that were left in the
code while debugging the handling of callbacks over
a NFSv4.1/4.2 backchannel was being done.

This patch removes them, since they are no longer
of benefit and cause "noise".

Requested by:	wollman
MFC after:	2 weeks
2026-03-25 13:53:22 -07:00
Rick Macklem 6580d04086 nfs_nfsdserv.c: Fix handling of archive flag for mkdir
An NFSv4.1/4.2 client can set/clear the archive, hidden
and system flags when creating non-regular files, such
as directories.

Without this patch, the setting of va_flags causes an
EPERM failure, since they are specified for VOP_MKDIR(),
VOP_MKNOD() and VOP_SYMLINK().

This patch sets va_flags == VNOVAL for the above VOP_xxx()
calls and then sets/clears the flags after creation,
which fixes the problem.

This bug only affects the Windows NFSv4.1/4.2 client.

PR:	293691
Tested by:	Dan Shelton <[email protected]>
MFC after:	2 weeks
2026-03-16 16:22:37 -07:00
Rick Macklem 016570c446 nfs_clstate.c: Handle the same stateid case correctly
When an NFSv4.1/4.2 sarver upgrades a read delegation to
a write delegation, it does not need to change the
delegation's stateid.

Without this patch, a DELEGRETURN of the stateid was done
for the case where the delegation stateid had not changed.
This return was bogus, since the delegation stateid now
represents the new write delegation.

This patch fixes the priblem by checking for "same stateid"
and only doing the DELEGRETURN when it is not the same.

PR:	289711
Tested by:	Peter Much <[email protected]_sub.org>
MFC after:	2 weeks
2026-03-08 14:09:36 -07:00
Rick Macklem 935cf3284f vfs_mount.c: Don't call VFS_MOUNT() if only exports are being updated
PR#293198 reports a hang within ZFS when exports
are being updated concurrently with a VOP_SETEXTATTR().
The hang appears to be caused by mishandling of the
z_teardown_lock, but fixing handling of this lock appears
to be a major effort. Since the hang occurs when
VFS_MOUNT() acquires a write/exclusive z_teardown_lock,
which rarely occurs, except when exports are being updated,
this patch avoids the VFS_MOUNT() call for this case.

Avoiding a VFS_MOUNT() call fixes the hang for the case
reported by PR#293198 and is also an optimization.
As such, this patch avoids the VFS_MOUNT() call when only exports
are being updated similar to what was already being done
within vnet prisons.

PR:	293198
Reviewed by:	kib, markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D55318
2026-02-17 14:59:57 -08:00
Rick Macklem 110f2567cb linux_file.c: Fix handling of NFS getdents() emulation
Bugzilla PR#292282 reports a problem, where a Linux
binary running in the Linuxulator gets bogus entries
in a readdir()/getdents() reply when the directory is
an NFS mount.

This appears to be caused by the NFS client including
entries with d_fileno == 0, which are always ignored by
BSD, but are not ignored by Linux.

This patch filters out the "d_fileno == 0" entries and
the reporter of the bugzilla PR notes that it fixes the
problem for him.

It could be argued that the NFS client should filter out
the "d_fileno == 0" entries, but the NFS client readdir
code is "fragile" and any change to it runs a significant
risk of causing regression type problems.

As such, since the LInuxulator is already broken for this
case, it seems safer to filter them out there.

PR:	292282
Tested by:	Jerry Williams <[email protected]>
Reviewed by:	markj
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D54679
2026-02-07 14:12:55 -08:00
Rick Macklem 4bfb7cfb70 runat: Add -h to manipulate a symlink's named attribute dir
Lionel Cons <[email protected]> requested
that a new option be added to runat(1) so that it could
be used to manipulate named attributes associated with
a symbolic link and not the file the symbolic link refers to).

This patch adds the option -h/--nofollow to do this.

Requested by:	Lionel Cons <[email protected]>
Reviewed by:	kib
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D55023
2026-02-02 14:38:13 -08:00
Rick Macklem 053449fa5c nfscl: Fix the build
Fixes:	f2155a6fb5 ("nfscl: Fix handling of case insensitive file systems")
2026-01-20 17:32:23 -08:00
Rick Macklem f2155a6fb5 nfscl: Fix handling of case insensitive file systems
Name caching must be handled somewhat differently
for case insensitive file systems.  Negative name
caching does not work and, for rename, all names
associated with the rename'd vnode must be disabled.

For a case insensitive ZFS file system that is exported,
the unpatched code did work, since the change in mtime
or ctime of the directory when other case names were
created or rename'd would disable the false name cache
hit.  However, an export of an msdosfs file system
breaks the NFS client, because it only works if ctime/mtime
is changed whenever a name is added/removed.  Depending
on what the server file system is, this may not happen,
due to clock resolution or lack of support for these
attributes.

This patch checks to see if the server file system is
case insensitive and modifies the name caching to handle
this.

There is still a problem if a case insensitive file system
is a subtree of a non-case insensitive is exported by the
NFSv4 server.  This can be fixed someday, when the NFSv4
client gets support for submounts within the mount.

Suggested by:	kib
MFC after:	2 weeks
2026-01-20 16:21:52 -08:00
Rick Macklem 4fc11c92d3 nfsd: Fix handling of attributes during Open/Create/Exclusive_41
When an NFSv4.n client specifies settings for attributes other
mode during a Open/Create/Exclusive_41, these other attributes
were not being set.

This patch resolves the problem by calling nfsrv_fixsattr()
after the VOP_CREATE() call in nfsvno_open() for this case.

There is no extant NFSv4.n client that currently does this,
as far as I know.

MFC after:	2 weeks
2026-01-15 15:27:22 -08:00
Rick Macklem a6d57f312f nfsd: Fix handling of hidden/system during Open/Create
When an NFSv4.n client specifies settings for the archive,
hidden and/or system attributes during a Open/Create, the
Open/Create fails for ZFS.  This is caused by ZFS doing
a secpolicy_xvattr() call, which fails for non-root.
If this check is bypassed, ZFS panics.

This patch resolves the problem by disabling va_flags
for the VOP_CREATE() call in the NFSv4.n server and
then setting the flags with a subsequent VOP_SETATTR().

This problem only affects FreeBSD-15 and main, since the
archive, system and hidden attributes are not enabled
for FreeBSD-14.

I think a similar problem exists for the NFSv4.n
Open/Create/Exclusive_41, but that will be resolved
in a future commit.

Note that the Linux, Solaris and FreeBSD clients
do not set archive, hidden or system for Open/Create,
so the bug does not affect mounts from those clients.

PR:	292283
Reported by:	Aurelien Couderc <[email protected]>
Tested by:	Aurelien Couderc <[email protected]>
MFC after:	2 weeks
2026-01-08 08:27:32 -08:00
Rick Macklem e8567de718 nfscl: Fix handling of POSIX draft default ACLs
A POSIX draft default ACL may not exist.  As such,
an ACL with zero ACEs needs to be allowed.

This patch fixes acquisition of POSIX draft default
ACLs when they do not exist on the directory.

Fixes:	a35bbd5d9f ("nfscommon: Add some support for POSIX draft ACLs")
2025-12-30 18:43:23 -08:00
Rick Macklem 4f184fd35d nfsd.8: Add a short paragraph w.r.t. NFSv3 vs NFSv4 setup
The nfsd can be configured to support NFSv3, NFSv4 or both
of them.

This patch adds a short paragraph to nfsd.8 to explain this.

This is a content change.

Reviewed by:	kib, zaiee (manpages)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D54279
2025-12-24 08:29:29 -08:00
Rick Macklem b94e4c7037 RELNOTES: Add an entry for 8e3fd450cc and friends 2025-12-22 18:51:41 -08:00
Rick Macklem 60eb371c2b UPDATING: Add an entry for commit 9f49f436a9 2025-12-22 15:28:59 -08:00
Rick Macklem e35191ccf3 nfs: Add some support for POSIX draft ACLs
An internet draft (expected to become an RFC someday)
https://datatracker.ietf.org/doc/draft-ietf-nfsv4-posix-acls
describes an extension to NFSv4.2 to handle POSIX draft ACLs.

This is the final patch in the series that enables
the extension of NFSv4.2 to support POSIX draft ACLs.
At this time, only UFS mounted with the "acls" option
will work, and only for FreeBSD built with these patches.
Patches for client and server for the Linux kernel are
in the works.  (I'll admit my next little project is
cleaning the Linux patches up for submission for upstream.)

To make these changes really useful, the FreeBSD port
of OpenZFS needs to be patched to add POSIX draft ACL
support.  (Support for POSIX draft ACLs is already in
the Linux port of OpenZFS.)

Interopeability with NFSv4.2 clients and servers that
do not support this extension should not be a problem.

Fixes:	a35bbd5d9f ("nfscommon: Add some support for POSIX draft ACLs")
2025-12-22 15:22:09 -08:00
Rick Macklem 9f49f436a9 nfs: Add some support for POSIX draft ACLs
An internet draft (expected to become an RFC someday)
https://datatracker.ietf.org/doc/draft-ietf-nfsv4-posix-acls
describes an extension to NFSv4.2 to handle POSIX draft ACLs.

This is the fifth of several patches that implement the
above draft.

This one mostly adds an extra argument to two functions
in nfscommon.ko.  Unfortunately, these functions are
called in many places, so the changes are numerous, but
straightforward.

Since the internal KAPI between the NFS modules is changed
by this commit, all of nfscommon.ko, nfscl.ko and nfsd.ko
must be rebuilt from sources.

There should be no semantics change for the series at
this point.

Fixes:	a35bbd5d9f ("nfscommon: Add some support for POSIX draft ACLs")
2025-12-22 13:51:15 -08:00
Rick Macklem 0e724de9ed nfscl: Add some support for POSIX draft ACLs
An internet draft (expected to become an RFC someday)
https://datatracker.ietf.org/doc/draft-ietf-nfsv4-posix-acls
describes an extension to NFSv4.2 to handle POSIX draft ACLs.

This is the fourth of several patches that implement the
above draft.

There should be no semantics change for the series at
this point.

Fixes:	a35bbd5d9f ("nfscommon: Add some support for POSIX draft ACLs")
2025-12-21 18:05:04 -08:00
Rick Macklem 949cff4dce nfscommon: Add some support for POSIX draft ACLs
An internet draft (expected to become an RFC someday)
https://datatracker.ietf.org/doc/draft-ietf-nfsv4-posix-acls
describes an extension to NFSv4.2 to handle POSIX draft ACLs.

This is the third of several patches that implement the
above draft.

There should be no semantics change for the series at
this point.

Fixes:	a35bbd5d9f ("nfscommon: Add some support for POSIX draft ACLs")
2025-12-21 17:07:10 -08:00
Rick Macklem 8e3fd450cc nfsd: Add some support for POSIX draft ACLs
An internet draft (expected to become an RFC someday)
https://datatracker.ietf.org/doc/draft-ietf-nfsv4-posix-acls
describes an extension to NFSv4.2 to handle POSIX draft ACLs.

This is the second of several patches that implement the
above draft.

The only semantics change would be if you have exported
a UFS file system mounted with the "acl" option.
In that case, you would see the acl attribute supported.
This is bogus, but will be handled in the next commit.

Fixes:	a35bbd5d9f ("nfscommon: Add some support for POSIX draft ACLs")
2025-12-21 16:08:05 -08:00
Rick Macklem a35bbd5d9f nfscommon: Add some support for POSIX draft ACLs
An internet draft (expected to become an RFC someday)
https://datatracker.ietf.org/doc/draft-ietf-nfsv4-posix-acls
describes an extension to NFSv4.2 to handle POSIX draft ACLs.

This is the first of several patches that implement the
above draft.

This patch should not result in a semantics change.
2025-12-21 14:28:12 -08:00
Rick Macklem aa1cf24088 nfs_nfsdstate.c: Add sanity checks for lock stateids
Bugzilla PR reported a crash caused by a synthetic client
doing a Lock operation request with a delegation stateid.

This patch fixes the problem by adding sanity checks
for the type of stateid provided as an argument to the
Lock and LockU operations.

It has been tested with the FreeBSD, Linux and Solaris 11.4
clients.  Hopefully, other NFSv4 clients will work ok
as well.

PR:	291080
Tested by:	Robert Morris <[email protected]>
MFC after:	2 weeks
2025-11-26 11:20:27 -08:00
Rick Macklem 088ced14a6 UPDATING: Add an entry for e5aa60d069 2025-11-02 16:20:26 -08:00
Rick Macklem b3de3c2dea param.h: Bump __FreeBSD_version for e5aa60d069
Commit e5aa60d069 changed the internal KAPI between
the NFS modules.  As such, they all need to be rebuilt
from sources.  Bump __FreeBSD_version to 1600004 for this.
2025-11-02 16:16:21 -08:00
Rick Macklem e5aa60d069 nfs: Add support for the new _PC_CASE_INSENSITIVE name
Commit d6864221d8 added support for the _PC_CASE_INSENSITIVE
name for pathconf, to indicate if case insensitive lookups
are configured.

This patch adds support for it for both NFSv4 and
NFSv3.

It also adds a fsidp argument to nfsv4_fillattr() which
will be used in future commit(s) related to NFSv4.n
directory delegations.

MFC after:	2 weeks
2025-11-02 13:38:45 -08:00
Rick Macklem b473bb274c pathconf.2: Document the new _PC_CASE_INSENSITIVE name
Commit d6864221d8 added support for the _PC_CASE_INSENSITIVE
name for pathconf, to indicate if case insensitive lookups
are configured.

This patch documents this new name and also updates
the description for _PC_HAS_HIDDENSYSTEM to also
include UF_ARCHIVE.

This is a content change.

Reviewed by:	kib
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D53508
2025-11-01 15:20:40 -07:00
Rick Macklem 8d5a88ac95 nfs_clvfsops.c: Allow long directory mount paths
Without this patch, the NFS client code for mounts has
an arbitrary 100 character limit for the directory path
being mounted on the server.

Someone reported this quite a while ago, but I cannot
find the email or bugzilla PR.

This patch fixes the problem by increasing the directory
path length limit to MNAMELEN, allocated via malloc() to
avoid using too much stack.

MFC after:	2 weeks
2025-10-29 14:41:12 -07:00
Rick Macklem 73551cd6ea nfs_commonsubs.c: Get rid of variable used as a constant
The variable ncl_mbuf_mhlen is set to MHLEN and only
used in one place.  This patch simply deletes it and
replaces it with MHLEN.

This patch should not affect semantics.

Spotted while fixing cases that could do large
NFSM_DISSECT() sizes.

MFC after:	2 weeks
2025-10-28 17:28:04 -07:00
Rick Macklem 9d13c87afd nfs_clrpcops.c: NFSM_DISSECT() reply for each dir separately
Without this patch, the entire reply for all directories in
the NFSv4 mount path are parsed at once.  This could cause
problems for mount paths with many directories in the path.

This patch fixes the problem by parsing each directory
reply in a loop.

Spotted while fixing other cases that could do large
NFSM_DISSECT() sizes.

MFC after:	3 days
2025-10-28 14:31:30 -07:00
Rick Macklem 4672adcea4 nfs_commonsubs.c: Add a sanity check for nid_ngroup
The nfsuserd(8) daemon passes user credentials
(uid + gids) into the kernel for users and groups
identified by name (received from a NFSv4 server).

This patch add a sanity check for the number of
groups (nid_ngroup) passed in.

It's only purpose is to protect against a bogus
nfsuserd(8) running in a jail.

Reported by:	Ilja Van Sprundel <[email protected]>
Reviewed by:	markj
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D53389
2025-10-28 07:44:14 -07:00
Rick Macklem 2c82cdd2e2 nfs_clrpcops.c: Check for too large a write reply
The "rlen" reply length for a Write operation/RPC
could cause trouble if a broken server replies with
too large a value.

Improve the sanity check for "rlen" to avoid this.

Reported by:	Ilja Van Sprundel <[email protected]>
Reviewed by:	emaste, markj
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D53368
2025-10-27 07:49:32 -07:00