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=1796384811; b=TYP3pGQEe2cPo25Wo7Q9GJry7dysAVlkSE+134DTKcDk5KHKosAT4pX0bEoomzSy0ZR+ 3BqBJSPw1sScHCqucxXG15SKqVT50wI6txBbJy9SHI1DI3hjsiIrfMLPYFOn1qt9ARjXZ MVssyO71G2rBH5JYXKK2yqHNcSOhwUb1CX4jYB5/3eCfEYn/K8FWuuD/6YQcMShUHj+lC k5Gp86x4+gaLDaD8L77W5jnlo1n8yjVyNj+Ynv3ew/B51aGFSlHaZrJwzFxMMNcRdHyNZ BNpo8NL97oHA25phgD5IjG9M0dIz1faolorkEJVIk4CC63BkEb+O9gESsDnMqwMJIrA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384811; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=S5jV7CiTCjZDuuKNBOfyZ7QUMizzRapgWBvG2ANsns4=; b=aH/VywXpONd2jjX5JrUodIZlPlZ3n27SgvICa2Xl3ds5SFIVofKWEjDOOYg2WEJ8sGud ItpwS5BHXf4+x6ecE4JyFzEm5B4J1vfRtpLMkW/cFYyKbHZ1femxvPk5hUqGJDhOcTH9S uXN+YxxEv2/nAf/S7GlZIyY9rPq0NYAHKKCFa0ngokGwcQBl6i5Rn1gOMckOH598j/UnP koY3fqoxhbrXKNSSatwBhy4gAXnxeUyuwwSciry+TJKi9IsChCMx9ka1O2YuOBpXU3Loy k+/Re/HSp3NO/pHZaTADAkkFjK1+xIwciZHTauc8N9ERCEpwJfctuRn8vIyc7NaKlIA== 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=IG0VJ7xE; 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 B8C7F606A322 for ; Fri, 4 Dec 2026 11:46:51 +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=IG0VJ7xE Received: by smtp.kernel.org (Postfix) with ESMTPSA id E52981F00897; Fri, 4 Dec 2026 11:46:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796384811; bh=S5jV7CiTCjZDuuKNBOfyZ7QUMizzRapgWBvG2ANsns4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=IG0VJ7xEQe4ZOaPd1v0s4hTXFt0rGmTH82lpLF9pFDTDbDxT+8wCjfNGsGGEfLy/T r/QPZFpeFa2nABPDDWbzugMLq1NBSqtUsKH5zZcZYloY3j+5Y9DxSsNyhOO7ryswwe bv95X5+wcVWXdfkMdpb9FBWR+3cUTL3kOUlK82uBImocE89jvUmFBZHIKYqmiTFq3P TLI/v/+2SxphlBMjmOqmrDnc6dzUOskr13Pi/VDsNIJ5t05AOBedkFl7UTcYmI8ZoU BJ9l7rH7rqCIv/MiHAYXIhis3iNinM8MVUz1CJZgD0cfq25Ysk19DkdhBbTb7Mu5ES QuQrX6SPMiy5A== From: Sasha Levin To: stable@vger.kernel.org Cc: Siddharth Chintamaneni , Adam Kim , Paulo Alcantara , Sasha Levin Subject: [PATCH 6.1.y] smb: client: fix busy dentry on unmount from persistent handle reopen Date: Fri, 4 Dec 2026 06:46:49 -0500 Message-ID: <20261204114603.2825038-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026120201-tattling-kung-1c6a@gregkh> References: <2026120201-tattling-kung-1c6a@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: adapted to older API: CIFS_SB(open_file->dentry->d_sb), outstanding_aio instead of outstanding_rreq, and the older cifs_reopen_persistent_handles/cifs_reopen_file signatures ] 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 55f33278078d1..e128a8177816a 100644 --- a/fs/smb/client/file.c +++ b/fs/smb/client/file.c @@ -1085,6 +1085,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) @@ -1100,16 +1101,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