Eliminate signals entirely from the mid-layer
PATCH 1/1 Eliminate signals entirely from the mid-layer
the attached patch removes SCSI's use of signals for killing the error handler thread. It also:
- changes the eh_notify semaphore to a completion
- adds complete_and_exit() to the thread
- uses a host structure flag to signal thread death instead of the signal
I'm currently travelling, so could someone test it out for me? Thanks,
James
# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas:
# ChangeSet 1.947 -> 1.948
# drivers/scsi/scsi_error.c 1.26 -> 1.27
# drivers/scsi/hosts.c 1.42 -> 1.43
# drivers/scsi/hosts.h 1.47 -> 1.48
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/01/10 jejb@mulgrave.(none) 1.948
# remove SCSI's use of signals for killing the error handler thread # # - change the eh_notify semaphore to a completion # - add complete_and_exit() to the thread # - use a host structure flag to signal thread death instead of the signal # -------------------------------------------- # diff -Nru a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c --- a/drivers/scsi/hosts.c Fri Jan 10 16:14:02 2003 +++ b/drivers/scsi/hosts.c Fri Jan 10 16:14:02 2003 @@ -36,6 +36,7 @@ #include <linux/init.h> #include <linux/interrupt.h> #include <linux/list.h> +#include <linux/completion.h>
#define __KERNEL_SYSCALLS__
@@ -335,10 +336,10 @@
* Next, kill the kernel error recovery thread for this host. */
if (shost->ehandler) {
- DECLARE_MUTEX_LOCKED(sem);
+ DECLARE_COMPLETION(sem);
shost->eh_notify = &sem;
- send_sig(SIGPWR, shost->ehandler, 1);
- down(&sem);
+ up(shost->eh_wait);
+ wait_for_completion(&sem);
shost->eh_notify = NULL;
}
@@ -368,7 +369,7 @@
{
struct Scsi_Host *shost, *shost_scr;
int gfp_mask;
- DECLARE_MUTEX_LOCKED(sem);
+ DECLARE_COMPLETION(sem);
/* Check to see if this host has any error handling facilities */
if(shost_tp->eh_strategy_handler == NULL &&@@ -464,7 +465,7 @@
* Now wait for the kernel error thread to initialize itself
* as it might be needed when we scan the bus.
*/
- down(&sem);
+ wait_for_completion(&sem);
shost->eh_notify = NULL;
shost->hostt->present++;
drivers/scsi/hosts.h +2 -1
@@ -381,11 +381,12 @@struct task_struct * ehandler;/* Error recovery thread. */ struct semaphore * eh_wait;/* The error recovery thread waits on this. */ -struct semaphore * eh_notify;/* wait for eh to begin */ +struct completion * eh_notify;/* wait for eh to begin or end */ struct semaphore * eh_action;/* Wait for specific actions on the host. */ unsigned int eh_active:1; /* Indicates the eh thread is awake and active ifthis is true. */ + unsigned int eh_kill:1; /* set when killing the eh thread */wait_queue_head_t host_wait;Scsi_Host_Template * hostt;atomic_t host_active;/* commands checked out */
drivers/scsi/scsi_error.c +9 -32
78 lines not on this page · raw message
Quoted 8 lines · James Bottomley [[email protected]] wrote:
the attached patch removes SCSI's use of signals for killing the error handler thread. It also:
- changes the
eh_notifysemaphore to a completion
- addscomplete_and_exit()to the thread
- uses a host structure flag to signal thread death instead of the signalI'm currently travelling, so could someone test it out for me? Thanks,
I will try to test it today or tomorrow. I am already setup for some error handler fault tests for a qlogicisp error handling update.
-andmike
--
Michael Anderson
[email protected]
Quoted 2 lines · [email protected] said:
I will try to test it today or tomorrow. I am already setup for some error handler fault tests for a qlogicisp error handling update.
Thanks. I forgot to say that it applies on top of Willem Riede's signal changes patch.
I've pushed it up to scsi-misc-2.5 to make the dependencies easier to manage.
James
Quoted 9 lines · On 2003.01.10 16:19 James Bottomley wrote:
the attached patch removes SCSI's use of signals for killing the error handler thread. It also:
- changes the
eh_notifysemaphore to a completion
- addscomplete_and_exit()to the thread
- uses a host structure flag to signal thread death instead of the signalI'm currently travelling, so could someone test it out for me? Thanks,
Sorry, James,
When I apply your patch, rmmod ide-scsi hangs. This is my log:
Jan 11 09:08:06 fallguy kernel: Error handler scsi_eh_2 waking up Jan 11 09:08:06 fallguy kernel: Total of 0 commands on 0 devices require eh work Jan 11 09:08:06 fallguy kernel: scsi_eh_get_sense: checking to see if we need to request sense Jan 11 09:08:06 fallguy kernel: scsi_restart_operations: waking up host to restart Jan 11 09:08:06 fallguy kernel: Error handler scsi_eh_2 sleeping
and ps shows:
...
040 0 236 1 15 0 0 0 down_i SW ? 0:00 [scsi_eh_2]
...
100 0 946 887 16 0 1324 380 scsi_u D pts/0 0:00 rmmod ide-scsi 044 0 947 946 16 0 0 0 do_exi Z pts/0 0:00 [kmodule0? <defunct>]
...
Regards, Willem Riede.
Quoted 1 line · [email protected] said:
When I apply your patch, rmmod ide-scsi hangs. This is my log:
Well, we all have these embarassing things we forget from time to time (like remembering actually to tell the daemon to die...). Can you try the attached as an additional patch?
Thanks,
James
===== drivers/scsi/hosts.c 1.43 vs edited =====
drivers/scsi/hosts.c +1 -0
@@ -338,6 +338,7 @@if (shost->ehandler) {DECLARE_COMPLETION (sem); shost->eh_notify = &sem; + shost->eh_kill =1 ;up (shost->eh_wait);wait_for_completion (&sem); shost->eh_notify =NULL ;
Quoted 6 lines · James Bottomley [[email protected]] wrote:
Quoted 1 line · [email protected] said:
When I apply your patch, rmmod ide-scsi hangs. This is my log:
Well, we all have these embarassing things we forget from time to time (like remembering actually to tell the daemon to die...). Can you try the attached as an additional patch?
I applied your patch plus this last change to my 2.5.55 view and the error handler is exiting on rmmod of scsi_debug.
I did some drive pulls and the error handler woke up and returned to sleep. (The errors where not cleared, but that is not related to your patch)
-andmike
--
Michael Anderson
[email protected]
Quoted 7 lines · On 2003.01.11 10:44 James Bottomley wrote:
Quoted 1 line · [email protected] said:
When I apply your patch, rmmod ide-scsi hangs. This is my log:
Well, we all have these embarassing things we forget from time to time (like remembering actually to tell the daemon to die...). Can you try the attached as an additional patch?
Success!
With this change rmmod completes, the error handler exits when it is supposed to, I can rmmod / modprobe ide-scsi repeatedly until I tire of it, and signals sent deliberately to the error handler process with kill have no effect.
Regards, Willem Riede.