mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-26 00:21:17 +00:00
kernfs: implement kernfs_root->supers list
Currently, there's no way to find out which super_blocks are associated with a given kernfs_root. Let's implement it - the planned inotify extension to kernfs_notify() needs it. Make kernfs_super_info point back to the super_block and chain it at kernfs_root->supers. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
a798c10faf
commit
7d568a8383
4 changed files with 21 additions and 0 deletions
|
@ -711,6 +711,7 @@ struct kernfs_root *kernfs_create_root(struct kernfs_syscall_ops *scops,
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
|
|
||||||
ida_init(&root->ino_ida);
|
ida_init(&root->ino_ida);
|
||||||
|
INIT_LIST_HEAD(&root->supers);
|
||||||
|
|
||||||
kn = __kernfs_new_node(root, "", S_IFDIR | S_IRUGO | S_IXUGO,
|
kn = __kernfs_new_node(root, "", S_IFDIR | S_IRUGO | S_IXUGO,
|
||||||
KERNFS_DIR);
|
KERNFS_DIR);
|
||||||
|
|
|
@ -49,6 +49,8 @@ static inline struct kernfs_root *kernfs_root(struct kernfs_node *kn)
|
||||||
* mount.c
|
* mount.c
|
||||||
*/
|
*/
|
||||||
struct kernfs_super_info {
|
struct kernfs_super_info {
|
||||||
|
struct super_block *sb;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The root associated with this super_block. Each super_block is
|
* The root associated with this super_block. Each super_block is
|
||||||
* identified by the root and ns it's associated with.
|
* identified by the root and ns it's associated with.
|
||||||
|
@ -62,6 +64,9 @@ struct kernfs_super_info {
|
||||||
* an array and compare kernfs_node tag against every entry.
|
* an array and compare kernfs_node tag against every entry.
|
||||||
*/
|
*/
|
||||||
const void *ns;
|
const void *ns;
|
||||||
|
|
||||||
|
/* anchored at kernfs_root->supers, protected by kernfs_mutex */
|
||||||
|
struct list_head node;
|
||||||
};
|
};
|
||||||
#define kernfs_info(SB) ((struct kernfs_super_info *)(SB->s_fs_info))
|
#define kernfs_info(SB) ((struct kernfs_super_info *)(SB->s_fs_info))
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,7 @@ static int kernfs_fill_super(struct super_block *sb)
|
||||||
struct inode *inode;
|
struct inode *inode;
|
||||||
struct dentry *root;
|
struct dentry *root;
|
||||||
|
|
||||||
|
info->sb = sb;
|
||||||
sb->s_blocksize = PAGE_CACHE_SIZE;
|
sb->s_blocksize = PAGE_CACHE_SIZE;
|
||||||
sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
|
sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
|
||||||
sb->s_magic = SYSFS_MAGIC;
|
sb->s_magic = SYSFS_MAGIC;
|
||||||
|
@ -166,12 +167,18 @@ struct dentry *kernfs_mount_ns(struct file_system_type *fs_type, int flags,
|
||||||
*new_sb_created = !sb->s_root;
|
*new_sb_created = !sb->s_root;
|
||||||
|
|
||||||
if (!sb->s_root) {
|
if (!sb->s_root) {
|
||||||
|
struct kernfs_super_info *info = kernfs_info(sb);
|
||||||
|
|
||||||
error = kernfs_fill_super(sb);
|
error = kernfs_fill_super(sb);
|
||||||
if (error) {
|
if (error) {
|
||||||
deactivate_locked_super(sb);
|
deactivate_locked_super(sb);
|
||||||
return ERR_PTR(error);
|
return ERR_PTR(error);
|
||||||
}
|
}
|
||||||
sb->s_flags |= MS_ACTIVE;
|
sb->s_flags |= MS_ACTIVE;
|
||||||
|
|
||||||
|
mutex_lock(&kernfs_mutex);
|
||||||
|
list_add(&info->node, &root->supers);
|
||||||
|
mutex_unlock(&kernfs_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return dget(sb->s_root);
|
return dget(sb->s_root);
|
||||||
|
@ -190,6 +197,10 @@ void kernfs_kill_sb(struct super_block *sb)
|
||||||
struct kernfs_super_info *info = kernfs_info(sb);
|
struct kernfs_super_info *info = kernfs_info(sb);
|
||||||
struct kernfs_node *root_kn = sb->s_root->d_fsdata;
|
struct kernfs_node *root_kn = sb->s_root->d_fsdata;
|
||||||
|
|
||||||
|
mutex_lock(&kernfs_mutex);
|
||||||
|
list_del(&info->node);
|
||||||
|
mutex_unlock(&kernfs_mutex);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Remove the superblock from fs_supers/s_instances
|
* Remove the superblock from fs_supers/s_instances
|
||||||
* so we can't find it, before freeing kernfs_super_info.
|
* so we can't find it, before freeing kernfs_super_info.
|
||||||
|
|
|
@ -144,6 +144,10 @@ struct kernfs_root {
|
||||||
/* private fields, do not use outside kernfs proper */
|
/* private fields, do not use outside kernfs proper */
|
||||||
struct ida ino_ida;
|
struct ida ino_ida;
|
||||||
struct kernfs_syscall_ops *syscall_ops;
|
struct kernfs_syscall_ops *syscall_ops;
|
||||||
|
|
||||||
|
/* list of kernfs_super_info of this root, protected by kernfs_mutex */
|
||||||
|
struct list_head supers;
|
||||||
|
|
||||||
wait_queue_head_t deactivate_waitq;
|
wait_queue_head_t deactivate_waitq;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue