From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796381439; b=BEWQoRnRU47WJivdVhU8DQu0e0Mj30FZDfYD22Fa1vmTQC+Wxys/+XZTwSHAiSpy2DVy 0GFp5hx3thl2TtfGSaDLrM23j2hVzSdW/7iU+MSKAXiyBqHZJTC9uCjRaFGWSS8CZmdVV 6oORPW4sY2wobFjyQrurQmbwznc7Sjx5EnoEnDqcgRCQMAp+ofgXENSLvwCtsytwveuO8 s4d/Ffv15ZTfyNLUyyzV5fO+p0YosgUvMlbjbzCD1yjSnZS0Xwqml36fVkabLYDlaLApj nHcjsLG2XuGmXDySMHvO81vAldgd6tgpzSV8cx8TqaiNbUEz64gIiMSvz718DHRDn+A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381439; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=CFCYOf4VRoOmuESFuaCvzqQhpJMnF0lxU1GAAJC0Wws=; b=WEnsEDRy008TelfiEcQO3TaErTSe61hEbdqIMPz69QUIiM16iANCdZPfmMVuhE7CooC5 yv4zA86V/IotGDEtbir1SDa1gQBK6cd4/WQ/noetNby1C/Ti8k6PArPzh7oZMfjreWvQi GMrEcLbGY3ldUDZwygGyLqftWPMt0agB8wc1XwhTeN7TmGW6nOH8CZfkXVgcGcDIlstVF UA+qX6+dR6sYV3MMAHioCScpGJ4j4L4DkOiQv/YDdcb2C+ETjXxoD/XZQdloYLtiZwxCs jwmr4WdA8JA4xzRaH4V3mBe60BxBH2kyd7yBhRiOCXHVPgnAGv+tNV0BDQ4sAoP38EA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=YYnrDto2; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A449606A32C; Fri, 4 Dec 2026 10:50:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=YYnrDto2 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A7901F000C2; Fri, 4 Dec 2026 10:50:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381438; bh=CFCYOf4VRoOmuESFuaCvzqQhpJMnF0lxU1GAAJC0Wws=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=YYnrDto2g4JFMKguX34q6SXoLqQ3QdTnIHdxNRBQH63PF4u+mkid8bBEVUex+Igli JGLlqh08BmHwy36AR2KFjyDXykA095igH025ziG8TShKFKC92qEQIWqXjd9oCH7Wv8 qvnq3L3jrvSFG3ILg3m0ltDEhg2kLTKS9gPaAmLA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Adam Kim , Siddharth Chintamaneni , Paulo Alcantara Subject: [PATCH 7.3 664/742] smb: client: fix busy dentry and inode on unmount from late oplock break Date: Fri, 4 Dec 2026 19:08:48 +0900 Message-ID: <20261204100652.712923468@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Siddharth Chintamaneni commit a10ec8dba77799a0460a4b3dfcac040ac452a325 upstream. 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 Signed-off-by: Siddharth Chintamaneni Signed-off-by: Paulo Alcantara Signed-off-by: Greg Kroah-Hartman --- fs/smb/client/cifsfs.c | 10 +++++----- fs/smb/client/file.c | 2 ++ fs/smb/client/misc.c | 6 +++++- 3 files changed, 12 insertions(+), 6 deletions(-) --- a/fs/smb/client/cifsfs.c +++ b/fs/smb/client/cifsfs.c @@ -380,11 +380,11 @@ static void cifs_kill_sb(struct super_bl flush_workqueue(deferredclose_wq); /* - * Wait for all in-flight netfs I/O requests to finish their - * cleanup_work so that any cifsFileInfo final puts they queue - * to fileinfo_put_wq/serverclose_wq have been queued, then - * drain the workqueue so the cfile dentry refs are dropped to - * avoid the busy dentry warning. + * Wait for all in-flight netfs I/O requests and oplock breaks + * to finish so that any cifsFileInfo final puts they queue to + * fileinfo_put_wq/serverclose_wq have been queued, then drain + * the workqueue so the cfile dentry refs are dropped to avoid + * the busy dentry warning. */ wait_var_event(&cifs_sb->outstanding_rreq, !atomic_read(&cifs_sb->outstanding_rreq)); --- a/fs/smb/client/file.c +++ b/fs/smb/client/file.c @@ -3848,6 +3848,8 @@ oplock_break_ack: out: cifs_done_oplock_break(cinode); iput(inode); + if (atomic_dec_and_test(&cifs_sb->outstanding_rreq)) + wake_up_var(&cifs_sb->outstanding_rreq); } #ifdef CONFIG_SWAP --- a/fs/smb/client/misc.c +++ b/fs/smb/client/misc.c @@ -373,6 +373,8 @@ void cifs_put_writer(struct cifsInodeInf */ void cifs_queue_oplock_break(struct cifsFileInfo *cfile) { + struct cifs_sb_info *cifs_sb = CIFS_SB(cfile->dentry); + /* * Bump the handle refcount now while we hold the * open_file_lock to enforce the validity of it for the oplock @@ -381,8 +383,10 @@ void cifs_queue_oplock_break(struct cifs * * Only take a reference if the work is actually queued. */ - if (queue_work(cifsoplockd_wq, &cfile->oplock_break)) + if (queue_work(cifsoplockd_wq, &cfile->oplock_break)) { cifsFileInfo_get(cfile); + atomic_inc(&cifs_sb->outstanding_rreq); + } } void cifs_done_oplock_break(struct cifsInodeInfo *cinode)