All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cifs: fix handlecache and multiuser
@ 2022-03-04  0:31 Ronnie Sahlberg
  2022-03-04 15:40 ` Paulo Alcantara
  0 siblings, 1 reply; 3+ messages in thread
From: Ronnie Sahlberg @ 2022-03-04  0:31 UTC (permalink / raw)
  To: linux-cifs; +Cc: Steve French

In multiuser each individual user has their own tcon structure for the
share and thus their own handle for a cached directory.
When we umount such a share we much make sure to release the pinned down dentry
for each such tcon and not just the master tcon.

Otherwise we will get nasty warnings on umount that dentries are still in use:
[ 3459.590047] BUG: Dentry 00000000115c6f41{i=12000000019d95,n=/}  still in use\
 (2) [unmount of cifs cifs]
...
[ 3459.590492] Call Trace:
[ 3459.590500]  d_walk+0x61/0x2a0
[ 3459.590518]  ? shrink_lock_dentry.part.0+0xe0/0xe0
[ 3459.590526]  shrink_dcache_for_umount+0x49/0x110
[ 3459.590535]  generic_shutdown_super+0x1a/0x110
[ 3459.590542]  kill_anon_super+0x14/0x30
[ 3459.590549]  cifs_kill_sb+0xf5/0x104 [cifs]
[ 3459.590773]  deactivate_locked_super+0x36/0xa0
[ 3459.590782]  cleanup_mnt+0x131/0x190
[ 3459.590789]  task_work_run+0x5c/0x90
[ 3459.590798]  exit_to_user_mode_loop+0x151/0x160
[ 3459.590809]  exit_to_user_mode_prepare+0x83/0xd0
[ 3459.590818]  syscall_exit_to_user_mode+0x12/0x30
[ 3459.590828]  do_syscall_64+0x48/0x90
[ 3459.590833]  entry_SYSCALL_64_after_hwframe+0x44/0xae

Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
 fs/cifs/cifsfs.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index dca42aa87d30..da6478b39eba 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -253,6 +253,9 @@ static void cifs_kill_sb(struct super_block *sb)
 	struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
 	struct cifs_tcon *tcon;
 	struct cached_fid *cfid;
+	struct rb_root *root = &cifs_sb->tlink_tree;
+	struct rb_node *node;
+	struct tcon_link *tlink;
 
 	/*
 	 * We ned to release all dentries for the cached directories
@@ -262,17 +265,21 @@ static void cifs_kill_sb(struct super_block *sb)
 		dput(cifs_sb->root);
 		cifs_sb->root = NULL;
 	}
-	tcon = cifs_sb_master_tcon(cifs_sb);
-	if (tcon) {
+	spin_lock(&cifs_sb->tlink_tree_lock);
+	node = rb_first(root);
+	while (node != NULL) {
+		tlink = rb_entry(node, struct tcon_link, tl_rbnode);
+		tcon = tlink_tcon(tlink);
 		cfid = &tcon->crfid;
 		mutex_lock(&cfid->fid_mutex);
 		if (cfid->dentry) {
-
 			dput(cfid->dentry);
 			cfid->dentry = NULL;
 		}
 		mutex_unlock(&cfid->fid_mutex);
+		node = rb_next(node);
 	}
+	spin_unlock(&cifs_sb->tlink_tree_lock);
 
 	kill_anon_super(sb);
 	cifs_umount(cifs_sb);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] cifs: fix handlecache and multiuser
  2022-03-04  0:31 [PATCH] cifs: fix handlecache and multiuser Ronnie Sahlberg
@ 2022-03-04 15:40 ` Paulo Alcantara
  2022-03-04 17:11   ` Steve French
  0 siblings, 1 reply; 3+ messages in thread
From: Paulo Alcantara @ 2022-03-04 15:40 UTC (permalink / raw)
  To: Ronnie Sahlberg, linux-cifs; +Cc: Steve French

Ronnie Sahlberg <lsahlber@redhat.com> writes:

> In multiuser each individual user has their own tcon structure for the
> share and thus their own handle for a cached directory.
> When we umount such a share we much make sure to release the pinned down dentry
> for each such tcon and not just the master tcon.
>
> Otherwise we will get nasty warnings on umount that dentries are still in use:
> [ 3459.590047] BUG: Dentry 00000000115c6f41{i=12000000019d95,n=/}  still in use\
>  (2) [unmount of cifs cifs]
> ...
> [ 3459.590492] Call Trace:
> [ 3459.590500]  d_walk+0x61/0x2a0
> [ 3459.590518]  ? shrink_lock_dentry.part.0+0xe0/0xe0
> [ 3459.590526]  shrink_dcache_for_umount+0x49/0x110
> [ 3459.590535]  generic_shutdown_super+0x1a/0x110
> [ 3459.590542]  kill_anon_super+0x14/0x30
> [ 3459.590549]  cifs_kill_sb+0xf5/0x104 [cifs]
> [ 3459.590773]  deactivate_locked_super+0x36/0xa0
> [ 3459.590782]  cleanup_mnt+0x131/0x190
> [ 3459.590789]  task_work_run+0x5c/0x90
> [ 3459.590798]  exit_to_user_mode_loop+0x151/0x160
> [ 3459.590809]  exit_to_user_mode_prepare+0x83/0xd0
> [ 3459.590818]  syscall_exit_to_user_mode+0x12/0x30
> [ 3459.590828]  do_syscall_64+0x48/0x90
> [ 3459.590833]  entry_SYSCALL_64_after_hwframe+0x44/0xae
>
> Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
> ---
>  fs/cifs/cifsfs.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)

Acked-by: Paulo Alcantara (SUSE) <pc@cjr.nz>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] cifs: fix handlecache and multiuser
  2022-03-04 15:40 ` Paulo Alcantara
