From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Howells Subject: [PATCH 29/30] AUTOFS: Make sure all dentries refs are released before calling kill_anon_super() [try #11] Date: Thu, 27 Jul 2006 21:53:31 +0100 Message-ID: <20060727205331.8443.32544.stgit@warthog.cambridge.redhat.com> References: <20060727205222.8443.29381.stgit@warthog.cambridge.redhat.com> Reply-To: Linux filesystem caching discussion list Content-Type: text/plain; charset=utf-8; format=fixed Content-Transfer-Encoding: quoted-printable Cc: linux-fsdevel@vger.kernel.org, linux-cachefs@redhat.com, nfsv4@linux-nfs.org, linux-kernel@vger.kernel.org Return-path: To: torvalds@osdl.org, akpm@osdl.org, steved@redhat.com, trond.myklebust@fys.uio.no In-Reply-To: <20060727205222.8443.29381.stgit@warthog.cambridge.redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-cachefs-bounces@redhat.com Errors-To: linux-cachefs-bounces@redhat.com List-Id: linux-fsdevel.vger.kernel.org Make sure all dentries refs are released before calling kill_anon_super()= so that the assumption that generic_shutdown_super() can completely destroy = the dentry tree for there will be no external references holds true. What was being done in the put_super() superblock op, is now done in the kill_sb() filesystem op instead, prior to calling kill_anon_super(). This makes the struct autofs_sb_info::root member variable redundant (sin= ce sb->s_root is still available), and so that is removed. The calls to shrink_dcache_sb() are also removed since they're also redundant as shrink_dcache_for_umount() will now be called after the cleanup routine. Signed-Off-By: David Howells Acked-by: Ian Kent --- fs/autofs4/autofs_i.h | 3 +-- fs/autofs4/init.c | 2 +- fs/autofs4/inode.c | 22 ++++------------------ fs/autofs4/waitq.c | 1 - 4 files changed, 6 insertions(+), 22 deletions(-) diff --git a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h index d6603d0..47e38f3 100644 --- a/fs/autofs4/autofs_i.h +++ b/fs/autofs4/autofs_i.h @@ -96,7 +96,6 @@ #define AUTOFS_TYPE_OFFSET 0x0004 =20 struct autofs_sb_info { u32 magic; - struct dentry *root; int pipefd; struct file *pipe; pid_t oz_pgrp; @@ -231,4 +230,4 @@ out: } =20 void autofs4_dentry_release(struct dentry *); - +extern void autofs4_kill_sb(struct super_block *); diff --git a/fs/autofs4/init.c b/fs/autofs4/init.c index 5d91933..723a1c5 100644 --- a/fs/autofs4/init.c +++ b/fs/autofs4/init.c @@ -24,7 +24,7 @@ static struct file_system_type autofs_fs .owner =3D THIS_MODULE, .name =3D "autofs", .get_sb =3D autofs_get_sb, - .kill_sb =3D kill_anon_super, + .kill_sb =3D autofs4_kill_sb, }; =20 static int __init init_autofs4_fs(void) diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c index fde78b1..1bf68c5 100644 --- a/fs/autofs4/inode.c +++ b/fs/autofs4/inode.c @@ -95,7 +95,7 @@ void autofs4_free_ino(struct autofs_info */ static void autofs4_force_release(struct autofs_sb_info *sbi) { - struct dentry *this_parent =3D sbi->root; + struct dentry *this_parent =3D sbi->sb->s_root; struct list_head *next; =20 spin_lock(&dcache_lock); @@ -126,7 +126,7 @@ resume: spin_lock(&dcache_lock); } =20 - if (this_parent !=3D sbi->root) { + if (this_parent !=3D sbi->sb->s_root) { struct dentry *dentry =3D this_parent; =20 next =3D this_parent->d_u.d_child.next; @@ -139,15 +139,9 @@ resume: goto resume; } spin_unlock(&dcache_lock); - - dput(sbi->root); - sbi->root =3D NULL; - shrink_dcache_sb(sbi->sb); - - return; } =20 -static void autofs4_put_super(struct super_block *sb) +void autofs4_kill_sb(struct super_block *sb) { struct autofs_sb_info *sbi =3D autofs4_sbi(sb); =20 @@ -162,6 +156,7 @@ static void autofs4_put_super(struct sup kfree(sbi); =20 DPRINTK("shutting down"); + kill_anon_super(sb); } =20 static int autofs4_show_options(struct seq_file *m, struct vfsmount *mnt= ) @@ -188,7 +183,6 @@ static int autofs4_show_options(struct s } =20 static struct super_operations autofs4_sops =3D { - .put_super =3D autofs4_put_super, .statfs =3D simple_statfs, .show_options =3D autofs4_show_options, }; @@ -314,7 +308,6 @@ int autofs4_fill_super(struct super_bloc =20 s->s_fs_info =3D sbi; sbi->magic =3D AUTOFS_SBI_MAGIC; - sbi->root =3D NULL; sbi->pipefd =3D -1; sbi->catatonic =3D 0; sbi->exp_timeout =3D 0; @@ -396,13 +389,6 @@ int autofs4_fill_super(struct super_bloc sbi->pipefd =3D pipefd; =20 /* - * Take a reference to the root dentry so we get a chance to - * clean up the dentry tree on umount. - * See autofs4_force_release. - */ - sbi->root =3D dget(root); - - /* * Success! Install the root dentry now to indicate completion. */ s->s_root =3D root; diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c index ce103e7..c0a6c8d 100644 --- a/fs/autofs4/waitq.c +++ b/fs/autofs4/waitq.c @@ -45,7 +45,6 @@ void autofs4_catatonic_mode(struct autof fput(sbi->pipe); /* Close the pipe */ sbi->pipe =3D NULL; } - shrink_dcache_sb(sbi->sb); } =20 static int autofs4_write(struct file *file, const void *addr, int bytes)