diff options
| author | Siddharth Chintamaneni <sidchintamaneni@gmail.com> | 2026-11-17 00:17:32 +0000 |
|---|---|---|
| committer | Paulo Alcantara <pc@manguebit.org> | 2026-11-19 10:40:52 -0300 |
| commit | a10ec8dba77799a0460a4b3dfcac040ac452a325 (patch) | |
| tree | b63662c4ef5d88a6eb7e3e8379345643495153f3 /tools/perf/scripts/python | |
| parent | 2a5bd7a2bbb787483cd69ecf099e2b591e3633b2 (diff) | |
smb: client: fix busy dentry and inode on unmount from late oplock break
During unmount, cifs_kill_sb() flushes cifsoplockd_wq and deferredclose_wq
before waiting on cifs_sb->outstanding_rreq for in-flight netfs I/O
requests to finish their cleanup_work in cifs_free_request().
While cifs_kill_sb() is waiting on outstanding_rreq, any cifsFileInfo
referenced by an in-flight request (req->cfile) still has cfile->count >= 1
and remains on tcon->openFileList. If the SMB server sends a lease or
oplock break for that file during this window, the demultiplex thread
(cifsd) finds cfile on tcon->openFileList and calls
cifs_queue_oplock_break(cfile), which takes a new reference on cfile and
queues cfile->oplock_break onto cifsoplockd_wq after cifsoplockd_wq was
already flushed:
Thread 1 (umount) Thread 2 (cifsd) Thread 3 (workers)
----------------- ---------------- ------------------
cifs_kill_sb()
flush(cifsoplockd_wq)
flush(deferredclose_wq)
wait(outstanding_rreq)
[blocks: rreq == 1]
SMB2 Lease Break
finds cfile on list
cifs_queue_oplock_break()
queue(cifsoplockd_wq)
cifsFileInfo_get(cfile)
[cfile->count: 1 -> 2]
cifs_oplock_break()
ihold(inode)
cifs_free_request()
cifsFileInfo_put()
[cfile->count: 2 -> 1]
dec(outstanding_rreq)
[wakes: rreq == 0]
flush(serverclose_wq)
flush(fileinfo_put_wq)
kill_anon_super(sb)
-> generic_shutdown_super()
BUG: Dentry still in use (1)
VFS: Busy inodes after unmount!
Furthermore, cifs_oplock_break() itself holds the inode via ihold() after
dropping cfile and may initiate writeback via filemap_fdatawrite(),
spawning new netfs I/O requests.
Fix this by counting queued oplock breaks in cifs_sb->outstanding_rreq
from when cifs_queue_oplock_break() queues the work until
cifs_oplock_break() finishes, so wait_var_event() in cifs_kill_sb() waits
for both in-flight I/O requests and any late oplock breaks to complete.
Fixes: 340cea84f691 ("cifs: open files should not hold ref on superblock")
Cc: stable@vger.kernel.org
Reported-by: Adam Kim <adamkim@microsoft.com>
Signed-off-by: Siddharth Chintamaneni <sidchintamaneni@gmail.com>
Signed-off-by: Paulo Alcantara <pc@manguebit.org>
Diffstat (limited to 'tools/perf/scripts/python')
0 files changed, 0 insertions, 0 deletions
