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)
Sat, Nov 2, 6:54 AM
Unknown Object (File)
Sat, Nov 2, 6:54 AM
Unknown Object (File)
Sat, Nov 2, 6:54 AM
Unknown Object (File)
Sat, Nov 2, 6:45 AM
Unknown Object (File)
Fri, Oct 18, 7:26 PM
Unknown Object (File)
Oct 9 2024, 8:03 AM
Unknown Object (File)
Oct 9 2024, 8:03 AM
Unknown Object (File)
Oct 9 2024, 8:02 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 37721
Build 34610: 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
837

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
837

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