DEVFS_FS
Bryan,
I am writing a longer reply to your previous posting,
but I really must jump in and correct a couple of important factual errors in your latest one.
Quoted 9 lines · Bryan Henderson
Quoted 8 lines
Examples: If you compile all USB drivers into the kernel, or if you modprobe them during boot scripts, then boot time is extended by the time taken to initialise the host controllers and connected devices. If you compile in SCSI drivers, boot time is further extended by the time taken to probe and initialise your SCSI devices.
Having drivers loaded
for devices which you aren't using can be significant,
Quoted 7 lines
So it sounds like you're talking about the feature of devfs in which the driver doesn't get loaded until someone refers to the /dev directory that refers to it. But that's not a characteristic of devfs -- that's just devfs keeping up with the classic mknod system. In the classic system (if you choose to set it up that way), the device driver doesn't get loaded until someone refers to its major number. That's part of the general module autoloading function.
Only with lookup trapping (either built into the old devfs
or as a separate facility), can you autoload on a reference to /dev/cdroms/cdrom0, because you do not know the device number, because, in turn, you do not know if it is scsi, iSCSI, IDE, or proprietary dinosaur. Also, in the case of IDE, knowing that you are looking for the first IDE cdrom drive does still does not tell you the major number (could be 3, 22, 33 or 34) or the minor number (determined by which cable and drive number on the cable).
Quoted 11 lines
Fundamentally, I believe devfs has this problem worse than the mknod system. Devfs strives to make meaningful names for devices, which means it has to some work, such as talk to the device, to create one. With the mknod system, devices often have names that have nothing to do with the true identity of the device, so a name can simply be implied. Taking SCSI as an example, a reasonable driver for a single parallel SCSI bus with one LU per target could simply assign minor number = target ID and do no initialization work at all. But the same driver in devfs would want to talk to the 16 possible targets and make up names more meaningful than target ID for them -- and omit from the namespace the ones that don't answer.
Your statement about SCSI and device numbers is factually
wrong, unless something has changed recently. There are four different major numbers for SCSI devices: cdrom (11 block), tape (9 char), disk(8 block), and scsi generic (21 char). None of these, not even scsi generic, uses minor device numbers that directly map to <channel,target,lun> ("channel" means "which scsi cable"). Every(?) scsi controller driver calls scsi_scan_host on initializing the controller card, and scsi_scan_host calls scsi_probe_lun on every target (and if the target exists and has meaningful other luns, then all of those luns as well), and the current numbering scheme for the scsi device drivers needs this information, since there is not predetermined mapping of <channel,target,lun> to minor device number.
Come to think of it, your example is actually an interesting
hypothetical example of why lookup trapping makes possible arrangements that are not possible just by invoking modprobe on unused major device numbers. You see, under the scsi-3 set of standards, luns are not limited to 3 bits; they're limited to 64 bits. If memory serves, I believe that Infiniband or iSCSI or both allow 64 bit luns, which obviously will not fit in the current space given to minor device numbers. For this reason, I expect the high level scsi code will never switch to using minor device numbers to directly encode <channel,target,lun>. On the other hand, some encoding of <channel,target,lun> would do just fine as device names for lookup trapping, which could invoke a handler that ask the SCSI subsystem to scan just that <channel,target,lun> and create the appropriate /dev entry.
Okay, so your choice of scsi as an example was unlucky.
How about if we consider IDE instead? The IDE drivers encode the device into minor device numbers, and the same device number is shared between CDROM and hard disk driver. Let's also ignore the complications that IDE block devices cover four major block device numbers (3, 22, 33, and 34) and ignore the fact that character device is 37 also maps to these devices for IDE tape and that there is also IDE scsi. Let's just talk about IDE cdrom versus disk selection for block major 3.
Under current devfs conventions, you do not have to an alias
like /dev/discs/disc1 that relies on sequential scanning until the second hard disk is found. Instead, you can use /dev/ide/host0/bus0/target1/lun0 if you like. The /dev/discs/disc1 symlink is not put in by the IDE host controller driver or the generic IDE code. The /dev/discs/disc1 symlink is created when the ide-disk driver calls register_disk, which calls devfs_add_disk. There is no #ifdef DEVFS_FS code in the kernel that I am aware of that forces additional sequential scanning when devfs is enabled.
Sequential type based names, what you kindly call
"meaningful names" (/dev/cdroms/cdrom0, /dev/discs/disc0, /dev/tapes/tape1) can be implemented with or without devfs-style lookup trapping. Without lookup trapping, you just have to identify all of the drives at boot and on hotplug events and have some utility called by the boot and hotplug scripts make the appropriate symbolic links. The difference with lookup trapping is that, as usual, it allows this to be deferred, and also it allows the system to stop scanning once it has found the requested device rather than having to scan all devices.
One minor caveat to this is that if you mix
names of the form /dev/ide/hostN/busN/targetN/lunN with names of the form /dev/discs/discN, *and* you want to rely on consistent numbering of /dev/discs/discN, then make sure that any attempt to bind drivers on /dev/ide/hostN will first make sure this has already been done for host0 through hostN-1. Currently, I believe this is already done for you in the case of parallel scsi and IDE, as I believe they both scan all devices at initialization. In any case, it still potentially avoids unnecessary device scans in comparison to not having lookup trapping.
No implementation of devfs that I am aware of actually
_requires_ the kernel to do any additional device scanning or requires user level programs to use the sequential type-based device names for disks, tapes and CD/DVD drives. In comparison, lookup trapping could help the kernel _avoid_ some unnecessary scanning for sites that want to use sequential type-based names, because it does not require all of the devices to be scanned in advance in order to be able to map a given type+number name (e.g., "cdrom1" just requires scanning until cdrom0 and cdrom1 are found).
__ ______________
Adam J. Richter \ /
[email protected] | g g d r a s i l
Quoted 3 lines
Quoted 3 lines
So it sounds like you're talking about the feature of devfs in which the
driver doesn't get loaded until someone refers to the /dev directory
that
Quoted 2 lines
Quoted 2 lines
refers to it. But that's not a characteristic of devfs -- that's just devfs keeping up with the classic mknod system. In the classic system
(if
Quoted 5 lines
Quoted 3 lines
you choose to set it up that way), the device driver doesn't get loaded until someone refers to its major number. That's part of the general module autoloading function.
Only with lookup trapping (either built into the old
devfs
Quoted 4 lines
or as a separate facility), can you autoload on a reference to
/dev/cdroms/cdrom0, because you do not know the device number, in turn, you do not know if it is scsi, iSCSI, IDE, or proprietary dinosaur.
I don't get what example you're envisioning. I do know that my cdrom device is scsi and I know (because I'm careful, of course) that its device number is (11,0). So I can make a /dev/cdroms/cdrom0 such that the device drivers for my cdrom device get loaded not at boot time, but when I first access /dev/cdroms/cdrom0. I assume you have an example in mind where, with classic mknod I would have to load the driver at boot time, but with devfs I could wait until the first access to /dev/cdroms/cdrom0. (Remember the assertion that's in question: that only devfs lets you defer occupying memory with a device driver until the device is used).
Quoted 2 lines
Quoted 2 lines
Taking SCSI
as an example, a reasonable driver for a single parallel SCSI bus with
one
Quoted 4 lines
Quoted 1 line
LU per target could simply assign minor number = target ID
Your statement about SCSI and device numbers is factually wrong... There are four different major numbers for SCSI devices:...
Well, not my statement but rather your interpretation of it. When I said "a reasonable driver..." I didn't mean the one people use today, which doesn't do anything like what I described. I was trying to make a simple hypothetical case to show the underlying concept that load-on-demand is harder in devfs than in classic mknod -- and furthermore that it's because devfs is expected to do better naming. (Technically, you could set up devfs so that the device special file name is as meaningless as it is with classic mknod, and then it would be as easy to do autoload. But that wouldn't really be in the spirit of devfs).
The fact that existing SCSI and ATA drivers don't make a reliable mapping between device number and useful device identity is a major selling point for devfs. But to the extent that someone can live with the unreliable mapping (for example, I live with it without too much trouble with the cdrom device I described above), autoloading is simpler with classic mknod than with devfs. And in this thread, I'm only arguing about whether devfs enables autoloading, not whether devfs enables good device naming.