G_WITHER_GEOM(9)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

πŸ’… G_WITHER_GEOM(9) β€” the kernel developer's manual, but make it cute

okay so this is a page from the Kernel Developer's Manual (yes, the 9 section, we're being serious and technical today bestie ✨) and it's about g_wither_geom β€” the function that literally lets your geom wither away and die when it gets the chance. iconic behaviour tbh πŸ₯€


🌸 NAME 🌸

g_wither_geom β€” destroy a geom plus all its related providers and consumers, whenever you get a chance, no rush πŸ’…


✨ SYNOPSIS ✨

#include <geom/geom.h>

void
g_wither_geom(struct g_geom *gp, int error);

πŸ¦‹ DESCRIPTION πŸ¦‹

so the g_wither_geom() function is basically the group chat message that says "hey GEOM, this geom gp? yeah it's gotta go πŸ’€". That's it. That's the whole vibe.

GEOM sets an error on each provider of the given geom β€” that happens during the orphaning process β€” and then it just waits for a chance to actually destroy the geom. Patient queen energy πŸ‘‘.

here's the lil cascade of consequences, pay attention:

  • If the access count of any possessed consumer goes to 0, that consumer gets detached and destroyed automatically. bye bestie 🫢
  • If the last consumer attached to any possessed provider gets detached, that provider gets destroyed.
  • If there are no more providers nor consumers left, the geom itself gets destroyed. periodt. πŸ’€

This whole thing is an automatic "garbage collect" so nobody has to duplicate the same code in every single class. we love DRY code, we hate copy-paste 😀

🚨 Before you call it: the field softc should be disposed of and set to NULL. Do that first. Not optional. that's the rule.

and ngl, here's the thing you gotta understand β€” g_wither_geom() gives you no guarantee that the geom will be immediately destroyed. mostly because the access counts of the geom's consumers and providers might not be 0. so when you're tempted to think "cool I called it on every geom in the class, we're done here" β€” nope πŸ™ˆ calling this function for every geom from a given class is not enough to be sure that the class can be unloaded. that's just how it is.


πŸ”₯ RESTRICTIONS/CONDITIONS πŸ”₯

these are the non-negotiables, bestie:

  • The argument error must be nonzero. zero is not the vibe, it will not slay here.
  • The topology lock has to be held. like, you must be holding it. do not skip this step. 😭

🌈 SEE ALSO 🌈

geom(4), DECLARE_GEOM_CLASS(9), g_access(9), g_attach(9), g_bio(9), g_consumer(9), g_data(9), g_event(9), g_geom(9), g_provider(9), g_provider_by_name(9)

go read those too, they're all part of the same friend group πŸ’–


πŸŽ€ AUTHORS πŸŽ€

This manual page was written by Pawel Jakub Dawidek <pjd@FreeBSD.org>. king behaviour, we thank him for his service 🫑


and that's the whole page! πŸ’œ cute lil sign-off: this one came out of Debian, dated January 16, 2004, and it lives at G_WITHER_GEOM(9). mwah, go wither some geoms responsibly πŸ§šβ€β™€οΈβœ¨

πŸ“¦ where this page comes from