diff options
author | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2008-11-29 08:55:47 -0500 |
---|---|---|
committer | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2008-11-29 11:07:56 -0500 |
commit | 2642b11295ebcc94843045933061bfbb263fce7f (patch) | |
tree | aa62e749e88e0d769d2d557d4a067168108943f1 /drivers/ieee1394/sbp2.c | |
parent | e47c1feb17e61ef4e2f245c0af0c5a8e2a7798b2 (diff) |
ieee1394: sbp2: fix race condition in state change
An intermediate transition from _RUNNING to _IN_SHUTDOWN could have been
missed by the former code.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers/ieee1394/sbp2.c')
-rw-r--r-- | drivers/ieee1394/sbp2.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c index 3f5dbcb2160..a373c18cf7b 100644 --- a/drivers/ieee1394/sbp2.c +++ b/drivers/ieee1394/sbp2.c | |||
@@ -895,12 +895,13 @@ static void sbp2_host_reset(struct hpsb_host *host) | |||
895 | return; | 895 | return; |
896 | 896 | ||
897 | read_lock_irqsave(&sbp2_hi_logical_units_lock, flags); | 897 | read_lock_irqsave(&sbp2_hi_logical_units_lock, flags); |
898 | |||
898 | list_for_each_entry(lu, &hi->logical_units, lu_list) | 899 | list_for_each_entry(lu, &hi->logical_units, lu_list) |
899 | if (likely(atomic_read(&lu->state) != | 900 | if (atomic_cmpxchg(&lu->state, |
900 | SBP2LU_STATE_IN_SHUTDOWN)) { | 901 | SBP2LU_STATE_RUNNING, SBP2LU_STATE_IN_RESET) |
901 | atomic_set(&lu->state, SBP2LU_STATE_IN_RESET); | 902 | == SBP2LU_STATE_RUNNING) |
902 | scsi_block_requests(lu->shost); | 903 | scsi_block_requests(lu->shost); |
903 | } | 904 | |
904 | read_unlock_irqrestore(&sbp2_hi_logical_units_lock, flags); | 905 | read_unlock_irqrestore(&sbp2_hi_logical_units_lock, flags); |
905 | } | 906 | } |
906 | 907 | ||