kernfs_drain(9)
π NAME π
okay so this page is all about kernfs_drain β the function that literally drains a kernfs_node. that's it, that's the whole name, no cap. it's giving "short and iconic", and honestly? we love that for it. β¨
this one lives in section 9 of the Kernel API Manual, so yeah, it's kernel-dev territory, bestie β grab your fave beverage and let's go π«Ά
πΈ SYNOPSIS πΈ
void kernfs_drain (struct kernfs_node *kn , bool drop_supers );
literally the whole signature right there. two args, one void return because this function does the work and doesn't hand you a result back β main character energy, honestly. π
π ARGUMENTS π
knβ thekernfs_nodeyou're about to drain. this is the girl you're working on. πdrop_supersβ set this totrueif this function is called with thekernfs_supers_rwsemlocked. yes bestie, thatkernfs_supers_rwsem. read the room (and your locking context) before you flip this one, ok? π
π¦ DESCRIPTION π¦
so what does it actually do. two things, and they're both kinda fierce:
- it drains existing usages of
knβ like, politely but firmly showing everyone the door πͺ - it nukes all existing mmaps of
kn. yes. nukes. that's the actual word. violent but iconic ππ₯
and here's the part that lowkey slays: multiple removers may invoke this function concurrently on kn, and all of them will return after draining is complete. so no weird "who goes first" drama β everybody waits, everybody returns, everybody's fine. synchronized queen behavior, fr fr π
β SEE ALSO β
the kernel file in question is ./fs/kernfs/dir.c, and it comes with a whole friend group of related functions β here's the full squad, no one gets left behind π«Ά:
kernfs_path_from_node_locked(9), kernfs_name(9), kernfs_path_from_node(9), pr_cont_kernfs_name(9), pr_cont_kernfs_path(9), kernfs_get_parent(9), kernfs_name_hash(9), kernfs_link_sibling(9), kernfs_unlink_sibling(9), kernfs_get_active(9), kernfs_put_active(9), kernfs_get(9), kernfs_put(9), kernfs_node_from_dentry(9), kernfs_add_one(9), kernfs_find_ns(9), kernfs_find_and_get_ns(9), kernfs_walk_and_get_ns(9), kernfs_create_root(9), kernfs_destroy_root(9), kernfs_root_to_node(9), kernfs_create_dir_ns(9), kernfs_create_empty_dir(9), kernfs_next_descendant_post(9), kernfs_activate(9), kernfs_show(9), kernfs_remove(9), kernfs_break_active_protection(9), kernfs_unbreak_active_protection(9), kernfs_remove_self(9), kernfs_remove_by_name_ns(9), kernfs_rename_ns(9)
like, that's a lot of friends. go read them too, iykyk π
okay that's the page!! this beauty came from ./fs/kernfs and it's dated October 2026 β so mark your calendar bestie, and slay your kernel work responsibly ππβ¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms