X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=drivers%2Fs390%2Fscsi%2Fzfcp_fsf.c;h=c007b6424e746cd63854ca8b69bfefbddcfc5802;hb=bcdd3a911499abd65bf1f123b2a6ad9c1d5611ea;hp=bf66fc6d8a97d458f0bf7c58bf8e4cec491ec1c5;hpb=516a4201bacfd61ea957039d6f47276ee9c32a0d;p=~andy%2Flinux diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c index bf66fc6d8a9..c007b6424e7 100644 --- a/drivers/s390/scsi/zfcp_fsf.c +++ b/drivers/s390/scsi/zfcp_fsf.c @@ -61,7 +61,6 @@ static int zfcp_fsf_fsfstatus_eval(struct zfcp_fsf_req *); static int zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req *); static int zfcp_fsf_req_dispatch(struct zfcp_fsf_req *); static void zfcp_fsf_req_dismiss(struct zfcp_fsf_req *); -static void zfcp_fsf_req_free(struct zfcp_fsf_req *); /* association between FSF command and FSF QTCB type */ static u32 fsf_qtcb_type[] = { @@ -149,13 +148,13 @@ zfcp_fsf_req_alloc(mempool_t *pool, int req_flags) * * locks: none */ -static void +void zfcp_fsf_req_free(struct zfcp_fsf_req *fsf_req) { if (likely(fsf_req->pool != NULL)) mempool_free(fsf_req, fsf_req->pool); - else - kfree(fsf_req); + else + kfree(fsf_req); } /* @@ -170,30 +169,21 @@ zfcp_fsf_req_free(struct zfcp_fsf_req *fsf_req) int zfcp_fsf_req_dismiss_all(struct zfcp_adapter *adapter) { - int retval = 0; struct zfcp_fsf_req *fsf_req, *tmp; + unsigned long flags; + LIST_HEAD(remove_queue); - list_for_each_entry_safe(fsf_req, tmp, &adapter->fsf_req_list_head, - list) - zfcp_fsf_req_dismiss(fsf_req); - /* wait_event_timeout? */ - while (!list_empty(&adapter->fsf_req_list_head)) { - ZFCP_LOG_DEBUG("fsf req list of adapter %s not yet empty\n", - zfcp_get_busid_by_adapter(adapter)); - /* wait for woken intiators to clean up their requests */ - msleep(jiffies_to_msecs(ZFCP_FSFREQ_CLEANUP_TIMEOUT)); - } + spin_lock_irqsave(&adapter->fsf_req_list_lock, flags); + list_splice_init(&adapter->fsf_req_list_head, &remove_queue); + atomic_set(&adapter->fsf_reqs_active, 0); + spin_unlock_irqrestore(&adapter->fsf_req_list_lock, flags); - /* consistency check */ - if (atomic_read(&adapter->fsf_reqs_active)) { - ZFCP_LOG_NORMAL("bug: There are still %d FSF requests pending " - "on adapter %s after cleanup.\n", - atomic_read(&adapter->fsf_reqs_active), - zfcp_get_busid_by_adapter(adapter)); - atomic_set(&adapter->fsf_reqs_active, 0); + list_for_each_entry_safe(fsf_req, tmp, &remove_queue, list) { + list_del(&fsf_req->list); + zfcp_fsf_req_dismiss(fsf_req); } - return retval; + return 0; } /* @@ -226,10 +216,6 @@ zfcp_fsf_req_complete(struct zfcp_fsf_req *fsf_req) { int retval = 0; int cleanup; - struct zfcp_adapter *adapter = fsf_req->adapter; - - /* do some statistics */ - atomic_dec(&adapter->fsf_reqs_active); if (unlikely(fsf_req->fsf_command == FSF_QTCB_UNSOLICITED_STATUS)) { ZFCP_LOG_DEBUG("Status read response received\n"); @@ -260,7 +246,7 @@ zfcp_fsf_req_complete(struct zfcp_fsf_req *fsf_req) * lock must not be held here since it will be * grabed by the called routine, too */ - zfcp_fsf_req_cleanup(fsf_req); + zfcp_fsf_req_free(fsf_req); } else { /* notify initiator waiting for the requests completion */ ZFCP_LOG_TRACE("waking initiator of FSF request %p\n",fsf_req); @@ -936,7 +922,7 @@ zfcp_fsf_status_read_handler(struct zfcp_fsf_req *fsf_req) if (fsf_req->status & ZFCP_STATUS_FSFREQ_DISMISSED) { mempool_free(status_buffer, adapter->pool.data_status_read); - zfcp_fsf_req_cleanup(fsf_req); + zfcp_fsf_req_free(fsf_req); goto out; } @@ -1033,7 +1019,7 @@ zfcp_fsf_status_read_handler(struct zfcp_fsf_req *fsf_req) break; } mempool_free(status_buffer, adapter->pool.data_status_read); - zfcp_fsf_req_cleanup(fsf_req); + zfcp_fsf_req_free(fsf_req); /* * recycle buffer and start new request repeat until outbound * queue is empty or adapter shutdown is requested @@ -1242,7 +1228,7 @@ zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *new_fsf_req) zfcp_get_busid_by_unit(unit)); debug_text_event(new_fsf_req->adapter->erp_dbf, 2, "fsf_s_pboxed"); - zfcp_erp_port_reopen(unit->port, 0); + zfcp_erp_port_boxed(unit->port); new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR | ZFCP_STATUS_FSFREQ_RETRY; break; @@ -1254,10 +1240,7 @@ zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *new_fsf_req) unit->fcp_lun, unit->port->wwpn, zfcp_get_busid_by_unit(unit)); debug_text_event(new_fsf_req->adapter->erp_dbf, 1, "fsf_s_lboxed"); - zfcp_erp_unit_reopen(unit, 0); - zfcp_cmd_dbf_event_fsf("unitbox", new_fsf_req, - &new_fsf_req->qtcb->header.fsf_status_qual, - sizeof(union fsf_status_qual)); + zfcp_erp_unit_boxed(unit); new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR | ZFCP_STATUS_FSFREQ_RETRY; break; @@ -1587,7 +1570,7 @@ zfcp_fsf_send_ct_handler(struct zfcp_fsf_req *fsf_req) "(adapter %s, port d_id=0x%08x)\n", zfcp_get_busid_by_port(port), port->d_id); debug_text_event(adapter->erp_dbf, 2, "fsf_s_pboxed"); - zfcp_erp_port_reopen(port, 0); + zfcp_erp_port_boxed(port); fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR | ZFCP_STATUS_FSFREQ_RETRY; break; @@ -1771,8 +1754,8 @@ zfcp_fsf_send_els(struct zfcp_send_els *els) static int zfcp_fsf_send_els_handler(struct zfcp_fsf_req *fsf_req) { struct zfcp_adapter *adapter; - fc_id_t d_id; struct zfcp_port *port; + fc_id_t d_id; struct fsf_qtcb_header *header; struct fsf_qtcb_bottom_support *bottom; struct zfcp_send_els *send_els; @@ -1781,6 +1764,7 @@ static int zfcp_fsf_send_els_handler(struct zfcp_fsf_req *fsf_req) send_els = fsf_req->data.send_els; adapter = send_els->adapter; + port = send_els->port; d_id = send_els->d_id; header = &fsf_req->qtcb->header; bottom = &fsf_req->qtcb->bottom.support; @@ -1817,13 +1801,8 @@ static int zfcp_fsf_send_els_handler(struct zfcp_fsf_req *fsf_req) switch (header->fsf_status_qual.word[0]){ case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: debug_text_event(adapter->erp_dbf, 1, "fsf_sq_ltest"); - if (send_els->ls_code != ZFCP_LS_ADISC) { - read_lock(&zfcp_data.config_lock); - port = zfcp_get_port_by_did(adapter, d_id); - if (port) - zfcp_test_link(port); - read_unlock(&zfcp_data.config_lock); - } + if (port && (send_els->ls_code != ZFCP_LS_ADISC)) + zfcp_test_link(port); fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; break; case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED: @@ -1913,11 +1892,8 @@ static int zfcp_fsf_send_els_handler(struct zfcp_fsf_req *fsf_req) } } debug_text_event(adapter->erp_dbf, 1, "fsf_s_access"); - read_lock(&zfcp_data.config_lock); - port = zfcp_get_port_by_did(adapter, d_id); if (port != NULL) zfcp_erp_port_access_denied(port); - read_unlock(&zfcp_data.config_lock); fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; break; @@ -2086,6 +2062,7 @@ zfcp_fsf_exchange_config_evaluate(struct zfcp_fsf_req *fsf_req, int xchg_ok) zfcp_erp_adapter_shutdown(adapter, 0); return -EIO; } + zfcp_set_fc_host_attrs(adapter); return 0; } @@ -2265,7 +2242,7 @@ zfcp_fsf_exchange_port_data(struct zfcp_adapter *adapter, wait_event(fsf_req->completion_wq, fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED); del_timer_sync(timer); - zfcp_fsf_req_cleanup(fsf_req); + zfcp_fsf_req_free(fsf_req); out: kfree(timer); return retval; @@ -2481,6 +2458,9 @@ zfcp_fsf_open_port_handler(struct zfcp_fsf_req *fsf_req) /* mark port as open */ atomic_set_mask(ZFCP_STATUS_COMMON_OPEN | ZFCP_STATUS_PORT_PHYS_OPEN, &port->status); + atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED | + ZFCP_STATUS_COMMON_ACCESS_BOXED, + &port->status); retval = 0; /* check whether D_ID has changed during open */ /* @@ -2824,7 +2804,7 @@ zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req *fsf_req) port->wwpn, zfcp_get_busid_by_port(port)); debug_text_event(fsf_req->adapter->erp_dbf, 1, "fsf_s_pboxed"); - zfcp_erp_port_reopen(port, 0); + zfcp_erp_port_boxed(port); fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR | ZFCP_STATUS_FSFREQ_RETRY; break; @@ -3056,7 +3036,7 @@ zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *fsf_req) "needs to be reopened\n", unit->port->wwpn, zfcp_get_busid_by_unit(unit)); debug_text_event(adapter->erp_dbf, 2, "fsf_s_pboxed"); - zfcp_erp_port_reopen(unit->port, 0); + zfcp_erp_port_boxed(unit->port); fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR | ZFCP_STATUS_FSFREQ_RETRY; break; @@ -3166,7 +3146,9 @@ zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *fsf_req) unit->handle); /* mark unit as open */ atomic_set_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status); - + atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED | + ZFCP_STATUS_COMMON_ACCESS_BOXED, + &unit->status); if (adapter->supported_features & FSF_FEATURE_LUN_SHARING){ if (!exclusive) atomic_set_mask(ZFCP_STATUS_UNIT_SHARED, @@ -3356,7 +3338,7 @@ zfcp_fsf_close_unit_handler(struct zfcp_fsf_req *fsf_req) unit->port->wwpn, zfcp_get_busid_by_unit(unit)); debug_text_event(fsf_req->adapter->erp_dbf, 2, "fsf_s_pboxed"); - zfcp_erp_port_reopen(unit->port, 0); + zfcp_erp_port_boxed(unit->port); fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR | ZFCP_STATUS_FSFREQ_RETRY; break; @@ -3902,10 +3884,7 @@ zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *fsf_req) "needs to be reopened\n", unit->port->wwpn, zfcp_get_busid_by_unit(unit)); debug_text_event(fsf_req->adapter->erp_dbf, 2, "fsf_s_pboxed"); - zfcp_erp_port_reopen(unit->port, 0); - zfcp_cmd_dbf_event_fsf("portbox", fsf_req, - &header->fsf_status_qual, - sizeof (union fsf_status_qual)); + zfcp_erp_port_boxed(unit->port); fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR | ZFCP_STATUS_FSFREQ_RETRY; break; @@ -3916,10 +3895,7 @@ zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *fsf_req) zfcp_get_busid_by_unit(unit), unit->port->wwpn, unit->fcp_lun); debug_text_event(fsf_req->adapter->erp_dbf, 1, "fsf_s_lboxed"); - zfcp_erp_unit_reopen(unit, 0); - zfcp_cmd_dbf_event_fsf("unitbox", fsf_req, - &header->fsf_status_qual, - sizeof(union fsf_status_qual)); + zfcp_erp_unit_boxed(unit); fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR | ZFCP_STATUS_FSFREQ_RETRY; break; @@ -4614,7 +4590,7 @@ zfcp_fsf_req_wait_and_cleanup(struct zfcp_fsf_req *fsf_req, *status = fsf_req->status; /* cleanup request */ - zfcp_fsf_req_cleanup(fsf_req); + zfcp_fsf_req_free(fsf_req); out: return retval; } @@ -4813,9 +4789,9 @@ zfcp_fsf_req_send(struct zfcp_fsf_req *fsf_req, struct timer_list *timer) inc_seq_no = 0; /* put allocated FSF request at list tail */ - write_lock_irqsave(&adapter->fsf_req_list_lock, flags); + spin_lock_irqsave(&adapter->fsf_req_list_lock, flags); list_add_tail(&fsf_req->list, &adapter->fsf_req_list_head); - write_unlock_irqrestore(&adapter->fsf_req_list_lock, flags); + spin_unlock_irqrestore(&adapter->fsf_req_list_lock, flags); /* figure out expiration time of timeout and start timeout */ if (unlikely(timer)) { @@ -4859,9 +4835,9 @@ zfcp_fsf_req_send(struct zfcp_fsf_req *fsf_req, struct timer_list *timer) */ if (timer) del_timer(timer); - write_lock_irqsave(&adapter->fsf_req_list_lock, flags); + spin_lock_irqsave(&adapter->fsf_req_list_lock, flags); list_del(&fsf_req->list); - write_unlock_irqrestore(&adapter->fsf_req_list_lock, flags); + spin_unlock_irqrestore(&adapter->fsf_req_list_lock, flags); /* * adjust the number of free SBALs in request queue as well as * position of first one @@ -4899,25 +4875,4 @@ zfcp_fsf_req_send(struct zfcp_fsf_req *fsf_req, struct timer_list *timer) return retval; } -/* - * function: zfcp_fsf_req_cleanup - * - * purpose: cleans up an FSF request and removes it from the specified list - * - * returns: - * - * assumption: no pending SB in SBALEs other than QTCB - */ -void -zfcp_fsf_req_cleanup(struct zfcp_fsf_req *fsf_req) -{ - struct zfcp_adapter *adapter = fsf_req->adapter; - unsigned long flags; - - write_lock_irqsave(&adapter->fsf_req_list_lock, flags); - list_del(&fsf_req->list); - write_unlock_irqrestore(&adapter->fsf_req_list_lock, flags); - zfcp_fsf_req_free(fsf_req); -} - #undef ZFCP_LOG_AREA