Commit f41c5934 authored by Li Zefan's avatar Li Zefan Committed by Greg Kroah-Hartman

kernfs: fix kernfs_node_from_dentry()

Currently kernfs_node_from_dentry() returns NULL for root dentry,
because root_dentry->d_op == NULL.

Due to this bug cgroupstats_build() returns -EINVAL for root cgroup.

  # mount -t cgroup -o cpuacct /cgroup
  # Documentation/accounting/getdelays -C /cgroup
  fatal reply error,  errno -22

With this fix:

  # Documentation/accounting/getdelays -C /cgroup
  sleeping 305, blocked 0, running 1, stopped 0, uninterruptible 1
Signed-off-by: default avatarLi Zefan <lizefan@huawei.com>
Acked-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9383f4c6
...@@ -500,7 +500,7 @@ const struct dentry_operations kernfs_dops = { ...@@ -500,7 +500,7 @@ const struct dentry_operations kernfs_dops = {
*/ */
struct kernfs_node *kernfs_node_from_dentry(struct dentry *dentry) struct kernfs_node *kernfs_node_from_dentry(struct dentry *dentry)
{ {
if (dentry->d_op == &kernfs_dops) if (dentry->d_sb->s_op == &kernfs_sops)
return dentry->d_fsdata; return dentry->d_fsdata;
return NULL; return NULL;
} }
......
...@@ -65,6 +65,7 @@ struct kernfs_super_info { ...@@ -65,6 +65,7 @@ struct kernfs_super_info {
}; };
#define kernfs_info(SB) ((struct kernfs_super_info *)(SB->s_fs_info)) #define kernfs_info(SB) ((struct kernfs_super_info *)(SB->s_fs_info))
extern const struct super_operations kernfs_sops;
extern struct kmem_cache *kernfs_node_cache; extern struct kmem_cache *kernfs_node_cache;
/* /*
......
...@@ -39,7 +39,7 @@ static int kernfs_sop_show_options(struct seq_file *sf, struct dentry *dentry) ...@@ -39,7 +39,7 @@ static int kernfs_sop_show_options(struct seq_file *sf, struct dentry *dentry)
return 0; return 0;
} }
static const struct super_operations kernfs_sops = { const struct super_operations kernfs_sops = {
.statfs = simple_statfs, .statfs = simple_statfs,
.drop_inode = generic_delete_inode, .drop_inode = generic_delete_inode,
.evict_inode = kernfs_evict_inode, .evict_inode = kernfs_evict_inode,
......
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