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=1796363028; b=m6eUfNTTI0KkVb2L+oqaXGVdbqPu/BaxyjhxlObvQGFy2AxKjCljkwnXksPzSsbJb63V oOysxmA5ZBgakcKgH1YdXHRHuAaq1kbzcr7ZsPOXVo9kVt1mFSrcTwNiA23B1Orlgu1vg YAJBzi1OF0WJZbywYe6YC82qd/cd9kgj1FcwFo84MLvGSzy4rFQczxqtIzgAX0RUDeJga +jo/5BvP3BOBcHWQx+RyiCEabrnxKGOc+3fdxD4eHlJ1hu3khmil7UI9Ysu6qmZYJsRME lnjEedMka6paCnoaqSD3qTEyRWDgQ0SxkB+yVcwD5FCZI1bcjXsYD+DVKAfqOgh9wvA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796363028; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=ajCJPmm1Uh5AcYoCwIL/+TFErJUm0RYNseUhRGyF4OI=; b=qYzp0iIdrt66hQvKCNNtIAq7R58DzSy8ehd/9O9oPGnzjlAhpBz6Am4Szmud1kErNEHL JRf6AE6GjpMq/cbQWYf9g1Fsu6zN+o3atnxhwcJgjs27q974nq6mefuN4IcQSJLK8EYA1 d5VbE2E8oYW3bFgxe/EPVXTLbxS7KxQtw2cB/+l0vxc6QcseRkRjWpHMvLw7oNdDV1BJx T4TslvverNs56c6wsnXJTRO3vRGiSmuWN7dArPMrPa+Z6Ld87DSHG9KBss9pZ0SLOao9w DsV8kLE0p1uVRAKjuufeTMOItx4VYrorJ5iolThs8riES3W8cj04rGKaYWsS9hmasbw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XXEEAjde; 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 E1B90606A332 for ; Fri, 4 Dec 2026 05:43:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XXEEAjde Received: by smtp.kernel.org (Postfix) with ESMTPSA id D03341F0092C; Fri, 4 Dec 2026 05:43:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796363027; bh=ajCJPmm1Uh5AcYoCwIL/+TFErJUm0RYNseUhRGyF4OI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=XXEEAjdezfxhqGummkEFV/4n3z1U5t/dtgv0UnrGKuZpswDiRtzBte2Z7qtUjI7OU yoYFkEU7Gd/ImOCW23czc97KwiEUmuDs+sjaUIS39jeFvY/SiTW/1FRzoRcC40W7cW KcVpXfeOtSfgXOq8Z0UP+yBHqlz5Si0DLKpVYRVZiQ2hszsJZUrsf2uAwsqhR123EJ YZEO1PG39jt87JuQkjVO7NVx1j00jYf4CmD+blmdFreG3jbyfg+kcXeVyZ21mK1Wff 1A448z+GwRPm3hGALavMOisyZ+1eUq4zfZ1Nzcz7TnRjTEWWLkASHWPqXDTqr0mZ+b H1hyoWmHBjjHQ== From: Sasha Levin To: stable@vger.kernel.org Cc: Siddharth Chintamaneni , Adam Kim , Paulo Alcantara , Sasha Levin Subject: [PATCH 6.6.y] smb: client: fix busy dentry on unmount from persistent handle reopen Date: Fri, 4 Dec 2026 00:43:45 -0500 Message-ID: <20261204054323.2818012-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026120201-worry-unopposed-16b7@gregkh> References: <2026120201-worry-unopposed-16b7@gregkh> 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 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 6.6 outstanding_aio counter and CIFS_SB(dentry->d_sb) for upstream's outstanding_rreq and CIFS_SB(dentry), and kept the older void-returning cifs_reopen_file() without the bound/nowait flags. ] Signed-off-by: Sasha Levin --- fs/smb/client/file.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c index 6fb4578eb0e0b..0653b852d6580 100644 --- a/fs/smb/client/file.c +++ b/fs/smb/client/file.c @@ -1303,6 +1303,7 @@ void cifs_reopen_persistent_handles(struct cifs_tcon *tcon) { struct cifsFileInfo *open_file, *tmp; + struct cifs_sb_info *cifs_sb; struct list_head tmp_list; if (!tcon->use_persistent || !tcon->need_reopen_files) @@ -1318,16 +1319,21 @@ cifs_reopen_persistent_handles(struct cifs_tcon *tcon) 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_aio); 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_aio)) + wake_up_var(&cifs_sb->outstanding_aio); } } -- 2.53.0