async scsi scanning, version 13
Subsystems (2)
PATCH 1/1 async scsi scanning, version 13
Version 13 ...
changes vs version 12:
Address akpm's comments:
- use DEFINE_SPINLOCK
- document how scsi_complete_async_scans works
- document why the memory allocation loop in scsi_complete_async_scans will eventually terminate
- document why we don't add ourselves to the list if it's already empty
shost_for_each_device is safe and shost_for_each_device_safe isn't. Delete shost_for_each_device_safe, use shost_for_each_device and update the docs for __shost_for_each_device and shost_for_each_device to be more accurate.
changes vs version 11:
Fix whitespace pointed out by Randy Dunlap.
Documentation/kernel-parameters.txt +5 -0
@@ -1426,6 +1426,11 @@ running once the system is up. scsi_logging= [SCSI] + scsi_mod.scan= [SCSI] sync (default) scans SCSI busses as they are + discovered. async scans them in kernel threads, + allowing boot to proceed. none ignores them, expecting + user space to do the scan. + selinux [SELINUX] Disable or enable SELinux at boot time. Format: { "0" | "1" } See security/selinux/Kconfig help text.
drivers/scsi/Makefile +2 -0
@@ -140,6 +140,8 @@ obj-$(CONFIG_CHR_DEV_SCH) += ch.o # This goes last, so that "real" scsi devices probe earlier obj-$(CONFIG_SCSI_DEBUG) += scsi_debug.o +obj-$(CONFIG_SCSI) += scsi_wait_scan.o + scsi_mod-y += scsi.o hosts.o scsi_ioctl.o constants.o \ scsicam.o scsi_error.o scsi_lib.o \ scsi_scan.o scsi_sysfs.o \
drivers/scsi/scsi_priv.h +3 -0
@@ -39,6 +39,9 @@ static inline void scsi_log_completion(s { };#endif +/* scsi_scan.c */ +int scsi_complete_async_scans (void ); +/* scsi_devinfo.c */ extern int scsi_get_device_flags(struct scsi_device *sdev, const unsigned char *vendor,
drivers/scsi/scsi_scan.c +197 -6
263 lines not on this page · raw message
drivers/scsi/scsi_wait_scan.c new file +31 -0
@@ -0,0 +1,31 @@ +/* +* scsi_wait_scan.c +* +* Copyright (C) 2006 James Bottomley <[email protected]> +* +* This is a simple module to wait until all the async scans are +* complete. The idea is to use it in initrd/initramfs scripts. You +* modprobe it after all the modprobes of the root SCSI drivers and it +* will wait until they have all finished scanning their busses before +* allowing the boot to proceed +*/ + +#include <linux/module.h> +#include "scsi_priv.h" + +static int __init wait_scan_init (void ) +{ +scsi_complete_async_scans (); +return 0 ; +} + +static void __exit wait_scan_exit(void) +{ +} + +MODULE_DESCRIPTION ("SCSI wait for scans" ); +MODULE_AUTHOR ("James Bottomley" ); +MODULE_LICENSE ("GPL" ); + +late_initcall (wait_scan_init); +module_exit (wait_scan_exit);
include/scsi/scsi_device.h +15 -15
@@ -223,13 +223,13 @@ extern struct scsi_device *__scsi_iterat struct scsi_device *);/** -* shost_for_each_device - iterate over all devices of a host -* @sdev: iterator -* @host: host whiches devices we want to iterate over +* shost_for_each_device - iterate over all devices of a host +* @sdev: the &struct scsi_device to use as a cursor +* @shost: the &struct scsi_host to iterate over * -* This traverses over each devices of @shost. The devices have -* a reference that must be released by scsi_host_put when breaking -* out of the loop. +* Iterator that returns each device attached to @shost. This loop +* takes a reference on each device and releases it at the end. If +* you break out of the loop, you must call scsi_device_put(sdev). */ #define shost_for_each_device (sdev, shost) \ for ((sdev) = __scsi_iterate_devices((shost), NULL); \
@@ -237,17 +237,17 @@ #define shost_for_each_device(sdev, shos (sdev) = __scsi_iterate_devices((shost), (sdev)))/** -* __shost_for_each_device - iterate over all devices of a host (UNLOCKED) -* @sdev: iterator -* @host: host whiches devices we want to iterate over +* __shost_for_each_device - iterate over all devices of a host (UNLOCKED) +* @sdev: the &struct scsi_device to use as a cursor +* @shost: the &struct scsi_host to iterate over * -* This traverses over each devices of @shost. It does _not_ take a -* reference on the scsi_device, thus it the whole loop must be protected -* by shost->host_lock. +* Iterator that returns each device attached to @shost. It does _not_ +* take a reference on the scsi_device, so the whole loop must be +* protected by shost->host_lock. * -* Note: The only reason why drivers would want to use this is because -* they're need to access the device list in irq context. Otherwise you -* really want to use shost_for_each_device instead. +* Note: The only reason to use this is because you need to access the +* device list in interrupt context. Otherwise you really want to use +* shost_for_each_device instead. */ #define __shost_for_each_device (sdev, shost) \ list_for_each_entry((sdev), &((shost)->__devices), siblings)
include/scsi/scsi_host.h +3 -0
@@ -552,6 +552,9 @@ struct Scsi_Host {/* task mgmt function in progress */ unsigned tmf_in_progress:1; +/* Asynchronous scan in progress */ + unsigned async_scan:1; +/* * Optional work queue to be utilized by the transport */
Quoted 11 lines · Matthew Wilcox
Version 13 ...
changes vs version 12:
Address akpm's comments:
- useDEFINE_SPINLOCK
- document howscsi_complete_async_scansworks
- document why the memory allocation loop inscsi_complete_async_scanswill eventually terminate
- document why we don't add ourselves to the list if it's already empty
Quoted 8 lines
shost_for_each_deviceis safe andshost_for_each_device_safeisn't. Deleteshost_for_each_device_safe, useshost_for_each_deviceand update the docs for__shost_for_each_deviceandshost_for_each_deviceto be more accurate.changes vs version 11:
Fix whitespace pointed out by Randy Dunlap.
OK, my plan for this is to place it in SCSI misc as soon as we get 2.6.19-rc1. That way we'll give it a thorough check out in -mm before it hits mainline.
By the way, a global change log (rather than changes relative to previous versions) would be appreciated.
James
Quoted 6 lines · James Bottomley
OK, my plan for this is to place it in SCSI misc as soon as we get 2.6.19-rc1. That way we'll give it a thorough check out in -mm before it hits mainline.
By the way, a global change log (rather than changes relative to previous versions) would be appreciated.
Certainly ...
Add ability to scan scsi busses asynchronously
Since it often takes around 20-30 seconds to scan a scsi bus, it's highly advantageous to do this in parallel with other things. The bulk of this patch is ensuring that devices don't change numbering, and that all devices are discovered prior to trying to start init. For those who build SCSI as modules, there's a new scsi_wait_scan module that will ensure all bus scans are finished.
This patch only handles drivers which call scsi_scan_host. Fibre Channel, SAS, SATA, USB and Firewire all need additional work.
Quoted 11 lines · Matthew Wilcox
Add ability to scan scsi busses asynchronously
Since it often takes around 20-30 seconds to scan a scsi bus, it's highly advantageous to do this in parallel with other things. The bulk of this patch is ensuring that devices don't change numbering, and that all devices are discovered prior to trying to start init. For those who build SCSI as modules, there's a new
scsi_wait_scanmodule that will ensure all bus scans are finished.This patch only handles drivers which call
scsi_scan_host. Fibre Channel, SAS, SATA, USB and Firewire all need additional work.
A note on FireWire/ SBP-2's status: We basically scan* asynchronously, although the scans are serialized across all FireWire devices on all buses. Parallelized scanning is on my long term to-do list. Serialized scanning is actually quick enough unless something goes wrong.
Integration of sbp2 with scsi_wait_scan is now on my to-do list too. It is orthogonal to parallelized scanning as a feature but probably somewhat coupled when it comes to an actual implementation.
So far, the few people who have the root filesystem (or any other filesystem that they want to have ready on boot) on an SBP-2 disk simply put a sleep into their initrd or run a more or less complete hotplug environment from initrd. The scsi_wait_scan module would certainly be more comfortable than that.
[ *) "scan" = read ISO 13213 configuration ROMs, then run protocol
driver probes including sbp2's login ]
Signature · 3 lines
Stefan Richter -=====-=-==- =-=- ---=- http://arcgraph.de/sr/