diff options
author | Matthew Wilcox <matthew@wil.cx> | 2006-12-07 21:29:27 -0500 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2007-01-03 17:57:31 -0500 |
commit | 8bcc24127be12967588db0ad0e614be937ee1d5a (patch) | |
tree | 1cf09463b1ba851985d88d3da4ba1ff5a4af6192 /drivers | |
parent | 23be331d9e5077edf07d73813f870d3b895c8593 (diff) |
[SCSI] Add missing completion to scsi_complete_async_scans()
If either scsi_complete_async_scans() is called a second time
before the first call has finished, or a host scan is started while
scsi_complete_async_scans() is still sleeping, it would fail to wake up
the other task, which would sleep forever.
I've changed the kernel-doc to make it clear that
scsi_complete_async_scans() only guarantees that scans which started
before it was called are guaranteed to have finished when it returns.
I considered making it wait until all scans are completed, but it can't
guarantee that no more scans will start before it returns anyway, and it
runs the risk of confusing other callers of scsi_complete_async_scans()
for hosts actually scanning.
Signed-off-by: Matthew Wilcox <matthew@wil.cx>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/scsi/scsi_scan.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 14e635aa44ce..13228312fc4d 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c | |||
@@ -133,12 +133,10 @@ struct async_scan_data { | |||
133 | /** | 133 | /** |
134 | * scsi_complete_async_scans - Wait for asynchronous scans to complete | 134 | * scsi_complete_async_scans - Wait for asynchronous scans to complete |
135 | * | 135 | * |
136 | * Asynchronous scans add themselves to the scanning_hosts list. Once | 136 | * When this function returns, any host which started scanning before |
137 | * that list is empty, we know that the scans are complete. Rather than | 137 | * this function was called will have finished its scan. Hosts which |
138 | * waking up periodically to check the state of the list, we pretend to be | 138 | * started scanning after this function was called may or may not have |
139 | * a scanning task by adding ourselves at the end of the list and going to | 139 | * finished. |
140 | * sleep. When the task before us wakes us up, we take ourselves off the | ||
141 | * list and return. | ||
142 | */ | 140 | */ |
143 | int scsi_complete_async_scans(void) | 141 | int scsi_complete_async_scans(void) |
144 | { | 142 | { |
@@ -171,6 +169,11 @@ int scsi_complete_async_scans(void) | |||
171 | 169 | ||
172 | spin_lock(&async_scan_lock); | 170 | spin_lock(&async_scan_lock); |
173 | list_del(&data->list); | 171 | list_del(&data->list); |
172 | if (!list_empty(&scanning_hosts)) { | ||
173 | struct async_scan_data *next = list_entry(scanning_hosts.next, | ||
174 | struct async_scan_data, list); | ||
175 | complete(&next->prev_finished); | ||
176 | } | ||
174 | done: | 177 | done: |
175 | spin_unlock(&async_scan_lock); | 178 | spin_unlock(&async_scan_lock); |
176 | 179 | ||