[PATCH] Revert "cifs: remove all cifs files before kill super"

From: Zizhi Wo

Date: Mon Aug 17 2026 - 23:13:27 EST


From: Zizhi Wo <wozizhi@xxxxxxxxxx>

This reverts commit 6d9a4aaaa8b2612b5ef9d581e2f286a458b71ee1.

First, directly flushing fileinfo_put_wq in that commit cannot guarantee
that all in-flight I/O has run its cleanup_work on system_dfl_wq and
subsequently called queue_work(fileinfo_put_wq, ...). Flushing only the
latter workqueue may therefore miss puts that have not yet been queued, so
the fix is not reliable in the first place. Moreover, this fix flushes
inside cifs_umount(), which means the busy-dentry warning can still be
triggered when umount_check() is called inside kill_anon_super(), because
kill_anon_super() is executed before cifs_umount().

Second, commit 75f5c412fa86 ("smb: client: fix busy dentry warning on
unmount after DIO") already drains both serverclose_wq and fileinfo_put_wq
in cifs_kill_sb(), before kill_anon_super(). By adding a per-superblock
outstanding-rreq counter, it guarantees that all cleanup_work for this sb
have run, and thus all relevant cfile puts are queued on fileinfo_put_wq
or serverclose_wq.

Third, no path between those drains and cifs_umount() can queue new work
onto either workqueue. In the "cifs_sb->root == NULL" path there are no
file-related workers either, so that case is safe as well.

Therefore the busy-dentry and null-ptr-deref problems cannot arise, and
the flush added by commit 6d9a4aaaa8b2 ("cifs: remove all cifs files before
kill super") is redundant and can be removed.

Signed-off-by: Zizhi Wo <wozizhi@xxxxxxxxxx>
---
fs/smb/client/connect.c | 3 ---
1 file changed, 3 deletions(-)

diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c
index ba749ec25a59..f9764f65430e 100644
--- a/fs/smb/client/connect.c
+++ b/fs/smb/client/connect.c
@@ -4001,13 +4001,10 @@ cifs_umount(struct cifs_sb_info *cifs_sb)
cifs_put_tlink(tlink);
spin_lock(&cifs_sb->tlink_tree_lock);
}
spin_unlock(&cifs_sb->tlink_tree_lock);

- flush_workqueue(serverclose_wq);
- flush_workqueue(fileinfo_put_wq);
-
kfree(cifs_sb->prepath);
call_rcu(&cifs_sb->rcu, delayed_free);
}

int
--
2.52.0