Subject: Re: detaching SCSI devices
To: der Mouse <mouse@Rodents.Montreal.QC.CA>
From: Chris G. Demetriou <firstname.lastname@example.org>
Date: 07/10/1999 10:10:34
der Mouse <mouse@Rodents.Montreal.QC.CA> writes:
> >> [config_detach and FSTATE_STAR devices]
> > Actually, as far as i'm concerned, the "right thing" to do here is
> > jsut keep the # of the first unit to be allocated to cloning
> > (FSTATE_STAR) devices, then just search for a free slot.
> This is equivalent to just starting from unit 0 and searching for a
> free slot; consider
> scsibus0 at ....
> scsibus* at ...
> sd4 at scsibus0 target 3 lun 1
> sd* at scsibus?
> The first unit the sd* can use is 0, but 4 has to be skipped. If you
> can skip 4 in your search, you can just start at 0 and skip when you
> have to anyway.
Actually, given the current implementation, doing what you suggest
above is a fair bit harder, since there's no compact representation of
which unit numbers are reserved.
If in a device's softc pointer array an entry above the first
cloning unit entry is NULL, that entry is safe to use for a cloning
If you start checking from 0, you have figure out whether every NULL
you see between 0 and the first cloning unit is unused, or is
'reserved' for some device. The only way to do that is searching the
We're not really worried about the time cost of doing that (though it
does start to add up; you've now got an N^3 algorithm, rather than an
N^2 one...), but it adds another loop of complexity to the code, and
that's kinda annoying. I was planning to be lazy and not check from 0
to the first cloning unit. 8-)
Chris Demetriou - email@example.com - http://www.netbsd.org/People/Pages/cgd.html
Disclaimer: Not speaking for NetBSD, just expressing my own opinion.