Skip to contentSkip to conversation

kernfs: fix kernfs_node_from_dentry()

PATCH In review Li Zefan 3 participants 4 messages Feb 14, 2014

Subsystems (2)
lore
Share & tools
lore

Li Zefan

author
#0 lore raw

PATCH 1/1 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

---
 fs/kernfs/dir.c             | 2 +-
 fs/kernfs/kernfs-internal.h | 1 +
 fs/kernfs/mount.c           | 2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)
fs/kernfs/dir.c +1 -1
index 939684e..300f57b 100644
@@ -501,7 +501,7 @@ const struct dentry_operations kernfs_dops = {
  */
 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 NULL;
 }
fs/kernfs/kernfs-internal.h +1 -0
index a91d7a1..8be13b2 100644
@@ -65,6 +65,7 @@ struct kernfs_super_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;
 
 /*
fs/kernfs/mount.c +1 -1
index e5b28b0..405279b 100644
@@ -39,7 +39,7 @@ static int kernfs_sop_show_options(struct seq_file *sf, struct dentry *dentry)
 	return 0;
 }
 
-static const struct super_operations kernfs_sops = {
+const struct super_operations kernfs_sops = {
 	.statfs		= simple_statfs,
 	.drop_inode	= generic_delete_inode,
 	.evict_inode	= kernfs_evict_inode,
Signature · 1 line
1.8.0.2
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Li Zefan

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
Quoted 6 lines

With this fix:

# Documentation/accounting/getdelays -C /cgroup sleeping 305, blocked 0, running 1, stopped 0, uninterruptible 1

Thanks!

Signature · 1 line
tejun
#2 lore raw
Quoted 10 lines · Tejun Heo
Quoted 9 lines · Li Zefan

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
Quoted 8 lines
Quoted 6 lines

With this fix:

# Documentation/accounting/getdelays -C /cgroup sleeping 305, blocked 0, running 1, stopped 0, uninterruptible 1

Is this needed for 3.14-final or 3.15-rc1?

thanks,

greg k-h

maintainer
#3 lore raw
Quoted 13 lines · Greg Kroah-Hartman
Quoted 12 lines · Tejun Heo
Quoted 11 lines · Li Zefan

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:

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

# Documentation/accounting/getdelays -C /cgroup sleeping 305, blocked 0, running 1, stopped 0, uninterruptible 1

Is this needed for 3.14-final or 3.15-rc1?

3.15-rc1, so, driver-core-next.

Thanks.

Signature · 1 line
tejun