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