2 * This file is part of the zfcp device driver for
3 * FCP adapters for IBM System z9 and zSeries.
5 * (C) Copyright IBM Corp. 2002, 2006
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #define ZFCP_LOG_AREA ZFCP_LOG_AREA_ERP
26 static int zfcp_erp_adisc(struct zfcp_port *);
27 static void zfcp_erp_adisc_handler(unsigned long);
29 static int zfcp_erp_adapter_reopen_internal(struct zfcp_adapter *, int);
30 static int zfcp_erp_port_forced_reopen_internal(struct zfcp_port *, int);
31 static int zfcp_erp_port_reopen_internal(struct zfcp_port *, int);
32 static int zfcp_erp_unit_reopen_internal(struct zfcp_unit *, int);
34 static int zfcp_erp_port_reopen_all_internal(struct zfcp_adapter *, int);
35 static int zfcp_erp_unit_reopen_all_internal(struct zfcp_port *, int);
37 static void zfcp_erp_adapter_block(struct zfcp_adapter *, int);
38 static void zfcp_erp_adapter_unblock(struct zfcp_adapter *);
39 static void zfcp_erp_port_block(struct zfcp_port *, int);
40 static void zfcp_erp_port_unblock(struct zfcp_port *);
41 static void zfcp_erp_unit_block(struct zfcp_unit *, int);
42 static void zfcp_erp_unit_unblock(struct zfcp_unit *);
44 static int zfcp_erp_thread(void *);
46 static int zfcp_erp_strategy(struct zfcp_erp_action *);
48 static int zfcp_erp_strategy_do_action(struct zfcp_erp_action *);
49 static int zfcp_erp_strategy_memwait(struct zfcp_erp_action *);
50 static int zfcp_erp_strategy_check_target(struct zfcp_erp_action *, int);
51 static int zfcp_erp_strategy_check_unit(struct zfcp_unit *, int);
52 static int zfcp_erp_strategy_check_port(struct zfcp_port *, int);
53 static int zfcp_erp_strategy_check_adapter(struct zfcp_adapter *, int);
54 static int zfcp_erp_strategy_statechange(int, u32, struct zfcp_adapter *,
56 struct zfcp_unit *, int);
57 static inline int zfcp_erp_strategy_statechange_detected(atomic_t *, u32);
58 static int zfcp_erp_strategy_followup_actions(int, struct zfcp_adapter *,
60 struct zfcp_unit *, int);
61 static int zfcp_erp_strategy_check_queues(struct zfcp_adapter *);
62 static int zfcp_erp_strategy_check_action(struct zfcp_erp_action *, int);
64 static int zfcp_erp_adapter_strategy(struct zfcp_erp_action *);
65 static int zfcp_erp_adapter_strategy_generic(struct zfcp_erp_action *, int);
66 static int zfcp_erp_adapter_strategy_close(struct zfcp_erp_action *);
67 static int zfcp_erp_adapter_strategy_close_qdio(struct zfcp_erp_action *);
68 static int zfcp_erp_adapter_strategy_close_fsf(struct zfcp_erp_action *);
69 static int zfcp_erp_adapter_strategy_open(struct zfcp_erp_action *);
70 static int zfcp_erp_adapter_strategy_open_qdio(struct zfcp_erp_action *);
71 static int zfcp_erp_adapter_strategy_open_fsf(struct zfcp_erp_action *);
72 static int zfcp_erp_adapter_strategy_open_fsf_xconfig(struct zfcp_erp_action *);
73 static int zfcp_erp_adapter_strategy_open_fsf_xport(struct zfcp_erp_action *);
74 static int zfcp_erp_adapter_strategy_open_fsf_statusread(
75 struct zfcp_erp_action *);
77 static int zfcp_erp_port_forced_strategy(struct zfcp_erp_action *);
78 static int zfcp_erp_port_forced_strategy_close(struct zfcp_erp_action *);
80 static int zfcp_erp_port_strategy(struct zfcp_erp_action *);
81 static int zfcp_erp_port_strategy_clearstati(struct zfcp_port *);
82 static int zfcp_erp_port_strategy_close(struct zfcp_erp_action *);
83 static int zfcp_erp_port_strategy_open(struct zfcp_erp_action *);
84 static int zfcp_erp_port_strategy_open_nameserver(struct zfcp_erp_action *);
85 static int zfcp_erp_port_strategy_open_nameserver_wakeup(
86 struct zfcp_erp_action *);
87 static int zfcp_erp_port_strategy_open_common(struct zfcp_erp_action *);
88 static int zfcp_erp_port_strategy_open_common_lookup(struct zfcp_erp_action *);
89 static int zfcp_erp_port_strategy_open_port(struct zfcp_erp_action *);
91 static int zfcp_erp_unit_strategy(struct zfcp_erp_action *);
92 static int zfcp_erp_unit_strategy_clearstati(struct zfcp_unit *);
93 static int zfcp_erp_unit_strategy_close(struct zfcp_erp_action *);
94 static int zfcp_erp_unit_strategy_open(struct zfcp_erp_action *);
96 static int zfcp_erp_action_dismiss_adapter(struct zfcp_adapter *);
97 static int zfcp_erp_action_dismiss_port(struct zfcp_port *);
98 static int zfcp_erp_action_dismiss_unit(struct zfcp_unit *);
99 static int zfcp_erp_action_dismiss(struct zfcp_erp_action *);
101 static int zfcp_erp_action_enqueue(int, struct zfcp_adapter *,
102 struct zfcp_port *, struct zfcp_unit *);
103 static int zfcp_erp_action_dequeue(struct zfcp_erp_action *);
104 static void zfcp_erp_action_cleanup(int, struct zfcp_adapter *,
105 struct zfcp_port *, struct zfcp_unit *,
108 static void zfcp_erp_action_ready(struct zfcp_erp_action *);
109 static int zfcp_erp_action_exists(struct zfcp_erp_action *);
111 static inline void zfcp_erp_action_to_ready(struct zfcp_erp_action *);
112 static inline void zfcp_erp_action_to_running(struct zfcp_erp_action *);
114 static void zfcp_erp_memwait_handler(unsigned long);
115 static void zfcp_erp_timeout_handler(unsigned long);
116 static inline void zfcp_erp_timeout_init(struct zfcp_erp_action *);
119 * zfcp_fsf_request_timeout_handler - called if a request timed out
120 * @data: pointer to adapter for handler function
122 * This function needs to be called if requests (ELS, Generic Service,
123 * or SCSI commands) exceed a certain time limit. The assumption is
124 * that after the time limit the adapter get stuck. So we trigger a reopen of
125 * the adapter. This should not be used for error recovery, SCSI abort
126 * commands and SCSI requests from SCSI mid-layer.
129 zfcp_fsf_request_timeout_handler(unsigned long data)
131 struct zfcp_adapter *adapter;
133 adapter = (struct zfcp_adapter *) data;
135 zfcp_erp_adapter_reopen(adapter, 0);
139 * function: zfcp_fsf_scsi_er_timeout_handler
141 * purpose: This function needs to be called whenever a SCSI error recovery
142 * action (abort/reset) does not return.
143 * Re-opening the adapter means that the command can be returned
144 * by zfcp (it is guarranteed that it does not return via the
145 * adapter anymore). The buffer can then be used again.
150 zfcp_fsf_scsi_er_timeout_handler(unsigned long data)
152 struct zfcp_adapter *adapter = (struct zfcp_adapter *) data;
154 ZFCP_LOG_NORMAL("warning: SCSI error recovery timed out. "
155 "Restarting all operations on the adapter %s\n",
156 zfcp_get_busid_by_adapter(adapter));
157 debug_text_event(adapter->erp_dbf, 1, "eh_lmem_tout");
158 zfcp_erp_adapter_reopen(adapter, 0);
166 * purpose: called if an adapter failed,
167 * initiates adapter recovery which is done
170 * returns: 0 - initiated action successfully
171 * <0 - failed to initiate action
174 zfcp_erp_adapter_reopen_internal(struct zfcp_adapter *adapter, int clear_mask)
178 debug_text_event(adapter->erp_dbf, 5, "a_ro");
179 ZFCP_LOG_DEBUG("reopen adapter %s\n",
180 zfcp_get_busid_by_adapter(adapter));
182 zfcp_erp_adapter_block(adapter, clear_mask);
184 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED, &adapter->status)) {
185 ZFCP_LOG_DEBUG("skipped reopen of failed adapter %s\n",
186 zfcp_get_busid_by_adapter(adapter));
187 debug_text_event(adapter->erp_dbf, 5, "a_ro_f");
188 /* ensure propagation of failed status to new devices */
189 zfcp_erp_adapter_failed(adapter);
193 retval = zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_ADAPTER,
194 adapter, NULL, NULL);
203 * purpose: Wrappper for zfcp_erp_adapter_reopen_internal
204 * used to ensure the correct locking
206 * returns: 0 - initiated action successfully
207 * <0 - failed to initiate action
210 zfcp_erp_adapter_reopen(struct zfcp_adapter *adapter, int clear_mask)
215 read_lock_irqsave(&zfcp_data.config_lock, flags);
216 write_lock(&adapter->erp_lock);
217 retval = zfcp_erp_adapter_reopen_internal(adapter, clear_mask);
218 write_unlock(&adapter->erp_lock);
219 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
225 zfcp_erp_adapter_shutdown(struct zfcp_adapter *adapter, int clear_mask)
229 retval = zfcp_erp_adapter_reopen(adapter,
230 ZFCP_STATUS_COMMON_RUNNING |
231 ZFCP_STATUS_COMMON_ERP_FAILED |
238 zfcp_erp_port_shutdown(struct zfcp_port *port, int clear_mask)
242 retval = zfcp_erp_port_reopen(port,
243 ZFCP_STATUS_COMMON_RUNNING |
244 ZFCP_STATUS_COMMON_ERP_FAILED |
251 zfcp_erp_unit_shutdown(struct zfcp_unit *unit, int clear_mask)
255 retval = zfcp_erp_unit_reopen(unit,
256 ZFCP_STATUS_COMMON_RUNNING |
257 ZFCP_STATUS_COMMON_ERP_FAILED |
265 * zfcp_erp_adisc - send ADISC ELS command
266 * @port: port structure
269 zfcp_erp_adisc(struct zfcp_port *port)
271 struct zfcp_adapter *adapter = port->adapter;
272 struct zfcp_send_els *send_els;
273 struct zfcp_ls_adisc *adisc;
274 void *address = NULL;
276 struct timer_list *timer;
278 send_els = kzalloc(sizeof(struct zfcp_send_els), GFP_ATOMIC);
279 if (send_els == NULL)
282 send_els->req = kzalloc(sizeof(struct scatterlist), GFP_ATOMIC);
283 if (send_els->req == NULL)
286 send_els->resp = kzalloc(sizeof(struct scatterlist), GFP_ATOMIC);
287 if (send_els->resp == NULL)
290 address = (void *) get_zeroed_page(GFP_ATOMIC);
294 zfcp_address_to_sg(address, send_els->req);
295 address += PAGE_SIZE >> 1;
296 zfcp_address_to_sg(address, send_els->resp);
297 send_els->req_count = send_els->resp_count = 1;
299 send_els->adapter = adapter;
300 send_els->port = port;
301 send_els->d_id = port->d_id;
302 send_els->handler = zfcp_erp_adisc_handler;
303 send_els->handler_data = (unsigned long) send_els;
305 adisc = zfcp_sg_to_address(send_els->req);
306 send_els->ls_code = adisc->code = ZFCP_LS_ADISC;
308 send_els->req->length = sizeof(struct zfcp_ls_adisc);
309 send_els->resp->length = sizeof(struct zfcp_ls_adisc_acc);
311 /* acc. to FC-FS, hard_nport_id in ADISC should not be set for ports
312 without FC-AL-2 capability, so we don't set it */
313 adisc->wwpn = fc_host_port_name(adapter->scsi_host);
314 adisc->wwnn = fc_host_node_name(adapter->scsi_host);
315 adisc->nport_id = fc_host_port_id(adapter->scsi_host);
316 ZFCP_LOG_INFO("ADISC request from s_id 0x%08x to d_id 0x%08x "
317 "(wwpn=0x%016Lx, wwnn=0x%016Lx, "
318 "hard_nport_id=0x%08x, nport_id=0x%08x)\n",
319 adisc->nport_id, send_els->d_id, (wwn_t) adisc->wwpn,
320 (wwn_t) adisc->wwnn, adisc->hard_nport_id,
323 timer = kmalloc(sizeof(struct timer_list), GFP_ATOMIC);
328 timer->function = zfcp_fsf_request_timeout_handler;
329 timer->data = (unsigned long) adapter;
330 timer->expires = ZFCP_FSF_REQUEST_TIMEOUT;
331 send_els->timer = timer;
333 retval = zfcp_fsf_send_els(send_els);
335 ZFCP_LOG_NORMAL("error: initiation of Send ELS failed for port "
336 "0x%08x on adapter %s\n", send_els->d_id,
337 zfcp_get_busid_by_adapter(adapter));
338 del_timer(send_els->timer);
348 __free_pages(send_els->req->page, 0);
349 if (send_els != NULL) {
350 kfree(send_els->timer);
351 kfree(send_els->req);
352 kfree(send_els->resp);
361 * zfcp_erp_adisc_handler - handler for ADISC ELS command
362 * @data: pointer to struct zfcp_send_els
364 * If ADISC failed (LS_RJT or timed out) forced reopen of the port is triggered.
367 zfcp_erp_adisc_handler(unsigned long data)
369 struct zfcp_send_els *send_els;
370 struct zfcp_port *port;
371 struct zfcp_adapter *adapter;
373 struct zfcp_ls_adisc_acc *adisc;
375 send_els = (struct zfcp_send_els *) data;
377 del_timer(send_els->timer);
379 adapter = send_els->adapter;
380 port = send_els->port;
381 d_id = send_els->d_id;
383 /* request rejected or timed out */
384 if (send_els->status != 0) {
385 ZFCP_LOG_NORMAL("ELS request rejected/timed out, "
386 "force physical port reopen "
387 "(adapter %s, port d_id=0x%08x)\n",
388 zfcp_get_busid_by_adapter(adapter), d_id);
389 debug_text_event(adapter->erp_dbf, 3, "forcreop");
390 if (zfcp_erp_port_forced_reopen(port, 0))
391 ZFCP_LOG_NORMAL("failed reopen of port "
392 "(adapter %s, wwpn=0x%016Lx)\n",
393 zfcp_get_busid_by_port(port),
398 adisc = zfcp_sg_to_address(send_els->resp);
400 ZFCP_LOG_INFO("ADISC response from d_id 0x%08x to s_id "
401 "0x%08x (wwpn=0x%016Lx, wwnn=0x%016Lx, "
402 "hard_nport_id=0x%08x, nport_id=0x%08x)\n",
403 d_id, fc_host_port_id(adapter->scsi_host),
404 (wwn_t) adisc->wwpn, (wwn_t) adisc->wwnn,
405 adisc->hard_nport_id, adisc->nport_id);
407 /* set wwnn for port */
409 port->wwnn = adisc->wwnn;
411 if (port->wwpn != adisc->wwpn) {
412 ZFCP_LOG_NORMAL("d_id assignment changed, reopening "
413 "port (adapter %s, wwpn=0x%016Lx, "
414 "adisc_resp_wwpn=0x%016Lx)\n",
415 zfcp_get_busid_by_port(port),
416 port->wwpn, (wwn_t) adisc->wwpn);
417 if (zfcp_erp_port_reopen(port, 0))
418 ZFCP_LOG_NORMAL("failed reopen of port "
419 "(adapter %s, wwpn=0x%016Lx)\n",
420 zfcp_get_busid_by_port(port),
426 __free_pages(send_els->req->page, 0);
427 kfree(send_els->timer);
428 kfree(send_els->req);
429 kfree(send_els->resp);
435 * zfcp_test_link - lightweight link test procedure
436 * @port: port to be tested
438 * Test status of a link to a remote port using the ELS command ADISC.
441 zfcp_test_link(struct zfcp_port *port)
446 retval = zfcp_erp_adisc(port);
449 ZFCP_LOG_NORMAL("reopen needed for port 0x%016Lx "
450 "on adapter %s\n ", port->wwpn,
451 zfcp_get_busid_by_port(port));
452 retval = zfcp_erp_port_forced_reopen(port, 0);
454 ZFCP_LOG_NORMAL("reopen of remote port 0x%016Lx "
455 "on adapter %s failed\n", port->wwpn,
456 zfcp_get_busid_by_port(port));
468 * purpose: called if a port failed to be opened normally
469 * initiates Forced Reopen recovery which is done
472 * returns: 0 - initiated action successfully
473 * <0 - failed to initiate action
476 zfcp_erp_port_forced_reopen_internal(struct zfcp_port *port, int clear_mask)
479 struct zfcp_adapter *adapter = port->adapter;
481 debug_text_event(adapter->erp_dbf, 5, "pf_ro");
482 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
484 ZFCP_LOG_DEBUG("forced reopen of port 0x%016Lx on adapter %s\n",
485 port->wwpn, zfcp_get_busid_by_port(port));
487 zfcp_erp_port_block(port, clear_mask);
489 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED, &port->status)) {
490 ZFCP_LOG_DEBUG("skipped forced reopen of failed port 0x%016Lx "
491 "on adapter %s\n", port->wwpn,
492 zfcp_get_busid_by_port(port));
493 debug_text_event(adapter->erp_dbf, 5, "pf_ro_f");
494 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
499 retval = zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_PORT_FORCED,
500 port->adapter, port, NULL);
509 * purpose: Wrappper for zfcp_erp_port_forced_reopen_internal
510 * used to ensure the correct locking
512 * returns: 0 - initiated action successfully
513 * <0 - failed to initiate action
516 zfcp_erp_port_forced_reopen(struct zfcp_port *port, int clear_mask)
520 struct zfcp_adapter *adapter;
522 adapter = port->adapter;
523 read_lock_irqsave(&zfcp_data.config_lock, flags);
524 write_lock(&adapter->erp_lock);
525 retval = zfcp_erp_port_forced_reopen_internal(port, clear_mask);
526 write_unlock(&adapter->erp_lock);
527 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
535 * purpose: called if a port is to be opened
536 * initiates Reopen recovery which is done
539 * returns: 0 - initiated action successfully
540 * <0 - failed to initiate action
543 zfcp_erp_port_reopen_internal(struct zfcp_port *port, int clear_mask)
546 struct zfcp_adapter *adapter = port->adapter;
548 debug_text_event(adapter->erp_dbf, 5, "p_ro");
549 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
551 ZFCP_LOG_DEBUG("reopen of port 0x%016Lx on adapter %s\n",
552 port->wwpn, zfcp_get_busid_by_port(port));
554 zfcp_erp_port_block(port, clear_mask);
556 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED, &port->status)) {
557 ZFCP_LOG_DEBUG("skipped reopen of failed port 0x%016Lx "
558 "on adapter %s\n", port->wwpn,
559 zfcp_get_busid_by_port(port));
560 debug_text_event(adapter->erp_dbf, 5, "p_ro_f");
561 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
562 /* ensure propagation of failed status to new devices */
563 zfcp_erp_port_failed(port);
568 retval = zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_PORT,
569 port->adapter, port, NULL);
576 * zfcp_erp_port_reopen - initiate reopen of a remote port
577 * @port: port to be reopened
578 * @clear_mask: specifies flags in port status to be cleared
579 * Return: 0 on success, < 0 on error
581 * This is a wrappper function for zfcp_erp_port_reopen_internal. It ensures
582 * correct locking. An error recovery task is initiated to do the reopen.
583 * To wait for the completion of the reopen zfcp_erp_wait should be used.
586 zfcp_erp_port_reopen(struct zfcp_port *port, int clear_mask)
590 struct zfcp_adapter *adapter = port->adapter;
592 read_lock_irqsave(&zfcp_data.config_lock, flags);
593 write_lock(&adapter->erp_lock);
594 retval = zfcp_erp_port_reopen_internal(port, clear_mask);
595 write_unlock(&adapter->erp_lock);
596 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
604 * purpose: called if a unit is to be opened
605 * initiates Reopen recovery which is done
608 * returns: 0 - initiated action successfully
609 * <0 - failed to initiate action
612 zfcp_erp_unit_reopen_internal(struct zfcp_unit *unit, int clear_mask)
615 struct zfcp_adapter *adapter = unit->port->adapter;
617 debug_text_event(adapter->erp_dbf, 5, "u_ro");
618 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun, sizeof (fcp_lun_t));
619 ZFCP_LOG_DEBUG("reopen of unit 0x%016Lx on port 0x%016Lx "
620 "on adapter %s\n", unit->fcp_lun,
621 unit->port->wwpn, zfcp_get_busid_by_unit(unit));
623 zfcp_erp_unit_block(unit, clear_mask);
625 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED, &unit->status)) {
626 ZFCP_LOG_DEBUG("skipped reopen of failed unit 0x%016Lx "
627 "on port 0x%016Lx on adapter %s\n",
628 unit->fcp_lun, unit->port->wwpn,
629 zfcp_get_busid_by_unit(unit));
630 debug_text_event(adapter->erp_dbf, 5, "u_ro_f");
631 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun,
637 retval = zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_UNIT,
638 unit->port->adapter, unit->port, unit);
644 * zfcp_erp_unit_reopen - initiate reopen of a unit
645 * @unit: unit to be reopened
646 * @clear_mask: specifies flags in unit status to be cleared
647 * Return: 0 on success, < 0 on error
649 * This is a wrappper for zfcp_erp_unit_reopen_internal. It ensures correct
650 * locking. An error recovery task is initiated to do the reopen.
651 * To wait for the completion of the reopen zfcp_erp_wait should be used.
654 zfcp_erp_unit_reopen(struct zfcp_unit *unit, int clear_mask)
658 struct zfcp_adapter *adapter;
659 struct zfcp_port *port;
662 adapter = port->adapter;
664 read_lock_irqsave(&zfcp_data.config_lock, flags);
665 write_lock(&adapter->erp_lock);
666 retval = zfcp_erp_unit_reopen_internal(unit, clear_mask);
667 write_unlock(&adapter->erp_lock);
668 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
676 * purpose: disable I/O,
677 * return any open requests and clean them up,
678 * aim: no pending and incoming I/O
683 zfcp_erp_adapter_block(struct zfcp_adapter *adapter, int clear_mask)
685 debug_text_event(adapter->erp_dbf, 6, "a_bl");
686 zfcp_erp_modify_adapter_status(adapter,
687 ZFCP_STATUS_COMMON_UNBLOCKED |
688 clear_mask, ZFCP_CLEAR);
694 * purpose: enable I/O
699 zfcp_erp_adapter_unblock(struct zfcp_adapter *adapter)
701 debug_text_event(adapter->erp_dbf, 6, "a_ubl");
702 atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &adapter->status);
708 * purpose: disable I/O,
709 * return any open requests and clean them up,
710 * aim: no pending and incoming I/O
715 zfcp_erp_port_block(struct zfcp_port *port, int clear_mask)
717 struct zfcp_adapter *adapter = port->adapter;
719 debug_text_event(adapter->erp_dbf, 6, "p_bl");
720 debug_event(adapter->erp_dbf, 6, &port->wwpn, sizeof (wwn_t));
721 zfcp_erp_modify_port_status(port,
722 ZFCP_STATUS_COMMON_UNBLOCKED | clear_mask,
729 * purpose: enable I/O
734 zfcp_erp_port_unblock(struct zfcp_port *port)
736 struct zfcp_adapter *adapter = port->adapter;
738 debug_text_event(adapter->erp_dbf, 6, "p_ubl");
739 debug_event(adapter->erp_dbf, 6, &port->wwpn, sizeof (wwn_t));
740 atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &port->status);
746 * purpose: disable I/O,
747 * return any open requests and clean them up,
748 * aim: no pending and incoming I/O
753 zfcp_erp_unit_block(struct zfcp_unit *unit, int clear_mask)
755 struct zfcp_adapter *adapter = unit->port->adapter;
757 debug_text_event(adapter->erp_dbf, 6, "u_bl");
758 debug_event(adapter->erp_dbf, 6, &unit->fcp_lun, sizeof (fcp_lun_t));
759 zfcp_erp_modify_unit_status(unit,
760 ZFCP_STATUS_COMMON_UNBLOCKED | clear_mask,
767 * purpose: enable I/O
772 zfcp_erp_unit_unblock(struct zfcp_unit *unit)
774 struct zfcp_adapter *adapter = unit->port->adapter;
776 debug_text_event(adapter->erp_dbf, 6, "u_ubl");
777 debug_event(adapter->erp_dbf, 6, &unit->fcp_lun, sizeof (fcp_lun_t));
778 atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &unit->status);
782 zfcp_erp_action_ready(struct zfcp_erp_action *erp_action)
784 struct zfcp_adapter *adapter = erp_action->adapter;
786 debug_text_event(adapter->erp_dbf, 4, "a_ar");
787 debug_event(adapter->erp_dbf, 4, &erp_action->action, sizeof (int));
789 zfcp_erp_action_to_ready(erp_action);
790 up(&adapter->erp_ready_sem);
798 * returns: <0 erp_action not found in any list
799 * ZFCP_ERP_ACTION_READY erp_action is in ready list
800 * ZFCP_ERP_ACTION_RUNNING erp_action is in running list
802 * locks: erp_lock must be held
805 zfcp_erp_action_exists(struct zfcp_erp_action *erp_action)
807 int retval = -EINVAL;
808 struct list_head *entry;
809 struct zfcp_erp_action *entry_erp_action;
810 struct zfcp_adapter *adapter = erp_action->adapter;
812 /* search in running list */
813 list_for_each(entry, &adapter->erp_running_head) {
815 list_entry(entry, struct zfcp_erp_action, list);
816 if (entry_erp_action == erp_action) {
817 retval = ZFCP_ERP_ACTION_RUNNING;
821 /* search in ready list */
822 list_for_each(entry, &adapter->erp_ready_head) {
824 list_entry(entry, struct zfcp_erp_action, list);
825 if (entry_erp_action == erp_action) {
826 retval = ZFCP_ERP_ACTION_READY;
836 * purpose: checks current status of action (timed out, dismissed, ...)
837 * and does appropriate preparations (dismiss fsf request, ...)
839 * locks: called under erp_lock (disabled interrupts)
844 zfcp_erp_strategy_check_fsfreq(struct zfcp_erp_action *erp_action)
847 struct zfcp_fsf_req *fsf_req = NULL;
848 struct zfcp_adapter *adapter = erp_action->adapter;
850 if (erp_action->fsf_req) {
851 /* take lock to ensure that request is not being deleted meanwhile */
852 spin_lock(&adapter->fsf_req_list_lock);
853 /* check whether fsf req does still exist */
854 list_for_each_entry(fsf_req, &adapter->fsf_req_list_head, list)
855 if (fsf_req == erp_action->fsf_req)
857 if (fsf_req && (fsf_req->erp_action == erp_action)) {
858 /* fsf_req still exists */
859 debug_text_event(adapter->erp_dbf, 3, "a_ca_req");
860 debug_event(adapter->erp_dbf, 3, &fsf_req,
861 sizeof (unsigned long));
862 /* dismiss fsf_req of timed out or dismissed erp_action */
863 if (erp_action->status & (ZFCP_STATUS_ERP_DISMISSED |
864 ZFCP_STATUS_ERP_TIMEDOUT)) {
865 debug_text_event(adapter->erp_dbf, 3,
867 fsf_req->status |= ZFCP_STATUS_FSFREQ_DISMISSED;
869 if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT) {
870 ZFCP_LOG_NORMAL("error: erp step timed out "
871 "(action=%d, fsf_req=%p)\n ",
873 erp_action->fsf_req);
876 * If fsf_req is neither dismissed nor completed
877 * then keep it running asynchronously and don't mess
878 * with the association of erp_action and fsf_req.
880 if (fsf_req->status & (ZFCP_STATUS_FSFREQ_COMPLETED |
881 ZFCP_STATUS_FSFREQ_DISMISSED)) {
882 /* forget about association between fsf_req
884 fsf_req->erp_action = NULL;
885 erp_action->fsf_req = NULL;
888 debug_text_event(adapter->erp_dbf, 3, "a_ca_gonereq");
890 * even if this fsf_req has gone, forget about
891 * association between erp_action and fsf_req
893 erp_action->fsf_req = NULL;
895 spin_unlock(&adapter->fsf_req_list_lock);
897 debug_text_event(adapter->erp_dbf, 3, "a_ca_noreq");
903 * purpose: generic handler for asynchronous events related to erp_action events
904 * (normal completion, time-out, dismissing, retry after
905 * low memory condition)
907 * note: deletion of timer is not required (e.g. in case of a time-out),
908 * but a second try does no harm,
909 * we leave it in here to allow for greater simplification
911 * returns: 0 - there was an action to handle
915 zfcp_erp_async_handler_nolock(struct zfcp_erp_action *erp_action,
916 unsigned long set_mask)
919 struct zfcp_adapter *adapter = erp_action->adapter;
921 if (zfcp_erp_action_exists(erp_action) == ZFCP_ERP_ACTION_RUNNING) {
922 debug_text_event(adapter->erp_dbf, 2, "a_asyh_ex");
923 debug_event(adapter->erp_dbf, 2, &erp_action->action,
925 if (!(set_mask & ZFCP_STATUS_ERP_TIMEDOUT))
926 del_timer(&erp_action->timer);
927 erp_action->status |= set_mask;
928 zfcp_erp_action_ready(erp_action);
931 /* action is ready or gone - nothing to do */
932 debug_text_event(adapter->erp_dbf, 3, "a_asyh_gone");
933 debug_event(adapter->erp_dbf, 3, &erp_action->action,
942 * purpose: generic handler for asynchronous events related to erp_action
943 * events (normal completion, time-out, dismissing, retry after
944 * low memory condition)
946 * note: deletion of timer is not required (e.g. in case of a time-out),
947 * but a second try does no harm,
948 * we leave it in here to allow for greater simplification
950 * returns: 0 - there was an action to handle
954 zfcp_erp_async_handler(struct zfcp_erp_action *erp_action,
955 unsigned long set_mask)
957 struct zfcp_adapter *adapter = erp_action->adapter;
961 write_lock_irqsave(&adapter->erp_lock, flags);
962 retval = zfcp_erp_async_handler_nolock(erp_action, set_mask);
963 write_unlock_irqrestore(&adapter->erp_lock, flags);
969 * purpose: is called for erp_action which was slept waiting for
970 * memory becoming avaliable,
971 * will trigger that this action will be continued
974 zfcp_erp_memwait_handler(unsigned long data)
976 struct zfcp_erp_action *erp_action = (struct zfcp_erp_action *) data;
977 struct zfcp_adapter *adapter = erp_action->adapter;
979 debug_text_event(adapter->erp_dbf, 2, "a_mwh");
980 debug_event(adapter->erp_dbf, 2, &erp_action->action, sizeof (int));
982 zfcp_erp_async_handler(erp_action, 0);
986 * purpose: is called if an asynchronous erp step timed out,
987 * action gets an appropriate flag and will be processed
991 zfcp_erp_timeout_handler(unsigned long data)
993 struct zfcp_erp_action *erp_action = (struct zfcp_erp_action *) data;
994 struct zfcp_adapter *adapter = erp_action->adapter;
996 debug_text_event(adapter->erp_dbf, 2, "a_th");
997 debug_event(adapter->erp_dbf, 2, &erp_action->action, sizeof (int));
999 zfcp_erp_async_handler(erp_action, ZFCP_STATUS_ERP_TIMEDOUT);
1003 * purpose: is called for an erp_action which needs to be ended
1004 * though not being done,
1005 * this is usually required if an higher is generated,
1006 * action gets an appropriate flag and will be processed
1009 * locks: erp_lock held (thus we need to call another handler variant)
1012 zfcp_erp_action_dismiss(struct zfcp_erp_action *erp_action)
1014 struct zfcp_adapter *adapter = erp_action->adapter;
1016 debug_text_event(adapter->erp_dbf, 2, "a_adis");
1017 debug_event(adapter->erp_dbf, 2, &erp_action->action, sizeof (int));
1019 zfcp_erp_async_handler_nolock(erp_action, ZFCP_STATUS_ERP_DISMISSED);
1025 zfcp_erp_thread_setup(struct zfcp_adapter *adapter)
1029 atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP, &adapter->status);
1031 retval = kernel_thread(zfcp_erp_thread, adapter, SIGCHLD);
1033 ZFCP_LOG_NORMAL("error: creation of erp thread failed for "
1035 zfcp_get_busid_by_adapter(adapter));
1036 debug_text_event(adapter->erp_dbf, 5, "a_thset_fail");
1038 wait_event(adapter->erp_thread_wqh,
1039 atomic_test_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP,
1041 debug_text_event(adapter->erp_dbf, 5, "a_thset_ok");
1044 return (retval < 0);
1054 * context: process (i.e. proc-fs or rmmod/insmod)
1056 * note: The caller of this routine ensures that the specified
1057 * adapter has been shut down and that this operation
1058 * has been completed. Thus, there are no pending erp_actions
1059 * which would need to be handled here.
1062 zfcp_erp_thread_kill(struct zfcp_adapter *adapter)
1066 atomic_set_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL, &adapter->status);
1067 up(&adapter->erp_ready_sem);
1069 wait_event(adapter->erp_thread_wqh,
1070 !atomic_test_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP,
1073 atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL,
1076 debug_text_event(adapter->erp_dbf, 5, "a_thki_ok");
1082 * purpose: is run as a kernel thread,
1083 * goes through list of error recovery actions of associated adapter
1084 * and delegates single action to execution
1089 zfcp_erp_thread(void *data)
1091 struct zfcp_adapter *adapter = (struct zfcp_adapter *) data;
1092 struct list_head *next;
1093 struct zfcp_erp_action *erp_action;
1094 unsigned long flags;
1096 daemonize("zfcperp%s", zfcp_get_busid_by_adapter(adapter));
1097 /* Block all signals */
1098 siginitsetinv(¤t->blocked, 0);
1099 atomic_set_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP, &adapter->status);
1100 debug_text_event(adapter->erp_dbf, 5, "a_th_run");
1101 wake_up(&adapter->erp_thread_wqh);
1103 while (!atomic_test_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL,
1104 &adapter->status)) {
1106 write_lock_irqsave(&adapter->erp_lock, flags);
1107 next = adapter->erp_ready_head.prev;
1108 write_unlock_irqrestore(&adapter->erp_lock, flags);
1110 if (next != &adapter->erp_ready_head) {
1112 list_entry(next, struct zfcp_erp_action, list);
1114 * process action (incl. [re]moving it
1115 * from 'ready' queue)
1117 zfcp_erp_strategy(erp_action);
1121 * sleep as long as there is nothing to do, i.e.
1122 * no action in 'ready' queue to be processed and
1123 * thread is not to be killed
1125 down_interruptible(&adapter->erp_ready_sem);
1126 debug_text_event(adapter->erp_dbf, 5, "a_th_woken");
1129 atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP, &adapter->status);
1130 debug_text_event(adapter->erp_dbf, 5, "a_th_stop");
1131 wake_up(&adapter->erp_thread_wqh);
1139 * purpose: drives single error recovery action and schedules higher and
1140 * subordinate actions, if necessary
1142 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
1143 * ZFCP_ERP_SUCCEEDED - action finished successfully (deqd)
1144 * ZFCP_ERP_FAILED - action finished unsuccessfully (deqd)
1145 * ZFCP_ERP_EXIT - action finished (dequeued), offline
1146 * ZFCP_ERP_DISMISSED - action canceled (dequeued)
1149 zfcp_erp_strategy(struct zfcp_erp_action *erp_action)
1152 struct zfcp_adapter *adapter = erp_action->adapter;
1153 struct zfcp_port *port = erp_action->port;
1154 struct zfcp_unit *unit = erp_action->unit;
1155 int action = erp_action->action;
1156 u32 status = erp_action->status;
1157 unsigned long flags;
1159 /* serialise dismissing, timing out, moving, enqueueing */
1160 read_lock_irqsave(&zfcp_data.config_lock, flags);
1161 write_lock(&adapter->erp_lock);
1163 /* dequeue dismissed action and leave, if required */
1164 retval = zfcp_erp_strategy_check_action(erp_action, retval);
1165 if (retval == ZFCP_ERP_DISMISSED) {
1166 debug_text_event(adapter->erp_dbf, 4, "a_st_dis1");
1171 * move action to 'running' queue before processing it
1172 * (to avoid a race condition regarding moving the
1173 * action to the 'running' queue and back)
1175 zfcp_erp_action_to_running(erp_action);
1178 * try to process action as far as possible,
1179 * no lock to allow for blocking operations (kmalloc, qdio, ...),
1180 * afterwards the lock is required again for the following reasons:
1181 * - dequeueing of finished action and enqueueing of
1182 * follow-up actions must be atomic so that any other
1183 * reopen-routine does not believe there is nothing to do
1184 * and that it is safe to enqueue something else,
1185 * - we want to force any control thread which is dismissing
1186 * actions to finish this before we decide about
1187 * necessary steps to be taken here further
1189 write_unlock(&adapter->erp_lock);
1190 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
1191 retval = zfcp_erp_strategy_do_action(erp_action);
1192 read_lock_irqsave(&zfcp_data.config_lock, flags);
1193 write_lock(&adapter->erp_lock);
1196 * check for dismissed status again to avoid follow-up actions,
1197 * failing of targets and so on for dismissed actions
1199 retval = zfcp_erp_strategy_check_action(erp_action, retval);
1202 case ZFCP_ERP_DISMISSED:
1203 /* leave since this action has ridden to its ancestors */
1204 debug_text_event(adapter->erp_dbf, 6, "a_st_dis2");
1206 case ZFCP_ERP_NOMEM:
1207 /* no memory to continue immediately, let it sleep */
1208 if (!(erp_action->status & ZFCP_STATUS_ERP_LOWMEM)) {
1209 ++adapter->erp_low_mem_count;
1210 erp_action->status |= ZFCP_STATUS_ERP_LOWMEM;
1212 /* This condition is true if there is no memory available
1213 for any erp_action on this adapter. This implies that there
1214 are no elements in the memory pool(s) left for erp_actions.
1215 This might happen if an erp_action that used a memory pool
1216 element was timed out.
1218 if (adapter->erp_total_count == adapter->erp_low_mem_count) {
1219 debug_text_event(adapter->erp_dbf, 3, "a_st_lowmem");
1220 ZFCP_LOG_NORMAL("error: no mempool elements available, "
1221 "restarting I/O on adapter %s "
1222 "to free mempool\n",
1223 zfcp_get_busid_by_adapter(adapter));
1224 zfcp_erp_adapter_reopen_internal(adapter, 0);
1226 debug_text_event(adapter->erp_dbf, 2, "a_st_memw");
1227 retval = zfcp_erp_strategy_memwait(erp_action);
1230 case ZFCP_ERP_CONTINUES:
1231 /* leave since this action runs asynchronously */
1232 debug_text_event(adapter->erp_dbf, 6, "a_st_cont");
1233 if (erp_action->status & ZFCP_STATUS_ERP_LOWMEM) {
1234 --adapter->erp_low_mem_count;
1235 erp_action->status &= ~ZFCP_STATUS_ERP_LOWMEM;
1239 /* ok, finished action (whatever its result is) */
1241 /* check for unrecoverable targets */
1242 retval = zfcp_erp_strategy_check_target(erp_action, retval);
1244 /* action must be dequeued (here to allow for further ones) */
1245 zfcp_erp_action_dequeue(erp_action);
1248 * put this target through the erp mill again if someone has
1249 * requested to change the status of a target being online
1250 * to offline or the other way around
1251 * (old retval is preserved if nothing has to be done here)
1253 retval = zfcp_erp_strategy_statechange(action, status, adapter,
1254 port, unit, retval);
1257 * leave if target is in permanent error state or if
1258 * action is repeated in order to process state change
1260 if (retval == ZFCP_ERP_EXIT) {
1261 debug_text_event(adapter->erp_dbf, 2, "a_st_exit");
1265 /* trigger follow up actions */
1266 zfcp_erp_strategy_followup_actions(action, adapter, port, unit, retval);
1269 write_unlock(&adapter->erp_lock);
1270 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
1272 if (retval != ZFCP_ERP_CONTINUES)
1273 zfcp_erp_action_cleanup(action, adapter, port, unit, retval);
1276 * a few tasks remain when the erp queues are empty
1277 * (don't do that if the last action evaluated was dismissed
1278 * since this clearly indicates that there is more to come) :
1279 * - close the name server port if it is open yet
1280 * (enqueues another [probably] final action)
1281 * - otherwise, wake up whoever wants to be woken when we are
1284 if (retval != ZFCP_ERP_DISMISSED)
1285 zfcp_erp_strategy_check_queues(adapter);
1287 debug_text_event(adapter->erp_dbf, 6, "a_st_done");
1297 * returns: ZFCP_ERP_DISMISSED - if action has been dismissed
1298 * retval - otherwise
1301 zfcp_erp_strategy_check_action(struct zfcp_erp_action *erp_action, int retval)
1303 struct zfcp_adapter *adapter = erp_action->adapter;
1305 zfcp_erp_strategy_check_fsfreq(erp_action);
1307 debug_event(adapter->erp_dbf, 5, &erp_action->action, sizeof (int));
1308 if (erp_action->status & ZFCP_STATUS_ERP_DISMISSED) {
1309 debug_text_event(adapter->erp_dbf, 3, "a_stcd_dis");
1310 zfcp_erp_action_dequeue(erp_action);
1311 retval = ZFCP_ERP_DISMISSED;
1313 debug_text_event(adapter->erp_dbf, 5, "a_stcd_nodis");
1319 zfcp_erp_strategy_do_action(struct zfcp_erp_action *erp_action)
1321 int retval = ZFCP_ERP_FAILED;
1322 struct zfcp_adapter *adapter = erp_action->adapter;
1325 * try to execute/continue action as far as possible,
1326 * note: no lock in subsequent strategy routines
1327 * (this allows these routine to call schedule, e.g.
1328 * kmalloc with such flags or qdio_initialize & friends)
1329 * Note: in case of timeout, the seperate strategies will fail
1330 * anyhow. No need for a special action. Even worse, a nameserver
1331 * failure would not wake up waiting ports without the call.
1333 switch (erp_action->action) {
1335 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
1336 retval = zfcp_erp_adapter_strategy(erp_action);
1339 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
1340 retval = zfcp_erp_port_forced_strategy(erp_action);
1343 case ZFCP_ERP_ACTION_REOPEN_PORT:
1344 retval = zfcp_erp_port_strategy(erp_action);
1347 case ZFCP_ERP_ACTION_REOPEN_UNIT:
1348 retval = zfcp_erp_unit_strategy(erp_action);
1352 debug_text_exception(adapter->erp_dbf, 1, "a_stda_bug");
1353 debug_event(adapter->erp_dbf, 1, &erp_action->action,
1355 ZFCP_LOG_NORMAL("bug: unknown erp action requested on "
1356 "adapter %s (action=%d)\n",
1357 zfcp_get_busid_by_adapter(erp_action->adapter),
1358 erp_action->action);
1367 * purpose: triggers retry of this action after a certain amount of time
1368 * by means of timer provided by erp_action
1370 * returns: ZFCP_ERP_CONTINUES - erp_action sleeps in erp running queue
1373 zfcp_erp_strategy_memwait(struct zfcp_erp_action *erp_action)
1375 int retval = ZFCP_ERP_CONTINUES;
1376 struct zfcp_adapter *adapter = erp_action->adapter;
1378 debug_text_event(adapter->erp_dbf, 6, "a_mwinit");
1379 debug_event(adapter->erp_dbf, 6, &erp_action->action, sizeof (int));
1380 init_timer(&erp_action->timer);
1381 erp_action->timer.function = zfcp_erp_memwait_handler;
1382 erp_action->timer.data = (unsigned long) erp_action;
1383 erp_action->timer.expires = jiffies + ZFCP_ERP_MEMWAIT_TIMEOUT;
1384 add_timer(&erp_action->timer);
1390 * function: zfcp_erp_adapter_failed
1392 * purpose: sets the adapter and all underlying devices to ERP_FAILED
1396 zfcp_erp_adapter_failed(struct zfcp_adapter *adapter)
1398 zfcp_erp_modify_adapter_status(adapter,
1399 ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET);
1400 ZFCP_LOG_NORMAL("adapter erp failed on adapter %s\n",
1401 zfcp_get_busid_by_adapter(adapter));
1402 debug_text_event(adapter->erp_dbf, 2, "a_afail");
1406 * function: zfcp_erp_port_failed
1408 * purpose: sets the port and all underlying devices to ERP_FAILED
1412 zfcp_erp_port_failed(struct zfcp_port *port)
1414 zfcp_erp_modify_port_status(port,
1415 ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET);
1417 if (atomic_test_mask(ZFCP_STATUS_PORT_WKA, &port->status))
1418 ZFCP_LOG_NORMAL("port erp failed (adapter %s, "
1419 "port d_id=0x%08x)\n",
1420 zfcp_get_busid_by_port(port), port->d_id);
1422 ZFCP_LOG_NORMAL("port erp failed (adapter %s, wwpn=0x%016Lx)\n",
1423 zfcp_get_busid_by_port(port), port->wwpn);
1425 debug_text_event(port->adapter->erp_dbf, 2, "p_pfail");
1426 debug_event(port->adapter->erp_dbf, 2, &port->wwpn, sizeof (wwn_t));
1430 * function: zfcp_erp_unit_failed
1432 * purpose: sets the unit to ERP_FAILED
1436 zfcp_erp_unit_failed(struct zfcp_unit *unit)
1438 zfcp_erp_modify_unit_status(unit,
1439 ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET);
1441 ZFCP_LOG_NORMAL("unit erp failed on unit 0x%016Lx on port 0x%016Lx "
1442 " on adapter %s\n", unit->fcp_lun,
1443 unit->port->wwpn, zfcp_get_busid_by_unit(unit));
1444 debug_text_event(unit->port->adapter->erp_dbf, 2, "u_ufail");
1445 debug_event(unit->port->adapter->erp_dbf, 2,
1446 &unit->fcp_lun, sizeof (fcp_lun_t));
1450 * function: zfcp_erp_strategy_check_target
1452 * purpose: increments the erp action count on the device currently in
1453 * recovery if the action failed or resets the count in case of
1454 * success. If a maximum count is exceeded the device is marked
1456 * The 'blocked' state of a target which has been recovered
1457 * successfully is reset.
1459 * returns: ZFCP_ERP_CONTINUES - action continues (not considered)
1460 * ZFCP_ERP_SUCCEEDED - action finished successfully
1461 * ZFCP_ERP_EXIT - action failed and will not continue
1464 zfcp_erp_strategy_check_target(struct zfcp_erp_action *erp_action, int result)
1466 struct zfcp_adapter *adapter = erp_action->adapter;
1467 struct zfcp_port *port = erp_action->port;
1468 struct zfcp_unit *unit = erp_action->unit;
1470 debug_text_event(adapter->erp_dbf, 5, "a_stct_norm");
1471 debug_event(adapter->erp_dbf, 5, &erp_action->action, sizeof (int));
1472 debug_event(adapter->erp_dbf, 5, &result, sizeof (int));
1474 switch (erp_action->action) {
1476 case ZFCP_ERP_ACTION_REOPEN_UNIT:
1477 result = zfcp_erp_strategy_check_unit(unit, result);
1480 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
1481 case ZFCP_ERP_ACTION_REOPEN_PORT:
1482 result = zfcp_erp_strategy_check_port(port, result);
1485 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
1486 result = zfcp_erp_strategy_check_adapter(adapter, result);
1494 zfcp_erp_strategy_statechange(int action,
1496 struct zfcp_adapter *adapter,
1497 struct zfcp_port *port,
1498 struct zfcp_unit *unit, int retval)
1500 debug_text_event(adapter->erp_dbf, 3, "a_stsc");
1501 debug_event(adapter->erp_dbf, 3, &action, sizeof (int));
1505 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
1506 if (zfcp_erp_strategy_statechange_detected(&adapter->status,
1508 zfcp_erp_adapter_reopen_internal(adapter, ZFCP_STATUS_COMMON_ERP_FAILED);
1509 retval = ZFCP_ERP_EXIT;
1513 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
1514 case ZFCP_ERP_ACTION_REOPEN_PORT:
1515 if (zfcp_erp_strategy_statechange_detected(&port->status,
1517 zfcp_erp_port_reopen_internal(port, ZFCP_STATUS_COMMON_ERP_FAILED);
1518 retval = ZFCP_ERP_EXIT;
1522 case ZFCP_ERP_ACTION_REOPEN_UNIT:
1523 if (zfcp_erp_strategy_statechange_detected(&unit->status,
1525 zfcp_erp_unit_reopen_internal(unit, ZFCP_STATUS_COMMON_ERP_FAILED);
1526 retval = ZFCP_ERP_EXIT;
1535 zfcp_erp_strategy_statechange_detected(atomic_t * target_status, u32 erp_status)
1538 /* take it online */
1539 (atomic_test_mask(ZFCP_STATUS_COMMON_RUNNING, target_status) &&
1540 (ZFCP_STATUS_ERP_CLOSE_ONLY & erp_status)) ||
1541 /* take it offline */
1542 (!atomic_test_mask(ZFCP_STATUS_COMMON_RUNNING, target_status) &&
1543 !(ZFCP_STATUS_ERP_CLOSE_ONLY & erp_status));
1547 zfcp_erp_strategy_check_unit(struct zfcp_unit *unit, int result)
1549 debug_text_event(unit->port->adapter->erp_dbf, 5, "u_stct");
1550 debug_event(unit->port->adapter->erp_dbf, 5, &unit->fcp_lun,
1551 sizeof (fcp_lun_t));
1554 case ZFCP_ERP_SUCCEEDED :
1555 atomic_set(&unit->erp_counter, 0);
1556 zfcp_erp_unit_unblock(unit);
1558 case ZFCP_ERP_FAILED :
1559 atomic_inc(&unit->erp_counter);
1560 if (atomic_read(&unit->erp_counter) > ZFCP_MAX_ERPS)
1561 zfcp_erp_unit_failed(unit);
1563 case ZFCP_ERP_EXIT :
1568 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED, &unit->status)) {
1569 zfcp_erp_unit_block(unit, 0); /* for ZFCP_ERP_SUCCEEDED */
1570 result = ZFCP_ERP_EXIT;
1577 zfcp_erp_strategy_check_port(struct zfcp_port *port, int result)
1579 debug_text_event(port->adapter->erp_dbf, 5, "p_stct");
1580 debug_event(port->adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
1583 case ZFCP_ERP_SUCCEEDED :
1584 atomic_set(&port->erp_counter, 0);
1585 zfcp_erp_port_unblock(port);
1587 case ZFCP_ERP_FAILED :
1588 atomic_inc(&port->erp_counter);
1589 if (atomic_read(&port->erp_counter) > ZFCP_MAX_ERPS)
1590 zfcp_erp_port_failed(port);
1592 case ZFCP_ERP_EXIT :
1597 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED, &port->status)) {
1598 zfcp_erp_port_block(port, 0); /* for ZFCP_ERP_SUCCEEDED */
1599 result = ZFCP_ERP_EXIT;
1606 zfcp_erp_strategy_check_adapter(struct zfcp_adapter *adapter, int result)
1608 debug_text_event(adapter->erp_dbf, 5, "a_stct");
1611 case ZFCP_ERP_SUCCEEDED :
1612 atomic_set(&adapter->erp_counter, 0);
1613 zfcp_erp_adapter_unblock(adapter);
1615 case ZFCP_ERP_FAILED :
1616 atomic_inc(&adapter->erp_counter);
1617 if (atomic_read(&adapter->erp_counter) > ZFCP_MAX_ERPS)
1618 zfcp_erp_adapter_failed(adapter);
1620 case ZFCP_ERP_EXIT :
1625 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED, &adapter->status)) {
1626 zfcp_erp_adapter_block(adapter, 0); /* for ZFCP_ERP_SUCCEEDED */
1627 result = ZFCP_ERP_EXIT;
1636 * purpose: remaining things in good cases,
1637 * escalation in bad cases
1642 zfcp_erp_strategy_followup_actions(int action,
1643 struct zfcp_adapter *adapter,
1644 struct zfcp_port *port,
1645 struct zfcp_unit *unit, int status)
1647 debug_text_event(adapter->erp_dbf, 5, "a_stfol");
1648 debug_event(adapter->erp_dbf, 5, &action, sizeof (int));
1650 /* initiate follow-up actions depending on success of finished action */
1653 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
1654 if (status == ZFCP_ERP_SUCCEEDED)
1655 zfcp_erp_port_reopen_all_internal(adapter, 0);
1657 zfcp_erp_adapter_reopen_internal(adapter, 0);
1660 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
1661 if (status == ZFCP_ERP_SUCCEEDED)
1662 zfcp_erp_port_reopen_internal(port, 0);
1664 zfcp_erp_adapter_reopen_internal(adapter, 0);
1667 case ZFCP_ERP_ACTION_REOPEN_PORT:
1668 if (status == ZFCP_ERP_SUCCEEDED)
1669 zfcp_erp_unit_reopen_all_internal(port, 0);
1671 zfcp_erp_port_forced_reopen_internal(port, 0);
1674 case ZFCP_ERP_ACTION_REOPEN_UNIT:
1675 if (status == ZFCP_ERP_SUCCEEDED) ; /* no further action */
1677 zfcp_erp_port_reopen_internal(unit->port, 0);
1685 zfcp_erp_strategy_check_queues(struct zfcp_adapter *adapter)
1687 unsigned long flags;
1689 read_lock_irqsave(&zfcp_data.config_lock, flags);
1690 read_lock(&adapter->erp_lock);
1691 if (list_empty(&adapter->erp_ready_head) &&
1692 list_empty(&adapter->erp_running_head)) {
1693 debug_text_event(adapter->erp_dbf, 4, "a_cq_wake");
1694 atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_PENDING,
1696 wake_up(&adapter->erp_done_wqh);
1698 debug_text_event(adapter->erp_dbf, 5, "a_cq_notempty");
1699 read_unlock(&adapter->erp_lock);
1700 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
1706 * zfcp_erp_wait - wait for completion of error recovery on an adapter
1707 * @adapter: adapter for which to wait for completion of its error recovery
1711 zfcp_erp_wait(struct zfcp_adapter *adapter)
1715 wait_event(adapter->erp_done_wqh,
1716 !atomic_test_mask(ZFCP_STATUS_ADAPTER_ERP_PENDING,
1723 zfcp_erp_modify_adapter_status(struct zfcp_adapter *adapter,
1724 u32 mask, int set_or_clear)
1726 struct zfcp_port *port;
1727 u32 common_mask = mask & ZFCP_COMMON_FLAGS;
1729 if (set_or_clear == ZFCP_SET) {
1730 atomic_set_mask(mask, &adapter->status);
1731 debug_text_event(adapter->erp_dbf, 3, "a_mod_as_s");
1733 atomic_clear_mask(mask, &adapter->status);
1734 if (mask & ZFCP_STATUS_COMMON_ERP_FAILED)
1735 atomic_set(&adapter->erp_counter, 0);
1736 debug_text_event(adapter->erp_dbf, 3, "a_mod_as_c");
1738 debug_event(adapter->erp_dbf, 3, &mask, sizeof (u32));
1740 /* Deal with all underlying devices, only pass common_mask */
1742 list_for_each_entry(port, &adapter->port_list_head, list)
1743 zfcp_erp_modify_port_status(port, common_mask,
1748 * function: zfcp_erp_modify_port_status
1750 * purpose: sets the port and all underlying devices to ERP_FAILED
1754 zfcp_erp_modify_port_status(struct zfcp_port *port, u32 mask, int set_or_clear)
1756 struct zfcp_unit *unit;
1757 u32 common_mask = mask & ZFCP_COMMON_FLAGS;
1759 if (set_or_clear == ZFCP_SET) {
1760 atomic_set_mask(mask, &port->status);
1761 debug_text_event(port->adapter->erp_dbf, 3, "p_mod_ps_s");
1763 atomic_clear_mask(mask, &port->status);
1764 if (mask & ZFCP_STATUS_COMMON_ERP_FAILED)
1765 atomic_set(&port->erp_counter, 0);
1766 debug_text_event(port->adapter->erp_dbf, 3, "p_mod_ps_c");
1768 debug_event(port->adapter->erp_dbf, 3, &port->wwpn, sizeof (wwn_t));
1769 debug_event(port->adapter->erp_dbf, 3, &mask, sizeof (u32));
1771 /* Modify status of all underlying devices, only pass common mask */
1773 list_for_each_entry(unit, &port->unit_list_head, list)
1774 zfcp_erp_modify_unit_status(unit, common_mask,
1779 * function: zfcp_erp_modify_unit_status
1781 * purpose: sets the unit to ERP_FAILED
1785 zfcp_erp_modify_unit_status(struct zfcp_unit *unit, u32 mask, int set_or_clear)
1787 if (set_or_clear == ZFCP_SET) {
1788 atomic_set_mask(mask, &unit->status);
1789 debug_text_event(unit->port->adapter->erp_dbf, 3, "u_mod_us_s");
1791 atomic_clear_mask(mask, &unit->status);
1792 if (mask & ZFCP_STATUS_COMMON_ERP_FAILED) {
1793 atomic_set(&unit->erp_counter, 0);
1795 debug_text_event(unit->port->adapter->erp_dbf, 3, "u_mod_us_c");
1797 debug_event(unit->port->adapter->erp_dbf, 3, &unit->fcp_lun,
1798 sizeof (fcp_lun_t));
1799 debug_event(unit->port->adapter->erp_dbf, 3, &mask, sizeof (u32));
1805 * purpose: Wrappper for zfcp_erp_port_reopen_all_internal
1806 * used to ensure the correct locking
1808 * returns: 0 - initiated action successfully
1809 * <0 - failed to initiate action
1812 zfcp_erp_port_reopen_all(struct zfcp_adapter *adapter, int clear_mask)
1815 unsigned long flags;
1817 read_lock_irqsave(&zfcp_data.config_lock, flags);
1818 write_lock(&adapter->erp_lock);
1819 retval = zfcp_erp_port_reopen_all_internal(adapter, clear_mask);
1820 write_unlock(&adapter->erp_lock);
1821 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
1827 zfcp_erp_port_reopen_all_internal(struct zfcp_adapter *adapter, int clear_mask)
1830 struct zfcp_port *port;
1832 list_for_each_entry(port, &adapter->port_list_head, list)
1833 if (!atomic_test_mask(ZFCP_STATUS_PORT_WKA, &port->status))
1834 zfcp_erp_port_reopen_internal(port, clear_mask);
1847 zfcp_erp_unit_reopen_all_internal(struct zfcp_port *port, int clear_mask)
1850 struct zfcp_unit *unit;
1852 list_for_each_entry(unit, &port->unit_list_head, list)
1853 zfcp_erp_unit_reopen_internal(unit, clear_mask);
1861 * purpose: this routine executes the 'Reopen Adapter' action
1862 * (the entire action is processed synchronously, since
1863 * there are no actions which might be run concurrently
1866 * returns: ZFCP_ERP_SUCCEEDED - action finished successfully
1867 * ZFCP_ERP_FAILED - action finished unsuccessfully
1870 zfcp_erp_adapter_strategy(struct zfcp_erp_action *erp_action)
1873 struct zfcp_adapter *adapter = erp_action->adapter;
1875 retval = zfcp_erp_adapter_strategy_close(erp_action);
1876 if (erp_action->status & ZFCP_STATUS_ERP_CLOSE_ONLY)
1877 retval = ZFCP_ERP_EXIT;
1879 retval = zfcp_erp_adapter_strategy_open(erp_action);
1881 debug_text_event(adapter->erp_dbf, 3, "a_ast/ret");
1882 debug_event(adapter->erp_dbf, 3, &erp_action->action, sizeof (int));
1883 debug_event(adapter->erp_dbf, 3, &retval, sizeof (int));
1885 if (retval == ZFCP_ERP_FAILED) {
1886 ZFCP_LOG_INFO("Waiting to allow the adapter %s "
1887 "to recover itself\n",
1888 zfcp_get_busid_by_adapter(adapter));
1889 msleep(jiffies_to_msecs(ZFCP_TYPE2_RECOVERY_TIME));
1900 * returns: ZFCP_ERP_SUCCEEDED - action finished successfully
1901 * ZFCP_ERP_FAILED - action finished unsuccessfully
1904 zfcp_erp_adapter_strategy_close(struct zfcp_erp_action *erp_action)
1908 atomic_set_mask(ZFCP_STATUS_COMMON_CLOSING,
1909 &erp_action->adapter->status);
1910 retval = zfcp_erp_adapter_strategy_generic(erp_action, 1);
1911 atomic_clear_mask(ZFCP_STATUS_COMMON_CLOSING,
1912 &erp_action->adapter->status);
1922 * returns: ZFCP_ERP_SUCCEEDED - action finished successfully
1923 * ZFCP_ERP_FAILED - action finished unsuccessfully
1926 zfcp_erp_adapter_strategy_open(struct zfcp_erp_action *erp_action)
1930 atomic_set_mask(ZFCP_STATUS_COMMON_OPENING,
1931 &erp_action->adapter->status);
1932 retval = zfcp_erp_adapter_strategy_generic(erp_action, 0);
1933 atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING,
1934 &erp_action->adapter->status);
1940 * function: zfcp_register_adapter
1942 * purpose: allocate the irq associated with this devno and register
1943 * the FSF adapter with the SCSI stack
1948 zfcp_erp_adapter_strategy_generic(struct zfcp_erp_action *erp_action, int close)
1950 int retval = ZFCP_ERP_SUCCEEDED;
1955 retval = zfcp_erp_adapter_strategy_open_qdio(erp_action);
1956 if (retval != ZFCP_ERP_SUCCEEDED)
1959 retval = zfcp_erp_adapter_strategy_open_fsf(erp_action);
1960 if (retval != ZFCP_ERP_SUCCEEDED)
1961 goto failed_openfcp;
1963 atomic_set_mask(ZFCP_STATUS_COMMON_OPEN, &erp_action->adapter->status);
1967 atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN,
1968 &erp_action->adapter->status);
1971 zfcp_erp_adapter_strategy_close_qdio(erp_action);
1972 zfcp_erp_adapter_strategy_close_fsf(erp_action);
1979 * function: zfcp_qdio_init
1981 * purpose: setup QDIO operation for specified adapter
1983 * returns: 0 - successful setup
1987 zfcp_erp_adapter_strategy_open_qdio(struct zfcp_erp_action *erp_action)
1991 volatile struct qdio_buffer_element *sbale;
1992 struct zfcp_adapter *adapter = erp_action->adapter;
1994 if (atomic_test_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &adapter->status)) {
1995 ZFCP_LOG_NORMAL("bug: second attempt to set up QDIO on "
1997 zfcp_get_busid_by_adapter(adapter));
2001 if (qdio_establish(&adapter->qdio_init_data) != 0) {
2002 ZFCP_LOG_INFO("error: establishment of QDIO queues failed "
2004 zfcp_get_busid_by_adapter(adapter));
2005 goto failed_qdio_establish;
2007 debug_text_event(adapter->erp_dbf, 3, "qdio_est");
2009 if (qdio_activate(adapter->ccw_device, 0) != 0) {
2010 ZFCP_LOG_INFO("error: activation of QDIO queues failed "
2012 zfcp_get_busid_by_adapter(adapter));
2013 goto failed_qdio_activate;
2015 debug_text_event(adapter->erp_dbf, 3, "qdio_act");
2018 * put buffers into response queue,
2020 for (i = 0; i < QDIO_MAX_BUFFERS_PER_Q; i++) {
2021 sbale = &(adapter->response_queue.buffer[i]->element[0]);
2023 sbale->flags = SBAL_FLAGS_LAST_ENTRY;
2027 ZFCP_LOG_TRACE("calling do_QDIO on adapter %s (flags=0x%x, "
2028 "queue_no=%i, index_in_queue=%i, count=%i)\n",
2029 zfcp_get_busid_by_adapter(adapter),
2030 QDIO_FLAG_SYNC_INPUT, 0, 0, QDIO_MAX_BUFFERS_PER_Q);
2032 retval = do_QDIO(adapter->ccw_device,
2033 QDIO_FLAG_SYNC_INPUT,
2034 0, 0, QDIO_MAX_BUFFERS_PER_Q, NULL);
2037 ZFCP_LOG_NORMAL("bug: setup of QDIO failed (retval=%d)\n",
2039 goto failed_do_qdio;
2041 adapter->response_queue.free_index = 0;
2042 atomic_set(&adapter->response_queue.free_count, 0);
2043 ZFCP_LOG_DEBUG("%i buffers successfully enqueued to "
2044 "response queue\n", QDIO_MAX_BUFFERS_PER_Q);
2046 /* set index of first avalable SBALS / number of available SBALS */
2047 adapter->request_queue.free_index = 0;
2048 atomic_set(&adapter->request_queue.free_count, QDIO_MAX_BUFFERS_PER_Q);
2049 adapter->request_queue.distance_from_int = 0;
2051 /* initialize waitqueue used to wait for free SBALs in requests queue */
2052 init_waitqueue_head(&adapter->request_wq);
2054 /* ok, we did it - skip all cleanups for different failures */
2055 atomic_set_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &adapter->status);
2056 retval = ZFCP_ERP_SUCCEEDED;
2062 failed_qdio_activate:
2063 debug_text_event(adapter->erp_dbf, 3, "qdio_down1a");
2064 while (qdio_shutdown(adapter->ccw_device,
2065 QDIO_FLAG_CLEANUP_USING_CLEAR) == -EINPROGRESS)
2067 debug_text_event(adapter->erp_dbf, 3, "qdio_down1b");
2069 failed_qdio_establish:
2071 retval = ZFCP_ERP_FAILED;
2078 * function: zfcp_qdio_cleanup
2080 * purpose: cleans up QDIO operation for the specified adapter
2082 * returns: 0 - successful cleanup
2083 * !0 - failed cleanup
2086 zfcp_erp_adapter_strategy_close_qdio(struct zfcp_erp_action *erp_action)
2088 int retval = ZFCP_ERP_SUCCEEDED;
2091 struct zfcp_adapter *adapter = erp_action->adapter;
2093 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &adapter->status)) {
2094 ZFCP_LOG_DEBUG("error: attempt to shut down inactive QDIO "
2095 "queues on adapter %s\n",
2096 zfcp_get_busid_by_adapter(adapter));
2097 retval = ZFCP_ERP_FAILED;
2102 * Get queue_lock and clear QDIOUP flag. Thus it's guaranteed that
2103 * do_QDIO won't be called while qdio_shutdown is in progress.
2106 write_lock_irq(&adapter->request_queue.queue_lock);
2107 atomic_clear_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &adapter->status);
2108 write_unlock_irq(&adapter->request_queue.queue_lock);
2110 debug_text_event(adapter->erp_dbf, 3, "qdio_down2a");
2111 while (qdio_shutdown(adapter->ccw_device,
2112 QDIO_FLAG_CLEANUP_USING_CLEAR) == -EINPROGRESS)
2114 debug_text_event(adapter->erp_dbf, 3, "qdio_down2b");
2117 * First we had to stop QDIO operation.
2118 * Now it is safe to take the following actions.
2121 /* Cleanup only necessary when there are unacknowledged buffers */
2122 if (atomic_read(&adapter->request_queue.free_count)
2123 < QDIO_MAX_BUFFERS_PER_Q) {
2124 first_used = (adapter->request_queue.free_index +
2125 atomic_read(&adapter->request_queue.free_count))
2126 % QDIO_MAX_BUFFERS_PER_Q;
2127 used_count = QDIO_MAX_BUFFERS_PER_Q -
2128 atomic_read(&adapter->request_queue.free_count);
2129 zfcp_qdio_zero_sbals(adapter->request_queue.buffer,
2130 first_used, used_count);
2132 adapter->response_queue.free_index = 0;
2133 atomic_set(&adapter->response_queue.free_count, 0);
2134 adapter->request_queue.free_index = 0;
2135 atomic_set(&adapter->request_queue.free_count, 0);
2136 adapter->request_queue.distance_from_int = 0;
2142 zfcp_erp_adapter_strategy_open_fsf(struct zfcp_erp_action *erp_action)
2146 retval = zfcp_erp_adapter_strategy_open_fsf_xconfig(erp_action);
2147 if (retval == ZFCP_ERP_FAILED)
2148 return ZFCP_ERP_FAILED;
2150 retval = zfcp_erp_adapter_strategy_open_fsf_xport(erp_action);
2151 if (retval == ZFCP_ERP_FAILED)
2152 return ZFCP_ERP_FAILED;
2154 return zfcp_erp_adapter_strategy_open_fsf_statusread(erp_action);
2158 zfcp_erp_adapter_strategy_open_fsf_xconfig(struct zfcp_erp_action *erp_action)
2160 int retval = ZFCP_ERP_SUCCEEDED;
2162 int sleep = ZFCP_EXCHANGE_CONFIG_DATA_FIRST_SLEEP;
2163 struct zfcp_adapter *adapter = erp_action->adapter;
2165 atomic_clear_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK, &adapter->status);
2167 for (retries = ZFCP_EXCHANGE_CONFIG_DATA_RETRIES; retries; retries--) {
2168 atomic_clear_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT,
2170 ZFCP_LOG_DEBUG("Doing exchange config data\n");
2171 write_lock_irq(&adapter->erp_lock);
2172 zfcp_erp_action_to_running(erp_action);
2173 write_unlock_irq(&adapter->erp_lock);
2174 zfcp_erp_timeout_init(erp_action);
2175 if (zfcp_fsf_exchange_config_data(erp_action)) {
2176 retval = ZFCP_ERP_FAILED;
2177 debug_text_event(adapter->erp_dbf, 5, "a_fstx_xf");
2178 ZFCP_LOG_INFO("error: initiation of exchange of "
2179 "configuration data failed for "
2181 zfcp_get_busid_by_adapter(adapter));
2184 debug_text_event(adapter->erp_dbf, 6, "a_fstx_xok");
2185 ZFCP_LOG_DEBUG("Xchange underway\n");
2189 * Both the normal completion handler as well as the timeout
2190 * handler will do an 'up' when the 'exchange config data'
2191 * request completes or times out. Thus, the signal to go on
2192 * won't be lost utilizing this semaphore.
2193 * Furthermore, this 'adapter_reopen' action is
2194 * guaranteed to be the only action being there (highest action
2195 * which prevents other actions from being created).
2196 * Resulting from that, the wake signal recognized here
2197 * _must_ be the one belonging to the 'exchange config
2200 down(&adapter->erp_ready_sem);
2201 if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT) {
2202 ZFCP_LOG_INFO("error: exchange of configuration data "
2203 "for adapter %s timed out\n",
2204 zfcp_get_busid_by_adapter(adapter));
2208 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT,
2212 ZFCP_LOG_DEBUG("host connection still initialising... "
2213 "waiting and retrying...\n");
2214 /* sleep a little bit before retry */
2215 msleep(jiffies_to_msecs(sleep));
2219 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK,
2220 &adapter->status)) {
2221 ZFCP_LOG_INFO("error: exchange of configuration data for "
2222 "adapter %s failed\n",
2223 zfcp_get_busid_by_adapter(adapter));
2224 retval = ZFCP_ERP_FAILED;
2231 zfcp_erp_adapter_strategy_open_fsf_xport(struct zfcp_erp_action *erp_action)
2234 struct zfcp_adapter *adapter;
2236 adapter = erp_action->adapter;
2237 atomic_clear_mask(ZFCP_STATUS_ADAPTER_XPORT_OK, &adapter->status);
2239 write_lock_irq(&adapter->erp_lock);
2240 zfcp_erp_action_to_running(erp_action);
2241 write_unlock_irq(&adapter->erp_lock);
2243 zfcp_erp_timeout_init(erp_action);
2244 ret = zfcp_fsf_exchange_port_data(erp_action, adapter, NULL);
2245 if (ret == -EOPNOTSUPP) {
2246 debug_text_event(adapter->erp_dbf, 3, "a_xport_notsupp");
2247 return ZFCP_ERP_SUCCEEDED;
2249 debug_text_event(adapter->erp_dbf, 3, "a_xport_failed");
2250 return ZFCP_ERP_FAILED;
2252 debug_text_event(adapter->erp_dbf, 6, "a_xport_ok");
2254 ret = ZFCP_ERP_SUCCEEDED;
2255 down(&adapter->erp_ready_sem);
2256 if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT) {
2257 ZFCP_LOG_INFO("error: exchange port data timed out (adapter "
2258 "%s)\n", zfcp_get_busid_by_adapter(adapter));
2259 ret = ZFCP_ERP_FAILED;
2261 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_XPORT_OK, &adapter->status)) {
2262 ZFCP_LOG_INFO("error: exchange port data failed (adapter "
2263 "%s\n", zfcp_get_busid_by_adapter(adapter));
2264 ret = ZFCP_ERP_FAILED;
2271 zfcp_erp_adapter_strategy_open_fsf_statusread(struct zfcp_erp_action
2274 int retval = ZFCP_ERP_SUCCEEDED;
2276 struct zfcp_adapter *adapter = erp_action->adapter;
2279 adapter->status_read_failed = 0;
2280 for (i = 0; i < ZFCP_STATUS_READS_RECOM; i++) {
2281 temp_ret = zfcp_fsf_status_read(adapter, ZFCP_WAIT_FOR_SBAL);
2283 ZFCP_LOG_INFO("error: set-up of unsolicited status "
2284 "notification failed on adapter %s\n",
2285 zfcp_get_busid_by_adapter(adapter));
2286 retval = ZFCP_ERP_FAILED;
2296 * function: zfcp_fsf_cleanup
2298 * purpose: cleanup FSF operation for specified adapter
2300 * returns: 0 - FSF operation successfully cleaned up
2301 * !0 - failed to cleanup FSF operation for this adapter
2304 zfcp_erp_adapter_strategy_close_fsf(struct zfcp_erp_action *erp_action)
2306 int retval = ZFCP_ERP_SUCCEEDED;
2307 struct zfcp_adapter *adapter = erp_action->adapter;
2310 * wake waiting initiators of requests,
2311 * return SCSI commands (with error status),
2312 * clean up all requests (synchronously)
2314 zfcp_fsf_req_dismiss_all(adapter);
2315 /* reset FSF request sequence number */
2316 adapter->fsf_req_seq_no = 0;
2317 /* all ports and units are closed */
2318 zfcp_erp_modify_adapter_status(adapter,
2319 ZFCP_STATUS_COMMON_OPEN, ZFCP_CLEAR);
2327 * purpose: this routine executes the 'Reopen Physical Port' action
2329 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2330 * ZFCP_ERP_SUCCEEDED - action finished successfully
2331 * ZFCP_ERP_FAILED - action finished unsuccessfully
2334 zfcp_erp_port_forced_strategy(struct zfcp_erp_action *erp_action)
2336 int retval = ZFCP_ERP_FAILED;
2337 struct zfcp_port *port = erp_action->port;
2338 struct zfcp_adapter *adapter = erp_action->adapter;
2340 switch (erp_action->step) {
2344 * the ULP spec. begs for waiting for oustanding commands
2346 case ZFCP_ERP_STEP_UNINITIALIZED:
2347 zfcp_erp_port_strategy_clearstati(port);
2349 * it would be sufficient to test only the normal open flag
2350 * since the phys. open flag cannot be set if the normal
2351 * open flag is unset - however, this is for readabilty ...
2353 if (atomic_test_mask((ZFCP_STATUS_PORT_PHYS_OPEN |
2354 ZFCP_STATUS_COMMON_OPEN),
2356 ZFCP_LOG_DEBUG("port 0x%016Lx is open -> trying "
2357 "close physical\n", port->wwpn);
2359 zfcp_erp_port_forced_strategy_close(erp_action);
2361 retval = ZFCP_ERP_FAILED;
2364 case ZFCP_ERP_STEP_PHYS_PORT_CLOSING:
2365 if (atomic_test_mask(ZFCP_STATUS_PORT_PHYS_OPEN,
2367 ZFCP_LOG_DEBUG("close physical failed for port "
2368 "0x%016Lx\n", port->wwpn);
2369 retval = ZFCP_ERP_FAILED;
2371 retval = ZFCP_ERP_SUCCEEDED;
2375 debug_text_event(adapter->erp_dbf, 3, "p_pfst/ret");
2376 debug_event(adapter->erp_dbf, 3, &port->wwpn, sizeof (wwn_t));
2377 debug_event(adapter->erp_dbf, 3, &erp_action->action, sizeof (int));
2378 debug_event(adapter->erp_dbf, 3, &retval, sizeof (int));
2386 * purpose: this routine executes the 'Reopen Port' action
2388 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2389 * ZFCP_ERP_SUCCEEDED - action finished successfully
2390 * ZFCP_ERP_FAILED - action finished unsuccessfully
2393 zfcp_erp_port_strategy(struct zfcp_erp_action *erp_action)
2395 int retval = ZFCP_ERP_FAILED;
2396 struct zfcp_port *port = erp_action->port;
2397 struct zfcp_adapter *adapter = erp_action->adapter;
2399 switch (erp_action->step) {
2403 * the ULP spec. begs for waiting for oustanding commands
2405 case ZFCP_ERP_STEP_UNINITIALIZED:
2406 zfcp_erp_port_strategy_clearstati(port);
2407 if (atomic_test_mask(ZFCP_STATUS_COMMON_OPEN, &port->status)) {
2408 ZFCP_LOG_DEBUG("port 0x%016Lx is open -> trying "
2409 "close\n", port->wwpn);
2410 retval = zfcp_erp_port_strategy_close(erp_action);
2412 } /* else it's already closed, open it */
2415 case ZFCP_ERP_STEP_PORT_CLOSING:
2416 if (atomic_test_mask(ZFCP_STATUS_COMMON_OPEN, &port->status)) {
2417 ZFCP_LOG_DEBUG("close failed for port 0x%016Lx\n",
2419 retval = ZFCP_ERP_FAILED;
2421 } /* else it's closed now, open it */
2424 if (erp_action->status & ZFCP_STATUS_ERP_CLOSE_ONLY)
2425 retval = ZFCP_ERP_EXIT;
2427 retval = zfcp_erp_port_strategy_open(erp_action);
2430 debug_text_event(adapter->erp_dbf, 3, "p_pst/ret");
2431 debug_event(adapter->erp_dbf, 3, &port->wwpn, sizeof (wwn_t));
2432 debug_event(adapter->erp_dbf, 3, &erp_action->action, sizeof (int));
2433 debug_event(adapter->erp_dbf, 3, &retval, sizeof (int));
2439 zfcp_erp_port_strategy_open(struct zfcp_erp_action *erp_action)
2443 if (atomic_test_mask(ZFCP_STATUS_PORT_WKA,
2444 &erp_action->port->status))
2445 retval = zfcp_erp_port_strategy_open_nameserver(erp_action);
2447 retval = zfcp_erp_port_strategy_open_common(erp_action);
2453 zfcp_erp_port_strategy_open_common(struct zfcp_erp_action *erp_action)
2456 struct zfcp_adapter *adapter = erp_action->adapter;
2457 struct zfcp_port *port = erp_action->port;
2459 switch (erp_action->step) {
2461 case ZFCP_ERP_STEP_UNINITIALIZED:
2462 case ZFCP_ERP_STEP_PHYS_PORT_CLOSING:
2463 case ZFCP_ERP_STEP_PORT_CLOSING:
2464 if (fc_host_port_type(adapter->scsi_host) == FC_PORTTYPE_PTP) {
2465 if (port->wwpn != adapter->peer_wwpn) {
2466 ZFCP_LOG_NORMAL("Failed to open port 0x%016Lx "
2467 "on adapter %s.\nPeer WWPN "
2468 "0x%016Lx does not match\n",
2470 zfcp_get_busid_by_adapter(adapter),
2471 adapter->peer_wwpn);
2472 zfcp_erp_port_failed(port);
2473 retval = ZFCP_ERP_FAILED;
2476 port->d_id = adapter->peer_d_id;
2477 atomic_set_mask(ZFCP_STATUS_PORT_DID_DID, &port->status);
2478 retval = zfcp_erp_port_strategy_open_port(erp_action);
2481 if (!(adapter->nameserver_port)) {
2482 retval = zfcp_nameserver_enqueue(adapter);
2484 ZFCP_LOG_NORMAL("error: nameserver port "
2485 "unavailable for adapter %s\n",
2486 zfcp_get_busid_by_adapter(adapter));
2487 retval = ZFCP_ERP_FAILED;
2491 if (!atomic_test_mask(ZFCP_STATUS_COMMON_UNBLOCKED,
2492 &adapter->nameserver_port->status)) {
2493 ZFCP_LOG_DEBUG("nameserver port is not open -> open "
2494 "nameserver port\n");
2495 /* nameserver port may live again */
2496 atomic_set_mask(ZFCP_STATUS_COMMON_RUNNING,
2497 &adapter->nameserver_port->status);
2498 if (zfcp_erp_port_reopen(adapter->nameserver_port, 0)
2501 ZFCP_ERP_STEP_NAMESERVER_OPEN;
2502 retval = ZFCP_ERP_CONTINUES;
2504 retval = ZFCP_ERP_FAILED;
2507 /* else nameserver port is already open, fall through */
2508 case ZFCP_ERP_STEP_NAMESERVER_OPEN:
2509 if (!atomic_test_mask(ZFCP_STATUS_COMMON_OPEN,
2510 &adapter->nameserver_port->status)) {
2511 ZFCP_LOG_DEBUG("open failed for nameserver port\n");
2512 retval = ZFCP_ERP_FAILED;
2514 ZFCP_LOG_DEBUG("nameserver port is open -> "
2515 "nameserver look-up for port 0x%016Lx\n",
2517 retval = zfcp_erp_port_strategy_open_common_lookup
2522 case ZFCP_ERP_STEP_NAMESERVER_LOOKUP:
2523 if (!atomic_test_mask(ZFCP_STATUS_PORT_DID_DID, &port->status)) {
2524 if (atomic_test_mask
2525 (ZFCP_STATUS_PORT_INVALID_WWPN, &port->status)) {
2526 ZFCP_LOG_DEBUG("nameserver look-up failed "
2527 "for port 0x%016Lx "
2528 "(misconfigured WWPN?)\n",
2530 zfcp_erp_port_failed(port);
2531 retval = ZFCP_ERP_EXIT;
2533 ZFCP_LOG_DEBUG("nameserver look-up failed for "
2534 "port 0x%016Lx\n", port->wwpn);
2535 retval = ZFCP_ERP_FAILED;
2538 ZFCP_LOG_DEBUG("port 0x%016Lx has d_id=0x%08x -> "
2539 "trying open\n", port->wwpn, port->d_id);
2540 retval = zfcp_erp_port_strategy_open_port(erp_action);
2544 case ZFCP_ERP_STEP_PORT_OPENING:
2545 /* D_ID might have changed during open */
2546 if (atomic_test_mask((ZFCP_STATUS_COMMON_OPEN |
2547 ZFCP_STATUS_PORT_DID_DID),
2549 ZFCP_LOG_DEBUG("port 0x%016Lx is open\n", port->wwpn);
2550 retval = ZFCP_ERP_SUCCEEDED;
2552 ZFCP_LOG_DEBUG("open failed for port 0x%016Lx\n",
2554 retval = ZFCP_ERP_FAILED;
2559 ZFCP_LOG_NORMAL("bug: unknown erp step 0x%08x\n",
2561 retval = ZFCP_ERP_FAILED;
2568 zfcp_erp_port_strategy_open_nameserver(struct zfcp_erp_action *erp_action)
2571 struct zfcp_port *port = erp_action->port;
2573 switch (erp_action->step) {
2575 case ZFCP_ERP_STEP_UNINITIALIZED:
2576 case ZFCP_ERP_STEP_PHYS_PORT_CLOSING:
2577 case ZFCP_ERP_STEP_PORT_CLOSING:
2578 ZFCP_LOG_DEBUG("port 0x%016Lx has d_id=0x%08x -> trying open\n",
2579 port->wwpn, port->d_id);
2580 retval = zfcp_erp_port_strategy_open_port(erp_action);
2583 case ZFCP_ERP_STEP_PORT_OPENING:
2584 if (atomic_test_mask(ZFCP_STATUS_COMMON_OPEN, &port->status)) {
2585 ZFCP_LOG_DEBUG("WKA port is open\n");
2586 retval = ZFCP_ERP_SUCCEEDED;
2588 ZFCP_LOG_DEBUG("open failed for WKA port\n");
2589 retval = ZFCP_ERP_FAILED;
2591 /* this is needed anyway (dont care for retval of wakeup) */
2592 ZFCP_LOG_DEBUG("continue other open port operations\n");
2593 zfcp_erp_port_strategy_open_nameserver_wakeup(erp_action);
2597 ZFCP_LOG_NORMAL("bug: unknown erp step 0x%08x\n",
2599 retval = ZFCP_ERP_FAILED;
2608 * purpose: makes the erp thread continue with reopen (physical) port
2609 * actions which have been paused until the name server port
2610 * is opened (or failed)
2612 * returns: 0 (a kind of void retval, its not used)
2615 zfcp_erp_port_strategy_open_nameserver_wakeup(struct zfcp_erp_action
2619 unsigned long flags;
2620 struct zfcp_adapter *adapter = ns_erp_action->adapter;
2621 struct zfcp_erp_action *erp_action, *tmp;
2623 read_lock_irqsave(&adapter->erp_lock, flags);
2624 list_for_each_entry_safe(erp_action, tmp, &adapter->erp_running_head,
2626 debug_text_event(adapter->erp_dbf, 4, "p_pstnsw_n");
2627 debug_event(adapter->erp_dbf, 4, &erp_action->port->wwpn,
2629 if (erp_action->step == ZFCP_ERP_STEP_NAMESERVER_OPEN) {
2630 debug_text_event(adapter->erp_dbf, 3, "p_pstnsw_w");
2631 debug_event(adapter->erp_dbf, 3,
2632 &erp_action->port->wwpn, sizeof (wwn_t));
2633 if (atomic_test_mask(
2634 ZFCP_STATUS_COMMON_ERP_FAILED,
2635 &adapter->nameserver_port->status))
2636 zfcp_erp_port_failed(erp_action->port);
2637 zfcp_erp_action_ready(erp_action);
2640 read_unlock_irqrestore(&adapter->erp_lock, flags);
2650 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2651 * ZFCP_ERP_FAILED - action finished unsuccessfully
2654 zfcp_erp_port_forced_strategy_close(struct zfcp_erp_action *erp_action)
2657 struct zfcp_adapter *adapter = erp_action->adapter;
2658 struct zfcp_port *port = erp_action->port;
2660 zfcp_erp_timeout_init(erp_action);
2661 retval = zfcp_fsf_close_physical_port(erp_action);
2662 if (retval == -ENOMEM) {
2663 debug_text_event(adapter->erp_dbf, 5, "o_pfstc_nomem");
2664 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2665 retval = ZFCP_ERP_NOMEM;
2668 erp_action->step = ZFCP_ERP_STEP_PHYS_PORT_CLOSING;
2670 debug_text_event(adapter->erp_dbf, 5, "o_pfstc_cpf");
2671 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2672 /* could not send 'open', fail */
2673 retval = ZFCP_ERP_FAILED;
2676 debug_text_event(adapter->erp_dbf, 6, "o_pfstc_cpok");
2677 debug_event(adapter->erp_dbf, 6, &port->wwpn, sizeof (wwn_t));
2678 retval = ZFCP_ERP_CONTINUES;
2684 zfcp_erp_port_strategy_clearstati(struct zfcp_port *port)
2687 struct zfcp_adapter *adapter = port->adapter;
2689 debug_text_event(adapter->erp_dbf, 5, "p_pstclst");
2690 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2692 atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING |
2693 ZFCP_STATUS_COMMON_CLOSING |
2694 ZFCP_STATUS_COMMON_ACCESS_DENIED |
2695 ZFCP_STATUS_PORT_DID_DID |
2696 ZFCP_STATUS_PORT_PHYS_CLOSING |
2697 ZFCP_STATUS_PORT_INVALID_WWPN,
2707 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2708 * ZFCP_ERP_FAILED - action finished unsuccessfully
2711 zfcp_erp_port_strategy_close(struct zfcp_erp_action *erp_action)
2714 struct zfcp_adapter *adapter = erp_action->adapter;
2715 struct zfcp_port *port = erp_action->port;
2717 zfcp_erp_timeout_init(erp_action);
2718 retval = zfcp_fsf_close_port(erp_action);
2719 if (retval == -ENOMEM) {
2720 debug_text_event(adapter->erp_dbf, 5, "p_pstc_nomem");
2721 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2722 retval = ZFCP_ERP_NOMEM;
2725 erp_action->step = ZFCP_ERP_STEP_PORT_CLOSING;
2727 debug_text_event(adapter->erp_dbf, 5, "p_pstc_cpf");
2728 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2729 /* could not send 'close', fail */
2730 retval = ZFCP_ERP_FAILED;
2733 debug_text_event(adapter->erp_dbf, 6, "p_pstc_cpok");
2734 debug_event(adapter->erp_dbf, 6, &port->wwpn, sizeof (wwn_t));
2735 retval = ZFCP_ERP_CONTINUES;
2745 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2746 * ZFCP_ERP_FAILED - action finished unsuccessfully
2749 zfcp_erp_port_strategy_open_port(struct zfcp_erp_action *erp_action)
2752 struct zfcp_adapter *adapter = erp_action->adapter;
2753 struct zfcp_port *port = erp_action->port;
2755 zfcp_erp_timeout_init(erp_action);
2756 retval = zfcp_fsf_open_port(erp_action);
2757 if (retval == -ENOMEM) {
2758 debug_text_event(adapter->erp_dbf, 5, "p_psto_nomem");
2759 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2760 retval = ZFCP_ERP_NOMEM;
2763 erp_action->step = ZFCP_ERP_STEP_PORT_OPENING;
2765 debug_text_event(adapter->erp_dbf, 5, "p_psto_opf");
2766 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2767 /* could not send 'open', fail */
2768 retval = ZFCP_ERP_FAILED;
2771 debug_text_event(adapter->erp_dbf, 6, "p_psto_opok");
2772 debug_event(adapter->erp_dbf, 6, &port->wwpn, sizeof (wwn_t));
2773 retval = ZFCP_ERP_CONTINUES;
2783 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2784 * ZFCP_ERP_FAILED - action finished unsuccessfully
2787 zfcp_erp_port_strategy_open_common_lookup(struct zfcp_erp_action *erp_action)
2790 struct zfcp_adapter *adapter = erp_action->adapter;
2791 struct zfcp_port *port = erp_action->port;
2793 zfcp_erp_timeout_init(erp_action);
2794 retval = zfcp_ns_gid_pn_request(erp_action);
2795 if (retval == -ENOMEM) {
2796 debug_text_event(adapter->erp_dbf, 5, "p_pstn_nomem");
2797 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2798 retval = ZFCP_ERP_NOMEM;
2801 erp_action->step = ZFCP_ERP_STEP_NAMESERVER_LOOKUP;
2803 debug_text_event(adapter->erp_dbf, 5, "p_pstn_ref");
2804 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2805 /* could not send nameserver request, fail */
2806 retval = ZFCP_ERP_FAILED;
2809 debug_text_event(adapter->erp_dbf, 6, "p_pstn_reok");
2810 debug_event(adapter->erp_dbf, 6, &port->wwpn, sizeof (wwn_t));
2811 retval = ZFCP_ERP_CONTINUES;
2819 * purpose: this routine executes the 'Reopen Unit' action
2820 * currently no retries
2822 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2823 * ZFCP_ERP_SUCCEEDED - action finished successfully
2824 * ZFCP_ERP_FAILED - action finished unsuccessfully
2827 zfcp_erp_unit_strategy(struct zfcp_erp_action *erp_action)
2829 int retval = ZFCP_ERP_FAILED;
2830 struct zfcp_unit *unit = erp_action->unit;
2831 struct zfcp_adapter *adapter = erp_action->adapter;
2833 switch (erp_action->step) {
2837 * the ULP spec. begs for waiting for oustanding commands
2839 case ZFCP_ERP_STEP_UNINITIALIZED:
2840 zfcp_erp_unit_strategy_clearstati(unit);
2841 if (atomic_test_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status)) {
2842 ZFCP_LOG_DEBUG("unit 0x%016Lx is open -> "
2843 "trying close\n", unit->fcp_lun);
2844 retval = zfcp_erp_unit_strategy_close(erp_action);
2847 /* else it's already closed, fall through */
2848 case ZFCP_ERP_STEP_UNIT_CLOSING:
2849 if (atomic_test_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status)) {
2850 ZFCP_LOG_DEBUG("close failed for unit 0x%016Lx\n",
2852 retval = ZFCP_ERP_FAILED;
2854 if (erp_action->status & ZFCP_STATUS_ERP_CLOSE_ONLY)
2855 retval = ZFCP_ERP_EXIT;
2857 ZFCP_LOG_DEBUG("unit 0x%016Lx is not open -> "
2858 "trying open\n", unit->fcp_lun);
2860 zfcp_erp_unit_strategy_open(erp_action);
2865 case ZFCP_ERP_STEP_UNIT_OPENING:
2866 if (atomic_test_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status)) {
2867 ZFCP_LOG_DEBUG("unit 0x%016Lx is open\n",
2869 retval = ZFCP_ERP_SUCCEEDED;
2871 ZFCP_LOG_DEBUG("open failed for unit 0x%016Lx\n",
2873 retval = ZFCP_ERP_FAILED;
2878 debug_text_event(adapter->erp_dbf, 3, "u_ust/ret");
2879 debug_event(adapter->erp_dbf, 3, &unit->fcp_lun, sizeof (fcp_lun_t));
2880 debug_event(adapter->erp_dbf, 3, &erp_action->action, sizeof (int));
2881 debug_event(adapter->erp_dbf, 3, &retval, sizeof (int));
2886 zfcp_erp_unit_strategy_clearstati(struct zfcp_unit *unit)
2889 struct zfcp_adapter *adapter = unit->port->adapter;
2891 debug_text_event(adapter->erp_dbf, 5, "u_ustclst");
2892 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun, sizeof (fcp_lun_t));
2894 atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING |
2895 ZFCP_STATUS_COMMON_CLOSING |
2896 ZFCP_STATUS_COMMON_ACCESS_DENIED |
2897 ZFCP_STATUS_UNIT_SHARED |
2898 ZFCP_STATUS_UNIT_READONLY,
2909 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2910 * ZFCP_ERP_FAILED - action finished unsuccessfully
2913 zfcp_erp_unit_strategy_close(struct zfcp_erp_action *erp_action)
2916 struct zfcp_adapter *adapter = erp_action->adapter;
2917 struct zfcp_unit *unit = erp_action->unit;
2919 zfcp_erp_timeout_init(erp_action);
2920 retval = zfcp_fsf_close_unit(erp_action);
2921 if (retval == -ENOMEM) {
2922 debug_text_event(adapter->erp_dbf, 5, "u_ustc_nomem");
2923 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun,
2924 sizeof (fcp_lun_t));
2925 retval = ZFCP_ERP_NOMEM;
2928 erp_action->step = ZFCP_ERP_STEP_UNIT_CLOSING;
2930 debug_text_event(adapter->erp_dbf, 5, "u_ustc_cuf");
2931 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun,
2932 sizeof (fcp_lun_t));
2933 /* could not send 'close', fail */
2934 retval = ZFCP_ERP_FAILED;
2937 debug_text_event(adapter->erp_dbf, 6, "u_ustc_cuok");
2938 debug_event(adapter->erp_dbf, 6, &unit->fcp_lun, sizeof (fcp_lun_t));
2939 retval = ZFCP_ERP_CONTINUES;
2950 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2951 * ZFCP_ERP_FAILED - action finished unsuccessfully
2954 zfcp_erp_unit_strategy_open(struct zfcp_erp_action *erp_action)
2957 struct zfcp_adapter *adapter = erp_action->adapter;
2958 struct zfcp_unit *unit = erp_action->unit;
2960 zfcp_erp_timeout_init(erp_action);
2961 retval = zfcp_fsf_open_unit(erp_action);
2962 if (retval == -ENOMEM) {
2963 debug_text_event(adapter->erp_dbf, 5, "u_usto_nomem");
2964 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun,
2965 sizeof (fcp_lun_t));
2966 retval = ZFCP_ERP_NOMEM;
2969 erp_action->step = ZFCP_ERP_STEP_UNIT_OPENING;
2971 debug_text_event(adapter->erp_dbf, 5, "u_usto_ouf");
2972 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun,
2973 sizeof (fcp_lun_t));
2974 /* could not send 'open', fail */
2975 retval = ZFCP_ERP_FAILED;
2978 debug_text_event(adapter->erp_dbf, 6, "u_usto_ouok");
2979 debug_event(adapter->erp_dbf, 6, &unit->fcp_lun, sizeof (fcp_lun_t));
2980 retval = ZFCP_ERP_CONTINUES;
2986 zfcp_erp_timeout_init(struct zfcp_erp_action *erp_action)
2988 init_timer(&erp_action->timer);
2989 erp_action->timer.function = zfcp_erp_timeout_handler;
2990 erp_action->timer.data = (unsigned long) erp_action;
2991 /* jiffies will be added in zfcp_fsf_req_send */
2992 erp_action->timer.expires = ZFCP_ERP_FSFREQ_TIMEOUT;
2998 * purpose: enqueue the specified error recovery action, if needed
3003 zfcp_erp_action_enqueue(int action,
3004 struct zfcp_adapter *adapter,
3005 struct zfcp_port *port, struct zfcp_unit *unit)
3008 struct zfcp_erp_action *erp_action = NULL;
3009 int stronger_action = 0;
3013 * We need some rules here which check whether we really need
3014 * this action or whether we should just drop it.
3015 * E.g. if there is a unfinished 'Reopen Port' request then we drop a
3016 * 'Reopen Unit' request for an associated unit since we can't
3017 * satisfy this request now. A 'Reopen Port' action will trigger
3018 * 'Reopen Unit' actions when it completes.
3019 * Thus, there are only actions in the queue which can immediately be
3020 * executed. This makes the processing of the action queue more
3024 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP,
3028 debug_event(adapter->erp_dbf, 4, &action, sizeof (int));
3029 /* check whether we really need this */
3031 case ZFCP_ERP_ACTION_REOPEN_UNIT:
3032 if (atomic_test_mask
3033 (ZFCP_STATUS_COMMON_ERP_INUSE, &unit->status)) {
3034 debug_text_event(adapter->erp_dbf, 4, "u_actenq_drp");
3035 debug_event(adapter->erp_dbf, 4, &port->wwpn,
3037 debug_event(adapter->erp_dbf, 4, &unit->fcp_lun,
3038 sizeof (fcp_lun_t));
3041 if (!atomic_test_mask
3042 (ZFCP_STATUS_COMMON_RUNNING, &port->status) ||
3044 (ZFCP_STATUS_COMMON_ERP_FAILED, &port->status)) {
3047 if (!atomic_test_mask
3048 (ZFCP_STATUS_COMMON_UNBLOCKED, &port->status)) {
3049 stronger_action = ZFCP_ERP_ACTION_REOPEN_PORT;
3052 /* fall through !!! */
3054 case ZFCP_ERP_ACTION_REOPEN_PORT:
3055 if (atomic_test_mask
3056 (ZFCP_STATUS_COMMON_ERP_INUSE, &port->status)) {
3057 debug_text_event(adapter->erp_dbf, 4, "p_actenq_drp");
3058 debug_event(adapter->erp_dbf, 4, &port->wwpn,
3062 /* fall through !!! */
3064 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
3065 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_INUSE,
3067 if (port->erp_action.action !=
3068 ZFCP_ERP_ACTION_REOPEN_PORT_FORCED) {
3069 ZFCP_LOG_INFO("dropped erp action %i (port "
3070 "0x%016Lx, action in use: %i)\n",
3072 port->erp_action.action);
3073 debug_text_event(adapter->erp_dbf, 4,
3076 debug_text_event(adapter->erp_dbf, 4,
3078 debug_event(adapter->erp_dbf, 4, &port->wwpn,
3082 if (!atomic_test_mask
3083 (ZFCP_STATUS_COMMON_RUNNING, &adapter->status) ||
3085 (ZFCP_STATUS_COMMON_ERP_FAILED, &adapter->status)) {
3088 if (!atomic_test_mask
3089 (ZFCP_STATUS_COMMON_UNBLOCKED, &adapter->status)) {
3090 stronger_action = ZFCP_ERP_ACTION_REOPEN_ADAPTER;
3093 /* fall through !!! */
3095 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
3096 if (atomic_test_mask
3097 (ZFCP_STATUS_COMMON_ERP_INUSE, &adapter->status)) {
3098 debug_text_event(adapter->erp_dbf, 4, "a_actenq_drp");
3104 debug_text_exception(adapter->erp_dbf, 1, "a_actenq_bug");
3105 debug_event(adapter->erp_dbf, 1, &action, sizeof (int));
3106 ZFCP_LOG_NORMAL("bug: unknown erp action requested "
3107 "on adapter %s (action=%d)\n",
3108 zfcp_get_busid_by_adapter(adapter), action);
3112 /* check whether we need something stronger first */
3113 if (stronger_action) {
3114 debug_text_event(adapter->erp_dbf, 4, "a_actenq_str");
3115 debug_event(adapter->erp_dbf, 4, &stronger_action,
3117 ZFCP_LOG_DEBUG("stronger erp action %d needed before "
3118 "erp action %d on adapter %s\n",
3119 stronger_action, action,
3120 zfcp_get_busid_by_adapter(adapter));
3121 action = stronger_action;
3124 /* mark adapter to have some error recovery pending */
3125 atomic_set_mask(ZFCP_STATUS_ADAPTER_ERP_PENDING, &adapter->status);
3127 /* setup error recovery action */
3130 case ZFCP_ERP_ACTION_REOPEN_UNIT:
3131 zfcp_unit_get(unit);
3132 atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &unit->status);
3133 erp_action = &unit->erp_action;
3134 if (!atomic_test_mask
3135 (ZFCP_STATUS_COMMON_RUNNING, &unit->status))
3136 status = ZFCP_STATUS_ERP_CLOSE_ONLY;
3139 case ZFCP_ERP_ACTION_REOPEN_PORT:
3140 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
3141 zfcp_port_get(port);
3142 zfcp_erp_action_dismiss_port(port);
3143 atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &port->status);
3144 erp_action = &port->erp_action;
3145 if (!atomic_test_mask
3146 (ZFCP_STATUS_COMMON_RUNNING, &port->status))
3147 status = ZFCP_STATUS_ERP_CLOSE_ONLY;
3150 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
3151 zfcp_adapter_get(adapter);
3152 zfcp_erp_action_dismiss_adapter(adapter);
3153 atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &adapter->status);
3154 erp_action = &adapter->erp_action;
3155 if (!atomic_test_mask
3156 (ZFCP_STATUS_COMMON_RUNNING, &adapter->status))
3157 status = ZFCP_STATUS_ERP_CLOSE_ONLY;
3161 debug_text_event(adapter->erp_dbf, 4, "a_actenq");
3163 memset(erp_action, 0, sizeof (struct zfcp_erp_action));
3164 erp_action->adapter = adapter;
3165 erp_action->port = port;
3166 erp_action->unit = unit;
3167 erp_action->action = action;
3168 erp_action->status = status;
3170 ++adapter->erp_total_count;
3172 /* finally put it into 'ready' queue and kick erp thread */
3173 list_add(&erp_action->list, &adapter->erp_ready_head);
3174 up(&adapter->erp_ready_sem);
3181 zfcp_erp_action_dequeue(struct zfcp_erp_action *erp_action)
3184 struct zfcp_adapter *adapter = erp_action->adapter;
3186 --adapter->erp_total_count;
3187 if (erp_action->status & ZFCP_STATUS_ERP_LOWMEM) {
3188 --adapter->erp_low_mem_count;
3189 erp_action->status &= ~ZFCP_STATUS_ERP_LOWMEM;
3192 debug_text_event(adapter->erp_dbf, 4, "a_actdeq");
3193 debug_event(adapter->erp_dbf, 4, &erp_action->action, sizeof (int));
3194 list_del(&erp_action->list);
3195 switch (erp_action->action) {
3196 case ZFCP_ERP_ACTION_REOPEN_UNIT:
3197 atomic_clear_mask(ZFCP_STATUS_COMMON_ERP_INUSE,
3198 &erp_action->unit->status);
3200 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
3201 case ZFCP_ERP_ACTION_REOPEN_PORT:
3202 atomic_clear_mask(ZFCP_STATUS_COMMON_ERP_INUSE,
3203 &erp_action->port->status);
3205 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
3206 atomic_clear_mask(ZFCP_STATUS_COMMON_ERP_INUSE,
3207 &erp_action->adapter->status);
3217 * zfcp_erp_action_cleanup
3219 * Register unit with scsi stack if appropriate and fix reference counts.
3220 * Note: Temporary units are not registered with scsi stack.
3223 zfcp_erp_action_cleanup(int action, struct zfcp_adapter *adapter,
3224 struct zfcp_port *port, struct zfcp_unit *unit,
3228 case ZFCP_ERP_ACTION_REOPEN_UNIT:
3229 if ((result == ZFCP_ERP_SUCCEEDED)
3230 && (!atomic_test_mask(ZFCP_STATUS_UNIT_TEMPORARY,
3234 atomic_set_mask(ZFCP_STATUS_UNIT_REGISTERED,
3236 scsi_scan_target(&port->rport->dev, 0,
3237 port->rport->scsi_target_id,
3240 zfcp_unit_put(unit);
3242 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
3243 case ZFCP_ERP_ACTION_REOPEN_PORT:
3244 if (atomic_test_mask(ZFCP_STATUS_PORT_NO_WWPN,
3246 zfcp_port_put(port);
3250 if ((result == ZFCP_ERP_SUCCEEDED)
3252 struct fc_rport_identifiers ids;
3253 ids.node_name = port->wwnn;
3254 ids.port_name = port->wwpn;
3255 ids.port_id = port->d_id;
3256 ids.roles = FC_RPORT_ROLE_FCP_TARGET;
3258 fc_remote_port_add(adapter->scsi_host, 0, &ids);
3260 ZFCP_LOG_NORMAL("failed registration of rport"
3261 "(adapter %s, wwpn=0x%016Lx)\n",
3262 zfcp_get_busid_by_port(port),
3265 scsi_flush_work(adapter->scsi_host);
3266 port->rport->maxframe_size = port->maxframe_size;
3267 port->rport->supported_classes =
3268 port->supported_classes;
3271 if ((result != ZFCP_ERP_SUCCEEDED) && port->rport) {
3272 fc_remote_port_delete(port->rport);
3275 zfcp_port_put(port);
3277 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
3278 if (result != ZFCP_ERP_SUCCEEDED) {
3279 struct zfcp_port *port;
3280 list_for_each_entry(port, &adapter->port_list_head, list)
3282 !atomic_test_mask(ZFCP_STATUS_PORT_WKA,
3284 fc_remote_port_delete(port->rport);
3288 zfcp_adapter_put(adapter);
3297 zfcp_erp_action_dismiss_adapter(struct zfcp_adapter *adapter)
3300 struct zfcp_port *port;
3302 debug_text_event(adapter->erp_dbf, 5, "a_actab");
3303 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &adapter->status))
3304 zfcp_erp_action_dismiss(&adapter->erp_action);
3306 list_for_each_entry(port, &adapter->port_list_head, list)
3307 zfcp_erp_action_dismiss_port(port);
3313 zfcp_erp_action_dismiss_port(struct zfcp_port *port)
3316 struct zfcp_unit *unit;
3317 struct zfcp_adapter *adapter = port->adapter;
3319 debug_text_event(adapter->erp_dbf, 5, "p_actab");
3320 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
3321 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &port->status))
3322 zfcp_erp_action_dismiss(&port->erp_action);
3324 list_for_each_entry(unit, &port->unit_list_head, list)
3325 zfcp_erp_action_dismiss_unit(unit);
3331 zfcp_erp_action_dismiss_unit(struct zfcp_unit *unit)
3334 struct zfcp_adapter *adapter = unit->port->adapter;
3336 debug_text_event(adapter->erp_dbf, 5, "u_actab");
3337 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun, sizeof (fcp_lun_t));
3338 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &unit->status))
3339 zfcp_erp_action_dismiss(&unit->erp_action);
3345 zfcp_erp_action_to_running(struct zfcp_erp_action *erp_action)
3347 struct zfcp_adapter *adapter = erp_action->adapter;
3349 debug_text_event(adapter->erp_dbf, 6, "a_toru");
3350 debug_event(adapter->erp_dbf, 6, &erp_action->action, sizeof (int));
3351 list_move(&erp_action->list, &erp_action->adapter->erp_running_head);
3355 zfcp_erp_action_to_ready(struct zfcp_erp_action *erp_action)
3357 struct zfcp_adapter *adapter = erp_action->adapter;
3359 debug_text_event(adapter->erp_dbf, 6, "a_tore");
3360 debug_event(adapter->erp_dbf, 6, &erp_action->action, sizeof (int));
3361 list_move(&erp_action->list, &erp_action->adapter->erp_ready_head);
3365 zfcp_erp_port_boxed(struct zfcp_port *port)
3367 struct zfcp_adapter *adapter = port->adapter;
3368 unsigned long flags;
3370 debug_text_event(adapter->erp_dbf, 3, "p_access_boxed");
3371 debug_event(adapter->erp_dbf, 3, &port->wwpn, sizeof(wwn_t));
3372 read_lock_irqsave(&zfcp_data.config_lock, flags);
3373 zfcp_erp_modify_port_status(port,
3374 ZFCP_STATUS_COMMON_ACCESS_BOXED,
3376 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
3377 zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED);
3381 zfcp_erp_unit_boxed(struct zfcp_unit *unit)
3383 struct zfcp_adapter *adapter = unit->port->adapter;
3385 debug_text_event(adapter->erp_dbf, 3, "u_access_boxed");
3386 debug_event(adapter->erp_dbf, 3, &unit->fcp_lun, sizeof(fcp_lun_t));
3387 zfcp_erp_modify_unit_status(unit,
3388 ZFCP_STATUS_COMMON_ACCESS_BOXED,
3390 zfcp_erp_unit_reopen(unit, ZFCP_STATUS_COMMON_ERP_FAILED);
3394 zfcp_erp_port_access_denied(struct zfcp_port *port)
3396 struct zfcp_adapter *adapter = port->adapter;
3397 unsigned long flags;
3399 debug_text_event(adapter->erp_dbf, 3, "p_access_denied");
3400 debug_event(adapter->erp_dbf, 3, &port->wwpn, sizeof(wwn_t));
3401 read_lock_irqsave(&zfcp_data.config_lock, flags);
3402 zfcp_erp_modify_port_status(port,
3403 ZFCP_STATUS_COMMON_ERP_FAILED |
3404 ZFCP_STATUS_COMMON_ACCESS_DENIED,
3406 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
3410 zfcp_erp_unit_access_denied(struct zfcp_unit *unit)
3412 struct zfcp_adapter *adapter = unit->port->adapter;
3414 debug_text_event(adapter->erp_dbf, 3, "u_access_denied");
3415 debug_event(adapter->erp_dbf, 3, &unit->fcp_lun, sizeof(fcp_lun_t));
3416 zfcp_erp_modify_unit_status(unit,
3417 ZFCP_STATUS_COMMON_ERP_FAILED |
3418 ZFCP_STATUS_COMMON_ACCESS_DENIED,
3423 zfcp_erp_adapter_access_changed(struct zfcp_adapter *adapter)
3425 struct zfcp_port *port;
3426 unsigned long flags;
3428 if (adapter->connection_features & FSF_FEATURE_NPIV_MODE)
3431 debug_text_event(adapter->erp_dbf, 3, "a_access_recover");
3432 debug_event(adapter->erp_dbf, 3, zfcp_get_busid_by_adapter(adapter), 8);
3434 read_lock_irqsave(&zfcp_data.config_lock, flags);
3435 if (adapter->nameserver_port)
3436 zfcp_erp_port_access_changed(adapter->nameserver_port);
3437 list_for_each_entry(port, &adapter->port_list_head, list)
3438 if (port != adapter->nameserver_port)
3439 zfcp_erp_port_access_changed(port);
3440 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
3444 zfcp_erp_port_access_changed(struct zfcp_port *port)
3446 struct zfcp_adapter *adapter = port->adapter;
3447 struct zfcp_unit *unit;
3449 debug_text_event(adapter->erp_dbf, 3, "p_access_recover");
3450 debug_event(adapter->erp_dbf, 3, &port->wwpn, sizeof(wwn_t));
3452 if (!atomic_test_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED,
3454 !atomic_test_mask(ZFCP_STATUS_COMMON_ACCESS_BOXED,
3456 if (!atomic_test_mask(ZFCP_STATUS_PORT_WKA, &port->status))
3457 list_for_each_entry(unit, &port->unit_list_head, list)
3458 zfcp_erp_unit_access_changed(unit);
3462 ZFCP_LOG_NORMAL("reopen of port 0x%016Lx on adapter %s "
3463 "(due to ACT update)\n",
3464 port->wwpn, zfcp_get_busid_by_adapter(adapter));
3465 if (zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED) != 0)
3466 ZFCP_LOG_NORMAL("failed reopen of port"
3467 "(adapter %s, wwpn=0x%016Lx)\n",
3468 zfcp_get_busid_by_adapter(adapter), port->wwpn);
3472 zfcp_erp_unit_access_changed(struct zfcp_unit *unit)
3474 struct zfcp_adapter *adapter = unit->port->adapter;
3476 debug_text_event(adapter->erp_dbf, 3, "u_access_recover");
3477 debug_event(adapter->erp_dbf, 3, &unit->fcp_lun, sizeof(fcp_lun_t));
3479 if (!atomic_test_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED,
3481 !atomic_test_mask(ZFCP_STATUS_COMMON_ACCESS_BOXED,
3485 ZFCP_LOG_NORMAL("reopen of unit 0x%016Lx on port 0x%016Lx "
3486 " on adapter %s (due to ACT update)\n",
3487 unit->fcp_lun, unit->port->wwpn,
3488 zfcp_get_busid_by_adapter(adapter));
3489 if (zfcp_erp_unit_reopen(unit, ZFCP_STATUS_COMMON_ERP_FAILED) != 0)
3490 ZFCP_LOG_NORMAL("failed reopen of unit (adapter %s, "
3491 "wwpn=0x%016Lx, fcp_lun=0x%016Lx)\n",
3492 zfcp_get_busid_by_adapter(adapter),
3493 unit->port->wwpn, unit->fcp_lun);
3496 #undef ZFCP_LOG_AREA