diff mbox series

[5/5] smb: During umount, flush any pending lease breaks for cached dirs

Message ID 20241108222906.3257172-6-paul@darkrain42.org
State New
Headers show
Series SMB cached directory fixes around reconnection/unmounting | expand

Commit Message

Paul Aurich Nov. 8, 2024, 10:29 p.m. UTC
*** WORK IN PROGRESS ***

If a lease break is received right as a filesystem is being unmounted,
it's possible for cifs_kill_sb() to race with a queued
smb2_cached_lease_break(). Since the cfid is no longer on the
cfids->entries list, close_all_cached_dirs() cannot drop the dentry,
leading to the unmount to report these BUGs:

BUG: Dentry ffff88814f37e358{i=1000000000080,n=/}  still in use (2) [unmount of cifs cifs]
VFS: Busy inodes after unmount of cifs (cifs)
------------[ cut here ]------------
kernel BUG at fs/super.c:661!

Flush anything in the cifsiod_wq workqueue in close_all_cached_dirs.

Fixes: ebe98f1447bb ("cifs: enable caching of directories for which a lease is held")
Cc: stable@vger.kernel.org
Signed-off-by: Paul Aurich <paul@darkrain42.org>
---
 fs/smb/client/cached_dir.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Steve French Nov. 8, 2024, 10:33 p.m. UTC | #1
Aah - thanks for this, I will try to test it out as well, and could be
very important if it also addresses a problem with the laundromat
cleanup race (with directory lease freeing) that I have also seen on
umount to Windows server.

Are there other patches in the series you want us to look at and/or
test (your email said patch 5/5)?


On Fri, Nov 8, 2024 at 4:29 PM Paul Aurich <paul@darkrain42.org> wrote:
>
> *** WORK IN PROGRESS ***
>
> If a lease break is received right as a filesystem is being unmounted,
> it's possible for cifs_kill_sb() to race with a queued
> smb2_cached_lease_break(). Since the cfid is no longer on the
> cfids->entries list, close_all_cached_dirs() cannot drop the dentry,
> leading to the unmount to report these BUGs:
>
> BUG: Dentry ffff88814f37e358{i=1000000000080,n=/}  still in use (2) [unmount of cifs cifs]
> VFS: Busy inodes after unmount of cifs (cifs)
> ------------[ cut here ]------------
> kernel BUG at fs/super.c:661!
>
> Flush anything in the cifsiod_wq workqueue in close_all_cached_dirs.
>
> Fixes: ebe98f1447bb ("cifs: enable caching of directories for which a lease is held")
> Cc: stable@vger.kernel.org
> Signed-off-by: Paul Aurich <paul@darkrain42.org>
> ---
>  fs/smb/client/cached_dir.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/fs/smb/client/cached_dir.c b/fs/smb/client/cached_dir.c
> index de1e41abdaf2..931108b3bb4a 100644
> --- a/fs/smb/client/cached_dir.c
> +++ b/fs/smb/client/cached_dir.c
> @@ -482,10 +482,13 @@ void close_all_cached_dirs(struct cifs_sb_info *cifs_sb)
>                 list_for_each_entry(cfid, &cfids->entries, entry) {
>                         dput(cfid->dentry);
>                         cfid->dentry = NULL;
>                 }
>         }
> +
> +       /* Flush any pending lease breaks */
> +       flush_workqueue(cifsiod_wq);
>  }
>
>  /*
>   * Invalidate all cached dirs when a TCON has been reset
>   * due to a session loss.
> --
> 2.45.2
>
>


--
Thanks,

Steve
diff mbox series

Patch

diff --git a/fs/smb/client/cached_dir.c b/fs/smb/client/cached_dir.c
index de1e41abdaf2..931108b3bb4a 100644
--- a/fs/smb/client/cached_dir.c
+++ b/fs/smb/client/cached_dir.c
@@ -482,10 +482,13 @@  void close_all_cached_dirs(struct cifs_sb_info *cifs_sb)
 		list_for_each_entry(cfid, &cfids->entries, entry) {
 			dput(cfid->dentry);
 			cfid->dentry = NULL;
 		}
 	}
+
+	/* Flush any pending lease breaks */
+	flush_workqueue(cifsiod_wq);
 }
 
 /*
  * Invalidate all cached dirs when a TCON has been reset
  * due to a session loss.