/* kn->parent and kn->name */
rwlock_t kernfs_rename_lock;
struct rcu_head rcu;
};
/* +1 to avoid triggering overflow warning when negating it */ #define KN_DEACTIVATED_BIAS (INT_MIN + 1)
/* KERNFS_TYPE_MASK and types are defined in include/linux/kernfs.h */
/** * kernfs_root - find out the kernfs_root a kernfs_node belongs to * @kn: kernfs_node of interest * * Return: the kernfs_root @kn belongs to.
*/ staticinlinestruct kernfs_root *kernfs_root(conststruct kernfs_node *kn)
{ conststruct kernfs_node *knp; /* if parent exists, it's always a dir; otherwise, @sd is a dir */
guard(rcu)();
knp = rcu_dereference(kn->__parent); if (knp)
kn = knp; return kn->dir.root;
}
/* * The root associated with this super_block. Each super_block is * identified by the root and ns it's associated with.
*/ struct kernfs_root *root;
/* * Each sb is associated with one namespace tag, currently the * network namespace of the task which mounted this kernfs * instance. If multiple tags become necessary, make the following * an array and compare kernfs_node tag against every entry.
*/ constvoid *ns;
/* anchored at kernfs_root->supers, protected by kernfs_rwsem */ struct list_head node;
}; #define kernfs_info(SB) ((struct kernfs_super_info *)(SB->s_fs_info))
staticinlinestruct kernfs_node *kernfs_parent(conststruct kernfs_node *kn)
{ /* * The kernfs_node::__parent remains valid within a RCU section. The kn * can be reparented (and renamed) which changes the entry. This can be * avoided by locking kernfs_root::kernfs_rwsem or * kernfs_root::kernfs_rename_lock. * Both locks can be used to obtain a reference on __parent. Once the * reference count reaches 0 then the node is about to be freed * and can not be renamed (or become a different parent) anymore.
*/ return rcu_dereference_check(kn->__parent,
kernfs_root_is_locked(kn) ||
kernfs_rename_is_locked(kn) ||
!atomic_read(&kn->count));
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.