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=1796382930; b=pUQqp3j2WlTNtiInUij+zQ4wzsAsAxMTTBx8tts4c76+nqaX0FZeOrVhCpqgFwX1WdvL Gn38EziwvPMHhmfQ3xFbRuEWxRXVkqQ2tCW0Fyl49WHhy939E41BZGvoxD/1Z2kW3q6ZP BpBBkGDp2wz2KWjHyLkunNbHJ7IkU+p1/Bna3M0l80sECr/TV6Mc+xRKK51aFMYGDxDLa Zi1H0ttK25P9EE2QNu+MuNjh5TULBLgMsEEa2+JJVpnOYrneHThtka1+ysCUtD/pXDq3A RYU8tNTjVv7gfxbTQ/AjHqzWnJtBZ7ZjWq6vQyB8adqaZTZ68u4XUMx6LdLi96zuGFw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382930; 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=+FejNDPJcM+JKB8bf7omCnhrIoeRhpZMvmq6XOE87VE=; b=1RriBK3bg/vZXPchzwBTBcgmTz9J5pL4+fEcr4kbpL0gY8wH5mtNhu3td7FVgNfrkZ91 23o4gD7XpnHc60IQ1OU3oqUgfEGU0cZ3rGSxPot4/AhQM0AE8v/JKDovDCcKdGWeMhknL lrefNheKddl4nB73At86jjfrJw/6DJOfn0SA8c0mp1v8xEswZT2IeHH61PjlrIiHx3nar vd2fcIGBtYeenz/wrrVw0g+sbNRUZlhBKANrv2Aq7cX9OE9E+uFh06ufzBLr/8aCt/CLs kZOLzxaL3TNuYHtF/ZipHxiaVA30qGlVDHv3jQCSC2rp2g0BMySthJGPCKflvXC7USg== 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="xLuAGX//"; 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 E4E72606A322; Fri, 4 Dec 2026 11:15:29 +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=xLuAGX// Received: by smtp.kernel.org (Postfix) with ESMTPSA id E995F1F0092C; Fri, 4 Dec 2026 11:15:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382929; bh=+FejNDPJcM+JKB8bf7omCnhrIoeRhpZMvmq6XOE87VE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=xLuAGX//gS7PGFgwtNnUFUZ5wPk5YfHne91SrPAWuqfytmJ8Mn+i4JgHo+J1zLtj3 kYGq7FXQ5QgAP5YULgPS8JcN+IwP19mXtd6qkhnZHcCsTJL+yS7Nk24sq3WiNKcnpH 8gdKU4ninEBGbLsX78TC2qABGiXxpFz6AQQ4MCIk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Adam Kim , Siddharth Chintamaneni , Paulo Alcantara , Sasha Levin Subject: [PATCH 6.18 654/703] smb: client: fix busy dentry on unmount from persistent handle reopen Date: Fri, 4 Dec 2026 19:09:13 +0900 Message-ID: <20261204100645.179810320@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Siddharth Chintamaneni [ Upstream commit 340ca61e9d31c31403013dc9190550d615844828 ] During unmount, cifs_kill_sb() waits on cifs_sb->outstanding_rreq for in-flight netfs I/O requests and oplock breaks to complete before flushing serverclose_wq and fileinfo_put_wq. While cifs_kill_sb() is waiting on outstanding_rreq, any cifsFileInfo referenced by an in-flight request (req->cfile) remains on tcon->openFileList. On a mount using persistent handles, if a reconnect runs on cifsiod_wq during this window, smb2_reconnect_server() calls cifs_reopen_persistent_handles(), which walks tcon->openFileList and takes a new reference on open_file via cifsFileInfo_get() to reopen the handle over the network: Thread 1 (umount) Thread 2 (cifsiod_wq) Thread 3 (workers) ----------------- --------------------- ------------------ cifs_kill_sb() wait(outstanding_rreq) [blocks: rreq == 1] smb2_reconnect_server() cifs_reopen_persistent_handles() finds open_file on list cifsFileInfo_get(open_file) [cfile->count: 1 -> 2] cifs_reopen_file() 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! Fix this by incrementing cifs_sb->outstanding_rreq when cifs_reopen_persistent_handles() takes a reference on open_file and decrementing it after cifsFileInfo_put(open_file), so wait_var_event() in cifs_kill_sb() waits for any in-progress persistent handle reopen to finish and queue its final put before draining fileinfo_put_wq. 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 [ sashal: Replaced the upstream CIFS_SB(open_file->dentry) with CIFS_SB(open_file->dentry->d_sb) and kept this tree's older void reopen function, without the bounded-reopen flags. ] Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/smb/client/file.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/fs/smb/client/file.c +++ b/fs/smb/client/file.c @@ -1583,6 +1583,7 @@ void cifs_reopen_persistent_handles(struct cifs_tcon *tcon) { struct cifsFileInfo *open_file, *tmp; + struct cifs_sb_info *cifs_sb; LIST_HEAD(tmp_list); if (!tcon->use_persistent || !tcon->need_reopen_files) @@ -1597,16 +1598,21 @@ cifs_reopen_persistent_handles(struct ci list_for_each_entry(open_file, &tcon->openFileList, tlist) { if (!open_file->invalidHandle) continue; + cifs_sb = CIFS_SB(open_file->dentry->d_sb); cifsFileInfo_get(open_file); + atomic_inc(&cifs_sb->outstanding_rreq); list_add_tail(&open_file->rlist, &tmp_list); } spin_unlock(&tcon->open_file_lock); list_for_each_entry_safe(open_file, tmp, &tmp_list, rlist) { + cifs_sb = CIFS_SB(open_file->dentry->d_sb); if (cifs_reopen_file(open_file, false /* do not flush */)) tcon->need_reopen_files = true; list_del_init(&open_file->rlist); cifsFileInfo_put(open_file); + if (atomic_dec_and_test(&cifs_sb->outstanding_rreq)) + wake_up_var(&cifs_sb->outstanding_rreq); } }