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. The full traces are in the attached
lp2178273-traces.zip.

Regression: I cannot answer that from our own history. We have no clean
comparison run on an older release, and the application had intermittent
problems before that I cannot attribute. What I can say from the source:
the client-side directory delegation code (the directory_delegations
parameter and the GET_DIR_DELEGATION request in _nfs4_proc_getattr) is
not in v6.8, v6.17 or v6.18 and first appears in v6.19. So this is not a
long-standing gap in older Ubuntu kernels; it came in with the new
feature, which is on by default in the 26.04 kernel.

-- 
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

Reply via email to