G_WITHER_GEOM(9)

πŸ’– G_WITHER_GEOM(9) πŸ’–

ok so bestie, welcome to the Kernel Developer's Manual β€” this one's g_wither_geom, and it's giving "cleanup crew, but make it ✨automatic✨". it lives in section 9, iykyk 🫢


✨ NAME ✨

g_wither_geom β€” destroy geom and related providers and consumers when you get a chance πŸ¦‹

like literally, whenever the universe says it's time. not now. eventually. no cap.


🌸 SYNOPSIS 🌸

#include <geom/geom.h>

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

πŸ’… DESCRIPTION πŸ’…

okay so. the g_wither_geom() function tells GEOM that geom gp is to be destroyed. that's the whole vibe. GEOM sets an error on each provider of the given geom (this happens in the orphaning process, periodt) and then it just… waits for a chance to destroy the geom. main character energy tbh, it does not rush.

here's the tea on what happens automatically:

  • If the access count of any possessed consumer goes to 0, the consumer will be detached and destroyed automatically. πŸ’€ gone. bye.
  • If the last consumer attached to any possessed provider will be detached, the provider will be destroyed. ✨
  • If there are no more providers nor consumers, the geom will be destroyed. 🌈 that's the moment.

this is an automatic β€œgarbage collect” to avoid duplicated code in all classes. iconic, honestly. saves everyone from copy-pasting the same sad cleanup logic forty times.

before it is called, field softc should be disposed of and set to NULL. πŸŽ€ do NOT forget this one bestie, it's a whole thing.

also note that the g_wither_geom() function gives no guarantee that the geom will be immediately destroyed, mostly because the access counts of the geom's consumers and providers may not be 0. 😭 yeah. that's why calling this function for every geom from a given class is not enough to be sure that the class can be unloaded. lowkey humbling but okay.


πŸŽ€ RESTRICTIONS/CONDITIONS πŸŽ€

  • The argument error must be nonzero. ⭐
  • The topology lock has to be held. πŸ”’
fr fr. hold that lock. don't be out here raw-dogging the topology. πŸ™ˆ

πŸ‘‘ 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)


🌸 AUTHORS 🌸

This manual page was written by Pawel Jakub Dawidek <pjd@FreeBSD.org>. 🫢 thank you for your service king


and that's the whole page bestie!! πŸ’œ this one came from the Debian crew, dated January 16, 2004 β€” so it's older than most of us and still serving looks. slay. πŸŽ€βœ¨πŸ’…

πŸ“¦ where this page comes from