qla2xxx: Fix possible race that could hang kthread_stop()
Subsystems (2)
PATCH 1/1 qla2xxx: Fix possible race that could hang kthread_stop()
There is a small race window in qla2x00_do_dpc() between checking for kthread_should_stop() and going to sleep after setting TASK_INTERRUPTIBLE. If qla2x00_free_device() is called in this window, kthread_stop will wait forever because there will be no one to wake up the process.
--- drivers/scsi/qla2xxx/qla_os.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/scsi/qla2xxx/qla_os.c +2 -0
@@ -3286,6 +3286,8 @@ qla2x00_do_dpc(void *data)DEBUG3 (printk ("qla2x00: DPC handler sleeping\n" ));set_current_state (TASK_INTERRUPTIBLE ); +if (kthread_should_stop ()) +break ;schedule ();__set_current_state (TASK_RUNNING );
Signature · 1 line
1.7.2.3
Quoted 18 lines · Bandan Das
There is a small race window in
qla2x00_do_dpc()between checking forkthread_should_stop()and going to sleep after settingTASK_INTERRUPTIBLE. Ifqla2x00_free_device()is called in this window,kthread_stopwill wait forever because there will be no one to wake up the process.Signed-off-by Bandan Das <[email protected]>Signed-off-by Nate Dailey <[email protected]>--- drivers/scsi/qla2xxx/qla_os.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)drivers/scsi/qla2xxx/qla_os.c +0
-0
drivers/scsi/qla2xxx/qla_os.c qla2x00_do_dpc(void *data) · line 3292
Quoted 7 lines
drivers/scsi/qla2xxx/qla_os.c +2
-0@@ -3286,6 +3286,8 @@ qla2x00_do_dpc(void *data)DEBUG3 (printk ("qla2x00: DPC handler sleeping\n" ));set_current_state (TASK_INTERRUPTIBLE ); +if (kthread_should_stop ()) +break ;schedule ();__set_current_state (TASK_RUNNING );
That's not really the accepted way to fix these race conditions because of the double check of kthread_should_stop(); this is
James
---
drivers/scsi/qla2xxx/qla_os.c +3 -1
@@ -3282,10 +3282,10 @@ qla2x00_do_dpc(void *data)set_user_nice (current,-20 ); +set_current_state (TASK_INTERRUPTIBLE );while (!kthread_should_stop ()) {DEBUG3 (printk ("qla2x00: DPC handler sleeping\n" )); -set_current_state (TASK_INTERRUPTIBLE );schedule ();__set_current_state (TASK_RUNNING );
@@ -3454,7 +3454,9 @@ qla2x00_do_dpc(void *data)qla2x00_do_dpc_all_vps (base_vha); ha->dpc_active =0 ; +set_current_state (TASK_INTERRUPTIBLE ); }/* End of while(1) */ +__set_current_state (TASK_RUNNING );DEBUG (printk ("scsi(%ld): DPC handler exiting\n" , base_vha->host_no));
Quoted 23 lines
That's not really the accepted way to fix these race conditions because of the double check of
kthread_should_stop(); this is
James---
drivers/scsi/qla2xxx/qla_os.c +1
-1@@ -3282,10 +3282,10 @@ qla2x00_do_dpc(void *data)set_user_nice (current,-20 ); +set_current_state (TASK_INTERRUPTIBLE );while (!kthread_should_stop ()) {DEBUG3 (printk ("qla2x00: DPC handler sleeping\n" )); -set_current_state (TASK_INTERRUPTIBLE );schedule ();__set_current_state (TASK_RUNNING );
drivers/scsi/qla2xxx/qla_os.c qla2x00_do_dpc(void *data) · line 3462
Quoted 9 lines
drivers/scsi/qla2xxx/qla_os.c +2
-0@@ -3454,7 +3454,9 @@ qla2x00_do_dpc(void *data)qla2x00_do_dpc_all_vps (base_vha); ha->dpc_active =0 ; +set_current_state (TASK_INTERRUPTIBLE ); }/* End of while(1) */ +__set_current_state (TASK_RUNNING );DEBUG (printk ("scsi(%ld): DPC handler exiting\n" , base_vha->host_no));
Yes, this looks more clean and will take care of the problem I am hitting.
Bandan
Madhu Iyengar
Acked-byWe at QLogic are fine with James's fix. Here's my ack:
Cheers,
Madhu
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Bandan Das
Sent: Thursday, January 27, 2011 1:33 PM
To: James Bottomley
Cc: Andrew Vasquez; [email protected]; [email protected]
Subject: Re: [PATCH] qla2xxx: Fix possible race that could hang kthread_stop()
Quoted 22 lines
That's not really the accepted way to fix these race conditions because of the double check of
kthread_should_stop(); this is
James---
drivers/scsi/qla2xxx/qla_os.c +1
-1@@ -3282,10 +3282,10 @@ qla2x00_do_dpc(void *data)set_user_nice (current,-20 ); +set_current_state (TASK_INTERRUPTIBLE );while (!kthread_should_stop ()) {DEBUG3 (printk ("qla2x00: DPC handler sleeping\n" )); -set_current_state (TASK_INTERRUPTIBLE );schedule ();__set_current_state (TASK_RUNNING );
drivers/scsi/qla2xxx/qla_os.c qla2x00_do_dpc(void *data) · line 3462
Quoted 9 lines
drivers/scsi/qla2xxx/qla_os.c +2
-0@@ -3454,7 +3454,9 @@ qla2x00_do_dpc(void *data)qla2x00_do_dpc_all_vps (base_vha); ha->dpc_active =0 ; +set_current_state (TASK_INTERRUPTIBLE ); }/* End of while(1) */ +__set_current_state (TASK_RUNNING );DEBUG (printk ("scsi(%ld): DPC handler exiting\n" , base_vha->host_no));
Yes, this looks more clean and will take care of the problem I am hitting.
Bandan
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
This message and any attached documents contain information from QLogic Corporation or its wholly-owned subsidiaries that may be confidential. If you are not the intended recipient, you may not read, copy, distribute, or use this information. If you have received this transmission in error, please notify the sender immediately by reply e-mail and then delete this message.
Quoted 6 lines · Madhu Iyengar
We at QLogic are fine with James's fix. Here's my ack:
Cheers,
Madhu
James, You are gonna take care of this or do you want me to send a new patch ? I am fine either ways.
Quoted 50 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Bandan Das
Sent: Thursday, January 27, 2011 1:33 PM
To: James Bottomley
Cc: Andrew Vasquez; [email protected]; [email protected]
Subject: Re: [PATCH] qla2xxx: Fix possible race that could hangkthread_stop()Quoted 22 lines
That's not really the accepted way to fix these race conditions because of the double check of
kthread_should_stop(); this is
James---
drivers/scsi/qla2xxx/qla_os.c +1
-1@@ -3282,10 +3282,10 @@ qla2x00_do_dpc(void *data)set_user_nice (current,-20 ); +set_current_state (TASK_INTERRUPTIBLE );while (!kthread_should_stop ()) {DEBUG3 (printk ("qla2x00: DPC handler sleeping\n" )); -set_current_state (TASK_INTERRUPTIBLE );schedule ();__set_current_state (TASK_RUNNING );drivers/scsi/qla2xxx/qla_os.c qla2x00_do_dpc(void *data) · line 3462
Quoted 9 lines
drivers/scsi/qla2xxx/qla_os.c +2
-0@@ -3454,7 +3454,9 @@ qla2x00_do_dpc(void *data)qla2x00_do_dpc_all_vps (base_vha); ha->dpc_active =0 ; +set_current_state (TASK_INTERRUPTIBLE ); }/* End of while(1) */ +__set_current_state (TASK_RUNNING );DEBUG (printk ("scsi(%ld): DPC handler exiting\n" , base_vha->host_no));Yes, this looks more clean and will take care of the problem I am hitting.
Bandan
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.htmlThis message and any attached documents contain information from QLogic Corporation or its wholly-owned subsidiaries that may be confidential. If you are not the intended recipient, you may not read, copy, distribute, or use this information. If you have received this transmission in error, please notify the sender immediately by reply e-mail and then delete this message.