···69#include "scsi_logging.h"7071static void scsi_done(struct scsi_cmnd *cmd);72-static int scsi_retry_command(struct scsi_cmnd *cmd);7374/*75 * Definitions and constants.···751 * isn't running --- used by scsi_times_out */752void __scsi_done(struct scsi_cmnd *cmd)753{754- unsigned long flags;755756 /*757 * Set the serial numbers back to zero···762 if (cmd->result)763 atomic_inc(&cmd->device->ioerr_cnt);76400765 /*766- * Next, enqueue the command into the done queue.767- * It is a per-CPU queue, so we just disable local interrupts768- * and need no spinlock.769 */770- local_irq_save(flags);771- list_add_tail(&cmd->eh_entry, &__get_cpu_var(scsi_done_q));772- raise_softirq_irqoff(SCSI_SOFTIRQ);773- local_irq_restore(flags);774-}775-776-/**777- * scsi_softirq - Perform post-interrupt processing of finished SCSI commands.778- *779- * This is the consumer of the done queue.780- *781- * This is called with all interrupts enabled. This should reduce782- * interrupt latency, stack depth, and reentrancy of the low-level783- * drivers.784- */785-static void scsi_softirq(struct softirq_action *h)786-{787- int disposition;788- LIST_HEAD(local_q);789-790- local_irq_disable();791- list_splice_init(&__get_cpu_var(scsi_done_q), &local_q);792- local_irq_enable();793-794- while (!list_empty(&local_q)) {795- struct scsi_cmnd *cmd = list_entry(local_q.next,796- struct scsi_cmnd, eh_entry);797- /* The longest time any command should be outstanding is the798- * per command timeout multiplied by the number of retries.799- *800- * For a typical command, this is 2.5 minutes */801- unsigned long wait_for 802- = cmd->allowed * cmd->timeout_per_command;803- list_del_init(&cmd->eh_entry);804-805- disposition = scsi_decide_disposition(cmd);806- if (disposition != SUCCESS &&807- time_before(cmd->jiffies_at_alloc + wait_for, jiffies)) {808- sdev_printk(KERN_ERR, cmd->device,809- "timing out command, waited %lus\n",810- wait_for/HZ);811- disposition = SUCCESS;812- }813-814- scsi_log_completion(cmd, disposition);815- switch (disposition) {816- case SUCCESS:817- scsi_finish_command(cmd);818- break;819- case NEEDS_RETRY:820- scsi_retry_command(cmd);821- break;822- case ADD_TO_MLQUEUE:823- scsi_queue_insert(cmd, SCSI_MLQUEUE_DEVICE_BUSY);824- break;825- default:826- if (!scsi_eh_scmd_add(cmd, 0))827- scsi_finish_command(cmd);828- }829- }830}831832/*···782 * level drivers should not become re-entrant as a result of783 * this.784 */785-static int scsi_retry_command(struct scsi_cmnd *cmd)786{787 /*788 * Restore the SCSI command state.···1215}1216EXPORT_SYMBOL(scsi_device_cancel);12171218-#ifdef CONFIG_HOTPLUG_CPU1219-static int scsi_cpu_notify(struct notifier_block *self,1220- unsigned long action, void *hcpu)1221-{1222- int cpu = (unsigned long)hcpu;1223-1224- switch(action) {1225- case CPU_DEAD:1226- /* Drain scsi_done_q. */1227- local_irq_disable();1228- list_splice_init(&per_cpu(scsi_done_q, cpu),1229- &__get_cpu_var(scsi_done_q));1230- raise_softirq_irqoff(SCSI_SOFTIRQ);1231- local_irq_enable();1232- break;1233- default:1234- break;1235- }1236- return NOTIFY_OK;1237-}1238-1239-static struct notifier_block __devinitdata scsi_cpu_nb = {1240- .notifier_call = scsi_cpu_notify,1241-};1242-1243-#define register_scsi_cpu() register_cpu_notifier(&scsi_cpu_nb)1244-#define unregister_scsi_cpu() unregister_cpu_notifier(&scsi_cpu_nb)1245-#else1246-#define register_scsi_cpu()1247-#define unregister_scsi_cpu()1248-#endif /* CONFIG_HOTPLUG_CPU */1249-1250MODULE_DESCRIPTION("SCSI core");1251MODULE_LICENSE("GPL");1252···1248 INIT_LIST_HEAD(&per_cpu(scsi_done_q, i));12491250 devfs_mk_dir("scsi");1251- open_softirq(SCSI_SOFTIRQ, scsi_softirq, NULL);1252- register_scsi_cpu();1253 printk(KERN_NOTICE "SCSI subsystem initialized\n");1254 return 0;1255···1275 devfs_remove("scsi");1276 scsi_exit_procfs();1277 scsi_exit_queue();1278- unregister_scsi_cpu();1279}12801281subsys_initcall(init_scsi);
···69#include "scsi_logging.h"7071static void scsi_done(struct scsi_cmnd *cmd);07273/*74 * Definitions and constants.···752 * isn't running --- used by scsi_times_out */753void __scsi_done(struct scsi_cmnd *cmd)754{755+ struct request *rq = cmd->request;756757 /*758 * Set the serial numbers back to zero···763 if (cmd->result)764 atomic_inc(&cmd->device->ioerr_cnt);765766+ BUG_ON(!rq);767+768 /*769+ * The uptodate/nbytes values don't matter, as we allow partial770+ * completes and thus will check this in the softirq callback0771 */772+ rq->completion_data = cmd;773+ blk_complete_request(rq);0000000000000000000000000000000000000000000000000000000000774}775776/*···840 * level drivers should not become re-entrant as a result of841 * this.842 */843+int scsi_retry_command(struct scsi_cmnd *cmd)844{845 /*846 * Restore the SCSI command state.···1273}1274EXPORT_SYMBOL(scsi_device_cancel);1275000000000000000000000000000000001276MODULE_DESCRIPTION("SCSI core");1277MODULE_LICENSE("GPL");1278···1338 INIT_LIST_HEAD(&per_cpu(scsi_done_q, i));13391340 devfs_mk_dir("scsi");001341 printk(KERN_NOTICE "SCSI subsystem initialized\n");1342 return 0;1343···1367 devfs_remove("scsi");1368 scsi_exit_procfs();1369 scsi_exit_queue();01370}13711372subsys_initcall(init_scsi);