Commit f2eb478f authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

kernfs: move struct kernfs_root out of the public view.



There is no need to have struct kernfs_root be part of kernfs.h for
the whole kernel to see and poke around it.  Move it internal to kernfs
code and provide a helper function, kernfs_root_to_node(), to handle the
one field that kernfs users were directly accessing from the structure.

Cc: Imran Khan <imran.f.khan@oracle.com>
Acked-by: default avatarTejun Heo <tj@kernel.org>
Link: https://lore.kernel.org/r/20220222070713.3517679-1-gregkh@linuxfoundation.org


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b4ae8c2f
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -3221,13 +3221,13 @@ static int __init rdtgroup_setup_root(void)

	list_add(&rdtgroup_default.rdtgroup_list, &rdt_all_groups);

	ret = rdtgroup_add_files(rdt_root->kn, RF_CTRL_BASE);
	ret = rdtgroup_add_files(kernfs_root_to_node(rdt_root), RF_CTRL_BASE);
	if (ret) {
		kernfs_destroy_root(rdt_root);
		goto out;
	}

	rdtgroup_default.kn = rdt_root->kn;
	rdtgroup_default.kn = kernfs_root_to_node(rdt_root);
	kernfs_activate(rdtgroup_default.kn);

out:
+9 −0
Original line number Diff line number Diff line
@@ -970,6 +970,15 @@ void kernfs_destroy_root(struct kernfs_root *root)
	kernfs_put(root->kn); /* will also free @root */
}

/**
 * kernfs_root_to_node - return the kernfs_node associated with a kernfs_root
 * @root: root to use to lookup
 */
struct kernfs_node *kernfs_root_to_node(struct kernfs_root *root)
{
	return root->kn;
}

/**
 * kernfs_create_dir_ns - create a directory
 * @parent: parent in which to create a new directory
+18 −0
Original line number Diff line number Diff line
@@ -31,6 +31,24 @@ struct kernfs_iattrs {
	atomic_t		user_xattr_size;
};

struct kernfs_root {
	/* published fields */
	struct kernfs_node	*kn;
	unsigned int		flags;	/* KERNFS_ROOT_* flags */

	/* private fields, do not use outside kernfs proper */
	struct idr		ino_idr;
	u32			last_id_lowbits;
	u32			id_highbits;
	struct kernfs_syscall_ops *syscall_ops;

	/* list of kernfs_super_info of this root, protected by kernfs_rwsem */
	struct list_head	supers;

	wait_queue_head_t	deactivate_waitq;
	struct rw_semaphore	kernfs_rwsem;
};

/* +1 to avoid triggering overflow warning when negating it */
#define KN_DEACTIVATED_BIAS		(INT_MIN + 1)

+1 −1
Original line number Diff line number Diff line
@@ -103,7 +103,7 @@ int __init sysfs_init(void)
	if (IS_ERR(sysfs_root))
		return PTR_ERR(sysfs_root);

	sysfs_root_kn = sysfs_root->kn;
	sysfs_root_kn = kernfs_root_to_node(sysfs_root);

	err = register_filesystem(&sysfs_fs_type);
	if (err) {
+4 −0
Original line number Diff line number Diff line
@@ -185,6 +185,7 @@ struct kernfs_syscall_ops {
			 struct kernfs_root *root);
};

#if 0
struct kernfs_root {
	/* published fields */
	struct kernfs_node	*kn;
@@ -202,6 +203,9 @@ struct kernfs_root {
	wait_queue_head_t	deactivate_waitq;
	struct rw_semaphore	kernfs_rwsem;
};
#endif

struct kernfs_node *kernfs_root_to_node(struct kernfs_root *root);

struct kernfs_open_file {
	/* published fields */
Loading