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=1796381441; b=I4HIbP44FEbHlFm9uVuCBWoywM1HxtoZJKSUuc4a4DLK0oDZLiy42m/KsHH0GtAVbpXP Xy3CIkzRRiJeDzK7umaqtmd9UDLe9BJKLMrFiK0K/IWExFGv7VEf094C084WoGqEavIXS o9P99w00RC+o1XTaF6dOrI05Uc6bbT8e0BeVnOzLTkcsDrW2OOcbzAa3WKacoAfkzDJLb k2EJyWMY0NPVaZ1zR81XA/0kkbuVYmEhWd9xbAXSHdaP6EQC+O/iS842xIq4g48Pp/+sF hnXO6y9nPBaNJecqV92b34LIT6czWk01O7A5Rc3b88z+X2WrSuXGOQNN7Pxyf5Xu+Ag== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381441; 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=basUOYZyz5G86pOCz50dJMxqk/UKyZG5EExNctGfcak=; b=CwySg5UYFxmFVE+Ry79fw7MyxLRxq5MNm2CZXw3hNH0eo9PDdypha5EI+WPc6FHoRHaJ qoZK2y2QS8zm8kFzd7gDf4ZmDKYz2mMT5rBqDsK3OmKcyAiOx9Ys9zTBIbZOFXOgvRgjS 4sYfQ65UEaqZCD1VEtPKdSOjBuHUcQkCZ0D0KSQ7GaIHmZHvFyJnpolZdVErJaUBgEj9P zO4CaDYQnYCJ4SuENZSTDzjYKE07Wu+cP2Gu5YxyXXkQyQqCeY1lrU0gTv3OcqdT0CR7A EmWadvK5HL2vzhPGMn32cUpCmfVfZSrDaH7U8PxXGiBdPCnE4/fgjPxieeXvkYgKwDA== 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=ab5O1JVF; 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 16FB2606A338; Fri, 4 Dec 2026 10:50:41 +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=ab5O1JVF Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80E4E1F000CE; Fri, 4 Dec 2026 10:50:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381440; bh=basUOYZyz5G86pOCz50dJMxqk/UKyZG5EExNctGfcak=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ab5O1JVFZIxVAc6jfxxPe3o18pd4GDyadDH27EpAlkp2aVbJHuAdpOecGCDYj8ir1 YQJFFMYke5MzetrzAJ2r8+aIVYMdTKdAusIxAhZY8b4hXCFMW8ePMp93uigcFaKemm 23oRuUwY3E3Agx4GaNd2inSP3UgcZkvgXPgwvuec= 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 665/742] smb: client: fix busy dentry on unmount from persistent handle reopen Date: Fri, 4 Dec 2026 19:08:49 +0900 Message-ID: <20261204100652.737673066@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: 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 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Siddharth Chintamaneni commit 340ca61e9d31c31403013dc9190550d615844828 upstream. 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 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 @@ -1876,6 +1876,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) @@ -1890,17 +1891,22 @@ 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); 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); /* do not flush */ if (cifs_reopen_file(open_file, false, 0)) 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); } }