Commit 39f7c4db authored by Miklos Szeredi's avatar Miklos Szeredi Committed by Al Viro

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: default avatarMiklos Szeredi <mszeredi@suse.cz>
Tested-by: default avatarToshiyuki Okajima <toshi.okajima@jp.fujitsu.com>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 34c80b1d
...@@ -29,6 +29,7 @@ struct mount { ...@@ -29,6 +29,7 @@ struct mount {
#endif #endif
struct list_head mnt_mounts; /* list of children, anchored here */ struct list_head mnt_mounts; /* list of children, anchored here */
struct list_head mnt_child; /* and going through their mnt_child */ struct list_head mnt_child; /* and going through their mnt_child */
struct list_head mnt_instance; /* mount instance on sb->s_mounts */
const char *mnt_devname; /* Name of device e.g. /dev/dsk/hda1 */ const char *mnt_devname; /* Name of device e.g. /dev/dsk/hda1 */
struct list_head mnt_list; struct list_head mnt_list;
struct list_head mnt_expire; /* link in fs-specific expiry list */ struct list_head mnt_expire; /* link in fs-specific expiry list */
......
...@@ -671,6 +671,9 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void ...@@ -671,6 +671,9 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void
mnt->mnt.mnt_sb = root->d_sb; mnt->mnt.mnt_sb = root->d_sb;
mnt->mnt_mountpoint = mnt->mnt.mnt_root; mnt->mnt_mountpoint = mnt->mnt.mnt_root;
mnt->mnt_parent = mnt; mnt->mnt_parent = mnt;
br_write_lock(vfsmount_lock);
list_add_tail(&mnt->mnt_instance, &root->d_sb->s_mounts);
br_write_unlock(vfsmount_lock);
return &mnt->mnt; return &mnt->mnt;
} }
EXPORT_SYMBOL_GPL(vfs_kern_mount); EXPORT_SYMBOL_GPL(vfs_kern_mount);
...@@ -699,6 +702,9 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root, ...@@ -699,6 +702,9 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root,
mnt->mnt.mnt_root = dget(root); mnt->mnt.mnt_root = dget(root);
mnt->mnt_mountpoint = mnt->mnt.mnt_root; mnt->mnt_mountpoint = mnt->mnt.mnt_root;
mnt->mnt_parent = mnt; mnt->mnt_parent = mnt;
br_write_lock(vfsmount_lock);
list_add_tail(&mnt->mnt_instance, &sb->s_mounts);
br_write_unlock(vfsmount_lock);
if (flag & CL_SLAVE) { if (flag & CL_SLAVE) {
list_add(&mnt->mnt_slave, &old->mnt_slave_list); list_add(&mnt->mnt_slave, &old->mnt_slave_list);
...@@ -781,6 +787,7 @@ static void mntput_no_expire(struct mount *mnt) ...@@ -781,6 +787,7 @@ static void mntput_no_expire(struct mount *mnt)
acct_auto_close_mnt(&mnt->mnt); acct_auto_close_mnt(&mnt->mnt);
goto put_again; goto put_again;
} }
list_del(&mnt->mnt_instance);
br_write_unlock(vfsmount_lock); br_write_unlock(vfsmount_lock);
mntfree(mnt); mntfree(mnt);
} }
......
...@@ -142,6 +142,7 @@ static struct super_block *alloc_super(struct file_system_type *type) ...@@ -142,6 +142,7 @@ static struct super_block *alloc_super(struct file_system_type *type)
INIT_LIST_HEAD(&s->s_dentry_lru); INIT_LIST_HEAD(&s->s_dentry_lru);
INIT_LIST_HEAD(&s->s_inode_lru); INIT_LIST_HEAD(&s->s_inode_lru);
spin_lock_init(&s->s_inode_lru_lock); spin_lock_init(&s->s_inode_lru_lock);
INIT_LIST_HEAD(&s->s_mounts);
init_rwsem(&s->s_umount); init_rwsem(&s->s_umount);
mutex_init(&s->s_lock); mutex_init(&s->s_lock);
lockdep_set_class(&s->s_umount, &type->s_umount_key); lockdep_set_class(&s->s_umount, &type->s_umount_key);
...@@ -200,6 +201,7 @@ static inline void destroy_super(struct super_block *s) ...@@ -200,6 +201,7 @@ static inline void destroy_super(struct super_block *s)
free_percpu(s->s_files); free_percpu(s->s_files);
#endif #endif
security_sb_free(s); security_sb_free(s);
WARN_ON(!list_empty(&s->s_mounts));
kfree(s->s_subtype); kfree(s->s_subtype);
kfree(s->s_options); kfree(s->s_options);
kfree(s); kfree(s);
......
...@@ -1428,6 +1428,7 @@ struct super_block { ...@@ -1428,6 +1428,7 @@ struct super_block {
#else #else
struct list_head s_files; struct list_head s_files;
#endif #endif
struct list_head s_mounts; /* list of mounts; _not_ for fs use */
/* s_dentry_lru, s_nr_dentry_unused protected by dcache.c lru locks */ /* s_dentry_lru, s_nr_dentry_unused protected by dcache.c lru locks */
struct list_head s_dentry_lru; /* unused dentry lru */ struct list_head s_dentry_lru; /* unused dentry lru */
int s_nr_dentry_unused; /* # of dentry on lru */ int s_nr_dentry_unused; /* # of dentry on lru */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment