diff options
| -rw-r--r-- | drivers/scsi/hosts.c | 23 | ||||
| -rw-r--r-- | drivers/scsi/scsi_error.c | 29 | ||||
| -rw-r--r-- | include/scsi/scsi_host.h | 2 |
3 files changed, 10 insertions, 44 deletions
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index 8640ad1c17e2..85503fad789a 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c | |||
| @@ -24,6 +24,7 @@ | |||
| 24 | #include <linux/module.h> | 24 | #include <linux/module.h> |
| 25 | #include <linux/blkdev.h> | 25 | #include <linux/blkdev.h> |
| 26 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
| 27 | #include <linux/kthread.h> | ||
| 27 | #include <linux/string.h> | 28 | #include <linux/string.h> |
| 28 | #include <linux/mm.h> | 29 | #include <linux/mm.h> |
| 29 | #include <linux/init.h> | 30 | #include <linux/init.h> |
| @@ -225,15 +226,8 @@ static void scsi_host_dev_release(struct device *dev) | |||
| 225 | struct Scsi_Host *shost = dev_to_shost(dev); | 226 | struct Scsi_Host *shost = dev_to_shost(dev); |
| 226 | struct device *parent = dev->parent; | 227 | struct device *parent = dev->parent; |
| 227 | 228 | ||
| 228 | if (shost->ehandler) { | 229 | if (shost->ehandler) |
| 229 | DECLARE_COMPLETION(sem); | 230 | kthread_stop(shost->ehandler); |
| 230 | shost->eh_notify = &sem; | ||
| 231 | shost->eh_kill = 1; | ||
| 232 | up(shost->eh_wait); | ||
| 233 | wait_for_completion(&sem); | ||
| 234 | shost->eh_notify = NULL; | ||
| 235 | } | ||
| 236 | |||
| 237 | if (shost->work_q) | 231 | if (shost->work_q) |
| 238 | destroy_workqueue(shost->work_q); | 232 | destroy_workqueue(shost->work_q); |
| 239 | 233 | ||
| @@ -263,7 +257,6 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) | |||
| 263 | { | 257 | { |
| 264 | struct Scsi_Host *shost; | 258 | struct Scsi_Host *shost; |
| 265 | int gfp_mask = GFP_KERNEL, rval; | 259 | int gfp_mask = GFP_KERNEL, rval; |
| 266 | DECLARE_COMPLETION(complete); | ||
| 267 | 260 | ||
| 268 | if (sht->unchecked_isa_dma && privsize) | 261 | if (sht->unchecked_isa_dma && privsize) |
| 269 | gfp_mask |= __GFP_DMA; | 262 | gfp_mask |= __GFP_DMA; |
| @@ -369,12 +362,12 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) | |||
| 369 | snprintf(shost->shost_classdev.class_id, BUS_ID_SIZE, "host%d", | 362 | snprintf(shost->shost_classdev.class_id, BUS_ID_SIZE, "host%d", |
| 370 | shost->host_no); | 363 | shost->host_no); |
| 371 | 364 | ||
| 372 | shost->eh_notify = &complete; | 365 | shost->ehandler = kthread_run(scsi_error_handler, shost, |
| 373 | rval = kernel_thread(scsi_error_handler, shost, 0); | 366 | "scsi_eh_%d", shost->host_no); |
| 374 | if (rval < 0) | 367 | if (IS_ERR(shost->ehandler)) { |
| 368 | rval = PTR_ERR(shost->ehandler); | ||
| 375 | goto fail_destroy_freelist; | 369 | goto fail_destroy_freelist; |
| 376 | wait_for_completion(&complete); | 370 | } |
| 377 | shost->eh_notify = NULL; | ||
| 378 | 371 | ||
| 379 | scsi_proc_hostdir_add(shost->hostt); | 372 | scsi_proc_hostdir_add(shost->hostt); |
| 380 | return shost; | 373 | return shost; |
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 688bce740786..ebe74ccb518a 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | #include <linux/string.h> | 20 | #include <linux/string.h> |
| 21 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
| 22 | #include <linux/kernel.h> | 22 | #include <linux/kernel.h> |
| 23 | #include <linux/kthread.h> | ||
| 23 | #include <linux/interrupt.h> | 24 | #include <linux/interrupt.h> |
| 24 | #include <linux/blkdev.h> | 25 | #include <linux/blkdev.h> |
| 25 | #include <linux/delay.h> | 26 | #include <linux/delay.h> |
| @@ -1585,16 +1586,8 @@ int scsi_error_handler(void *data) | |||
| 1585 | int rtn; | 1586 | int rtn; |
| 1586 | DECLARE_MUTEX_LOCKED(sem); | 1587 | DECLARE_MUTEX_LOCKED(sem); |
| 1587 | 1588 | ||
| 1588 | /* | ||
| 1589 | * Flush resources | ||
| 1590 | */ | ||
| 1591 | |||
| 1592 | daemonize("scsi_eh_%d", shost->host_no); | ||
| 1593 | |||
| 1594 | current->flags |= PF_NOFREEZE; | 1589 | current->flags |= PF_NOFREEZE; |
| 1595 | |||
| 1596 | shost->eh_wait = &sem; | 1590 | shost->eh_wait = &sem; |
| 1597 | shost->ehandler = current; | ||
| 1598 | 1591 | ||
| 1599 | /* | 1592 | /* |
| 1600 | * Wake up the thread that created us. | 1593 | * Wake up the thread that created us. |
| @@ -1602,8 +1595,6 @@ int scsi_error_handler(void *data) | |||
| 1602 | SCSI_LOG_ERROR_RECOVERY(3, printk("Wake up parent of" | 1595 | SCSI_LOG_ERROR_RECOVERY(3, printk("Wake up parent of" |
| 1603 | " scsi_eh_%d\n",shost->host_no)); | 1596 | " scsi_eh_%d\n",shost->host_no)); |
| 1604 | 1597 | ||
| 1605 | complete(shost->eh_notify); | ||
| 1606 | |||
| 1607 | while (1) { | 1598 | while (1) { |
| 1608 | /* | 1599 | /* |
| 1609 | * If we get a signal, it means we are supposed to go | 1600 | * If we get a signal, it means we are supposed to go |
| @@ -1624,7 +1615,7 @@ int scsi_error_handler(void *data) | |||
| 1624 | * semaphores isn't unreasonable. | 1615 | * semaphores isn't unreasonable. |
| 1625 | */ | 1616 | */ |
| 1626 | down_interruptible(&sem); | 1617 | down_interruptible(&sem); |
| 1627 | if (shost->eh_kill) | 1618 | if (kthread_should_stop()) |
| 1628 | break; | 1619 | break; |
| 1629 | 1620 | ||
| 1630 | SCSI_LOG_ERROR_RECOVERY(1, printk("Error handler" | 1621 | SCSI_LOG_ERROR_RECOVERY(1, printk("Error handler" |
| @@ -1663,22 +1654,6 @@ int scsi_error_handler(void *data) | |||
| 1663 | * Make sure that nobody tries to wake us up again. | 1654 | * Make sure that nobody tries to wake us up again. |
| 1664 | */ | 1655 | */ |
| 1665 | shost->eh_wait = NULL; | 1656 | shost->eh_wait = NULL; |
| 1666 | |||
| 1667 | /* | ||
| 1668 | * Knock this down too. From this point on, the host is flying | ||
| 1669 | * without a pilot. If this is because the module is being unloaded, | ||
| 1670 | * that's fine. If the user sent a signal to this thing, we are | ||
| 1671 | * potentially in real danger. | ||
| 1672 | */ | ||
| 1673 | shost->eh_active = 0; | ||
| 1674 | shost->ehandler = NULL; | ||
| 1675 | |||
| 1676 | /* | ||
| 1677 | * If anyone is waiting for us to exit (i.e. someone trying to unload | ||
| 1678 | * a driver), then wake up that process to let them know we are on | ||
| 1679 | * the way out the door. | ||
| 1680 | */ | ||
| 1681 | complete_and_exit(shost->eh_notify, 0); | ||
| 1682 | return 0; | 1657 | return 0; |
| 1683 | } | 1658 | } |
| 1684 | 1659 | ||
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index ac1b6125e3ae..916144be208b 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h | |||
| @@ -467,12 +467,10 @@ struct Scsi_Host { | |||
| 467 | struct task_struct * ehandler; /* Error recovery thread. */ | 467 | struct task_struct * ehandler; /* Error recovery thread. */ |
| 468 | struct semaphore * eh_wait; /* The error recovery thread waits | 468 | struct semaphore * eh_wait; /* The error recovery thread waits |
| 469 | on this. */ | 469 | on this. */ |
| 470 | struct completion * eh_notify; /* wait for eh to begin or end */ | ||
| 471 | struct semaphore * eh_action; /* Wait for specific actions on the | 470 | struct semaphore * eh_action; /* Wait for specific actions on the |
| 472 | host. */ | 471 | host. */ |
| 473 | unsigned int eh_active:1; /* Indicates the eh thread is awake and active if | 472 | unsigned int eh_active:1; /* Indicates the eh thread is awake and active if |
| 474 | this is true. */ | 473 | this is true. */ |
| 475 | unsigned int eh_kill:1; /* set when killing the eh thread */ | ||
| 476 | wait_queue_head_t host_wait; | 474 | wait_queue_head_t host_wait; |
| 477 | struct scsi_host_template *hostt; | 475 | struct scsi_host_template *hostt; |
| 478 | struct scsi_transport_template *transportt; | 476 | struct scsi_transport_template *transportt; |