@ 2022-03-04 17:11   ` Steve French
  0 siblings, 0 replies; 3+ messages in thread
From: Steve French @ 2022-03-04 17:11 UTC (permalink / raw)
  To: Paulo Alcantara; +Cc: Ronnie Sahlberg, linux-cifs

Added Acked-by and also added cc: Stable


On Fri, Mar 4, 2022 at 9:40 AM Paulo Alcantara <pc@cjr.nz> wrote:
>
> Ronnie Sahlberg <lsahlber@redhat.com> writes:
>
> > In multiuser each individual user has their own tcon structure for the
> > share and thus their own handle for a cached directory.
> > When we umount such a share we much make sure to release the pinned down dentry
> > for each such tcon and not just the master tcon.
> >
> > Otherwise we will get nasty warnings on umount that dentries are still in use:
> > [ 3459.590047] BUG: Dentry 00000000115c6f41{i=12000000019d95,n=/}  still in use\
> >  (2) [unmount of cifs cifs]
> > ...
> > [ 3459.590492] Call Trace:
> > [ 3459.590500]  d_walk+0x61/0x2a0
> > [ 3459.590518]  ? shrink_lock_dentry.part.0+0xe0/0xe0
> > [ 3459.590526]  shrink_dcache_for_umount+0x49/0x110
> > [ 3459.590535]  generic_shutdown_super+0x1a/0x110
> > [ 3459.590542]  kill_anon_super+0x14/0x30
> > [ 3459.590549]  cifs_kill_sb+0xf5/0x104 [cifs]
> > [ 3459.590773]  deactivate_locked_super+0x36/0xa0
> > [ 3459.590782]  cleanup_mnt+0x131/0x190
> > [ 3459.590789]  task_work_run+0x5c/0x90
> > [ 3459.590798]  exit_to_user_mode_loop+0x151/0x160
> > [ 3459.590809]  exit_to_user_mode_prepare+0x83/0xd0
> > [ 3459.590818]  syscall_exit_to_user_mode+0x12/0x30
> > [ 3459.590828]  do_syscall_64+0x48/0x90
> > [ 3459.590833]  entry_SYSCALL_64_after_hwframe+0x44/0xae
> >
> > Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
> > ---
> >  fs/cifs/cifsfs.c | 13 ++++++++++---
> >  1 file changed, 10 insertions(+), 3 deletions(-)
>
> Acked-by: Paulo Alcantara (SUSE) <pc@cjr.nz>



-- 
Thanks,

Steve

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-03-04 17:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-04  0:31 [PATCH] cifs: fix handlecache and multiuser Ronnie Sahlberg
2022-03-04 15:40 ` Paulo Alcantara
2022-03-04 17:11   ` Steve French

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.