Page MenuHomeFreeBSD

geom: create disk_free() to free uninitialized disks
AbandonedPublic

Authored by imp on Mar 9 2021, 8:29 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Nov 28, 10:25 PM
Unknown Object (File)
Tue, Nov 25, 1:58 AM
Unknown Object (File)
Mon, Nov 24, 12:22 PM
Unknown Object (File)
Sun, Nov 23, 1:03 AM
Unknown Object (File)
Sat, Nov 22, 3:04 PM
Unknown Object (File)
Thu, Nov 20, 8:35 AM
Unknown Object (File)
Nov 8 2025, 8:12 AM
Unknown Object (File)
Oct 31 2025, 12:30 AM
Subscribers

Details

Reviewers
glebius
kevans
mav
ken
scottl
phk
Group Reviewers
manpages
Summary

disk_destroy() only works on disks that have proceeded through
disk_create(). Creating disks is a multi-step process. There are times
that we may need to free nascent disks that have been allocated, but not
created. disk_free() will free the memory allocated with disk_alloc()
when the creation of the disk needs to be aborted before it can proceed
to disk_create() for whatever reason.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 37706
Build 34595: arc lint + arc unit

Event Timeline

imp requested review of this revision.Mar 9 2021, 8:29 PM
rpokala added inline comments.
sys/geom/geom_disk.c
822

I would call disk_free(dp) here, to benefit from the KASSERT()s, and to make it abundantly clear that disk_free() is always the final destination of memory from disk_alloc().

On second thought, I'm going to abandon this approach and schedule the cam register routine into a taskqueue so we can sleep. There's no good retry mechanism here, and adding one would make things more complicated. We can switch to waiting for memory to have a more robust system with simpler code. This also matches at least some of the feedback I've received privately (thanks Chuck). I'll post that review when I have it done.

sys/geom/geom_disk.c
822

Not a bad idea... I'll shuffle and regen.