[SCSI] zfcp: fix adapter erp when link is unplugged

Remove endless polling for replug of the local link. Just wait for
link up notification.

Signed-off-by: Andreas Herrmann <aherrman@de.ibm.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>

authored by Andreas Herrmann and committed by 2f8f3ed5 c8024eb5

+69 -90
-5
drivers/s390/scsi/zfcp_def.h
··· 152 152 #define ZFCP_EXCHANGE_CONFIG_DATA_FIRST_SLEEP 100 153 153 #define ZFCP_EXCHANGE_CONFIG_DATA_RETRIES 7 154 154 155 - /* Retry 5 times every 2 second, then every minute */ 156 - #define ZFCP_EXCHANGE_PORT_DATA_SHORT_RETRIES 5 157 - #define ZFCP_EXCHANGE_PORT_DATA_SHORT_SLEEP 200 158 - #define ZFCP_EXCHANGE_PORT_DATA_LONG_SLEEP 6000 159 - 160 155 /* timeout value for "default timer" for fsf requests */ 161 156 #define ZFCP_FSF_REQUEST_TIMEOUT (60*HZ); 162 157
+28 -52
drivers/s390/scsi/zfcp_erp.c
··· 2246 2246 { 2247 2247 int retval; 2248 2248 2249 - if ((atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, 2250 - &erp_action->adapter->status)) && 2251 - (erp_action->adapter->adapter_features & 2252 - FSF_FEATURE_HBAAPI_MANAGEMENT)) { 2253 - zfcp_erp_adapter_strategy_open_fsf_xport(erp_action); 2254 - atomic_set(&erp_action->adapter->erp_counter, 0); 2255 - return ZFCP_ERP_FAILED; 2256 - } 2257 - 2258 2249 retval = zfcp_erp_adapter_strategy_open_fsf_xconfig(erp_action); 2259 2250 if (retval == ZFCP_ERP_FAILED) 2260 2251 return ZFCP_ERP_FAILED; ··· 2257 2266 return zfcp_erp_adapter_strategy_open_fsf_statusread(erp_action); 2258 2267 } 2259 2268 2260 - /* 2261 - * function: 2262 - * 2263 - * purpose: 2264 - * 2265 - * returns: 2266 - */ 2267 2269 static int 2268 2270 zfcp_erp_adapter_strategy_open_fsf_xconfig(struct zfcp_erp_action *erp_action) 2269 2271 { ··· 2334 2350 zfcp_erp_adapter_strategy_open_fsf_xport(struct zfcp_erp_action *erp_action) 2335 2351 { 2336 2352 int ret; 2337 - int retries; 2338 - int sleep; 2339 - struct zfcp_adapter *adapter = erp_action->adapter; 2353 + struct zfcp_adapter *adapter; 2340 2354 2355 + adapter = erp_action->adapter; 2341 2356 atomic_clear_mask(ZFCP_STATUS_ADAPTER_XPORT_OK, &adapter->status); 2342 2357 2343 - retries = 0; 2344 - do { 2345 - write_lock(&adapter->erp_lock); 2346 - zfcp_erp_action_to_running(erp_action); 2347 - write_unlock(&adapter->erp_lock); 2348 - zfcp_erp_timeout_init(erp_action); 2349 - ret = zfcp_fsf_exchange_port_data(erp_action, adapter, NULL); 2350 - if (ret == -EOPNOTSUPP) { 2351 - debug_text_event(adapter->erp_dbf, 3, "a_xport_notsupp"); 2352 - return ZFCP_ERP_SUCCEEDED; 2353 - } else if (ret) { 2354 - debug_text_event(adapter->erp_dbf, 3, "a_xport_failed"); 2355 - return ZFCP_ERP_FAILED; 2356 - } 2357 - debug_text_event(adapter->erp_dbf, 6, "a_xport_ok"); 2358 + write_lock(&adapter->erp_lock); 2359 + zfcp_erp_action_to_running(erp_action); 2360 + write_unlock(&adapter->erp_lock); 2358 2361 2359 - down(&adapter->erp_ready_sem); 2360 - if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT) { 2361 - ZFCP_LOG_INFO("error: exchange of port data " 2362 - "for adapter %s timed out\n", 2363 - zfcp_get_busid_by_adapter(adapter)); 2364 - break; 2365 - } 2366 - if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, 2367 - &adapter->status)) 2368 - break; 2362 + zfcp_erp_timeout_init(erp_action); 2363 + ret = zfcp_fsf_exchange_port_data(erp_action, adapter, NULL); 2364 + if (ret == -EOPNOTSUPP) { 2365 + debug_text_event(adapter->erp_dbf, 3, "a_xport_notsupp"); 2366 + return ZFCP_ERP_SUCCEEDED; 2367 + } else if (ret) { 2368 + debug_text_event(adapter->erp_dbf, 3, "a_xport_failed"); 2369 + return ZFCP_ERP_FAILED; 2370 + } 2371 + debug_text_event(adapter->erp_dbf, 6, "a_xport_ok"); 2369 2372 2370 - if (retries < ZFCP_EXCHANGE_PORT_DATA_SHORT_RETRIES) { 2371 - sleep = ZFCP_EXCHANGE_PORT_DATA_SHORT_SLEEP; 2372 - retries++; 2373 - } else 2374 - sleep = ZFCP_EXCHANGE_PORT_DATA_LONG_SLEEP; 2375 - schedule_timeout(sleep); 2376 - } while (1); 2373 + ret = ZFCP_ERP_SUCCEEDED; 2374 + down(&adapter->erp_ready_sem); 2375 + if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT) { 2376 + ZFCP_LOG_INFO("error: exchange port data timed out (adapter " 2377 + "%s)\n", zfcp_get_busid_by_adapter(adapter)); 2378 + ret = ZFCP_ERP_FAILED; 2379 + } 2380 + if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_XPORT_OK, &adapter->status)) { 2381 + ZFCP_LOG_INFO("error: exchange port data failed (adapter " 2382 + "%s\n", zfcp_get_busid_by_adapter(adapter)); 2383 + ret = ZFCP_ERP_FAILED; 2384 + } 2377 2385 2378 - return ZFCP_ERP_SUCCEEDED; 2386 + return ret; 2379 2387 } 2380 2388 2381 2389 /*
+41 -33
drivers/s390/scsi/zfcp_fsf.c
··· 388 388 case FSF_PROT_LINK_DOWN: 389 389 zfcp_fsf_link_down_info_eval(adapter, 390 390 &prot_status_qual->link_down_info); 391 + zfcp_erp_adapter_reopen(adapter, 0); 391 392 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; 392 393 break; 393 394 ··· 559 558 560 559 atomic_set_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, &adapter->status); 561 560 562 - if (link_down == NULL) { 563 - zfcp_erp_adapter_reopen(adapter, 0); 564 - return; 565 - } 561 + if (link_down == NULL) 562 + goto out; 566 563 567 564 switch (link_down->error_code) { 568 565 case FSF_PSQ_LINK_NO_LIGHT: ··· 642 643 link_down->explanation_code, 643 644 link_down->vendor_specific_code); 644 645 645 - switch (link_down->error_code) { 646 - case FSF_PSQ_LINK_NO_LIGHT: 647 - case FSF_PSQ_LINK_WRAP_PLUG: 648 - case FSF_PSQ_LINK_NO_FCP: 649 - case FSF_PSQ_LINK_FIRMWARE_UPDATE: 650 - zfcp_erp_adapter_reopen(adapter, 0); 651 - break; 652 - default: 653 - zfcp_erp_adapter_failed(adapter); 654 - } 646 + out: 647 + zfcp_erp_adapter_failed(adapter); 655 648 } 656 649 657 650 /* ··· 2295 2304 return retval; 2296 2305 } 2297 2306 2307 + /** 2308 + * zfcp_fsf_exchange_port_evaluate 2309 + * @fsf_req: fsf_req which belongs to xchg port data request 2310 + * @xchg_ok: specifies if xchg port data was incomplete or complete (0/1) 2311 + */ 2312 + static void 2313 + zfcp_fsf_exchange_port_evaluate(struct zfcp_fsf_req *fsf_req, int xchg_ok) 2314 + { 2315 + struct zfcp_adapter *adapter; 2316 + struct fsf_qtcb *qtcb; 2317 + struct fsf_qtcb_bottom_port *bottom, *data; 2318 + struct Scsi_Host *shost; 2319 + 2320 + adapter = fsf_req->adapter; 2321 + qtcb = fsf_req->qtcb; 2322 + bottom = &qtcb->bottom.port; 2323 + shost = adapter->scsi_host; 2324 + 2325 + data = (struct fsf_qtcb_bottom_port*) fsf_req->data; 2326 + if (data) 2327 + memcpy(data, bottom, sizeof(struct fsf_qtcb_bottom_port)); 2328 + 2329 + if (adapter->connection_features & FSF_FEATURE_NPIV_MODE) 2330 + fc_host_permanent_port_name(shost) = bottom->wwpn; 2331 + else 2332 + fc_host_permanent_port_name(shost) = fc_host_port_name(shost); 2333 + fc_host_maxframe_size(shost) = bottom->maximum_frame_size; 2334 + fc_host_supported_speeds(shost) = bottom->supported_speed; 2335 + } 2298 2336 2299 2337 /** 2300 2338 * zfcp_fsf_exchange_port_data_handler - handler for exchange_port_data request ··· 2332 2312 static void 2333 2313 zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req *fsf_req) 2334 2314 { 2335 - struct zfcp_adapter *adapter = fsf_req->adapter; 2336 - struct Scsi_Host *shost = adapter->scsi_host; 2337 - struct fsf_qtcb *qtcb = fsf_req->qtcb; 2338 - struct fsf_qtcb_bottom_port *bottom, *data; 2315 + struct zfcp_adapter *adapter; 2316 + struct fsf_qtcb *qtcb; 2317 + 2318 + adapter = fsf_req->adapter; 2319 + qtcb = fsf_req->qtcb; 2339 2320 2340 2321 if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) 2341 2322 return; 2342 2323 2343 2324 switch (qtcb->header.fsf_status) { 2344 2325 case FSF_GOOD: 2326 + zfcp_fsf_exchange_port_evaluate(fsf_req, 1); 2345 2327 atomic_set_mask(ZFCP_STATUS_ADAPTER_XPORT_OK, &adapter->status); 2346 - 2347 - bottom = &qtcb->bottom.port; 2348 - data = (struct fsf_qtcb_bottom_port*) fsf_req->data; 2349 - if (data) 2350 - memcpy(data, bottom, sizeof(struct fsf_qtcb_bottom_port)); 2351 - if (adapter->connection_features & FSF_FEATURE_NPIV_MODE) 2352 - fc_host_permanent_port_name(shost) = bottom->wwpn; 2353 - else 2354 - fc_host_permanent_port_name(shost) = 2355 - fc_host_port_name(shost); 2356 - fc_host_maxframe_size(shost) = bottom->maximum_frame_size; 2357 - fc_host_supported_speeds(shost) = bottom->supported_speed; 2358 2328 break; 2359 - 2360 2329 case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE: 2330 + zfcp_fsf_exchange_port_evaluate(fsf_req, 0); 2361 2331 atomic_set_mask(ZFCP_STATUS_ADAPTER_XPORT_OK, &adapter->status); 2362 - 2363 2332 zfcp_fsf_link_down_info_eval(adapter, 2364 2333 &qtcb->header.fsf_status_qual.link_down_info); 2365 2334 break; 2366 - 2367 2335 default: 2368 2336 debug_text_event(adapter->erp_dbf, 0, "xchg-port-ng"); 2369 2337 debug_event(adapter->erp_dbf, 0,