diff options
author | Volker Sameske <sameske@de.ibm.com> | 2006-08-02 05:05:16 -0400 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2006-08-06 12:31:00 -0400 |
commit | fea9d6c7bcd8ff1d60ff74f27ba483b3820b18a3 (patch) | |
tree | 9fd3c531809f5b7a275540e5467a59e50b6630b7 /drivers/s390/scsi/zfcp_qdio.c | |
parent | c2602c48b5ebde55b418ba252737bf60caa4bab0 (diff) |
[SCSI] zfcp: improve management of request IDs
Improve request handling. Use hash table to manage request IDs.
Signed-off-by: Volker Sameske <sameske@de.ibm.com>
Signed-off-by: Andreas Herrmann <aherrman@de.ibm.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/s390/scsi/zfcp_qdio.c')
-rw-r--r-- | drivers/s390/scsi/zfcp_qdio.c | 79 |
1 files changed, 32 insertions, 47 deletions
diff --git a/drivers/s390/scsi/zfcp_qdio.c b/drivers/s390/scsi/zfcp_qdio.c index 49ea5add4abc..dbd9f48e863e 100644 --- a/drivers/s390/scsi/zfcp_qdio.c +++ b/drivers/s390/scsi/zfcp_qdio.c | |||
@@ -282,6 +282,37 @@ zfcp_qdio_request_handler(struct ccw_device *ccw_device, | |||
282 | return; | 282 | return; |
283 | } | 283 | } |
284 | 284 | ||
285 | /** | ||
286 | * zfcp_qdio_reqid_check - checks for valid reqids or unsolicited status | ||
287 | */ | ||
288 | static int zfcp_qdio_reqid_check(struct zfcp_adapter *adapter, | ||
289 | unsigned long req_id) | ||
290 | { | ||
291 | struct zfcp_fsf_req *fsf_req; | ||
292 | unsigned long flags; | ||
293 | |||
294 | debug_long_event(adapter->erp_dbf, 4, req_id); | ||
295 | |||
296 | spin_lock_irqsave(&adapter->req_list_lock, flags); | ||
297 | fsf_req = zfcp_reqlist_ismember(adapter, req_id); | ||
298 | |||
299 | if (!fsf_req) { | ||
300 | spin_unlock_irqrestore(&adapter->req_list_lock, flags); | ||
301 | ZFCP_LOG_NORMAL("error: unknown request id (%ld).\n", req_id); | ||
302 | zfcp_erp_adapter_reopen(adapter, 0); | ||
303 | return -EINVAL; | ||
304 | } | ||
305 | |||
306 | zfcp_reqlist_remove(adapter, req_id); | ||
307 | atomic_dec(&adapter->reqs_active); | ||
308 | spin_unlock_irqrestore(&adapter->req_list_lock, flags); | ||
309 | |||
310 | /* finish the FSF request */ | ||
311 | zfcp_fsf_req_complete(fsf_req); | ||
312 | |||
313 | return 0; | ||
314 | } | ||
315 | |||
285 | /* | 316 | /* |
286 | * function: zfcp_qdio_response_handler | 317 | * function: zfcp_qdio_response_handler |
287 | * | 318 | * |
@@ -344,7 +375,7 @@ zfcp_qdio_response_handler(struct ccw_device *ccw_device, | |||
344 | /* look for QDIO request identifiers in SB */ | 375 | /* look for QDIO request identifiers in SB */ |
345 | buffere = &buffer->element[buffere_index]; | 376 | buffere = &buffer->element[buffere_index]; |
346 | retval = zfcp_qdio_reqid_check(adapter, | 377 | retval = zfcp_qdio_reqid_check(adapter, |
347 | (void *) buffere->addr); | 378 | (unsigned long) buffere->addr); |
348 | 379 | ||
349 | if (retval) { | 380 | if (retval) { |
350 | ZFCP_LOG_NORMAL("bug: unexpected inbound " | 381 | ZFCP_LOG_NORMAL("bug: unexpected inbound " |
@@ -415,52 +446,6 @@ zfcp_qdio_response_handler(struct ccw_device *ccw_device, | |||
415 | return; | 446 | return; |
416 | } | 447 | } |
417 | 448 | ||
418 | /* | ||
419 | * function: zfcp_qdio_reqid_check | ||
420 | * | ||
421 | * purpose: checks for valid reqids or unsolicited status | ||
422 | * | ||
423 | * returns: 0 - valid request id or unsolicited status | ||
424 | * !0 - otherwise | ||
425 | */ | ||
426 | int | ||
427 | zfcp_qdio_reqid_check(struct zfcp_adapter *adapter, void *sbale_addr) | ||
428 | { | ||
429 | struct zfcp_fsf_req *fsf_req; | ||
430 | unsigned long flags; | ||
431 | |||
432 | /* invalid (per convention used in this driver) */ | ||
433 | if (unlikely(!sbale_addr)) { | ||
434 | ZFCP_LOG_NORMAL("bug: invalid reqid\n"); | ||
435 | return -EINVAL; | ||
436 | } | ||
437 | |||
438 | /* valid request id and thus (hopefully :) valid fsf_req address */ | ||
439 | fsf_req = (struct zfcp_fsf_req *) sbale_addr; | ||
440 | |||
441 | /* serialize with zfcp_fsf_req_dismiss_all */ | ||
442 | spin_lock_irqsave(&adapter->fsf_req_list_lock, flags); | ||
443 | if (list_empty(&adapter->fsf_req_list_head)) { | ||
444 | spin_unlock_irqrestore(&adapter->fsf_req_list_lock, flags); | ||
445 | return 0; | ||
446 | } | ||
447 | list_del(&fsf_req->list); | ||
448 | atomic_dec(&adapter->fsf_reqs_active); | ||
449 | spin_unlock_irqrestore(&adapter->fsf_req_list_lock, flags); | ||
450 | |||
451 | if (unlikely(adapter != fsf_req->adapter)) { | ||
452 | ZFCP_LOG_NORMAL("bug: invalid reqid (fsf_req=%p, " | ||
453 | "fsf_req->adapter=%p, adapter=%p)\n", | ||
454 | fsf_req, fsf_req->adapter, adapter); | ||
455 | return -EINVAL; | ||
456 | } | ||
457 | |||
458 | /* finish the FSF request */ | ||
459 | zfcp_fsf_req_complete(fsf_req); | ||
460 | |||
461 | return 0; | ||
462 | } | ||
463 | |||
464 | /** | 449 | /** |
465 | * zfcp_qdio_sbale_get - return pointer to SBALE of qdio_queue | 450 | * zfcp_qdio_sbale_get - return pointer to SBALE of qdio_queue |
466 | * @queue: queue from which SBALE should be returned | 451 | * @queue: queue from which SBALE should be returned |