Hi Andrei,
here are my results from a dedicated test client (amd64, Ubuntu 26.04.1,
reader with directory_delegations=Y, writer is a second client, server
knfsd on 7.0.0-44.44). Same reproducer as in the description, 8
directories per run:
Ubuntu 7.0.0-44.44 (stock, two runs) 0 of 8 visible after 180 s
7.0.0-44.44 + 84800a8d1d22 0 of 8
mainline v7.4-rc5 (kernel.ubuntu.com build) 0 of 8
7.0.0-44.44 + 84800a8d1d22 + experiment below 8 of 8 at the first lookup
84800a8d1d22 applies cleanly to Ubuntu-7.0.0-44.44 (one hunk, offset 33 lines)
but does not fix this, and current mainline is affected as well. In every run
the server showed read delegations for the reader on all 8 directories from
about 2 s after the remote create.
Tracing (nfs/nfs4 tracepoints plus a kprobe on
nfs_force_lookup_revalidate) shows the same sequence on all three
failing kernels:
cat nfs_revalidate_inode_enter: fileid=...1992 version=7714315229156096230
cache_validity=0x0
cat nfs4_set_delegation: fmode=READ fileid=...1992
cat nfs4_getattr: error=0 fileid=...1992
cat nfs_refresh_inode_enter: version=7714315229156096230 cache_validity=0x0
cat nfs_refresh_inode_exit: version=7714315722818212263 cache_validity=0x0
_nfs4_proc_getattr() installs the directory delegation before the caller
applies the returned attributes. nfs_update_inode() then sees
have_delegation == true, so on the change attribute mismatch it skips
the branch that calls nfs_force_lookup_revalidate() and just stores the
new change attribute. The negative dentry's verifier still matches, the
attribute cache never expires under the delegation, and no further
LOOKUP for the name is sent until the directory is listed.
cache_validity is 0 throughout, which is why the condition added by
84800a8d1d22 never fires.
To confirm, I added this (experiment only, not a proposed fix):
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ static int nfs_update_inode(...)
} else if (!have_delegation) {
nfs_ooo_record(nfsi, fattr);
nfs_ooo_merge(...);
+ } else if (S_ISDIR(inode->i_mode)) {
+ nfs_force_lookup_revalidate(inode);
}
With it the kprobe fires once per directory at the delegation grant and
all 8 files are visible at the first lookup.
Notes: the two self-built kernels use the Ubuntu tree at the 44.44 tag
with a localmodconfig-reduced config (NFSv4 client options unchanged).
Each non-stock variant was run once. I can attach the full traces.
Regression: <to be confirmed by you>
I will file the runtime-switch hang separately. Reproducing it might be
more risky and thus difficult.
Regards
Benjamin
_________________________________
IO ANALYTICA
+49 (171) 93 111 44
[email protected]
https://ioanalytica.com
PGP: D624 FD12 5790 BCDC 3932 1766 1D98 013A 4F78 8B82
> On 1. Dec 2026, at 12:38, Andrei Gherzan <[email protected]> wrote:
>
> Hello. Thanks for this. It would be very useful if you were able to
> build and test with the commit you are referencing applied (or confirm
> it cleanly applies against your 7.0.0-44.44 tree). That would help
> confirm it's the right fix.
>
> The hang you saw after flipping directory_delegations=N at runtime on a
> client holding ~18,000 delegations sounds like a distinct issue to me.
> It might be worth its own bug report with whatever logs you have from
> that incident (console output, server-side delegation counts over time).
>
> One more question: have you seen this behave correctly on an older
> Ubuntu/kernel release? Trying to work out whether this is a regression
> or a long-standing gap.
>
> Thanks,
> Andrei
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/2178273
>
> Title:
> NFSv4.2 client returns ENOENT indefinitely for a file created by
> another client once it holds a directory delegation
>
> Status in linux package in Ubuntu:
> New
>
> Bug description:
> SUMMARY
>
> With NFSv4 directory delegations enabled (the default,
> nfsv4.directory_delegations=Y), a client can report ENOENT for a file
> that another client created minutes, hours or days ago. The stale
> negative dentry is never revalidated for as long as the client holds a
> directory delegation on the parent directory and nobody changes that
> directory again. Listing the directory on the affected client (ls,
> find) makes the file appear immediately.
>
> Booting the affected client with "options nfsv4
> directory_delegations=N" makes the problem disappear.
>
> IMPACT
>
> Any application that runs on several NFS clients, probes for a name
> and expects to see it after another node has written it. Observed in
> production with a clustered file-sync server (two nodes, shared object
> store on NFS): node A checks whether an object exists, node B writes
> it (temp file + rename), node A then fails to read it. Individual
> objects stayed invisible on one node for up to 85 hours, until the
> node was rebooted. Sync clients reported "failed to upload blocks".
>
> ENVIRONMENT
>
> Distribution: Ubuntu 26.04.1 LTS (resolute)
> Client kernel: 7.0.0-44-generic (7.0.0-44.44); also seen with 7.0.0-43.43
> Client /proc/version_signature: Ubuntu 7.0.0-44.44-generic 7.0.14
> Architecture: reproduced with arm64 clients and with amd64 clients; the
> server is amd64
> Server kernel: 7.0.0-43-generic (7.0.0-43.43), knfsd, at the time of the
> tests
> nfs-utils: 1:2.8.5-1ubuntu1 on client and server
> Exported filesystem: XFS, export options
> rw,async,no_subtree_check,no_root_squash,sec=sys
> Mount options:
> vers=4.2,hard,proto=tcp,timeo=600,retrans=2,rsize=1048576,wsize=1048576,sec=sys
> (defaults acdirmin=30, acdirmax=60, lookupcache=all)
>
> REPRODUCER
>
> Two clients A and B mount the same export at /mnt/t. The reader on A
> must be ONE long-lived process, like a daemon. If every step runs in a
> fresh login session the problem does not show: a new session makes the
> client send ACCESS for the directory, which refreshes the cached
> directory attributes.
>
> # B: prepare a directory with one existing file, then leave it alone for
> >= 75 s
> mkdir /mnt/t/d && echo x > /mnt/t/d/g
>
> # A: ONE shell, as root, running all of the following without interruption
> D=/mnt/t/d
> # 1) for 30 s: look up the missing name and read the existing file
> for i in $(seq 10); do [ -e $D/f ]; cat $D/g >/dev/null; sleep 3; done
> sleep 4 # B creates the file during this pause (see below)
> # 2) for 50 s: keep reading the OTHER file; never touch f, never list the
> directory
> for i in $(seq 25); do cat $D/g >/dev/null; sleep 2; done
> # 3) now look up f by name
> for i in $(seq 36); do [ -e $D/f ] && { echo visible; break; }; sleep 5;
> done
>
> # B: about 3 s after A finished step 1
> echo x > /mnt/t/d/f.tmp && mv /mnt/t/d/f.tmp /mnt/t/d/f
>
> Result with directory_delegations=Y on A:
> /mnt/t/d/f stays ENOENT on A (checked for 180 s, i.e. three times acdirmax;
> in production for days). "ls /mnt/t/d" on A lists f, and from then on f can
> be opened by name.
> On the server, /proc/fs/nfsd/clients/*/states shows no delegation for A on d
> before B creates the file, and a read delegation for A on d from about 13 s
> after the create until the end of the test. B holds one as well.
>
> Result with "options nfsv4 directory_delegations=N" on A (set in
> /etc/modprobe.d, client rebooted):
> f is visible in step 3 at the first lookup. A holds no delegation on d.
>
> Runs (8 directories each, same server, same two clients):
>
> Reader A delegations on, writer B on: 0 of 8 files
> visible on A after 180 s
> Reader A delegations OFF, writer B on: 8 of 8
> Reader A delegations OFF, writer B on (repeat): 8 of 8
> Reader A delegations on, writer B OFF (roles swapped): 0 of 8
>
> The same sequence gave 0 of 8 on a second pair of clients in another
> cluster against the same server.
>
> Sequences that do NOT reproduce it:
> - A holds the delegation before B creates the file: the server recalls it
> and A sees the file at once.
> - A stays away from the directory for longer than acdirmax after the create
> and only then touches it: A revalidates the directory first and sees the file.
> - A only repeats the lookup of f and reads nothing else in the directory: f
> appears after about 60 s (ordinary attribute cache timeout).
>
> So the negative dentry survives when A obtains the directory
> delegation AFTER the remote create, but WITHIN the attribute cache
> lifetime of the directory.
>
> ANALYSIS (from reading v7.0 fs/nfs; not verified with tracing)
>
> - nfs_neg_need_reval() trusts a negative dentry if nfs_check_verifier()
> passes, i.e. if the dentry's verifier still equals the directory's cached
> change attribute.
> - While a directory delegation is held, the cached directory attributes are
> treated as authoritative: nfs_attribute_cache_expired() returns 0 for
> delegated attributes, and __nfs_revalidate_inode() returns early for a
> directory with a delegation:
>
> } else if (nfs_have_directory_delegation(inode)) {
> status = 0;
> goto out;
> }
>
> - A directory delegation is requested with the next GETATTR after
> ACCESS, CREATE, REMOVE or RENAME on the directory
> (should_request_dir_deleg()).
>
> What I could not determine is why the client keeps the pre-create
> change attribute and the old negative dentry when the delegation is
> granted after the create; the GETATTR that carries GET_DIR_DELEGATION
> should have returned the new change attribute.
>
> Upstream commit 84800a8d1d22 ("nfs: don't skip revalidate on directory
> delegation when attrs flagged stale", v7.2) touches the early return
> quoted above. It is not in the Ubuntu 7.0.0-44.44 kernel. I have not
> tested whether it fixes this case, and I have not tested a mainline
> kernel.
>
> WORKAROUNDS
>
> - "options nfsv4 directory_delegations=N" in /etc/modprobe.d/, then reboot
> the client. Verified above; rolled out to 14 clients.
> - By code reading, lookupcache=positive should also avoid the stale negative
> dentry (NFS_MOUNT_LOOKUP_CACHE_NONEG is checked before the verifier). Not
> tested.
>
> SIDE NOTE: DO NOT CHANGE THE PARAMETER AT RUN TIME
>
> Writing N to /sys/module/nfsv4/parameters/directory_delegations on a
> busy client that held about 18,000 delegations made that client
> unusable within two minutes: NFS operations stalled, new processes
> could no longer be started (SSH logins and container execs hung), and
> the machine needed a hard reset. On the server the client's delegation
> count dropped from 18,261 to 5,431 and then stopped.
> nfs4_have_delegation() marks a held directory delegation for return on
> every check once the parameter is off, so this looks like a mass
> return gone wrong. Observed once, not investigated further.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2178273/+subscriptions
>
** Attachment added: "lp2178273-traces.zip"
https://bugs.launchpad.net/bugs/2178273/+attachment/6022526/+files/lp2178273-traces.zip
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2178273
Title:
NFSv4.2 client returns ENOENT indefinitely for a file created by
another client once it holds a directory delegation
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2178273/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs