Re: SCSI device numbering

Albert Cahalan (albert@ccs.neu.edu)
Tue, 2 Jul 1996 01:41:32 -0400 (EDT)


> From: jms@pobox.com (Johnie Stafford)
> >>>>> "ac" == Albert Cahalan <albert@ccs.neu.edu> writes:
>> From: eric@aib.com (Eric Youngdale)
>>>
>>>> Anyway, I think we should be ok with a 12+20 bit dev_t,
>>>> that sounds like the best solution right now.
>>>
>>> OK, but the point was that 20 bits for a minor number is
>>> insufficient for a fixed mapping of devices to minor numbers.
>>> It would be sufficient if we wanted to continue to use dynamic
>>> mapping of minors to devices, of course.
>
>> No, it is sufficient for everything, including really weird
>> SCSI adapters. Using nibble boundries (for nice hex output),
>> dev_t can be split as follows:
>
>> Purpose Bits Normal Extreme
>> controller 4 <= 1 2
>> bus 4 == 0 1
>> device 8 <= 2 4
>
> What about wide SCSI? It does 16 devices.

No problem. 8 _bits_ gives 2^8-1 devices, which is 255.
That is over 15 times what you need for wide SCSI.

>> lun 8 == 0 3
>> partition 4 <= 3 4
>
> What about an entry for the entire disk (eg. /dev/sda)? What about
> logical partitions? If you include the entry for the entire disk, I
> use 9 entries for my primary disk.

Yes, 4 _bits_ is 2^4 entries. That gives you 15 partitions
plus the entire disk, just like now.

>> Note that the number of bits allowed is far more than normally
>> needed and is sufficient for every system reported to the kernel
>> list. The extra 4 bits can be left reserved or used for the
>> (rather artificial IMHO) distinction between disk and CD or
>> whatever.
>
> I think you are about 10 or 12 bits short.

You don't need X _bits_ for X devices. You need log2(X),
rounded up to the nearest integer.