Public bug reported:

Split out from LP: #2178273.

Ubuntu 26.04.1, client kernel 7.0.0-44.44 (amd64), server knfsd on 7.0.0-44.44, 
NFSv4.2.
Client /proc/version_signature: Ubuntu 7.0.0-44.44-generic 7.0.14

Steps:
1. Client holds read delegations on 20,000 directories (verified in 
/proc/fs/nfsd/clients/*/states on the server).
2. Three processes on the client keep creating files in those directories 
(open(O_CREAT) in a loop).
3. echo N > /sys/module/nfsv4/parameters/directory_delegations

Result: all three writers stop immediately. The server-side delegation
count drops from 20,005 to 5,663 and stays there. After 45 s: "watchdog:
BUG: soft lockup - CPU#0 stuck for 45s! [bash:3049]", later on five
CPUs, plus "rcu_preempt self-detected stall". Tasks then block in
cgroup_procs_write -> synchronize_rcu, so systemd can no longer start
units or sessions; about two minutes later sshd stops accepting
connections while the host still answers ping. Only a hard reset helps.

With lookup/stat-only load instead of creates, the same switch returns
all 20,000 delegations within about a second and nothing hangs.

Stack of the stuck writers:

  _raw_spin_lock
  nfs_clear_verifier_delegated [nfs]
  nfs4_inode_set_return_delegation_on_close [nfsv4]
  nfs4_have_delegation [nfsv4]
  nfs4_update_changeattr_locked [nfsv4]     <- called with dir->i_lock held
  _nfs4_proc_open [nfsv4]
  ...
  nfs_atomic_open [nfs]

Other CPUs are stuck with this stack (state manager thread, and path
walk via nfs_permission). I cannot tell whether this is a second
deadlock or these tasks are just waiting for an i_lock held by one of
the stuck writers:

  _raw_spin_lock
  nfs_clear_verifier_delegated [nfs]
  nfs4_inode_set_return_delegation_on_close [nfsv4]
  nfs4_have_delegation [nfsv4]
  nfs_clear_verifier_delegated [nfs]
  nfs_server_return_marked_delegations [nfsv4]
  nfs4_state_manager [nfsv4]

nfs4_have_delegation() calls nfs4_inode_set_return_delegation_on_close()
for a directory whenever directory_delegations is off, and that path
takes inode->i_lock in nfs_clear_verifier_delegated().
nfs4_update_changeattr_locked() calls nfs4_have_delegation() with that
lock already held.

Reproduced once. Full client dmesg, script output and server delegation
counts attached. Not run on mainline, but the functions on this path
(nfs4_have_delegation, nfs4_inode_set_return_delegation_on_close,
nfs_clear_verifier_delegated, nfs4_update_changeattr_locked) are
textually identical in v7.4-rc5.

** Affects: linux (Ubuntu)
     Importance: Undecided
         Status: New

** Attachment added: "Client kernel log (dmesg) of the hang: soft lockups, RCU 
stall, blocked tasks, sysrq-w/l/t output"
   
https://bugs.launchpad.net/bugs/2178553/+attachment/6022535/+files/client-dmesg.log

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2178553

Title:
  NFSv4 client deadlocks on inode->i_lock when
  nfsv4.directory_delegations is set to N at run time while directory
  delegations are held

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2178553/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to