diff options
Diffstat (limited to 'drivers/s390/scsi/zfcp_scsi.c')
| -rw-r--r-- | drivers/s390/scsi/zfcp_scsi.c | 297 |
1 files changed, 83 insertions, 214 deletions
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c index 31a76065cf28..3dcd1bfba3b4 100644 --- a/drivers/s390/scsi/zfcp_scsi.c +++ b/drivers/s390/scsi/zfcp_scsi.c | |||
| @@ -44,7 +44,8 @@ static int zfcp_scsi_eh_abort_handler(struct scsi_cmnd *); | |||
| 44 | static int zfcp_scsi_eh_device_reset_handler(struct scsi_cmnd *); | 44 | static int zfcp_scsi_eh_device_reset_handler(struct scsi_cmnd *); |
| 45 | static int zfcp_scsi_eh_bus_reset_handler(struct scsi_cmnd *); | 45 | static int zfcp_scsi_eh_bus_reset_handler(struct scsi_cmnd *); |
| 46 | static int zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *); | 46 | static int zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *); |
| 47 | static int zfcp_task_management_function(struct zfcp_unit *, u8); | 47 | static int zfcp_task_management_function(struct zfcp_unit *, u8, |
| 48 | struct scsi_cmnd *); | ||
| 48 | 49 | ||
| 49 | static struct zfcp_unit *zfcp_unit_lookup(struct zfcp_adapter *, int, scsi_id_t, | 50 | static struct zfcp_unit *zfcp_unit_lookup(struct zfcp_adapter *, int, scsi_id_t, |
| 50 | scsi_lun_t); | 51 | scsi_lun_t); |
| @@ -242,7 +243,10 @@ static void | |||
| 242 | zfcp_scsi_command_fail(struct scsi_cmnd *scpnt, int result) | 243 | zfcp_scsi_command_fail(struct scsi_cmnd *scpnt, int result) |
| 243 | { | 244 | { |
| 244 | set_host_byte(&scpnt->result, result); | 245 | set_host_byte(&scpnt->result, result); |
| 245 | zfcp_cmd_dbf_event_scsi("failing", scpnt); | 246 | if ((scpnt->device != NULL) && (scpnt->device->host != NULL)) |
| 247 | zfcp_scsi_dbf_event_result("fail", 4, | ||
| 248 | (struct zfcp_adapter*) scpnt->device->host->hostdata[0], | ||
| 249 | scpnt); | ||
| 246 | /* return directly */ | 250 | /* return directly */ |
| 247 | scpnt->scsi_done(scpnt); | 251 | scpnt->scsi_done(scpnt); |
| 248 | } | 252 | } |
| @@ -414,67 +418,38 @@ zfcp_port_lookup(struct zfcp_adapter *adapter, int channel, scsi_id_t id) | |||
| 414 | return (struct zfcp_port *) NULL; | 418 | return (struct zfcp_port *) NULL; |
| 415 | } | 419 | } |
| 416 | 420 | ||
| 417 | /* | 421 | /** |
| 418 | * function: zfcp_scsi_eh_abort_handler | 422 | * zfcp_scsi_eh_abort_handler - abort the specified SCSI command |
| 419 | * | 423 | * @scpnt: pointer to scsi_cmnd to be aborted |
| 420 | * purpose: tries to abort the specified (timed out) SCSI command | 424 | * Return: SUCCESS - command has been aborted and cleaned up in internal |
| 421 | * | 425 | * bookkeeping, SCSI stack won't be called for aborted command |
| 422 | * note: We do not need to care for a SCSI command which completes | 426 | * FAILED - otherwise |
| 423 | * normally but late during this abort routine runs. | ||
| 424 | * We are allowed to return late commands to the SCSI stack. | ||
| 425 | * It tracks the state of commands and will handle late commands. | ||
| 426 | * (Usually, the normal completion of late commands is ignored with | ||
| 427 | * respect to the running abort operation. Grep for 'done_late' | ||
| 428 | * in the SCSI stacks sources.) | ||
| 429 | * | 427 | * |
| 430 | * returns: SUCCESS - command has been aborted and cleaned up in internal | 428 | * We do not need to care for a SCSI command which completes normally |
| 431 | * bookkeeping, | 429 | * but late during this abort routine runs. We are allowed to return |
| 432 | * SCSI stack won't be called for aborted command | 430 | * late commands to the SCSI stack. It tracks the state of commands and |
| 433 | * FAILED - otherwise | 431 | * will handle late commands. (Usually, the normal completion of late |
| 432 | * commands is ignored with respect to the running abort operation.) | ||
| 434 | */ | 433 | */ |
| 435 | int | 434 | int |
| 436 | __zfcp_scsi_eh_abort_handler(struct scsi_cmnd *scpnt) | 435 | zfcp_scsi_eh_abort_handler(struct scsi_cmnd *scpnt) |
| 437 | { | 436 | { |
| 437 | struct Scsi_Host *scsi_host; | ||
| 438 | struct zfcp_adapter *adapter; | ||
| 439 | struct zfcp_unit *unit; | ||
| 438 | int retval = SUCCESS; | 440 | int retval = SUCCESS; |
| 439 | struct zfcp_fsf_req *new_fsf_req, *old_fsf_req; | 441 | struct zfcp_fsf_req *new_fsf_req = NULL; |
| 440 | struct zfcp_adapter *adapter = (struct zfcp_adapter *) scpnt->device->host->hostdata[0]; | 442 | struct zfcp_fsf_req *old_fsf_req; |
| 441 | struct zfcp_unit *unit = (struct zfcp_unit *) scpnt->device->hostdata; | ||
| 442 | struct zfcp_port *port = unit->port; | ||
| 443 | struct Scsi_Host *scsi_host = scpnt->device->host; | ||
| 444 | union zfcp_req_data *req_data = NULL; | ||
| 445 | unsigned long flags; | 443 | unsigned long flags; |
| 446 | u32 status = 0; | 444 | |
| 447 | 445 | scsi_host = scpnt->device->host; | |
| 448 | /* the components of a abort_dbf record (fixed size record) */ | 446 | adapter = (struct zfcp_adapter *) scsi_host->hostdata[0]; |
| 449 | u64 dbf_scsi_cmnd = (unsigned long) scpnt; | 447 | unit = (struct zfcp_unit *) scpnt->device->hostdata; |
| 450 | char dbf_opcode[ZFCP_ABORT_DBF_LENGTH]; | ||
| 451 | wwn_t dbf_wwn = port->wwpn; | ||
| 452 | fcp_lun_t dbf_fcp_lun = unit->fcp_lun; | ||
| 453 | u64 dbf_retries = scpnt->retries; | ||
| 454 | u64 dbf_allowed = scpnt->allowed; | ||
| 455 | u64 dbf_timeout = 0; | ||
| 456 | u64 dbf_fsf_req = 0; | ||
| 457 | u64 dbf_fsf_status = 0; | ||
| 458 | u64 dbf_fsf_qual[2] = { 0, 0 }; | ||
| 459 | char dbf_result[ZFCP_ABORT_DBF_LENGTH] = "##undef"; | ||
| 460 | |||
| 461 | memset(dbf_opcode, 0, ZFCP_ABORT_DBF_LENGTH); | ||
| 462 | memcpy(dbf_opcode, | ||
| 463 | scpnt->cmnd, | ||
| 464 | min(scpnt->cmd_len, (unsigned char) ZFCP_ABORT_DBF_LENGTH)); | ||
| 465 | 448 | ||
| 466 | ZFCP_LOG_INFO("aborting scsi_cmnd=%p on adapter %s\n", | 449 | ZFCP_LOG_INFO("aborting scsi_cmnd=%p on adapter %s\n", |
| 467 | scpnt, zfcp_get_busid_by_adapter(adapter)); | 450 | scpnt, zfcp_get_busid_by_adapter(adapter)); |
| 468 | 451 | ||
| 469 | spin_unlock_irq(scsi_host->host_lock); | 452 | /* avoid race condition between late normal completion and abort */ |
| 470 | |||
| 471 | /* | ||
| 472 | * Race condition between normal (late) completion and abort has | ||
| 473 | * to be avoided. | ||
| 474 | * The entirity of all accesses to scsi_req have to be atomic. | ||
| 475 | * scsi_req is usually part of the fsf_req and thus we block the | ||
| 476 | * release of fsf_req as long as we need to access scsi_req. | ||
| 477 | */ | ||
| 478 | write_lock_irqsave(&adapter->abort_lock, flags); | 453 | write_lock_irqsave(&adapter->abort_lock, flags); |
| 479 | 454 | ||
| 480 | /* | 455 | /* |
| @@ -484,144 +459,47 @@ __zfcp_scsi_eh_abort_handler(struct scsi_cmnd *scpnt) | |||
| 484 | * this routine returns. (scpnt is parameter passed to this routine | 459 | * this routine returns. (scpnt is parameter passed to this routine |
| 485 | * and must not disappear during abort even on late completion.) | 460 | * and must not disappear during abort even on late completion.) |
| 486 | */ | 461 | */ |
| 487 | req_data = (union zfcp_req_data *) scpnt->host_scribble; | 462 | old_fsf_req = (struct zfcp_fsf_req *) scpnt->host_scribble; |
| 488 | /* DEBUG */ | ||
| 489 | ZFCP_LOG_DEBUG("req_data=%p\n", req_data); | ||
| 490 | if (!req_data) { | ||
| 491 | ZFCP_LOG_DEBUG("late command completion overtook abort\n"); | ||
| 492 | /* | ||
| 493 | * That's it. | ||
| 494 | * Do not initiate abort but return SUCCESS. | ||
| 495 | */ | ||
| 496 | write_unlock_irqrestore(&adapter->abort_lock, flags); | ||
| 497 | retval = SUCCESS; | ||
| 498 | strncpy(dbf_result, "##late1", ZFCP_ABORT_DBF_LENGTH); | ||
| 499 | goto out; | ||
| 500 | } | ||
| 501 | |||
| 502 | /* Figure out which fsf_req needs to be aborted. */ | ||
| 503 | old_fsf_req = req_data->send_fcp_command_task.fsf_req; | ||
| 504 | |||
| 505 | dbf_fsf_req = (unsigned long) old_fsf_req; | ||
| 506 | dbf_timeout = | ||
| 507 | (jiffies - req_data->send_fcp_command_task.start_jiffies) / HZ; | ||
| 508 | |||
| 509 | ZFCP_LOG_DEBUG("old_fsf_req=%p\n", old_fsf_req); | ||
| 510 | if (!old_fsf_req) { | 463 | if (!old_fsf_req) { |
| 511 | write_unlock_irqrestore(&adapter->abort_lock, flags); | 464 | write_unlock_irqrestore(&adapter->abort_lock, flags); |
| 512 | ZFCP_LOG_NORMAL("bug: no old fsf request found\n"); | 465 | zfcp_scsi_dbf_event_abort("lte1", adapter, scpnt, new_fsf_req); |
| 513 | ZFCP_LOG_NORMAL("req_data:\n"); | 466 | retval = SUCCESS; |
| 514 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL, | ||
| 515 | (char *) req_data, sizeof (union zfcp_req_data)); | ||
| 516 | ZFCP_LOG_NORMAL("scsi_cmnd:\n"); | ||
| 517 | ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL, | ||
| 518 | (char *) scpnt, sizeof (struct scsi_cmnd)); | ||
| 519 | retval = FAILED; | ||
| 520 | strncpy(dbf_result, "##bug:r", ZFCP_ABORT_DBF_LENGTH); | ||
| 521 | goto out; | 467 | goto out; |
| 522 | } | 468 | } |
| 523 | old_fsf_req->data.send_fcp_command_task.scsi_cmnd = NULL; | 469 | old_fsf_req->data = 0; |
| 524 | /* mark old request as being aborted */ | ||
| 525 | old_fsf_req->status |= ZFCP_STATUS_FSFREQ_ABORTING; | 470 | old_fsf_req->status |= ZFCP_STATUS_FSFREQ_ABORTING; |
| 526 | /* | ||
| 527 | * We have to collect all information (e.g. unit) needed by | ||
| 528 | * zfcp_fsf_abort_fcp_command before calling that routine | ||
| 529 | * since that routine is not allowed to access | ||
| 530 | * fsf_req which it is going to abort. | ||
| 531 | * This is because of we need to release fsf_req_list_lock | ||
| 532 | * before calling zfcp_fsf_abort_fcp_command. | ||
| 533 | * Since this lock will not be held, fsf_req may complete | ||
| 534 | * late and may be released meanwhile. | ||
| 535 | */ | ||
| 536 | ZFCP_LOG_DEBUG("unit 0x%016Lx (%p)\n", unit->fcp_lun, unit); | ||
| 537 | 471 | ||
| 538 | /* | 472 | /* don't access old_fsf_req after releasing the abort_lock */ |
| 539 | * We block (call schedule) | ||
| 540 | * That's why we must release the lock and enable the | ||
| 541 | * interrupts before. | ||
| 542 | * On the other hand we do not need the lock anymore since | ||
| 543 | * all critical accesses to scsi_req are done. | ||
| 544 | */ | ||
| 545 | write_unlock_irqrestore(&adapter->abort_lock, flags); | 473 | write_unlock_irqrestore(&adapter->abort_lock, flags); |
| 546 | /* call FSF routine which does the abort */ | 474 | /* call FSF routine which does the abort */ |
| 547 | new_fsf_req = zfcp_fsf_abort_fcp_command((unsigned long) old_fsf_req, | 475 | new_fsf_req = zfcp_fsf_abort_fcp_command((unsigned long) old_fsf_req, |
| 548 | adapter, unit, 0); | 476 | adapter, unit, 0); |
| 549 | ZFCP_LOG_DEBUG("new_fsf_req=%p\n", new_fsf_req); | ||
| 550 | if (!new_fsf_req) { | 477 | if (!new_fsf_req) { |
| 478 | ZFCP_LOG_INFO("error: initiation of Abort FCP Cmnd failed\n"); | ||
| 551 | retval = FAILED; | 479 | retval = FAILED; |
| 552 | ZFCP_LOG_NORMAL("error: initiation of Abort FCP Cmnd " | ||
| 553 | "failed\n"); | ||
| 554 | strncpy(dbf_result, "##nores", ZFCP_ABORT_DBF_LENGTH); | ||
| 555 | goto out; | 480 | goto out; |
| 556 | } | 481 | } |
| 557 | 482 | ||
| 558 | /* wait for completion of abort */ | 483 | /* wait for completion of abort */ |
| 559 | ZFCP_LOG_DEBUG("waiting for cleanup...\n"); | ||
| 560 | #if 1 | ||
| 561 | /* | ||
| 562 | * FIXME: | ||
| 563 | * copying zfcp_fsf_req_wait_and_cleanup code is not really nice | ||
| 564 | */ | ||
| 565 | __wait_event(new_fsf_req->completion_wq, | 484 | __wait_event(new_fsf_req->completion_wq, |
| 566 | new_fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED); | 485 | new_fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED); |
| 567 | status = new_fsf_req->status; | 486 | |
| 568 | dbf_fsf_status = new_fsf_req->qtcb->header.fsf_status; | ||
| 569 | /* | ||
| 570 | * Ralphs special debug load provides timestamps in the FSF | ||
| 571 | * status qualifier. This might be specified later if being | ||
| 572 | * useful for debugging aborts. | ||
| 573 | */ | ||
| 574 | dbf_fsf_qual[0] = | ||
| 575 | *(u64 *) & new_fsf_req->qtcb->header.fsf_status_qual.word[0]; | ||
| 576 | dbf_fsf_qual[1] = | ||
| 577 | *(u64 *) & new_fsf_req->qtcb->header.fsf_status_qual.word[2]; | ||
| 578 | zfcp_fsf_req_free(new_fsf_req); | ||
| 579 | #else | ||
| 580 | retval = zfcp_fsf_req_wait_and_cleanup(new_fsf_req, | ||
| 581 | ZFCP_UNINTERRUPTIBLE, &status); | ||
| 582 | #endif | ||
| 583 | ZFCP_LOG_DEBUG("Waiting for cleanup complete, status=0x%x\n", status); | ||
| 584 | /* status should be valid since signals were not permitted */ | 487 | /* status should be valid since signals were not permitted */ |
| 585 | if (status & ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED) { | 488 | if (new_fsf_req->status & ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED) { |
| 489 | zfcp_scsi_dbf_event_abort("okay", adapter, scpnt, new_fsf_req); | ||
| 586 | retval = SUCCESS; | 490 | retval = SUCCESS; |
| 587 | strncpy(dbf_result, "##succ", ZFCP_ABORT_DBF_LENGTH); | 491 | } else if (new_fsf_req->status & ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED) { |
| 588 | } else if (status & ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED) { | 492 | zfcp_scsi_dbf_event_abort("lte2", adapter, scpnt, new_fsf_req); |
| 589 | retval = SUCCESS; | 493 | retval = SUCCESS; |
| 590 | strncpy(dbf_result, "##late2", ZFCP_ABORT_DBF_LENGTH); | ||
| 591 | } else { | 494 | } else { |
| 495 | zfcp_scsi_dbf_event_abort("fail", adapter, scpnt, new_fsf_req); | ||
| 592 | retval = FAILED; | 496 | retval = FAILED; |
| 593 | strncpy(dbf_result, "##fail", ZFCP_ABORT_DBF_LENGTH); | ||
| 594 | } | 497 | } |
| 595 | 498 | zfcp_fsf_req_free(new_fsf_req); | |
| 596 | out: | 499 | out: |
| 597 | debug_event(adapter->abort_dbf, 1, &dbf_scsi_cmnd, sizeof (u64)); | ||
| 598 | debug_event(adapter->abort_dbf, 1, &dbf_opcode, ZFCP_ABORT_DBF_LENGTH); | ||
| 599 | debug_event(adapter->abort_dbf, 1, &dbf_wwn, sizeof (wwn_t)); | ||
| 600 | debug_event(adapter->abort_dbf, 1, &dbf_fcp_lun, sizeof (fcp_lun_t)); | ||
| 601 | debug_event(adapter->abort_dbf, 1, &dbf_retries, sizeof (u64)); | ||
| 602 | debug_event(adapter->abort_dbf, 1, &dbf_allowed, sizeof (u64)); | ||
| 603 | debug_event(adapter->abort_dbf, 1, &dbf_timeout, sizeof (u64)); | ||
| 604 | debug_event(adapter->abort_dbf, 1, &dbf_fsf_req, sizeof (u64)); | ||
| 605 | debug_event(adapter->abort_dbf, 1, &dbf_fsf_status, sizeof (u64)); | ||
| 606 | debug_event(adapter->abort_dbf, 1, &dbf_fsf_qual[0], sizeof (u64)); | ||
| 607 | debug_event(adapter->abort_dbf, 1, &dbf_fsf_qual[1], sizeof (u64)); | ||
| 608 | debug_text_event(adapter->abort_dbf, 1, dbf_result); | ||
| 609 | |||
| 610 | spin_lock_irq(scsi_host->host_lock); | ||
| 611 | return retval; | 500 | return retval; |
| 612 | } | 501 | } |
| 613 | 502 | ||
| 614 | int | ||
| 615 | zfcp_scsi_eh_abort_handler(struct scsi_cmnd *scpnt) | ||
| 616 | { | ||
| 617 | int rc; | ||
| 618 | struct Scsi_Host *scsi_host = scpnt->device->host; | ||
| 619 | spin_lock_irq(scsi_host->host_lock); | ||
| 620 | rc = __zfcp_scsi_eh_abort_handler(scpnt); | ||
| 621 | spin_unlock_irq(scsi_host->host_lock); | ||
| 622 | return rc; | ||
| 623 | } | ||
| 624 | |||
| 625 | /* | 503 | /* |
| 626 | * function: zfcp_scsi_eh_device_reset_handler | 504 | * function: zfcp_scsi_eh_device_reset_handler |
| 627 | * | 505 | * |
| @@ -651,8 +529,9 @@ zfcp_scsi_eh_device_reset_handler(struct scsi_cmnd *scpnt) | |||
| 651 | */ | 529 | */ |
| 652 | if (!atomic_test_mask(ZFCP_STATUS_UNIT_NOTSUPPUNITRESET, | 530 | if (!atomic_test_mask(ZFCP_STATUS_UNIT_NOTSUPPUNITRESET, |
| 653 | &unit->status)) { | 531 | &unit->status)) { |
| 654 | retval = | 532 | retval = zfcp_task_management_function(unit, |
| 655 | zfcp_task_management_function(unit, FCP_LOGICAL_UNIT_RESET); | 533 | FCP_LOGICAL_UNIT_RESET, |
| 534 | scpnt); | ||
| 656 | if (retval) { | 535 | if (retval) { |
| 657 | ZFCP_LOG_DEBUG("unit reset failed (unit=%p)\n", unit); | 536 | ZFCP_LOG_DEBUG("unit reset failed (unit=%p)\n", unit); |
| 658 | if (retval == -ENOTSUPP) | 537 | if (retval == -ENOTSUPP) |
| @@ -668,7 +547,7 @@ zfcp_scsi_eh_device_reset_handler(struct scsi_cmnd *scpnt) | |||
| 668 | goto out; | 547 | goto out; |
| 669 | } | 548 | } |
| 670 | } | 549 | } |
| 671 | retval = zfcp_task_management_function(unit, FCP_TARGET_RESET); | 550 | retval = zfcp_task_management_function(unit, FCP_TARGET_RESET, scpnt); |
| 672 | if (retval) { | 551 | if (retval) { |
| 673 | ZFCP_LOG_DEBUG("target reset failed (unit=%p)\n", unit); | 552 | ZFCP_LOG_DEBUG("target reset failed (unit=%p)\n", unit); |
| 674 | retval = FAILED; | 553 | retval = FAILED; |
| @@ -681,12 +560,12 @@ zfcp_scsi_eh_device_reset_handler(struct scsi_cmnd *scpnt) | |||
| 681 | } | 560 | } |
| 682 | 561 | ||
| 683 | static int | 562 | static int |
| 684 | zfcp_task_management_function(struct zfcp_unit *unit, u8 tm_flags) | 563 | zfcp_task_management_function(struct zfcp_unit *unit, u8 tm_flags, |
| 564 | struct scsi_cmnd *scpnt) | ||
| 685 | { | 565 | { |
| 686 | struct zfcp_adapter *adapter = unit->port->adapter; | 566 | struct zfcp_adapter *adapter = unit->port->adapter; |
| 687 | int retval; | ||
| 688 | int status; | ||
| 689 | struct zfcp_fsf_req *fsf_req; | 567 | struct zfcp_fsf_req *fsf_req; |
| 568 | int retval = 0; | ||
| 690 | 569 | ||
| 691 | /* issue task management function */ | 570 | /* issue task management function */ |
| 692 | fsf_req = zfcp_fsf_send_fcp_command_task_management | 571 | fsf_req = zfcp_fsf_send_fcp_command_task_management |
| @@ -696,70 +575,63 @@ zfcp_task_management_function(struct zfcp_unit *unit, u8 tm_flags) | |||
| 696 | "failed for unit 0x%016Lx on port 0x%016Lx on " | 575 | "failed for unit 0x%016Lx on port 0x%016Lx on " |
| 697 | "adapter %s\n", unit->fcp_lun, unit->port->wwpn, | 576 | "adapter %s\n", unit->fcp_lun, unit->port->wwpn, |
| 698 | zfcp_get_busid_by_adapter(adapter)); | 577 | zfcp_get_busid_by_adapter(adapter)); |
| 578 | zfcp_scsi_dbf_event_devreset("nres", tm_flags, unit, scpnt); | ||
| 699 | retval = -ENOMEM; | 579 | retval = -ENOMEM; |
| 700 | goto out; | 580 | goto out; |
| 701 | } | 581 | } |
| 702 | 582 | ||
| 703 | retval = zfcp_fsf_req_wait_and_cleanup(fsf_req, | 583 | __wait_event(fsf_req->completion_wq, |
| 704 | ZFCP_UNINTERRUPTIBLE, &status); | 584 | fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED); |
| 585 | |||
| 705 | /* | 586 | /* |
| 706 | * check completion status of task management function | 587 | * check completion status of task management function |
| 707 | * (status should always be valid since no signals permitted) | ||
| 708 | */ | 588 | */ |
| 709 | if (status & ZFCP_STATUS_FSFREQ_TMFUNCFAILED) | 589 | if (fsf_req->status & ZFCP_STATUS_FSFREQ_TMFUNCFAILED) { |
| 590 | zfcp_scsi_dbf_event_devreset("fail", tm_flags, unit, scpnt); | ||
| 710 | retval = -EIO; | 591 | retval = -EIO; |
| 711 | else if (status & ZFCP_STATUS_FSFREQ_TMFUNCNOTSUPP) | 592 | } else if (fsf_req->status & ZFCP_STATUS_FSFREQ_TMFUNCNOTSUPP) { |
| 593 | zfcp_scsi_dbf_event_devreset("nsup", tm_flags, unit, scpnt); | ||
| 712 | retval = -ENOTSUPP; | 594 | retval = -ENOTSUPP; |
| 713 | else | 595 | } else |
| 714 | retval = 0; | 596 | zfcp_scsi_dbf_event_devreset("okay", tm_flags, unit, scpnt); |
| 597 | |||
| 598 | zfcp_fsf_req_free(fsf_req); | ||
| 715 | out: | 599 | out: |
| 716 | return retval; | 600 | return retval; |
| 717 | } | 601 | } |
| 718 | 602 | ||
| 719 | /* | 603 | /** |
| 720 | * function: zfcp_scsi_eh_bus_reset_handler | 604 | * zfcp_scsi_eh_bus_reset_handler - reset bus (reopen adapter) |
| 721 | * | ||
| 722 | * purpose: | ||
| 723 | * | ||
| 724 | * returns: | ||
| 725 | */ | 605 | */ |
| 726 | int | 606 | int |
| 727 | zfcp_scsi_eh_bus_reset_handler(struct scsi_cmnd *scpnt) | 607 | zfcp_scsi_eh_bus_reset_handler(struct scsi_cmnd *scpnt) |
| 728 | { | 608 | { |
| 729 | int retval = 0; | 609 | struct zfcp_unit *unit = (struct zfcp_unit*) scpnt->device->hostdata; |
| 730 | struct zfcp_unit *unit; | 610 | struct zfcp_adapter *adapter = unit->port->adapter; |
| 731 | 611 | ||
| 732 | unit = (struct zfcp_unit *) scpnt->device->hostdata; | ||
| 733 | ZFCP_LOG_NORMAL("bus reset because of problems with " | 612 | ZFCP_LOG_NORMAL("bus reset because of problems with " |
| 734 | "unit 0x%016Lx\n", unit->fcp_lun); | 613 | "unit 0x%016Lx\n", unit->fcp_lun); |
| 735 | zfcp_erp_adapter_reopen(unit->port->adapter, 0); | 614 | zfcp_erp_adapter_reopen(adapter, 0); |
| 736 | zfcp_erp_wait(unit->port->adapter); | 615 | zfcp_erp_wait(adapter); |
| 737 | retval = SUCCESS; | ||
| 738 | 616 | ||
| 739 | return retval; | 617 | return SUCCESS; |
| 740 | } | 618 | } |
| 741 | 619 | ||
| 742 | /* | 620 | /** |
| 743 | * function: zfcp_scsi_eh_host_reset_handler | 621 | * zfcp_scsi_eh_host_reset_handler - reset host (reopen adapter) |
| 744 | * | ||
| 745 | * purpose: | ||
| 746 | * | ||
| 747 | * returns: | ||
| 748 | */ | 622 | */ |
| 749 | int | 623 | int |
| 750 | zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt) | 624 | zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt) |
| 751 | { | 625 | { |
| 752 | int retval = 0; | 626 | struct zfcp_unit *unit = (struct zfcp_unit*) scpnt->device->hostdata; |
| 753 | struct zfcp_unit *unit; | 627 | struct zfcp_adapter *adapter = unit->port->adapter; |
| 754 | 628 | ||
| 755 | unit = (struct zfcp_unit *) scpnt->device->hostdata; | ||
| 756 | ZFCP_LOG_NORMAL("host reset because of problems with " | 629 | ZFCP_LOG_NORMAL("host reset because of problems with " |
| 757 | "unit 0x%016Lx\n", unit->fcp_lun); | 630 | "unit 0x%016Lx\n", unit->fcp_lun); |
| 758 | zfcp_erp_adapter_reopen(unit->port->adapter, 0); | 631 | zfcp_erp_adapter_reopen(adapter, 0); |
| 759 | zfcp_erp_wait(unit->port->adapter); | 632 | zfcp_erp_wait(adapter); |
| 760 | retval = SUCCESS; | ||
| 761 | 633 | ||
| 762 | return retval; | 634 | return SUCCESS; |
| 763 | } | 635 | } |
| 764 | 636 | ||
| 765 | /* | 637 | /* |
| @@ -826,10 +698,16 @@ void | |||
| 826 | zfcp_adapter_scsi_unregister(struct zfcp_adapter *adapter) | 698 | zfcp_adapter_scsi_unregister(struct zfcp_adapter *adapter) |
| 827 | { | 699 | { |
| 828 | struct Scsi_Host *shost; | 700 | struct Scsi_Host *shost; |
| 701 | struct zfcp_port *port; | ||
| 829 | 702 | ||
| 830 | shost = adapter->scsi_host; | 703 | shost = adapter->scsi_host; |
| 831 | if (!shost) | 704 | if (!shost) |
| 832 | return; | 705 | return; |
| 706 | read_lock_irq(&zfcp_data.config_lock); | ||
| 707 | list_for_each_entry(port, &adapter->port_list_head, list) | ||
| 708 | if (port->rport) | ||
| 709 | port->rport = NULL; | ||
| 710 | read_unlock_irq(&zfcp_data.config_lock); | ||
| 833 | fc_remove_host(shost); | 711 | fc_remove_host(shost); |
| 834 | scsi_remove_host(shost); | 712 | scsi_remove_host(shost); |
| 835 | scsi_host_put(shost); | 713 | scsi_host_put(shost); |
| @@ -904,18 +782,6 @@ zfcp_get_node_name(struct scsi_target *starget) | |||
| 904 | read_unlock_irqrestore(&zfcp_data.config_lock, flags); | 782 | read_unlock_irqrestore(&zfcp_data.config_lock, flags); |
| 905 | } | 783 | } |
| 906 | 784 | ||
| 907 | void | ||
| 908 | zfcp_set_fc_host_attrs(struct zfcp_adapter *adapter) | ||
| 909 | { | ||
| 910 | struct Scsi_Host *shost = adapter->scsi_host; | ||
| 911 | |||
| 912 | fc_host_node_name(shost) = adapter->wwnn; | ||
| 913 | fc_host_port_name(shost) = adapter->wwpn; | ||
| 914 | strncpy(fc_host_serial_number(shost), adapter->serial_number, | ||
| 915 | min(FC_SERIAL_NUMBER_SIZE, 32)); | ||
| 916 | fc_host_supported_classes(shost) = FC_COS_CLASS2 | FC_COS_CLASS3; | ||
| 917 | } | ||
| 918 | |||
| 919 | struct fc_function_template zfcp_transport_functions = { | 785 | struct fc_function_template zfcp_transport_functions = { |
| 920 | .get_starget_port_id = zfcp_get_port_id, | 786 | .get_starget_port_id = zfcp_get_port_id, |
| 921 | .get_starget_port_name = zfcp_get_port_name, | 787 | .get_starget_port_name = zfcp_get_port_name, |
| @@ -927,7 +793,10 @@ struct fc_function_template zfcp_transport_functions = { | |||
| 927 | .show_host_node_name = 1, | 793 | .show_host_node_name = 1, |
| 928 | .show_host_port_name = 1, | 794 | .show_host_port_name = 1, |
| 929 | .show_host_supported_classes = 1, | 795 | .show_host_supported_classes = 1, |
| 796 | .show_host_maxframe_size = 1, | ||
| 930 | .show_host_serial_number = 1, | 797 | .show_host_serial_number = 1, |
| 798 | .show_host_speed = 1, | ||
| 799 | .show_host_port_id = 1, | ||
| 931 | }; | 800 | }; |
| 932 | 801 | ||
| 933 | /** | 802 | /** |
