Commit a182f7a3 authored by Christoph Hellwig's avatar Christoph Hellwig

[PATCH] get rid of scan_scsis

this function was a multiplexer for two very different things, but
with my last patch one of those faded away and only one callers
is left.  Simplify it to what's still needed and rename to
scsi_scan_host.
parent 865e9146
...@@ -315,7 +315,7 @@ int scsi_add_host(struct Scsi_Host *shost) ...@@ -315,7 +315,7 @@ int scsi_add_host(struct Scsi_Host *shost)
sht->info ? sht->info(shost) : sht->name); sht->info ? sht->info(shost) : sht->name);
device_register(&shost->host_driverfs_dev); device_register(&shost->host_driverfs_dev);
scan_scsis(shost, 0, 0, 0, 0); scsi_scan_host(shost);
for (sdev = shost->host_queue; sdev; sdev = sdev->next) { for (sdev = shost->host_queue; sdev; sdev = sdev->next) {
if (sdev->host->hostt != sht) if (sdev->host->hostt != sht)
......
...@@ -519,7 +519,7 @@ static inline void scsi_set_pci_device(struct Scsi_Host *shost, ...@@ -519,7 +519,7 @@ static inline void scsi_set_pci_device(struct Scsi_Host *shost,
/* /*
* Prototypes for functions/data in scsi_scan.c * Prototypes for functions/data in scsi_scan.c
*/ */
extern void scan_scsis(struct Scsi_Host *, uint, uint, uint, uint); extern void scsi_scan_host(struct Scsi_Host *);
struct Scsi_Device_Template struct Scsi_Device_Template
{ {
......
...@@ -1990,111 +1990,56 @@ static void scsi_scan_target(Scsi_Device *sdevscan, struct Scsi_Host *shost, ...@@ -1990,111 +1990,56 @@ static void scsi_scan_target(Scsi_Device *sdevscan, struct Scsi_Host *shost,
} }
/** /**
* scsi_scan_selected_lun - probe and add one LUN * scsi_scan_host - scan the given adapter
* @shost: adapter to scan
* *
* Description: * Description:
* Probe a single LUN on @shost, @channel, @id and @lun. If the LUN is * Iterate and call scsi_scan_target to scan all possible target id's
* found, set the queue depth, allocate command blocks, and call * on all possible channels.
* init/attach/finish of the upper level (sd, sg, etc.) drivers.
**/ **/
static void scsi_scan_selected_lun(struct Scsi_Host *shost, uint channel, void scsi_scan_host(struct Scsi_Host *shost)
uint id, uint lun)
{ {
Scsi_Device *sdevscan, *sdev = NULL; struct scsi_device *sdevscan;
int res; uint channel, id, order_id;
if ((channel > shost->max_channel) || (id >= shost->max_id) || /*
(lun >= shost->max_lun)) * The blk layer queue allocation is a bit expensive to
return; * repeat for each channel and id - for FCP max_id is near
* 255: each call to scsi_alloc_sdev() implies a call to
sdevscan = scsi_alloc_sdev(shost, channel, id, lun); * blk_init_queue, and then blk_init_free_list, where 2 *
* queue_nr_requests requests are allocated. Don't do so
* here for scsi_scan_selected_lun, since we end up
* calling select_queue_depths with an extra Scsi_Device
* on the host_queue list.
*/
sdevscan = scsi_alloc_sdev(shost, 0, 0, 0);
if (sdevscan == NULL) if (sdevscan == NULL)
return; return;
/*
sdevscan->scsi_level = scsi_find_scsi_level(channel, id, shost); * The sdevscan host, channel, id and lun are filled in as
res = scsi_probe_and_add_lun(sdevscan, &sdev, NULL); * needed to scan.
scsi_free_sdev(sdevscan); */
for (channel = 0; channel <= shost->max_channel; channel++) {
if (res != SCSI_SCAN_LUN_PRESENT)
return;
scsi_attach_device(sdev);
}
/**
* scan_scsis - scan the given adapter, or scan a single LUN
* @shost: adapter to scan
* @hardcoded: 1 if a single channel/id/lun should be scanned, else 0
* @hchannel: channel to scan for hardcoded case
* @hid: target id to scan for hardcoded case
* @hlun: lun to scan for hardcoded case
*
* Description:
* If @hardcoded is 1, call scsi_scan_selected_lun to scan a single
* LUN; else, iterate and call scsi_scan_target to scan all possible
* target id's on all possible channels.
**/
void scan_scsis(struct Scsi_Host *shost, uint hardcoded, uint hchannel,
uint hid, uint hlun)
{
if (hardcoded == 1) {
/* /*
* XXX Overload hchannel/hid/hlun to figure out what to * XXX adapter drivers when possible (FCP, iSCSI)
* scan, and use the standard scanning code rather than * could modify max_id to match the current max,
* this function - that way, an entire bus (or fabric), or * not the absolute max.
* target id can be scanned. There are problems with queue
* depth and the init/attach/finish that must be resolved
* before (re-)scanning can handle finding more than one new
* LUN.
* *
* For example, set hchannel 0 and hid to 5, and hlun to -1 * XXX add a shost id iterator, so for example,
* in order to scan all LUNs on channel 0, target id 5. * the FC ID can be the same as a target id
*/ * without a huge overhead of sparse id's.
scsi_scan_selected_lun(shost, hchannel, hid, hlun);
} else {
Scsi_Device *sdevscan;
uint channel;
unsigned int id, order_id;
/*
* The blk layer queue allocation is a bit expensive to
* repeat for each channel and id - for FCP max_id is near
* 255: each call to scsi_alloc_sdev() implies a call to
* blk_init_queue, and then blk_init_free_list, where 2 *
* queue_nr_requests requests are allocated. Don't do so
* here for scsi_scan_selected_lun, since we end up
* calling select_queue_depths with an extra Scsi_Device
* on the host_queue list.
*/
sdevscan = scsi_alloc_sdev(shost, 0, 0, 0);
if (sdevscan == NULL)
return;
/*
* The sdevscan host, channel, id and lun are filled in as
* needed to scan.
*/ */
for (channel = 0; channel <= shost->max_channel; channel++) { for (id = 0; id < shost->max_id; ++id) {
/* if (shost->reverse_ordering)
* XXX adapter drivers when possible (FCP, iSCSI) /*
* could modify max_id to match the current max, * Scan from high to low id.
* not the absolute max. */
* order_id = shost->max_id - id - 1;
* XXX add a shost id iterator, so for example, else
* the FC ID can be the same as a target id order_id = id;
* without a huge overhead of sparse id's. scsi_scan_target(sdevscan, shost, channel,
*/ order_id);
for (id = 0; id < shost->max_id; ++id) {
if (shost->reverse_ordering)
/*
* Scan from high to low id.
*/
order_id = shost->max_id - id - 1;
else
order_id = id;
scsi_scan_target(sdevscan, shost, channel,
order_id);
}
} }
scsi_free_sdev(sdevscan);
} }
scsi_free_sdev(sdevscan);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment