Commit 8521f378 authored by James Bottomley's avatar James Bottomley

[SCSI] move build commandblocks to before attach so attach can send I/O

parent a049055c
......@@ -561,15 +561,16 @@ int scsi_register_host(Scsi_Host_Template *shost_tp)
shost = list_entry(lh, struct Scsi_Host, sh_list);
for (sdev = shost->host_queue; sdev; sdev = sdev->next)
if (sdev->host->hostt == shost_tp) {
scsi_build_commandblocks(sdev);
if (sdev->current_queue_depth == 0)
goto out_of_space;
for (sdev_tp = scsi_devicelist;
sdev_tp;
sdev_tp = sdev_tp->next)
if (sdev_tp->attach)
(*sdev_tp->attach) (sdev);
if (sdev->attached) {
scsi_build_commandblocks(sdev);
if (sdev->current_queue_depth == 0)
goto out_of_space;
if (!sdev->attached) {
scsi_release_commandblocks(sdev);
}
}
}
......
......@@ -2019,18 +2019,22 @@ int scsi_register_device(struct Scsi_Device_Template *tpnt)
shpnt = scsi_host_get_next(shpnt)) {
for (SDpnt = shpnt->host_queue; SDpnt;
SDpnt = SDpnt->next) {
scsi_build_commandblocks(SDpnt);
if (SDpnt->current_queue_depth == 0) {
out_of_space = 1;
continue;
}
if (tpnt->attach)
(*tpnt->attach) (SDpnt);
/*
* If this driver attached to the device, and don't have any
* command blocks for this device, allocate some.
*/
if (SDpnt->attached && SDpnt->current_queue_depth == 0) {
if (SDpnt->attached)
SDpnt->online = TRUE;
scsi_build_commandblocks(SDpnt);
if (SDpnt->current_queue_depth == 0)
out_of_space = 1;
}
else
scsi_release_commandblocks(SDpnt);
}
}
......
......@@ -1995,24 +1995,28 @@ static void scsi_scan_selected_lun(struct Scsi_Host *shost, uint channel,
sdevscan->scsi_level = scsi_find_scsi_level(channel, id, shost);
res = scsi_probe_and_add_lun(sdevscan, &sdev, NULL);
scsi_free_sdev(sdevscan);
if (res == SCSI_SCAN_LUN_PRESENT) {
if (res != SCSI_SCAN_LUN_PRESENT)
return;
BUG_ON(sdev == NULL);
scsi_build_commandblocks(sdev);
if (sdev->current_queue_depth == 0) {
printk(ALLOC_FAILURE_MSG, __FUNCTION__);
return;
}
for (sdt = scsi_devicelist; sdt; sdt = sdt->next)
if (sdt->init && sdt->dev_noticed)
(*sdt->init) ();
for (sdt = scsi_devicelist; sdt; sdt = sdt->next)
if (sdt->attach) {
if (sdt->attach)
(*sdt->attach) (sdev);
if (sdev->attached) {
scsi_build_commandblocks(sdev);
if (sdev->current_queue_depth == 0)
printk(ALLOC_FAILURE_MSG,
__FUNCTION__);
}
}
}
if (!sdev->attached)
scsi_release_commandblocks(sdev);
}
/**
......
......@@ -481,11 +481,11 @@ static int sr_attach(Scsi_Device * SDp)
if (i >= sr_template.dev_max)
panic("scsi_devices corrupt (sr)");
scsi_CDs[i].device = SDp;
if (sr_init_one(cpnt, i))
goto fail;
scsi_CDs[i].device = SDp;
sr_template.nr_dev++;
if (sr_template.nr_dev > sr_template.dev_max)
panic("scsi_devices corrupt (sr)");
......
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