nfs_common: need lock during iterate through the list
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hello!
Quoted 56 lines · Yi Wang
From: Cheng Lin <[email protected]>
If the elem is deleted during be iterated on it, the iteration process will fall into an endless loop.
kernel: NMI watchdog: BUG: soft lockup - CPU#4 stuck for 22s! [nfsd:17137]
PID: 17137 TASK:
ffff8818d93c0000CPU: 4 COMMAND: "nfsd"[exception RIP: __state_in_grace+76] RIP: ffffffffc00e817c RSP: ffff8818d3aefc98 RFLAGS: 00000246 RAX: ffff881dc0c38298 RBX: ffffffff81b03580 RCX: ffff881dc02c9f50 RDX: ffff881e3fce8500 RSI: 0000000000000001 RDI: ffffffff81b03580 RBP: ffff8818d3aefca0 R8: 0000000000000020 R9: ffff8818d3aefd40 R10: ffff88017fc03800 R11: ffff8818e83933c0 R12: ffff8818d3aefd40 R13: 0000000000000000 R14: ffff8818e8391068 R15: ffff8818fa6e4000 CS: 0010 SS: 0018#0 [
ffff8818d3aefc98]opens_in_graceatffffffffc00e81e3[grace] #1 [ffff8818d3aefca8]nfs4_preprocess_stateid_opatffffffffc02a3e6c[nfsd] #2 [ffff8818d3aefd18]nfsd4_writeatffffffffc028ed5b[nfsd]
#3 [ffff8818d3aefd80]nfsd4_proc_compoundatffffffffc0290a0d[nfsd] #4 [ffff8818d3aefdd0]nfsd_dispatchatffffffffc027b800[nfsd] #5 [ffff8818d3aefe08]svc_process_commonatffffffffc02017f3[sunrpc] #6 [ffff8818d3aefe70]svc_processatffffffffc0201ce3[sunrpc] #7 [ffff8818d3aefe98] nfsd atffffffffc027b117[nfsd]
#8 [ffff8818d3aefec8] kthread atffffffff810b88c1
#9 [ffff8818d3aeff50]ret_from_forkatffffffff816d1607The troublemake elem:
crash>lock_managerffff881dc0c38298
structlock_manager{list = { next = 0xffff881dc0c38298, prev = 0xffff881dc0c38298},
block_opens= false
}Signed-off-by Cheng Lin <[email protected]>Signed-off-by Yi Wang <[email protected]>--- fs/nfs_common/grace.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)fs/nfs_common/grace.c +1
-1@@ -69,10 +69,14 @@ __state_in_grace(struct net *net, bool open)if (!open)return !list_empty (grace_list); +spin_lock (&grace_lock);list_for_each_entry (lm, grace_list, list) { -if (lm->block_opens)
fs/nfs_common/grace.c __state_in_grace(struct net *net, bool open)
Quoted 10 lines
fs/nfs_common/grace.c +4
-1+if (lm->block_opens) { +spin_unlock (&grace_lock);return true; + } } +spin_unlock (&grace_lock);return false; } --
This looks most closely related to NFSD, so I've applied it to my NFSD tree for the next merge window. I've also added
You can find it in the cel-next topic branch in my kernel repo:
git://git.linux-nfs.org/projects/cel/cel-2.6.git
Incidentally, the e-mail encoding mangled the white space and I don't see the e-mail showing up on lore.kernel.org. I applied it by hand since it was small, but this should be addressed for future patches so our patch handling infrastructure can deal properly with your submissions. Thanks!
--
Chuck Lever