From: "Adam J. Richter" Subject: Re: DEVFS_FS Date: Sat, 13 Nov 2004 08:29:12 -0800 Message-ID: <200411131629.iADGTCn15423@adam.yggdrasil.com> Cc: jamie@shareable.org, linux-fsdevel@vger.kernel.org Return-path: Received: from [61.48.52.165] ([61.48.52.165]:65503 "EHLO adam.yggdrasil.com") by vger.kernel.org with ESMTP id S261870AbUKMQjt (ORCPT ); Sat, 13 Nov 2004 11:39:49 -0500 To: hbryan@us.ibm.com Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org 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. On Fri, 12 Nov 2004 10:50:25 -0800, Bryan Henderson wrote: >>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, >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). >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" 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 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 . On the other hand, some encoding of would do just fine as device names for lookup trapping, which could invoke a handler that ask the SCSI subsystem to scan just that 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 \ / adam@yggdrasil.com | g g d r a s i l