when building the port audio/ardour, it runs a find over the staging area. Code location (as of now) is here: https://cgit.freebsd.org/ports/tree/audio/ardour/Makefile#n90 This basically finds and then strips a few dozen library files. /usr/ports is on NFS. And this command does not return in linear time. Some of the libary files are symlinks. And these need 137 to 259 seconds to access (until the process eventually stalls entirely). Also, during these seconds the respective directory is not accessible; apparently there is some deadlock. Communication is host to guest locally. Systems are mostly idle. Client side settings: # /etc/fstab: 192.168.97.17:/var/sysup/mnt/tmp.6.30322 /usr/ports nfs nfsv4,readahead=1,rw,async 0 0 nfs_client_enable="YES" nfs_access_cache="600" nfs_bufpackets="32" nfscbd_enable="YES" Server side settings: nfs_server_enable="YES" nfs_server_flags="-u -t --minthreads 2 --maxthreads 20 -h 192.168.97.17 -h fd00::123" nfsv4_server_enable="YES" vfs.nfsd.enable_stringtouid=1 vfs.nfsd.issue_delegations=1 Testing shows this: # for i in $FILES do echo $i time strip $i done /usr/ports/audio/ardour/work/stage/usr/local/lib/ardour8/libptformat.so.0 137.79 real 0.01 user 1.50 sys /usr/ports/audio/ardour/work/stage/usr/local/lib/ardour8/libaaf.so 259.95 real 0.00 user 7.08 sys /usr/ports/audio/ardour/work/stage/usr/local/lib/ardour8/vamp/libardourvamppyin.so 136.47 real 0.00 user 0.48 sys /usr/ports/audio/ardour/work/stage/usr/local/lib/ardour8/libwaveview.so.0.0.0 0.05 real 0.00 user 0.01 sys /usr/ports/audio/ardour/work/stage/usr/local/lib/ardour8/libardour.so.3.0.0 1.00 real 0.00 user 0.47 sys /usr/ports/audio/ardour/work/stage/usr/local/lib/ardour8/libpbd.so 136.55 real 0.00 user 0.51 sys /usr/ports/audio/ardour/work/stage/usr/local/lib/ardour8/libpbd.so.4.1.0 0.10 real 0.00 user 0.01 sys /usr/ports/audio/ardour/work/stage/usr/local/lib/ardour8/libwidgets.so 136.62 real 0.00 user 0.53 sys /usr/ports/audio/ardour/work/stage/usr/local/lib/ardour8/libwidgets.so.0 0.18 real 0.01 user 0.02 sys /usr/ports/audio/ardour/work/stage/usr/local/lib/ardour8/libaudiographer.so.0 136.50 real 0.01 user 0.49 sys /usr/ports/audio/ardour/work/stage/usr/local/lib/ardour8/engines/libclearlooks.so 0.04 real 0.00 user 0.00 sys /usr/ports/audio/ardour/work/stage/usr/local/lib/ardour8/libtemporal.so.0 136.52 real 0.00 user 0.50 sys /usr/ports/audio/ardour/work/stage/usr/local/lib/ardour8/libcanvas.so 257.29 real 0.00 user 4.90 sys /usr/ports/audio/ardour/work/stage/usr/local/lib/ardour8/libgtkmm2ext.so.0.8.3 0.49 real 0.00 user 0.41 sys /usr/ports/audio/ardour/work/stage/usr/local/lib/ardour8/libwidgets.so 271.81 real 0.00 user 20.73 sys Interesting here is the accumulation of delays around certain values, like 137 or 258. Maybe this gives a bit more of a clue: # ps axlww | grep 50895 ; procstat -kk 50895 0 50895 50894 11 24 0 23936 8844 nfstry D+ 1 0:00.18 /usr/bin/strip /usr/ports/audio/ardour/work/stage/usr/local/lib/ardour8/libpbd.so PID TID COMM TDNAME KSTACK 50895 100713 strip - mi_switch+0xc3 sleepq_timedwait+0x2f _sleep+0x1e5 nfs_catnap+0x43 newnfs_request+0x14c3 nfscl_request+0x5c nfsrpc_rename+0x445 nfs_renamerpc+0x67 nfs_sillyrename+0xf9 nfs_remove+0x111 vop_sigdefer+0x2f VOP_REMOVE_APV+0x2d kern_funlinkat+0x40f sys_unlink+0x28 filemon_wrapper_unlink+0x13 amd64_syscall+0x118 fast_syscall_common+0xf8
I found the problem being setting on the client: nfscbd_enable="YES" Removing it, the "nfstry" status was not observed again yet.
I finally found a place where the issue appears somehow reproducible, so that debugging can be put in place. Running "git commit" in a nfs-mounted /usr/ports gets all the way through until near the end when it tries to rename("/usr/ports/.git/HEAD.lock","/usr/ports/.git/HEAD"). That rename() then takes 136 seconds: 208.557521019 0.001095461 openat(AT_FDCWD,".git/logs/HEAD",O_WRONLY|O_APPEND|O_CREAT,0666) = 3 (0x3) 208.574163154 0.016549171 write(3,"3754f93cb84ba98cab6af9197debbe22"...,192) = 192 (0xc0) 208.574516583 0.000263536 close(3) = 0 (0x0) 208.574873362 0.000260186 fstatat(AT_FDCWD,"/usr/ports/.git/HEAD",{ mode=-rw-r--r-- ,inode=98432,size=41,blksize=4096 },AT_SYMLINK_NOFOLLOW) = 0 (0x0) 345.013475256 136.438519818 rename("/usr/ports/.git/HEAD.lock","/usr/ports/.git/HEAD") = 0 (0x0) 345.017156753 0.003254916 access(".git/hooks/reference-transaction",X_OK) ERR#2 'No such file or directory' 345.018147271 0.000731442 fstatat(AT_FDCWD,".git/CHERRY_PICK_HEAD",0x820dea580,AT_SYMLINK_NOFOLLOW) ERR#2 'No such file or directory' More interesting is the network traffic between nfs client and server during these 136 seconds, which repeatedly goes like this: 18:35:19.260807 IP 192.168.97.5.900 > 192.168.97.17.2049: Flags [P.], seq 125136848:125137132, ack 430758341, win 22032, options [nop,nop,TS val 885962725 ecr 1618335444], length 284: NFS request xid 1784465120 280 getattr fh 0,6/2 18:35:19.261091 IP 192.168.97.17.2049 > 192.168.97.5.900: Flags [P.], seq 430758341:430758537, ack 125137132, win 29128, options [nop,nop,TS val 1618343639 ecr 885962725], length 196: NFS reply xid 1784465120 reply ok 192 getattr ERROR: Request couldn't be completed in time 18:35:19.301145 IP 192.168.97.5.900 > 192.168.97.17.2049: Flags [.], ack 430758537, win 22032, options [nop,nop,TS val 885962765 ecr 1618343639], length 0 18:35:34.265610 IP 192.168.97.5.900 > 192.168.97.17.2049: Flags [P.], seq 125137132:125137416, ack 430758537, win 22032, options [nop,nop,TS val 885977731 ecr 1618343639], length 284: NFS request xid 1784465121 280 getattr fh 0,6/2 18:35:34.265914 IP 192.168.97.17.2049 > 192.168.97.5.900: Flags [P.], seq 430758537:430758733, ack 125137416, win 29128, options [nop,nop,TS val 1618358644 ecr 885977731], length 196: NFS reply xid 1784465121 reply ok 192 getattr ERROR: Request couldn't be completed in time 18:35:34.305678 IP 192.168.97.5.900 > 192.168.97.17.2049: Flags [.], ack 430758733, win 22032, options [nop,nop,TS val 885977771 ecr 1618358644], length 0 I have no idea why the server cannot complete a request here. The exported filesystem was on-demand created (zfs clone) exclusively for this client, there cannot be any conflicting access.
(In reply to Peter Much from comment #2) Can you capture packets via tcpdump -s 0 -w out.pcap ... and provide out.pcap so I can look at it in wireshakr? (tcpdump knows nothing about NFS. For example, I have no idea what it means by "Request couldn't be completed in time". (There is no such error reply in NFSv4. It might mean NFS4ERR_DELAY, but this is not a correct definition, so I cannot know.) Also, it is the exact operation within the RPC that generates the error that matters and I can see that in wireshark which, unlike tcpdump, knows NFSv4.
(In reply to Rick Macklem from comment #3) Hi Rick, I tried, but currently the error doesn't want to reproduce, at least not at the places I know about. The "couldn't be completed in time" is apparently: 10008 /* NFS3ERR_JUKEBOX */ (from contrib/tcpdump/print-nfs.c) I understand it is not so really useful to log NFS4 as NFS3. I should have known that, or maybe rather, somebody should have improved the tcpdump... Anyway, when the ugly thing appears again and annoys me (and it will certainly annoy me) I'll remember this...
(In reply to Peter Much from comment #4) NFS3ERR_JUKEBOX is the same as NFS4ERR_DELAY (they even use the same #). But there is no way to know which operation generated it. However, this (and your comment w.r.t. not running nfscbd helping) is weird, in that I would only expect this when delegations are enabled. Please check.. # sysctl vfs.nfsd.issue_delegations on the server. (It should be 0 unless you set it to 1, but??)
(In reply to Rick Macklem from comment #5) Yes it is using delegations! As the filesystems are generated exclusively for a single client, I thought this appropriate. I did set vfs.nfsd.issue_delegations=1 into /etc/sysctl.conf on the server, yes. And on the clients when NOT enabling nfscbd I have not seen the delays. When enabling nfscbd, they appear or (currently) do not appear, I don't really know when and why.
(In reply to Peter Much from comment #6) That slowdown will most likely be a delegation recall. Now, why does it take so long? A packet trace in wireshark would answer the question, but it is likely that a lot of writebacks to the server were required prior to the delegation return. The RFCs require a delegation recall when rename occurs. In this case, it is a sillyrename, which refers to a rename being done because the file is being removed while still open. (There is an argument that, for the sillyrename case, the recall is not needed, but the RFCs say "do it", so??) There might be an underlying issue that makes the recall take so long, but without a packet trace, there is no way of knowing. Bottom line, delegations are not enabled by default for a reason. They can result in significant reductions in RPC counts, but can also result in delegation recalls that take a long time. Set vfs.nfsd.issue_delegations=0 and the slowdowns will go away. (Without the nfscbd running, the server is not supposed to issue delegations, so that had the same effect.)
(In reply to Rick Macklem from comment #3) Okay, here we go: https://oper.dinoex.de/garret/download/out.pcap.PR289711.xz That is going to be big, and I cannot cut it short. It basically contains the ports-tree. ;) The critical section start near 17:24:56.99
(In reply to Peter Much from comment #8) Well, the packet trace is interesting... Just before the Rename that gets NFS4ERR_DELAY as a reply, the client does a recovery for some reason. At packet#893453 it does an ExchangeID, etc. which is what normally happens when a server reboots. But the server does not appear to have rebooted? The client no longer has a delegation (or you might say it doesn't think it has a delegation), but the server does think it has a delegation, which causes the long delay related to the Rename. The workaround is to disable delegations, but it would be nice to know what triggers the client to do this recovery. I'll look at it some more, to try and figure that out. (It gets a NFS4ERR_BAD_STATEID from the server, but I didn't think that would trigger it?)
(In reply to Rick Macklem from comment #9) Yes that is interesting. I have also some interesting things observed. I had to hunt a bug crashing my apache webserver (lingering there for apparently 20+ years with nobody bothering), so I had to rebuild it a couple of times. Rebuiling with stdout/err redirected into /usr/ports/www/apache24, into the NFS, most invocations of ranlib get stuck in 'nfstryop' and take an eternity. NOT redirecting the output, things run normally. but the server's syslog gets occasionally flooded with this kind of messages: Feb 25 15:23:02 <kern.crit> edge kernel: [598789] nfsrv_cache_session: no session IPaddr=192.168.97.5, check NFS clients for unique /etc/hostid's Feb 25 15:23:03 <kern.crit> edge kernel: [598790] nfsrv_cache_session: no session IPaddr=192.168.97.5, check NFS clients for unique /etc/hostid's Feb 25 15:23:04 <kern.crit> edge kernel: [598791] nfsrv_cache_session: no session IPaddr=192.168.97.5, check NFS clients for unique /etc/hostid's Feb 25 15:23:08 <kern.crit> edge kernel: [598795] nfsrv_cache_session: no session IPaddr=192.168.97.5, check NFS clients for unique /etc/hostid's I checked that hostid, it looks fine, and it is recorded in nfs-stablerestart on the server also hundreds of times. There is also some interesting data in the client syslog: Feb 25 15:12:41 vbuild0 kernel: Initiate recovery. If server has not rebooted, check NFS clients for unique /etc/hostid's Feb 25 15:12:41 vbuild0 syslogd: last message repeated 2 times Feb 25 15:12:41 vbuild0 kernel: nfscl: never fnd open Feb 25 15:17:02 vbuild0 kernel: nfsv4 expired locks lost Feb 25 15:17:24 vbuild0 kernel: Initiate recovery. If server has not rebooted, check NFS clients for unique /etc/hostid's Feb 25 15:17:45 vbuild0 syslogd: last message repeated 4 times Feb 25 15:23:02 vbuild0 syslogd: last message repeated 1 times Feb 25 15:23:14 vbuild0 syslogd: last message repeated 2 times Setting debuglevel=1 on the client gives a bit more data, but rather unintellegible to me. At 20:55:31 is the delay, and 20:59:24 is reflected on the server with this: Feb 25 20:59:24 <kern.crit> edge kernel: [618971] nfsrv_cache_session: no session IPaddr=192.168.97.5, check NFS clients for unique /etc/hostid's Feb 25 20:59:24 <kern.crit> edge syslogd: last message repeated 3 times Feb 25 20:53:25 vbuild0 kernel: proc=69 reps=10025 Feb 25 20:53:25 vbuild0 kernel: exchangeid err=0 reps=0 Feb 25 20:53:25 vbuild0 kernel: aft exch=0 Feb 25 20:53:25 vbuild0 kernel: aft createsess=0 Feb 25 20:53:25 vbuild0 kernel: aft reclaimcomp=0 Feb 25 20:53:25 vbuild0 kernel: cbproc=0 Feb 25 20:53:25 vbuild0 kernel: cbrep sent Feb 25 20:55:00 vbuild0 kernel: proc=69 reps=10025 Feb 25 20:55:00 vbuild0 kernel: exchangeid err=0 reps=0 Feb 25 20:55:00 vbuild0 kernel: aft exch=0 Feb 25 20:55:00 vbuild0 kernel: aft createsess=0 Feb 25 20:55:00 vbuild0 kernel: aft reclaimcomp=0 Feb 25 20:55:00 vbuild0 kernel: cbproc=0 Feb 25 20:55:00 vbuild0 kernel: cbrep sent Feb 25 20:55:00 vbuild0 kernel: proc=14 reps=10008 Feb 25 20:55:31 vbuild0 syslogd: last message repeated 15 times Feb 25 20:57:01 vbuild0 syslogd: last message repeated 6 times Feb 25 20:59:24 vbuild0 kernel: proc=2 reps=10025 Feb 25 20:59:24 vbuild0 kernel: exchangeid err=0 reps=0 Feb 25 20:59:24 vbuild0 kernel: proc=35 reps=10011 Feb 25 20:59:24 vbuild0 kernel: aft exch=0 Feb 25 20:59:24 vbuild0 kernel: n2op=8 n2st=10011 Feb 25 20:59:24 vbuild0 kernel: proc=35 reps=10052 Feb 25 20:59:24 vbuild0 kernel: fop=53 fst=10052 Feb 25 20:59:24 vbuild0 kernel: failed seq=10052 Feb 25 20:59:24 vbuild0 kernel: Got badsession Feb 25 20:59:24 vbuild0 kernel: Initiate recovery. If server has not rebooted, check NFS clients for unique /etc/hostid's Feb 25 20:59:24 vbuild0 kernel: Marked defunct Feb 25 20:59:24 vbuild0 kernel: aft createsess=0 Feb 25 20:59:24 vbuild0 kernel: nop=53 nst=10052 Feb 25 20:59:24 vbuild0 kernel: aft reclaimcomp=0 Feb 25 20:59:24 vbuild0 kernel: proc=35 reps=10025 Feb 25 20:59:24 vbuild0 kernel: n2op=8 n2st=10025 Feb 25 20:59:24 vbuild0 kernel: proc=35 reps=10025 Feb 25 20:59:24 vbuild0 kernel: n2op=8 n2st=10025 Feb 25 20:59:24 vbuild0 kernel: proc=35 reps=10025 Feb 25 20:59:24 vbuild0 kernel: n2op=8 n2st=10025 Feb 25 20:59:24 vbuild0 kernel: proc=35 reps=10025 Feb 25 20:59:24 vbuild0 kernel: n2op=8 n2st=10025 Feb 25 20:59:24 vbuild0 kernel: cbproc=0 Feb 25 20:59:24 vbuild0 kernel: cbrep sent Feb 25 20:59:24 vbuild0 kernel: proc=35 reps=10025 Feb 25 20:59:24 vbuild0 kernel: n2op=8 n2st=10025 Feb 25 20:59:24 vbuild0 kernel: proc=35 reps=10025 Feb 25 20:59:24 vbuild0 kernel: n2op=8 n2st=10025 ...
(In reply to Peter Much from comment #10) Well, expired (lost locks) indicates that the client has been network partitioned from the server for some reason (assuming the server did not reboot). or Two or more clients end up with the same hostid. This typically happens when someone clones root disk images with a /etc/hostid set in it. or Something else is somehow causing the NFS4ERR_BAD_STATEID error return (that's the 10025 replies). For NFSv4.1/4.2, which is what you should be getting, I cannot think how this can ever happen. Just in case, check this with # nfsstat -m on the client while mounted. It should not show a minor version of 0. Another thing that can cause serious confusion is dismounting a file system on the server while it is exported. (This causes all sorts of weirdness, because it uncovers the parent fs and that file system might not be exported or will have a different inode# for the mount point or..) I will take a closer look at the packet dump one of these days and see if I can figure out more w.r.t. what is going on. And this is happening when you do not have delegations enabled? (vfs.nfsd.issue_delegations=0)
Created attachment 268431 [details] nfs_clstate.c: Fix an open which has the same delegation stateid The packet trace indicates that the NFS client does a DELEGRETURN of a delegation stateid when the server returns a write delegation with the same delegation stateid as was in a prior read delegation. For this case, the DELEGRETURN should not be done, since it gets rid of the new write delegation. Hopefully the reporter can test with this patch and delegations enabled, to see if it alleviates the problem. (The patch is against main, so it might not apply to 14.3 cleanly, but it is small enough that it can be done manually.)
The packet trace definitely showed at least one bug in the NFSv4.2 client. The patch in the attachment should fix the problem, if I understand it correctly. There also appears to be a bug in the NFSv4.2 server when handling the recovery done via EXCHANGE_ID, CREATE_SESSION,.. Since a recovery done this way when the server has not rebooted is even described in the RFC as far as I am aware, I believe it should delete "old delegations" when the client does RECLAIM_COMPLETE. I will look at this, but the patch in the attachment should stop the NFS4ERR_BAD_STATEID reply that causes the recovery in the first place. Hopefully Peter can test the patch applied to the NFS client when delegations are enabled on the server and nfscbd is running on the client?
(In reply to Rick Macklem from comment #12) Sorry for delay, I just gave the patch a try, and it looks very good; no more problems perceived. I cannot currently run more extensive things, but those issues I've described here, do not seem to happen anymore.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=016570c4463d5908953355ee1cf9a385ad9601b4 commit 016570c4463d5908953355ee1cf9a385ad9601b4 Author: Rick Macklem <rmacklem@FreeBSD.org> AuthorDate: 2026-03-08 21:09:36 +0000 Commit: Rick Macklem <rmacklem@FreeBSD.org> CommitDate: 2026-03-08 21:09:36 +0000 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 <pmc@citylink.dinoex_sub.org> MFC after: 2 weeks sys/fs/nfsclient/nfs_clstate.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
The patch has been committed to main and will be MFC'd. Thanks for reporting this and testing the patch.
A commit in branch stable/15 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=b2fc2556c1eae29eb58529800ed0a213740df4e6 commit b2fc2556c1eae29eb58529800ed0a213740df4e6 Author: Rick Macklem <rmacklem@FreeBSD.org> AuthorDate: 2026-03-08 21:09:36 +0000 Commit: Rick Macklem <rmacklem@FreeBSD.org> CommitDate: 2026-03-22 00:49:33 +0000 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 (cherry picked from commit 016570c4463d5908953355ee1cf9a385ad9601b4) sys/fs/nfsclient/nfs_clstate.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=d288383b4d80e4b5e1bac09722e63d27074f4244 commit d288383b4d80e4b5e1bac09722e63d27074f4244 Author: Rick Macklem <rmacklem@FreeBSD.org> AuthorDate: 2026-03-08 21:09:36 +0000 Commit: Rick Macklem <rmacklem@FreeBSD.org> CommitDate: 2026-03-22 00:53:32 +0000 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 (cherry picked from commit 016570c4463d5908953355ee1cf9a385ad9601b4) sys/fs/nfsclient/nfs_clstate.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
The patch has been MFC'd.