aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@suse.cz>2011-11-21 06:11:30 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2012-01-06 23:20:12 -0500
commit39f7c4db1d2d9e2e2a90abdf34811783089d217d (patch)
treecbc3496ce21e26b5891bb4c4d4155853317ddfb3
parent34c80b1d93e6e20ca9dea0baf583a5b5510d92d4 (diff)
vfs: keep list of mounts for each superblock
Keep track of vfsmounts belonging to a superblock. List is protected by vfsmount_lock. Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Tested-by: Toshiyuki Okajima <toshi.okajima@jp.fujitsu.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--fs/mount.h1
-rw-r--r--fs/namespace.c7
-rw-r--r--fs/super.c2
-rw-r--r--include/linux/fs.h1
4 files changed, 11 insertions, 0 deletions
diff --git a/fs/mount.h b/fs/mount.h
index 0921b51e27e2..4ef36d93e5a2 100644
--- a/fs/mount.h
+++ b/fs/mount.h
@@ -29,6 +29,7 @@ struct mount {
29#endif 29#endif
30 struct list_head mnt_mounts; /* list of children, anchored here */ 30 struct list_head mnt_mounts; /* list of children, anchored here */
31 struct list_head mnt_child; /* and going through their mnt_child */ 31 struct list_head mnt_child; /* and going through their mnt_child */
32 struct list_head mnt_instance; /* mount instance on sb->s_mounts */
32 const char *mnt_devname; /* Name of device e.g. /dev/dsk/hda1 */ 33 const char *mnt_devname; /* Name of device e.g. /dev/dsk/hda1 */
33 struct list_head mnt_list; 34 struct list_head mnt_list;
34 struct list_head mnt_expire; /* link in fs-specific expiry list */ 35 struct list_head mnt_expire; /* link in fs-specific expiry list */
diff --git a/fs/namespace.c b/fs/namespace.c
index db65e2e4921f..145217b088d1 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -671,6 +671,9 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void
671 mnt->mnt.mnt_sb = root->d_sb; 671 mnt->mnt.mnt_sb = root->d_sb;
672 mnt->mnt_mountpoint = mnt->mnt.mnt_root; 672 mnt->mnt_mountpoint = mnt->mnt.mnt_root;
673 mnt->mnt_parent = mnt; 673 mnt->mnt_parent = mnt;
674 br_write_lock(vfsmount_lock);
675 list_add_tail(&mnt->mnt_instance, &root->d_sb->s_mounts);
676 br_write_unlock(vfsmount_lock);
674 return &mnt->mnt; 677 return &mnt->mnt;
675} 678}
676EXPORT_SYMBOL_GPL(vfs_kern_mount); 679EXPORT_SYMBOL_GPL(vfs_kern_mount);
@@ -699,6 +702,9 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root,
699 mnt->mnt.mnt_root = dget(root); 702 mnt->mnt.mnt_root = dget(root);
700 mnt->mnt_mountpoint = mnt->mnt.mnt_root; 703 mnt->mnt_mountpoint = mnt->mnt.mnt_root;
701 mnt->mnt_parent = mnt; 704 mnt->mnt_parent = mnt;
705 br_write_lock(vfsmount_lock);
706 list_add_tail(&mnt->mnt_instance, &sb->s_mounts);
707 br_write_unlock(vfsmount_lock);
702 708
703 if (flag & CL_SLAVE) { 709 if (flag & CL_SLAVE) {
704 list_add(&mnt->mnt_slave, &old->mnt_slave_list); 710 list_add(&mnt->mnt_slave, &old->mnt_slave_list);
@@ -781,6 +787,7 @@ put_again:
781 acct_auto_close_mnt(&mnt->mnt); 787 acct_auto_close_mnt(&mnt->mnt);
782 goto put_again; 788 goto put_again;
783 } 789 }
790 list_del(&mnt->mnt_instance);
784 br_write_unlock(vfsmount_lock); 791 br_write_unlock(vfsmount_lock);
785 mntfree(mnt); 792 mntfree(mnt);
786} 793}
diff --git a/fs/super.c b/fs/super.c
index 0413f51a9f0f..993ca8f128d6 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -142,6 +142,7 @@ static struct super_block *alloc_super(struct file_system_type *type)
142 INIT_LIST_HEAD(&s->s_dentry_lru); 142 INIT_LIST_HEAD(&s->s_dentry_lru);
143 INIT_LIST_HEAD(&s->s_inode_lru); 143 INIT_LIST_HEAD(&s->s_inode_lru);
144 spin_lock_init(&s->s_inode_lru_lock); 144 spin_lock_init(&s->s_inode_lru_lock);
145 INIT_LIST_HEAD(&s->s_mounts);
145 init_rwsem(&s->s_umount); 146 init_rwsem(&s->s_umount);
146 mutex_init(&s->s_lock); 147 mutex_init(&s->s_lock);
147 lockdep_set_class(&s->s_umount, &type->s_umount_key); 148 lockdep_set_class(&s->s_umount, &type->s_umount_key);
@@ -200,6 +201,7 @@ static inline void destroy_super(struct super_block *s)
200 free_percpu(s->s_files); 201 free_percpu(s->s_files);
201#endif 202#endif
202 security_sb_free(s); 203 security_sb_free(s);
204 WARN_ON(!list_empty(&s->s_mounts));
203 kfree(s->s_subtype); 205 kfree(s->s_subtype);
204 kfree(s->s_options); 206 kfree(s->s_options);
205 kfree(s); 207 kfree(s);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index cc1021fd19ef..03385acd71e8 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1428,6 +1428,7 @@ struct super_block {
1428#else 1428#else
1429 struct list_head s_files; 1429 struct list_head s_files;
1430#endif 1430#endif
1431 struct list_head s_mounts; /* list of mounts; _not_ for fs use */
1431 /* s_dentry_lru, s_nr_dentry_unused protected by dcache.c lru locks */ 1432 /* s_dentry_lru, s_nr_dentry_unused protected by dcache.c lru locks */
1432 struct list_head s_dentry_lru; /* unused dentry lru */ 1433 struct list_head s_dentry_lru; /* unused dentry lru */
1433 int s_nr_dentry_unused; /* # of dentry on lru */ 1434 int s_nr_dentry_unused; /* # of dentry on lru */