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 deleted meanwhile */
852 spin_lock(&adapter->req_list_lock);
853 if ((!zfcp_reqlist_ismember(adapter,
854 erp_action->fsf_req->req_id)) &&
855 (fsf_req->erp_action == erp_action)) {
856 /* fsf_req still exists */
857 debug_text_event(adapter->erp_dbf, 3, "a_ca_req");
858 debug_event(adapter->erp_dbf, 3, &fsf_req,
859 sizeof (unsigned long));
860 /* dismiss fsf_req of timed out/dismissed erp_action */
861 if (erp_action->status & (ZFCP_STATUS_ERP_DISMISSED |
862 ZFCP_STATUS_ERP_TIMEDOUT)) {
863 debug_text_event(adapter->erp_dbf, 3,
865 fsf_req->status |= ZFCP_STATUS_FSFREQ_DISMISSED;
867 if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT) {
868 ZFCP_LOG_NORMAL("error: erp step timed out "
869 "(action=%d, fsf_req=%p)\n ",
871 erp_action->fsf_req);
874 * If fsf_req is neither dismissed nor completed
875 * then keep it running asynchronously and don't mess
876 * with the association of erp_action and fsf_req.
878 if (fsf_req->status & (ZFCP_STATUS_FSFREQ_COMPLETED |
879 ZFCP_STATUS_FSFREQ_DISMISSED)) {
880 /* forget about association between fsf_req
882 fsf_req->erp_action = NULL;
883 erp_action->fsf_req = NULL;
886 debug_text_event(adapter->erp_dbf, 3, "a_ca_gonereq");
888 * even if this fsf_req has gone, forget about
889 * association between erp_action and fsf_req
891 erp_action->fsf_req = NULL;
893 spin_unlock(&adapter->req_list_lock);
895 debug_text_event(adapter->erp_dbf, 3, "a_ca_noreq");
901 * purpose: generic handler for asynchronous events related to erp_action events
902 * (normal completion, time-out, dismissing, retry after
903 * low memory condition)
905 * note: deletion of timer is not required (e.g. in case of a time-out),
906 * but a second try does no harm,
907 * we leave it in here to allow for greater simplification
909 * returns: 0 - there was an action to handle
913 zfcp_erp_async_handler_nolock(struct zfcp_erp_action *erp_action,
914 unsigned long set_mask)
917 struct zfcp_adapter *adapter = erp_action->adapter;
919 if (zfcp_erp_action_exists(erp_action) == ZFCP_ERP_ACTION_RUNNING) {
920 debug_text_event(adapter->erp_dbf, 2, "a_asyh_ex");
921 debug_event(adapter->erp_dbf, 2, &erp_action->action,
923 if (!(set_mask & ZFCP_STATUS_ERP_TIMEDOUT))
924 del_timer(&erp_action->timer);
925 erp_action->status |= set_mask;
926 zfcp_erp_action_ready(erp_action);
929 /* action is ready or gone - nothing to do */
930 debug_text_event(adapter->erp_dbf, 3, "a_asyh_gone");
931 debug_event(adapter->erp_dbf, 3, &erp_action->action,
940 * purpose: generic handler for asynchronous events related to erp_action
941 * events (normal completion, time-out, dismissing, retry after
942 * low memory condition)
944 * note: deletion of timer is not required (e.g. in case of a time-out),
945 * but a second try does no harm,
946 * we leave it in here to allow for greater simplification
948 * returns: 0 - there was an action to handle
952 zfcp_erp_async_handler(struct zfcp_erp_action *erp_action,
953 unsigned long set_mask)
955 struct zfcp_adapter *adapter = erp_action->adapter;
959 write_lock_irqsave(&adapter->erp_lock, flags);
960 retval = zfcp_erp_async_handler_nolock(erp_action, set_mask);
961 write_unlock_irqrestore(&adapter->erp_lock, flags);
967 * purpose: is called for erp_action which was slept waiting for
968 * memory becoming avaliable,
969 * will trigger that this action will be continued
972 zfcp_erp_memwait_handler(unsigned long data)
974 struct zfcp_erp_action *erp_action = (struct zfcp_erp_action *) data;
975 struct zfcp_adapter *adapter = erp_action->adapter;
977 debug_text_event(adapter->erp_dbf, 2, "a_mwh");
978 debug_event(adapter->erp_dbf, 2, &erp_action->action, sizeof (int));
980 zfcp_erp_async_handler(erp_action, 0);
984 * purpose: is called if an asynchronous erp step timed out,
985 * action gets an appropriate flag and will be processed
989 zfcp_erp_timeout_handler(unsigned long data)
991 struct zfcp_erp_action *erp_action = (struct zfcp_erp_action *) data;
992 struct zfcp_adapter *adapter = erp_action->adapter;
994 debug_text_event(adapter->erp_dbf, 2, "a_th");
995 debug_event(adapter->erp_dbf, 2, &erp_action->action, sizeof (int));
997 zfcp_erp_async_handler(erp_action, ZFCP_STATUS_ERP_TIMEDOUT);
1001 * purpose: is called for an erp_action which needs to be ended
1002 * though not being done,
1003 * this is usually required if an higher is generated,
1004 * action gets an appropriate flag and will be processed
1007 * locks: erp_lock held (thus we need to call another handler variant)
1010 zfcp_erp_action_dismiss(struct zfcp_erp_action *erp_action)
1012 struct zfcp_adapter *adapter = erp_action->adapter;
1014 debug_text_event(adapter->erp_dbf, 2, "a_adis");
1015 debug_event(adapter->erp_dbf, 2, &erp_action->action, sizeof (int));
1017 zfcp_erp_async_handler_nolock(erp_action, ZFCP_STATUS_ERP_DISMISSED);
1023 zfcp_erp_thread_setup(struct zfcp_adapter *adapter)
1027 atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP, &adapter->status);
1029 retval = kernel_thread(zfcp_erp_thread, adapter, SIGCHLD);
1031 ZFCP_LOG_NORMAL("error: creation of erp thread failed for "
1033 zfcp_get_busid_by_adapter(adapter));
1034 debug_text_event(adapter->erp_dbf, 5, "a_thset_fail");
1036 wait_event(adapter->erp_thread_wqh,
1037 atomic_test_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP,
1039 debug_text_event(adapter->erp_dbf, 5, "a_thset_ok");
1042 return (retval < 0);
1052 * context: process (i.e. proc-fs or rmmod/insmod)
1054 * note: The caller of this routine ensures that the specified
1055 * adapter has been shut down and that this operation
1056 * has been completed. Thus, there are no pending erp_actions
1057 * which would need to be handled here.
1060 zfcp_erp_thread_kill(struct zfcp_adapter *adapter)
1064 atomic_set_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL, &adapter->status);
1065 up(&adapter->erp_ready_sem);
1067 wait_event(adapter->erp_thread_wqh,
1068 !atomic_test_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP,
1071 atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL,
1074 debug_text_event(adapter->erp_dbf, 5, "a_thki_ok");
1080 * purpose: is run as a kernel thread,
1081 * goes through list of error recovery actions of associated adapter
1082 * and delegates single action to execution
1087 zfcp_erp_thread(void *data)
1089 struct zfcp_adapter *adapter = (struct zfcp_adapter *) data;
1090 struct list_head *next;
1091 struct zfcp_erp_action *erp_action;
1092 unsigned long flags;
1094 daemonize("zfcperp%s", zfcp_get_busid_by_adapter(adapter));
1095 /* Block all signals */
1096 siginitsetinv(¤t->blocked, 0);
1097 atomic_set_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP, &adapter->status);
1098 debug_text_event(adapter->erp_dbf, 5, "a_th_run");
1099 wake_up(&adapter->erp_thread_wqh);
1101 while (!atomic_test_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL,
1102 &adapter->status)) {
1104 write_lock_irqsave(&adapter->erp_lock, flags);
1105 next = adapter->erp_ready_head.prev;
1106 write_unlock_irqrestore(&adapter->erp_lock, flags);
1108 if (next != &adapter->erp_ready_head) {
1110 list_entry(next, struct zfcp_erp_action, list);
1112 * process action (incl. [re]moving it
1113 * from 'ready' queue)
1115 zfcp_erp_strategy(erp_action);
1119 * sleep as long as there is nothing to do, i.e.
1120 * no action in 'ready' queue to be processed and
1121 * thread is not to be killed
1123 down_interruptible(&adapter->erp_ready_sem);
1124 debug_text_event(adapter->erp_dbf, 5, "a_th_woken");
1127 atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP, &adapter->status);
1128 debug_text_event(adapter->erp_dbf, 5, "a_th_stop");
1129 wake_up(&adapter->erp_thread_wqh);
1137 * purpose: drives single error recovery action and schedules higher and
1138 * subordinate actions, if necessary
1140 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
1141 * ZFCP_ERP_SUCCEEDED - action finished successfully (deqd)
1142 * ZFCP_ERP_FAILED - action finished unsuccessfully (deqd)
1143 * ZFCP_ERP_EXIT - action finished (dequeued), offline
1144 * ZFCP_ERP_DISMISSED - action canceled (dequeued)
1147 zfcp_erp_strategy(struct zfcp_erp_action *erp_action)
1150 struct zfcp_adapter *adapter = erp_action->adapter;
1151 struct zfcp_port *port = erp_action->port;
1152 struct zfcp_unit *unit = erp_action->unit;
1153 int action = erp_action->action;
1154 u32 status = erp_action->status;
1155 unsigned long flags;
1157 /* serialise dismissing, timing out, moving, enqueueing */
1158 read_lock_irqsave(&zfcp_data.config_lock, flags);
1159 write_lock(&adapter->erp_lock);
1161 /* dequeue dismissed action and leave, if required */
1162 retval = zfcp_erp_strategy_check_action(erp_action, retval);
1163 if (retval == ZFCP_ERP_DISMISSED) {
1164 debug_text_event(adapter->erp_dbf, 4, "a_st_dis1");
1169 * move action to 'running' queue before processing it
1170 * (to avoid a race condition regarding moving the
1171 * action to the 'running' queue and back)
1173 zfcp_erp_action_to_running(erp_action);
1176 * try to process action as far as possible,
1177 * no lock to allow for blocking operations (kmalloc, qdio, ...),
1178 * afterwards the lock is required again for the following reasons:
1179 * - dequeueing of finished action and enqueueing of
1180 * follow-up actions must be atomic so that any other
1181 * reopen-routine does not believe there is nothing to do
1182 * and that it is safe to enqueue something else,
1183 * - we want to force any control thread which is dismissing
1184 * actions to finish this before we decide about
1185 * necessary steps to be taken here further
1187 write_unlock(&adapter->erp_lock);
1188 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
1189 retval = zfcp_erp_strategy_do_action(erp_action);
1190 read_lock_irqsave(&zfcp_data.config_lock, flags);
1191 write_lock(&adapter->erp_lock);
1194 * check for dismissed status again to avoid follow-up actions,
1195 * failing of targets and so on for dismissed actions
1197 retval = zfcp_erp_strategy_check_action(erp_action, retval);
1200 case ZFCP_ERP_DISMISSED:
1201 /* leave since this action has ridden to its ancestors */
1202 debug_text_event(adapter->erp_dbf, 6, "a_st_dis2");
1204 case ZFCP_ERP_NOMEM:
1205 /* no memory to continue immediately, let it sleep */
1206 if (!(erp_action->status & ZFCP_STATUS_ERP_LOWMEM)) {
1207 ++adapter->erp_low_mem_count;
1208 erp_action->status |= ZFCP_STATUS_ERP_LOWMEM;
1210 /* This condition is true if there is no memory available
1211 for any erp_action on this adapter. This implies that there
1212 are no elements in the memory pool(s) left for erp_actions.
1213 This might happen if an erp_action that used a memory pool
1214 element was timed out.
1216 if (adapter->erp_total_count == adapter->erp_low_mem_count) {
1217 debug_text_event(adapter->erp_dbf, 3, "a_st_lowmem");
1218 ZFCP_LOG_NORMAL("error: no mempool elements available, "
1219 "restarting I/O on adapter %s "
1220 "to free mempool\n",
1221 zfcp_get_busid_by_adapter(adapter));
1222 zfcp_erp_adapter_reopen_internal(adapter, 0);
1224 debug_text_event(adapter->erp_dbf, 2, "a_st_memw");
1225 retval = zfcp_erp_strategy_memwait(erp_action);
1228 case ZFCP_ERP_CONTINUES:
1229 /* leave since this action runs asynchronously */
1230 debug_text_event(adapter->erp_dbf, 6, "a_st_cont");
1231 if (erp_action->status & ZFCP_STATUS_ERP_LOWMEM) {
1232 --adapter->erp_low_mem_count;
1233 erp_action->status &= ~ZFCP_STATUS_ERP_LOWMEM;
1237 /* ok, finished action (whatever its result is) */
1239 /* check for unrecoverable targets */
1240 retval = zfcp_erp_strategy_check_target(erp_action, retval);
1242 /* action must be dequeued (here to allow for further ones) */
1243 zfcp_erp_action_dequeue(erp_action);
1246 * put this target through the erp mill again if someone has
1247 * requested to change the status of a target being online
1248 * to offline or the other way around
1249 * (old retval is preserved if nothing has to be done here)
1251 retval = zfcp_erp_strategy_statechange(action, status, adapter,
1252 port, unit, retval);
1255 * leave if target is in permanent error state or if
1256 * action is repeated in order to process state change
1258 if (retval == ZFCP_ERP_EXIT) {
1259 debug_text_event(adapter->erp_dbf, 2, "a_st_exit");
1263 /* trigger follow up actions */
1264 zfcp_erp_strategy_followup_actions(action, adapter, port, unit, retval);
1267 write_unlock(&adapter->erp_lock);
1268 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
1270 if (retval != ZFCP_ERP_CONTINUES)
1271 zfcp_erp_action_cleanup(action, adapter, port, unit, retval);
1274 * a few tasks remain when the erp queues are empty
1275 * (don't do that if the last action evaluated was dismissed
1276 * since this clearly indicates that there is more to come) :
1277 * - close the name server port if it is open yet
1278 * (enqueues another [probably] final action)
1279 * - otherwise, wake up whoever wants to be woken when we are
1282 if (retval != ZFCP_ERP_DISMISSED)
1283 zfcp_erp_strategy_check_queues(adapter);
1285 debug_text_event(adapter->erp_dbf, 6, "a_st_done");
1295 * returns: ZFCP_ERP_DISMISSED - if action has been dismissed
1296 * retval - otherwise
1299 zfcp_erp_strategy_check_action(struct zfcp_erp_action *erp_action, int retval)
1301 struct zfcp_adapter *adapter = erp_action->adapter;
1303 zfcp_erp_strategy_check_fsfreq(erp_action);
1305 debug_event(adapter->erp_dbf, 5, &erp_action->action, sizeof (int));
1306 if (erp_action->status & ZFCP_STATUS_ERP_DISMISSED) {
1307 debug_text_event(adapter->erp_dbf, 3, "a_stcd_dis");
1308 zfcp_erp_action_dequeue(erp_action);
1309 retval = ZFCP_ERP_DISMISSED;
1311 debug_text_event(adapter->erp_dbf, 5, "a_stcd_nodis");
1317 zfcp_erp_strategy_do_action(struct zfcp_erp_action *erp_action)
1319 int retval = ZFCP_ERP_FAILED;
1320 struct zfcp_adapter *adapter = erp_action->adapter;
1323 * try to execute/continue action as far as possible,
1324 * note: no lock in subsequent strategy routines
1325 * (this allows these routine to call schedule, e.g.
1326 * kmalloc with such flags or qdio_initialize & friends)
1327 * Note: in case of timeout, the seperate strategies will fail
1328 * anyhow. No need for a special action. Even worse, a nameserver
1329 * failure would not wake up waiting ports without the call.
1331 switch (erp_action->action) {
1333 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
1334 retval = zfcp_erp_adapter_strategy(erp_action);
1337 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
1338 retval = zfcp_erp_port_forced_strategy(erp_action);
1341 case ZFCP_ERP_ACTION_REOPEN_PORT:
1342 retval = zfcp_erp_port_strategy(erp_action);
1345 case ZFCP_ERP_ACTION_REOPEN_UNIT:
1346 retval = zfcp_erp_unit_strategy(erp_action);
1350 debug_text_exception(adapter->erp_dbf, 1, "a_stda_bug");
1351 debug_event(adapter->erp_dbf, 1, &erp_action->action,
1353 ZFCP_LOG_NORMAL("bug: unknown erp action requested on "
1354 "adapter %s (action=%d)\n",
1355 zfcp_get_busid_by_adapter(erp_action->adapter),
1356 erp_action->action);
1365 * purpose: triggers retry of this action after a certain amount of time
1366 * by means of timer provided by erp_action
1368 * returns: ZFCP_ERP_CONTINUES - erp_action sleeps in erp running queue
1371 zfcp_erp_strategy_memwait(struct zfcp_erp_action *erp_action)
1373 int retval = ZFCP_ERP_CONTINUES;
1374 struct zfcp_adapter *adapter = erp_action->adapter;
1376 debug_text_event(adapter->erp_dbf, 6, "a_mwinit");
1377 debug_event(adapter->erp_dbf, 6, &erp_action->action, sizeof (int));
1378 init_timer(&erp_action->timer);
1379 erp_action->timer.function = zfcp_erp_memwait_handler;
1380 erp_action->timer.data = (unsigned long) erp_action;
1381 erp_action->timer.expires = jiffies + ZFCP_ERP_MEMWAIT_TIMEOUT;
1382 add_timer(&erp_action->timer);
1388 * function: zfcp_erp_adapter_failed
1390 * purpose: sets the adapter and all underlying devices to ERP_FAILED
1394 zfcp_erp_adapter_failed(struct zfcp_adapter *adapter)
1396 zfcp_erp_modify_adapter_status(adapter,
1397 ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET);
1398 ZFCP_LOG_NORMAL("adapter erp failed on adapter %s\n",
1399 zfcp_get_busid_by_adapter(adapter));
1400 debug_text_event(adapter->erp_dbf, 2, "a_afail");
1404 * function: zfcp_erp_port_failed
1406 * purpose: sets the port and all underlying devices to ERP_FAILED
1410 zfcp_erp_port_failed(struct zfcp_port *port)
1412 zfcp_erp_modify_port_status(port,
1413 ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET);
1415 if (atomic_test_mask(ZFCP_STATUS_PORT_WKA, &port->status))
1416 ZFCP_LOG_NORMAL("port erp failed (adapter %s, "
1417 "port d_id=0x%08x)\n",
1418 zfcp_get_busid_by_port(port), port->d_id);
1420 ZFCP_LOG_NORMAL("port erp failed (adapter %s, wwpn=0x%016Lx)\n",
1421 zfcp_get_busid_by_port(port), port->wwpn);
1423 debug_text_event(port->adapter->erp_dbf, 2, "p_pfail");
1424 debug_event(port->adapter->erp_dbf, 2, &port->wwpn, sizeof (wwn_t));
1428 * function: zfcp_erp_unit_failed
1430 * purpose: sets the unit to ERP_FAILED
1434 zfcp_erp_unit_failed(struct zfcp_unit *unit)
1436 zfcp_erp_modify_unit_status(unit,
1437 ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET);
1439 ZFCP_LOG_NORMAL("unit erp failed on unit 0x%016Lx on port 0x%016Lx "
1440 " on adapter %s\n", unit->fcp_lun,
1441 unit->port->wwpn, zfcp_get_busid_by_unit(unit));
1442 debug_text_event(unit->port->adapter->erp_dbf, 2, "u_ufail");
1443 debug_event(unit->port->adapter->erp_dbf, 2,
1444 &unit->fcp_lun, sizeof (fcp_lun_t));
1448 * function: zfcp_erp_strategy_check_target
1450 * purpose: increments the erp action count on the device currently in
1451 * recovery if the action failed or resets the count in case of
1452 * success. If a maximum count is exceeded the device is marked
1454 * The 'blocked' state of a target which has been recovered
1455 * successfully is reset.
1457 * returns: ZFCP_ERP_CONTINUES - action continues (not considered)
1458 * ZFCP_ERP_SUCCEEDED - action finished successfully
1459 * ZFCP_ERP_EXIT - action failed and will not continue
1462 zfcp_erp_strategy_check_target(struct zfcp_erp_action *erp_action, int result)
1464 struct zfcp_adapter *adapter = erp_action->adapter;
1465 struct zfcp_port *port = erp_action->port;
1466 struct zfcp_unit *unit = erp_action->unit;
1468 debug_text_event(adapter->erp_dbf, 5, "a_stct_norm");
1469 debug_event(adapter->erp_dbf, 5, &erp_action->action, sizeof (int));
1470 debug_event(adapter->erp_dbf, 5, &result, sizeof (int));
1472 switch (erp_action->action) {
1474 case ZFCP_ERP_ACTION_REOPEN_UNIT:
1475 result = zfcp_erp_strategy_check_unit(unit, result);
1478 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
1479 case ZFCP_ERP_ACTION_REOPEN_PORT:
1480 result = zfcp_erp_strategy_check_port(port, result);
1483 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
1484 result = zfcp_erp_strategy_check_adapter(adapter, result);
1492 zfcp_erp_strategy_statechange(int action,
1494 struct zfcp_adapter *adapter,
1495 struct zfcp_port *port,
1496 struct zfcp_unit *unit, int retval)
1498 debug_text_event(adapter->erp_dbf, 3, "a_stsc");
1499 debug_event(adapter->erp_dbf, 3, &action, sizeof (int));
1503 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
1504 if (zfcp_erp_strategy_statechange_detected(&adapter->status,
1506 zfcp_erp_adapter_reopen_internal(adapter, ZFCP_STATUS_COMMON_ERP_FAILED);
1507 retval = ZFCP_ERP_EXIT;
1511 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
1512 case ZFCP_ERP_ACTION_REOPEN_PORT:
1513 if (zfcp_erp_strategy_statechange_detected(&port->status,
1515 zfcp_erp_port_reopen_internal(port, ZFCP_STATUS_COMMON_ERP_FAILED);
1516 retval = ZFCP_ERP_EXIT;
1520 case ZFCP_ERP_ACTION_REOPEN_UNIT:
1521 if (zfcp_erp_strategy_statechange_detected(&unit->status,
1523 zfcp_erp_unit_reopen_internal(unit, ZFCP_STATUS_COMMON_ERP_FAILED);
1524 retval = ZFCP_ERP_EXIT;
1533 zfcp_erp_strategy_statechange_detected(atomic_t * target_status, u32 erp_status)
1536 /* take it online */
1537 (atomic_test_mask(ZFCP_STATUS_COMMON_RUNNING, target_status) &&
1538 (ZFCP_STATUS_ERP_CLOSE_ONLY & erp_status)) ||
1539 /* take it offline */
1540 (!atomic_test_mask(ZFCP_STATUS_COMMON_RUNNING, target_status) &&
1541 !(ZFCP_STATUS_ERP_CLOSE_ONLY & erp_status));
1545 zfcp_erp_strategy_check_unit(struct zfcp_unit *unit, int result)
1547 debug_text_event(unit->port->adapter->erp_dbf, 5, "u_stct");
1548 debug_event(unit->port->adapter->erp_dbf, 5, &unit->fcp_lun,
1549 sizeof (fcp_lun_t));
1552 case ZFCP_ERP_SUCCEEDED :
1553 atomic_set(&unit->erp_counter, 0);
1554 zfcp_erp_unit_unblock(unit);
1556 case ZFCP_ERP_FAILED :
1557 atomic_inc(&unit->erp_counter);
1558 if (atomic_read(&unit->erp_counter) > ZFCP_MAX_ERPS)
1559 zfcp_erp_unit_failed(unit);
1561 case ZFCP_ERP_EXIT :
1566 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED, &unit->status)) {
1567 zfcp_erp_unit_block(unit, 0); /* for ZFCP_ERP_SUCCEEDED */
1568 result = ZFCP_ERP_EXIT;
1575 zfcp_erp_strategy_check_port(struct zfcp_port *port, int result)
1577 debug_text_event(port->adapter->erp_dbf, 5, "p_stct");
1578 debug_event(port->adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
1581 case ZFCP_ERP_SUCCEEDED :
1582 atomic_set(&port->erp_counter, 0);
1583 zfcp_erp_port_unblock(port);
1585 case ZFCP_ERP_FAILED :
1586 atomic_inc(&port->erp_counter);
1587 if (atomic_read(&port->erp_counter) > ZFCP_MAX_ERPS)
1588 zfcp_erp_port_failed(port);
1590 case ZFCP_ERP_EXIT :
1595 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED, &port->status)) {
1596 zfcp_erp_port_block(port, 0); /* for ZFCP_ERP_SUCCEEDED */
1597 result = ZFCP_ERP_EXIT;
1604 zfcp_erp_strategy_check_adapter(struct zfcp_adapter *adapter, int result)
1606 debug_text_event(adapter->erp_dbf, 5, "a_stct");
1609 case ZFCP_ERP_SUCCEEDED :
1610 atomic_set(&adapter->erp_counter, 0);
1611 zfcp_erp_adapter_unblock(adapter);
1613 case ZFCP_ERP_FAILED :
1614 atomic_inc(&adapter->erp_counter);
1615 if (atomic_read(&adapter->erp_counter) > ZFCP_MAX_ERPS)
1616 zfcp_erp_adapter_failed(adapter);
1618 case ZFCP_ERP_EXIT :
1623 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED, &adapter->status)) {
1624 zfcp_erp_adapter_block(adapter, 0); /* for ZFCP_ERP_SUCCEEDED */
1625 result = ZFCP_ERP_EXIT;
1634 * purpose: remaining things in good cases,
1635 * escalation in bad cases
1640 zfcp_erp_strategy_followup_actions(int action,
1641 struct zfcp_adapter *adapter,
1642 struct zfcp_port *port,
1643 struct zfcp_unit *unit, int status)
1645 debug_text_event(adapter->erp_dbf, 5, "a_stfol");
1646 debug_event(adapter->erp_dbf, 5, &action, sizeof (int));
1648 /* initiate follow-up actions depending on success of finished action */
1651 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
1652 if (status == ZFCP_ERP_SUCCEEDED)
1653 zfcp_erp_port_reopen_all_internal(adapter, 0);
1655 zfcp_erp_adapter_reopen_internal(adapter, 0);
1658 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
1659 if (status == ZFCP_ERP_SUCCEEDED)
1660 zfcp_erp_port_reopen_internal(port, 0);
1662 zfcp_erp_adapter_reopen_internal(adapter, 0);
1665 case ZFCP_ERP_ACTION_REOPEN_PORT:
1666 if (status == ZFCP_ERP_SUCCEEDED)
1667 zfcp_erp_unit_reopen_all_internal(port, 0);
1669 zfcp_erp_port_forced_reopen_internal(port, 0);
1672 case ZFCP_ERP_ACTION_REOPEN_UNIT:
1673 if (status == ZFCP_ERP_SUCCEEDED) ; /* no further action */
1675 zfcp_erp_port_reopen_internal(unit->port, 0);
1683 zfcp_erp_strategy_check_queues(struct zfcp_adapter *adapter)
1685 unsigned long flags;
1687 read_lock_irqsave(&zfcp_data.config_lock, flags);
1688 read_lock(&adapter->erp_lock);
1689 if (list_empty(&adapter->erp_ready_head) &&
1690 list_empty(&adapter->erp_running_head)) {
1691 debug_text_event(adapter->erp_dbf, 4, "a_cq_wake");
1692 atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_PENDING,
1694 wake_up(&adapter->erp_done_wqh);
1696 debug_text_event(adapter->erp_dbf, 5, "a_cq_notempty");
1697 read_unlock(&adapter->erp_lock);
1698 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
1704 * zfcp_erp_wait - wait for completion of error recovery on an adapter
1705 * @adapter: adapter for which to wait for completion of its error recovery
1709 zfcp_erp_wait(struct zfcp_adapter *adapter)
1713 wait_event(adapter->erp_done_wqh,
1714 !atomic_test_mask(ZFCP_STATUS_ADAPTER_ERP_PENDING,
1721 zfcp_erp_modify_adapter_status(struct zfcp_adapter *adapter,
1722 u32 mask, int set_or_clear)
1724 struct zfcp_port *port;
1725 u32 common_mask = mask & ZFCP_COMMON_FLAGS;
1727 if (set_or_clear == ZFCP_SET) {
1728 atomic_set_mask(mask, &adapter->status);
1729 debug_text_event(adapter->erp_dbf, 3, "a_mod_as_s");
1731 atomic_clear_mask(mask, &adapter->status);
1732 if (mask & ZFCP_STATUS_COMMON_ERP_FAILED)
1733 atomic_set(&adapter->erp_counter, 0);
1734 debug_text_event(adapter->erp_dbf, 3, "a_mod_as_c");
1736 debug_event(adapter->erp_dbf, 3, &mask, sizeof (u32));
1738 /* Deal with all underlying devices, only pass common_mask */
1740 list_for_each_entry(port, &adapter->port_list_head, list)
1741 zfcp_erp_modify_port_status(port, common_mask,
1746 * function: zfcp_erp_modify_port_status
1748 * purpose: sets the port and all underlying devices to ERP_FAILED
1752 zfcp_erp_modify_port_status(struct zfcp_port *port, u32 mask, int set_or_clear)
1754 struct zfcp_unit *unit;
1755 u32 common_mask = mask & ZFCP_COMMON_FLAGS;
1757 if (set_or_clear == ZFCP_SET) {
1758 atomic_set_mask(mask, &port->status);
1759 debug_text_event(port->adapter->erp_dbf, 3, "p_mod_ps_s");
1761 atomic_clear_mask(mask, &port->status);
1762 if (mask & ZFCP_STATUS_COMMON_ERP_FAILED)
1763 atomic_set(&port->erp_counter, 0);
1764 debug_text_event(port->adapter->erp_dbf, 3, "p_mod_ps_c");
1766 debug_event(port->adapter->erp_dbf, 3, &port->wwpn, sizeof (wwn_t));
1767 debug_event(port->adapter->erp_dbf, 3, &mask, sizeof (u32));
1769 /* Modify status of all underlying devices, only pass common mask */
1771 list_for_each_entry(unit, &port->unit_list_head, list)
1772 zfcp_erp_modify_unit_status(unit, common_mask,
1777 * function: zfcp_erp_modify_unit_status
1779 * purpose: sets the unit to ERP_FAILED
1783 zfcp_erp_modify_unit_status(struct zfcp_unit *unit, u32 mask, int set_or_clear)
1785 if (set_or_clear == ZFCP_SET) {
1786 atomic_set_mask(mask, &unit->status);
1787 debug_text_event(unit->port->adapter->erp_dbf, 3, "u_mod_us_s");
1789 atomic_clear_mask(mask, &unit->status);
1790 if (mask & ZFCP_STATUS_COMMON_ERP_FAILED) {
1791 atomic_set(&unit->erp_counter, 0);
1793 debug_text_event(unit->port->adapter->erp_dbf, 3, "u_mod_us_c");
1795 debug_event(unit->port->adapter->erp_dbf, 3, &unit->fcp_lun,
1796 sizeof (fcp_lun_t));
1797 debug_event(unit->port->adapter->erp_dbf, 3, &mask, sizeof (u32));
1803 * purpose: Wrappper for zfcp_erp_port_reopen_all_internal
1804 * used to ensure the correct locking
1806 * returns: 0 - initiated action successfully
1807 * <0 - failed to initiate action
1810 zfcp_erp_port_reopen_all(struct zfcp_adapter *adapter, int clear_mask)
1813 unsigned long flags;
1815 read_lock_irqsave(&zfcp_data.config_lock, flags);
1816 write_lock(&adapter->erp_lock);
1817 retval = zfcp_erp_port_reopen_all_internal(adapter, clear_mask);
1818 write_unlock(&adapter->erp_lock);
1819 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
1825 zfcp_erp_port_reopen_all_internal(struct zfcp_adapter *adapter, int clear_mask)
1828 struct zfcp_port *port;
1830 list_for_each_entry(port, &adapter->port_list_head, list)
1831 if (!atomic_test_mask(ZFCP_STATUS_PORT_WKA, &port->status))
1832 zfcp_erp_port_reopen_internal(port, clear_mask);
1845 zfcp_erp_unit_reopen_all_internal(struct zfcp_port *port, int clear_mask)
1848 struct zfcp_unit *unit;
1850 list_for_each_entry(unit, &port->unit_list_head, list)
1851 zfcp_erp_unit_reopen_internal(unit, clear_mask);
1859 * purpose: this routine executes the 'Reopen Adapter' action
1860 * (the entire action is processed synchronously, since
1861 * there are no actions which might be run concurrently
1864 * returns: ZFCP_ERP_SUCCEEDED - action finished successfully
1865 * ZFCP_ERP_FAILED - action finished unsuccessfully
1868 zfcp_erp_adapter_strategy(struct zfcp_erp_action *erp_action)
1871 struct zfcp_adapter *adapter = erp_action->adapter;
1873 retval = zfcp_erp_adapter_strategy_close(erp_action);
1874 if (erp_action->status & ZFCP_STATUS_ERP_CLOSE_ONLY)
1875 retval = ZFCP_ERP_EXIT;
1877 retval = zfcp_erp_adapter_strategy_open(erp_action);
1879 debug_text_event(adapter->erp_dbf, 3, "a_ast/ret");
1880 debug_event(adapter->erp_dbf, 3, &erp_action->action, sizeof (int));
1881 debug_event(adapter->erp_dbf, 3, &retval, sizeof (int));
1883 if (retval == ZFCP_ERP_FAILED) {
1884 ZFCP_LOG_INFO("Waiting to allow the adapter %s "
1885 "to recover itself\n",
1886 zfcp_get_busid_by_adapter(adapter));
1887 msleep(jiffies_to_msecs(ZFCP_TYPE2_RECOVERY_TIME));
1898 * returns: ZFCP_ERP_SUCCEEDED - action finished successfully
1899 * ZFCP_ERP_FAILED - action finished unsuccessfully
1902 zfcp_erp_adapter_strategy_close(struct zfcp_erp_action *erp_action)
1906 atomic_set_mask(ZFCP_STATUS_COMMON_CLOSING,
1907 &erp_action->adapter->status);
1908 retval = zfcp_erp_adapter_strategy_generic(erp_action, 1);
1909 atomic_clear_mask(ZFCP_STATUS_COMMON_CLOSING,
1910 &erp_action->adapter->status);
1920 * returns: ZFCP_ERP_SUCCEEDED - action finished successfully
1921 * ZFCP_ERP_FAILED - action finished unsuccessfully
1924 zfcp_erp_adapter_strategy_open(struct zfcp_erp_action *erp_action)
1928 atomic_set_mask(ZFCP_STATUS_COMMON_OPENING,
1929 &erp_action->adapter->status);
1930 retval = zfcp_erp_adapter_strategy_generic(erp_action, 0);
1931 atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING,
1932 &erp_action->adapter->status);
1938 * function: zfcp_register_adapter
1940 * purpose: allocate the irq associated with this devno and register
1941 * the FSF adapter with the SCSI stack
1946 zfcp_erp_adapter_strategy_generic(struct zfcp_erp_action *erp_action, int close)
1948 int retval = ZFCP_ERP_SUCCEEDED;
1953 retval = zfcp_erp_adapter_strategy_open_qdio(erp_action);
1954 if (retval != ZFCP_ERP_SUCCEEDED)
1957 retval = zfcp_erp_adapter_strategy_open_fsf(erp_action);
1958 if (retval != ZFCP_ERP_SUCCEEDED)
1959 goto failed_openfcp;
1961 atomic_set_mask(ZFCP_STATUS_COMMON_OPEN, &erp_action->adapter->status);
1965 atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN,
1966 &erp_action->adapter->status);
1969 zfcp_erp_adapter_strategy_close_qdio(erp_action);
1970 zfcp_erp_adapter_strategy_close_fsf(erp_action);
1977 * function: zfcp_qdio_init
1979 * purpose: setup QDIO operation for specified adapter
1981 * returns: 0 - successful setup
1985 zfcp_erp_adapter_strategy_open_qdio(struct zfcp_erp_action *erp_action)
1989 volatile struct qdio_buffer_element *sbale;
1990 struct zfcp_adapter *adapter = erp_action->adapter;
1992 if (atomic_test_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &adapter->status)) {
1993 ZFCP_LOG_NORMAL("bug: second attempt to set up QDIO on "
1995 zfcp_get_busid_by_adapter(adapter));
1999 if (qdio_establish(&adapter->qdio_init_data) != 0) {
2000 ZFCP_LOG_INFO("error: establishment of QDIO queues failed "
2002 zfcp_get_busid_by_adapter(adapter));
2003 goto failed_qdio_establish;
2005 debug_text_event(adapter->erp_dbf, 3, "qdio_est");
2007 if (qdio_activate(adapter->ccw_device, 0) != 0) {
2008 ZFCP_LOG_INFO("error: activation of QDIO queues failed "
2010 zfcp_get_busid_by_adapter(adapter));
2011 goto failed_qdio_activate;
2013 debug_text_event(adapter->erp_dbf, 3, "qdio_act");
2016 * put buffers into response queue,
2018 for (i = 0; i < QDIO_MAX_BUFFERS_PER_Q; i++) {
2019 sbale = &(adapter->response_queue.buffer[i]->element[0]);
2021 sbale->flags = SBAL_FLAGS_LAST_ENTRY;
2025 ZFCP_LOG_TRACE("calling do_QDIO on adapter %s (flags=0x%x, "
2026 "queue_no=%i, index_in_queue=%i, count=%i)\n",
2027 zfcp_get_busid_by_adapter(adapter),
2028 QDIO_FLAG_SYNC_INPUT, 0, 0, QDIO_MAX_BUFFERS_PER_Q);
2030 retval = do_QDIO(adapter->ccw_device,
2031 QDIO_FLAG_SYNC_INPUT,
2032 0, 0, QDIO_MAX_BUFFERS_PER_Q, NULL);
2035 ZFCP_LOG_NORMAL("bug: setup of QDIO failed (retval=%d)\n",
2037 goto failed_do_qdio;
2039 adapter->response_queue.free_index = 0;
2040 atomic_set(&adapter->response_queue.free_count, 0);
2041 ZFCP_LOG_DEBUG("%i buffers successfully enqueued to "
2042 "response queue\n", QDIO_MAX_BUFFERS_PER_Q);
2044 /* set index of first avalable SBALS / number of available SBALS */
2045 adapter->request_queue.free_index = 0;
2046 atomic_set(&adapter->request_queue.free_count, QDIO_MAX_BUFFERS_PER_Q);
2047 adapter->request_queue.distance_from_int = 0;
2049 /* initialize waitqueue used to wait for free SBALs in requests queue */
2050 init_waitqueue_head(&adapter->request_wq);
2052 /* ok, we did it - skip all cleanups for different failures */
2053 atomic_set_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &adapter->status);
2054 retval = ZFCP_ERP_SUCCEEDED;
2060 failed_qdio_activate:
2061 debug_text_event(adapter->erp_dbf, 3, "qdio_down1a");
2062 while (qdio_shutdown(adapter->ccw_device,
2063 QDIO_FLAG_CLEANUP_USING_CLEAR) == -EINPROGRESS)
2065 debug_text_event(adapter->erp_dbf, 3, "qdio_down1b");
2067 failed_qdio_establish:
2069 retval = ZFCP_ERP_FAILED;
2076 * function: zfcp_qdio_cleanup
2078 * purpose: cleans up QDIO operation for the specified adapter
2080 * returns: 0 - successful cleanup
2081 * !0 - failed cleanup
2084 zfcp_erp_adapter_strategy_close_qdio(struct zfcp_erp_action *erp_action)
2086 int retval = ZFCP_ERP_SUCCEEDED;
2089 struct zfcp_adapter *adapter = erp_action->adapter;
2091 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &adapter->status)) {
2092 ZFCP_LOG_DEBUG("error: attempt to shut down inactive QDIO "
2093 "queues on adapter %s\n",
2094 zfcp_get_busid_by_adapter(adapter));
2095 retval = ZFCP_ERP_FAILED;
2100 * Get queue_lock and clear QDIOUP flag. Thus it's guaranteed that
2101 * do_QDIO won't be called while qdio_shutdown is in progress.
2104 write_lock_irq(&adapter->request_queue.queue_lock);
2105 atomic_clear_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &adapter->status);
2106 write_unlock_irq(&adapter->request_queue.queue_lock);
2108 debug_text_event(adapter->erp_dbf, 3, "qdio_down2a");
2109 while (qdio_shutdown(adapter->ccw_device,
2110 QDIO_FLAG_CLEANUP_USING_CLEAR) == -EINPROGRESS)
2112 debug_text_event(adapter->erp_dbf, 3, "qdio_down2b");
2115 * First we had to stop QDIO operation.
2116 * Now it is safe to take the following actions.
2119 /* Cleanup only necessary when there are unacknowledged buffers */
2120 if (atomic_read(&adapter->request_queue.free_count)
2121 < QDIO_MAX_BUFFERS_PER_Q) {
2122 first_used = (adapter->request_queue.free_index +
2123 atomic_read(&adapter->request_queue.free_count))
2124 % QDIO_MAX_BUFFERS_PER_Q;
2125 used_count = QDIO_MAX_BUFFERS_PER_Q -
2126 atomic_read(&adapter->request_queue.free_count);
2127 zfcp_qdio_zero_sbals(adapter->request_queue.buffer,
2128 first_used, used_count);
2130 adapter->response_queue.free_index = 0;
2131 atomic_set(&adapter->response_queue.free_count, 0);
2132 adapter->request_queue.free_index = 0;
2133 atomic_set(&adapter->request_queue.free_count, 0);
2134 adapter->request_queue.distance_from_int = 0;
2140 zfcp_erp_adapter_strategy_open_fsf(struct zfcp_erp_action *erp_action)
2144 retval = zfcp_erp_adapter_strategy_open_fsf_xconfig(erp_action);
2145 if (retval == ZFCP_ERP_FAILED)
2146 return ZFCP_ERP_FAILED;
2148 retval = zfcp_erp_adapter_strategy_open_fsf_xport(erp_action);
2149 if (retval == ZFCP_ERP_FAILED)
2150 return ZFCP_ERP_FAILED;
2152 return zfcp_erp_adapter_strategy_open_fsf_statusread(erp_action);
2156 zfcp_erp_adapter_strategy_open_fsf_xconfig(struct zfcp_erp_action *erp_action)
2158 int retval = ZFCP_ERP_SUCCEEDED;
2160 int sleep = ZFCP_EXCHANGE_CONFIG_DATA_FIRST_SLEEP;
2161 struct zfcp_adapter *adapter = erp_action->adapter;
2163 atomic_clear_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK, &adapter->status);
2165 for (retries = ZFCP_EXCHANGE_CONFIG_DATA_RETRIES; retries; retries--) {
2166 atomic_clear_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT,
2168 ZFCP_LOG_DEBUG("Doing exchange config data\n");
2169 write_lock_irq(&adapter->erp_lock);
2170 zfcp_erp_action_to_running(erp_action);
2171 write_unlock_irq(&adapter->erp_lock);
2172 zfcp_erp_timeout_init(erp_action);
2173 if (zfcp_fsf_exchange_config_data(erp_action)) {
2174 retval = ZFCP_ERP_FAILED;
2175 debug_text_event(adapter->erp_dbf, 5, "a_fstx_xf");
2176 ZFCP_LOG_INFO("error: initiation of exchange of "
2177 "configuration data failed for "
2179 zfcp_get_busid_by_adapter(adapter));
2182 debug_text_event(adapter->erp_dbf, 6, "a_fstx_xok");
2183 ZFCP_LOG_DEBUG("Xchange underway\n");
2187 * Both the normal completion handler as well as the timeout
2188 * handler will do an 'up' when the 'exchange config data'
2189 * request completes or times out. Thus, the signal to go on
2190 * won't be lost utilizing this semaphore.
2191 * Furthermore, this 'adapter_reopen' action is
2192 * guaranteed to be the only action being there (highest action
2193 * which prevents other actions from being created).
2194 * Resulting from that, the wake signal recognized here
2195 * _must_ be the one belonging to the 'exchange config
2198 down(&adapter->erp_ready_sem);
2199 if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT) {
2200 ZFCP_LOG_INFO("error: exchange of configuration data "
2201 "for adapter %s timed out\n",
2202 zfcp_get_busid_by_adapter(adapter));
2206 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT,
2210 ZFCP_LOG_DEBUG("host connection still initialising... "
2211 "waiting and retrying...\n");
2212 /* sleep a little bit before retry */
2213 msleep(jiffies_to_msecs(sleep));
2217 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK,
2218 &adapter->status)) {
2219 ZFCP_LOG_INFO("error: exchange of configuration data for "
2220 "adapter %s failed\n",
2221 zfcp_get_busid_by_adapter(adapter));
2222 retval = ZFCP_ERP_FAILED;
2229 zfcp_erp_adapter_strategy_open_fsf_xport(struct zfcp_erp_action *erp_action)
2232 struct zfcp_adapter *adapter;
2234 adapter = erp_action->adapter;
2235 atomic_clear_mask(ZFCP_STATUS_ADAPTER_XPORT_OK, &adapter->status);
2237 write_lock_irq(&adapter->erp_lock);
2238 zfcp_erp_action_to_running(erp_action);
2239 write_unlock_irq(&adapter->erp_lock);
2241 zfcp_erp_timeout_init(erp_action);
2242 ret = zfcp_fsf_exchange_port_data(erp_action, adapter, NULL);
2243 if (ret == -EOPNOTSUPP) {
2244 debug_text_event(adapter->erp_dbf, 3, "a_xport_notsupp");
2245 return ZFCP_ERP_SUCCEEDED;
2247 debug_text_event(adapter->erp_dbf, 3, "a_xport_failed");
2248 return ZFCP_ERP_FAILED;
2250 debug_text_event(adapter->erp_dbf, 6, "a_xport_ok");
2252 ret = ZFCP_ERP_SUCCEEDED;
2253 down(&adapter->erp_ready_sem);
2254 if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT) {
2255 ZFCP_LOG_INFO("error: exchange port data timed out (adapter "
2256 "%s)\n", zfcp_get_busid_by_adapter(adapter));
2257 ret = ZFCP_ERP_FAILED;
2259 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_XPORT_OK, &adapter->status)) {
2260 ZFCP_LOG_INFO("error: exchange port data failed (adapter "
2261 "%s\n", zfcp_get_busid_by_adapter(adapter));
2262 ret = ZFCP_ERP_FAILED;
2269 zfcp_erp_adapter_strategy_open_fsf_statusread(struct zfcp_erp_action
2272 int retval = ZFCP_ERP_SUCCEEDED;
2274 struct zfcp_adapter *adapter = erp_action->adapter;
2277 adapter->status_read_failed = 0;
2278 for (i = 0; i < ZFCP_STATUS_READS_RECOM; i++) {
2279 temp_ret = zfcp_fsf_status_read(adapter, ZFCP_WAIT_FOR_SBAL);
2281 ZFCP_LOG_INFO("error: set-up of unsolicited status "
2282 "notification failed on adapter %s\n",
2283 zfcp_get_busid_by_adapter(adapter));
2284 retval = ZFCP_ERP_FAILED;
2294 * function: zfcp_fsf_cleanup
2296 * purpose: cleanup FSF operation for specified adapter
2298 * returns: 0 - FSF operation successfully cleaned up
2299 * !0 - failed to cleanup FSF operation for this adapter
2302 zfcp_erp_adapter_strategy_close_fsf(struct zfcp_erp_action *erp_action)
2304 int retval = ZFCP_ERP_SUCCEEDED;
2305 struct zfcp_adapter *adapter = erp_action->adapter;
2308 * wake waiting initiators of requests,
2309 * return SCSI commands (with error status),
2310 * clean up all requests (synchronously)
2312 zfcp_fsf_req_dismiss_all(adapter);
2313 /* reset FSF request sequence number */
2314 adapter->fsf_req_seq_no = 0;
2315 /* all ports and units are closed */
2316 zfcp_erp_modify_adapter_status(adapter,
2317 ZFCP_STATUS_COMMON_OPEN, ZFCP_CLEAR);
2325 * purpose: this routine executes the 'Reopen Physical Port' action
2327 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2328 * ZFCP_ERP_SUCCEEDED - action finished successfully
2329 * ZFCP_ERP_FAILED - action finished unsuccessfully
2332 zfcp_erp_port_forced_strategy(struct zfcp_erp_action *erp_action)
2334 int retval = ZFCP_ERP_FAILED;
2335 struct zfcp_port *port = erp_action->port;
2336 struct zfcp_adapter *adapter = erp_action->adapter;
2338 switch (erp_action->step) {
2342 * the ULP spec. begs for waiting for oustanding commands
2344 case ZFCP_ERP_STEP_UNINITIALIZED:
2345 zfcp_erp_port_strategy_clearstati(port);
2347 * it would be sufficient to test only the normal open flag
2348 * since the phys. open flag cannot be set if the normal
2349 * open flag is unset - however, this is for readabilty ...
2351 if (atomic_test_mask((ZFCP_STATUS_PORT_PHYS_OPEN |
2352 ZFCP_STATUS_COMMON_OPEN),
2354 ZFCP_LOG_DEBUG("port 0x%016Lx is open -> trying "
2355 "close physical\n", port->wwpn);
2357 zfcp_erp_port_forced_strategy_close(erp_action);
2359 retval = ZFCP_ERP_FAILED;
2362 case ZFCP_ERP_STEP_PHYS_PORT_CLOSING:
2363 if (atomic_test_mask(ZFCP_STATUS_PORT_PHYS_OPEN,
2365 ZFCP_LOG_DEBUG("close physical failed for port "
2366 "0x%016Lx\n", port->wwpn);
2367 retval = ZFCP_ERP_FAILED;
2369 retval = ZFCP_ERP_SUCCEEDED;
2373 debug_text_event(adapter->erp_dbf, 3, "p_pfst/ret");
2374 debug_event(adapter->erp_dbf, 3, &port->wwpn, sizeof (wwn_t));
2375 debug_event(adapter->erp_dbf, 3, &erp_action->action, sizeof (int));
2376 debug_event(adapter->erp_dbf, 3, &retval, sizeof (int));
2384 * purpose: this routine executes the 'Reopen Port' action
2386 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2387 * ZFCP_ERP_SUCCEEDED - action finished successfully
2388 * ZFCP_ERP_FAILED - action finished unsuccessfully
2391 zfcp_erp_port_strategy(struct zfcp_erp_action *erp_action)
2393 int retval = ZFCP_ERP_FAILED;
2394 struct zfcp_port *port = erp_action->port;
2395 struct zfcp_adapter *adapter = erp_action->adapter;
2397 switch (erp_action->step) {
2401 * the ULP spec. begs for waiting for oustanding commands
2403 case ZFCP_ERP_STEP_UNINITIALIZED:
2404 zfcp_erp_port_strategy_clearstati(port);
2405 if (atomic_test_mask(ZFCP_STATUS_COMMON_OPEN, &port->status)) {
2406 ZFCP_LOG_DEBUG("port 0x%016Lx is open -> trying "
2407 "close\n", port->wwpn);
2408 retval = zfcp_erp_port_strategy_close(erp_action);
2410 } /* else it's already closed, open it */
2413 case ZFCP_ERP_STEP_PORT_CLOSING:
2414 if (atomic_test_mask(ZFCP_STATUS_COMMON_OPEN, &port->status)) {
2415 ZFCP_LOG_DEBUG("close failed for port 0x%016Lx\n",
2417 retval = ZFCP_ERP_FAILED;
2419 } /* else it's closed now, open it */
2422 if (erp_action->status & ZFCP_STATUS_ERP_CLOSE_ONLY)
2423 retval = ZFCP_ERP_EXIT;
2425 retval = zfcp_erp_port_strategy_open(erp_action);
2428 debug_text_event(adapter->erp_dbf, 3, "p_pst/ret");
2429 debug_event(adapter->erp_dbf, 3, &port->wwpn, sizeof (wwn_t));
2430 debug_event(adapter->erp_dbf, 3, &erp_action->action, sizeof (int));
2431 debug_event(adapter->erp_dbf, 3, &retval, sizeof (int));
2437 zfcp_erp_port_strategy_open(struct zfcp_erp_action *erp_action)
2441 if (atomic_test_mask(ZFCP_STATUS_PORT_WKA,
2442 &erp_action->port->status))
2443 retval = zfcp_erp_port_strategy_open_nameserver(erp_action);
2445 retval = zfcp_erp_port_strategy_open_common(erp_action);
2451 zfcp_erp_port_strategy_open_common(struct zfcp_erp_action *erp_action)
2454 struct zfcp_adapter *adapter = erp_action->adapter;
2455 struct zfcp_port *port = erp_action->port;
2457 switch (erp_action->step) {
2459 case ZFCP_ERP_STEP_UNINITIALIZED:
2460 case ZFCP_ERP_STEP_PHYS_PORT_CLOSING:
2461 case ZFCP_ERP_STEP_PORT_CLOSING:
2462 if (fc_host_port_type(adapter->scsi_host) == FC_PORTTYPE_PTP) {
2463 if (port->wwpn != adapter->peer_wwpn) {
2464 ZFCP_LOG_NORMAL("Failed to open port 0x%016Lx "
2465 "on adapter %s.\nPeer WWPN "
2466 "0x%016Lx does not match\n",
2468 zfcp_get_busid_by_adapter(adapter),
2469 adapter->peer_wwpn);
2470 zfcp_erp_port_failed(port);
2471 retval = ZFCP_ERP_FAILED;
2474 port->d_id = adapter->peer_d_id;
2475 atomic_set_mask(ZFCP_STATUS_PORT_DID_DID, &port->status);
2476 retval = zfcp_erp_port_strategy_open_port(erp_action);
2479 if (!(adapter->nameserver_port)) {
2480 retval = zfcp_nameserver_enqueue(adapter);
2482 ZFCP_LOG_NORMAL("error: nameserver port "
2483 "unavailable for adapter %s\n",
2484 zfcp_get_busid_by_adapter(adapter));
2485 retval = ZFCP_ERP_FAILED;
2489 if (!atomic_test_mask(ZFCP_STATUS_COMMON_UNBLOCKED,
2490 &adapter->nameserver_port->status)) {
2491 ZFCP_LOG_DEBUG("nameserver port is not open -> open "
2492 "nameserver port\n");
2493 /* nameserver port may live again */
2494 atomic_set_mask(ZFCP_STATUS_COMMON_RUNNING,
2495 &adapter->nameserver_port->status);
2496 if (zfcp_erp_port_reopen(adapter->nameserver_port, 0)
2499 ZFCP_ERP_STEP_NAMESERVER_OPEN;
2500 retval = ZFCP_ERP_CONTINUES;
2502 retval = ZFCP_ERP_FAILED;
2505 /* else nameserver port is already open, fall through */
2506 case ZFCP_ERP_STEP_NAMESERVER_OPEN:
2507 if (!atomic_test_mask(ZFCP_STATUS_COMMON_OPEN,
2508 &adapter->nameserver_port->status)) {
2509 ZFCP_LOG_DEBUG("open failed for nameserver port\n");
2510 retval = ZFCP_ERP_FAILED;
2512 ZFCP_LOG_DEBUG("nameserver port is open -> "
2513 "nameserver look-up for port 0x%016Lx\n",
2515 retval = zfcp_erp_port_strategy_open_common_lookup
2520 case ZFCP_ERP_STEP_NAMESERVER_LOOKUP:
2521 if (!atomic_test_mask(ZFCP_STATUS_PORT_DID_DID, &port->status)) {
2522 if (atomic_test_mask
2523 (ZFCP_STATUS_PORT_INVALID_WWPN, &port->status)) {
2524 ZFCP_LOG_DEBUG("nameserver look-up failed "
2525 "for port 0x%016Lx "
2526 "(misconfigured WWPN?)\n",
2528 zfcp_erp_port_failed(port);
2529 retval = ZFCP_ERP_EXIT;
2531 ZFCP_LOG_DEBUG("nameserver look-up failed for "
2532 "port 0x%016Lx\n", port->wwpn);
2533 retval = ZFCP_ERP_FAILED;
2536 ZFCP_LOG_DEBUG("port 0x%016Lx has d_id=0x%08x -> "
2537 "trying open\n", port->wwpn, port->d_id);
2538 retval = zfcp_erp_port_strategy_open_port(erp_action);
2542 case ZFCP_ERP_STEP_PORT_OPENING:
2543 /* D_ID might have changed during open */
2544 if (atomic_test_mask((ZFCP_STATUS_COMMON_OPEN |
2545 ZFCP_STATUS_PORT_DID_DID),
2547 ZFCP_LOG_DEBUG("port 0x%016Lx is open\n", port->wwpn);
2548 retval = ZFCP_ERP_SUCCEEDED;
2550 ZFCP_LOG_DEBUG("open failed for port 0x%016Lx\n",
2552 retval = ZFCP_ERP_FAILED;
2557 ZFCP_LOG_NORMAL("bug: unknown erp step 0x%08x\n",
2559 retval = ZFCP_ERP_FAILED;
2566 zfcp_erp_port_strategy_open_nameserver(struct zfcp_erp_action *erp_action)
2569 struct zfcp_port *port = erp_action->port;
2571 switch (erp_action->step) {
2573 case ZFCP_ERP_STEP_UNINITIALIZED:
2574 case ZFCP_ERP_STEP_PHYS_PORT_CLOSING:
2575 case ZFCP_ERP_STEP_PORT_CLOSING:
2576 ZFCP_LOG_DEBUG("port 0x%016Lx has d_id=0x%08x -> trying open\n",
2577 port->wwpn, port->d_id);
2578 retval = zfcp_erp_port_strategy_open_port(erp_action);
2581 case ZFCP_ERP_STEP_PORT_OPENING:
2582 if (atomic_test_mask(ZFCP_STATUS_COMMON_OPEN, &port->status)) {
2583 ZFCP_LOG_DEBUG("WKA port is open\n");
2584 retval = ZFCP_ERP_SUCCEEDED;
2586 ZFCP_LOG_DEBUG("open failed for WKA port\n");
2587 retval = ZFCP_ERP_FAILED;
2589 /* this is needed anyway (dont care for retval of wakeup) */
2590 ZFCP_LOG_DEBUG("continue other open port operations\n");
2591 zfcp_erp_port_strategy_open_nameserver_wakeup(erp_action);
2595 ZFCP_LOG_NORMAL("bug: unknown erp step 0x%08x\n",
2597 retval = ZFCP_ERP_FAILED;
2606 * purpose: makes the erp thread continue with reopen (physical) port
2607 * actions which have been paused until the name server port
2608 * is opened (or failed)
2610 * returns: 0 (a kind of void retval, its not used)
2613 zfcp_erp_port_strategy_open_nameserver_wakeup(struct zfcp_erp_action
2617 unsigned long flags;
2618 struct zfcp_adapter *adapter = ns_erp_action->adapter;
2619 struct zfcp_erp_action *erp_action, *tmp;
2621 read_lock_irqsave(&adapter->erp_lock, flags);
2622 list_for_each_entry_safe(erp_action, tmp, &adapter->erp_running_head,
2624 debug_text_event(adapter->erp_dbf, 4, "p_pstnsw_n");
2625 debug_event(adapter->erp_dbf, 4, &erp_action->port->wwpn,
2627 if (erp_action->step == ZFCP_ERP_STEP_NAMESERVER_OPEN) {
2628 debug_text_event(adapter->erp_dbf, 3, "p_pstnsw_w");
2629 debug_event(adapter->erp_dbf, 3,
2630 &erp_action->port->wwpn, sizeof (wwn_t));
2631 if (atomic_test_mask(
2632 ZFCP_STATUS_COMMON_ERP_FAILED,
2633 &adapter->nameserver_port->status))
2634 zfcp_erp_port_failed(erp_action->port);
2635 zfcp_erp_action_ready(erp_action);
2638 read_unlock_irqrestore(&adapter->erp_lock, flags);
2648 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2649 * ZFCP_ERP_FAILED - action finished unsuccessfully
2652 zfcp_erp_port_forced_strategy_close(struct zfcp_erp_action *erp_action)
2655 struct zfcp_adapter *adapter = erp_action->adapter;
2656 struct zfcp_port *port = erp_action->port;
2658 zfcp_erp_timeout_init(erp_action);
2659 retval = zfcp_fsf_close_physical_port(erp_action);
2660 if (retval == -ENOMEM) {
2661 debug_text_event(adapter->erp_dbf, 5, "o_pfstc_nomem");
2662 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2663 retval = ZFCP_ERP_NOMEM;
2666 erp_action->step = ZFCP_ERP_STEP_PHYS_PORT_CLOSING;
2668 debug_text_event(adapter->erp_dbf, 5, "o_pfstc_cpf");
2669 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2670 /* could not send 'open', fail */
2671 retval = ZFCP_ERP_FAILED;
2674 debug_text_event(adapter->erp_dbf, 6, "o_pfstc_cpok");
2675 debug_event(adapter->erp_dbf, 6, &port->wwpn, sizeof (wwn_t));
2676 retval = ZFCP_ERP_CONTINUES;
2682 zfcp_erp_port_strategy_clearstati(struct zfcp_port *port)
2685 struct zfcp_adapter *adapter = port->adapter;
2687 debug_text_event(adapter->erp_dbf, 5, "p_pstclst");
2688 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2690 atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING |
2691 ZFCP_STATUS_COMMON_CLOSING |
2692 ZFCP_STATUS_COMMON_ACCESS_DENIED |
2693 ZFCP_STATUS_PORT_DID_DID |
2694 ZFCP_STATUS_PORT_PHYS_CLOSING |
2695 ZFCP_STATUS_PORT_INVALID_WWPN,
2705 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2706 * ZFCP_ERP_FAILED - action finished unsuccessfully
2709 zfcp_erp_port_strategy_close(struct zfcp_erp_action *erp_action)
2712 struct zfcp_adapter *adapter = erp_action->adapter;
2713 struct zfcp_port *port = erp_action->port;
2715 zfcp_erp_timeout_init(erp_action);
2716 retval = zfcp_fsf_close_port(erp_action);
2717 if (retval == -ENOMEM) {
2718 debug_text_event(adapter->erp_dbf, 5, "p_pstc_nomem");
2719 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2720 retval = ZFCP_ERP_NOMEM;
2723 erp_action->step = ZFCP_ERP_STEP_PORT_CLOSING;
2725 debug_text_event(adapter->erp_dbf, 5, "p_pstc_cpf");
2726 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2727 /* could not send 'close', fail */
2728 retval = ZFCP_ERP_FAILED;
2731 debug_text_event(adapter->erp_dbf, 6, "p_pstc_cpok");
2732 debug_event(adapter->erp_dbf, 6, &port->wwpn, sizeof (wwn_t));
2733 retval = ZFCP_ERP_CONTINUES;
2743 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2744 * ZFCP_ERP_FAILED - action finished unsuccessfully
2747 zfcp_erp_port_strategy_open_port(struct zfcp_erp_action *erp_action)
2750 struct zfcp_adapter *adapter = erp_action->adapter;
2751 struct zfcp_port *port = erp_action->port;
2753 zfcp_erp_timeout_init(erp_action);
2754 retval = zfcp_fsf_open_port(erp_action);
2755 if (retval == -ENOMEM) {
2756 debug_text_event(adapter->erp_dbf, 5, "p_psto_nomem");
2757 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2758 retval = ZFCP_ERP_NOMEM;
2761 erp_action->step = ZFCP_ERP_STEP_PORT_OPENING;
2763 debug_text_event(adapter->erp_dbf, 5, "p_psto_opf");
2764 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2765 /* could not send 'open', fail */
2766 retval = ZFCP_ERP_FAILED;
2769 debug_text_event(adapter->erp_dbf, 6, "p_psto_opok");
2770 debug_event(adapter->erp_dbf, 6, &port->wwpn, sizeof (wwn_t));
2771 retval = ZFCP_ERP_CONTINUES;
2781 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2782 * ZFCP_ERP_FAILED - action finished unsuccessfully
2785 zfcp_erp_port_strategy_open_common_lookup(struct zfcp_erp_action *erp_action)
2788 struct zfcp_adapter *adapter = erp_action->adapter;
2789 struct zfcp_port *port = erp_action->port;
2791 zfcp_erp_timeout_init(erp_action);
2792 retval = zfcp_ns_gid_pn_request(erp_action);
2793 if (retval == -ENOMEM) {
2794 debug_text_event(adapter->erp_dbf, 5, "p_pstn_nomem");
2795 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2796 retval = ZFCP_ERP_NOMEM;
2799 erp_action->step = ZFCP_ERP_STEP_NAMESERVER_LOOKUP;
2801 debug_text_event(adapter->erp_dbf, 5, "p_pstn_ref");
2802 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2803 /* could not send nameserver request, fail */
2804 retval = ZFCP_ERP_FAILED;
2807 debug_text_event(adapter->erp_dbf, 6, "p_pstn_reok");
2808 debug_event(adapter->erp_dbf, 6, &port->wwpn, sizeof (wwn_t));
2809 retval = ZFCP_ERP_CONTINUES;
2817 * purpose: this routine executes the 'Reopen Unit' action
2818 * currently no retries
2820 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2821 * ZFCP_ERP_SUCCEEDED - action finished successfully
2822 * ZFCP_ERP_FAILED - action finished unsuccessfully
2825 zfcp_erp_unit_strategy(struct zfcp_erp_action *erp_action)
2827 int retval = ZFCP_ERP_FAILED;
2828 struct zfcp_unit *unit = erp_action->unit;
2829 struct zfcp_adapter *adapter = erp_action->adapter;
2831 switch (erp_action->step) {
2835 * the ULP spec. begs for waiting for oustanding commands
2837 case ZFCP_ERP_STEP_UNINITIALIZED:
2838 zfcp_erp_unit_strategy_clearstati(unit);
2839 if (atomic_test_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status)) {
2840 ZFCP_LOG_DEBUG("unit 0x%016Lx is open -> "
2841 "trying close\n", unit->fcp_lun);
2842 retval = zfcp_erp_unit_strategy_close(erp_action);
2845 /* else it's already closed, fall through */
2846 case ZFCP_ERP_STEP_UNIT_CLOSING:
2847 if (atomic_test_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status)) {
2848 ZFCP_LOG_DEBUG("close failed for unit 0x%016Lx\n",
2850 retval = ZFCP_ERP_FAILED;
2852 if (erp_action->status & ZFCP_STATUS_ERP_CLOSE_ONLY)
2853 retval = ZFCP_ERP_EXIT;
2855 ZFCP_LOG_DEBUG("unit 0x%016Lx is not open -> "
2856 "trying open\n", unit->fcp_lun);
2858 zfcp_erp_unit_strategy_open(erp_action);
2863 case ZFCP_ERP_STEP_UNIT_OPENING:
2864 if (atomic_test_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status)) {
2865 ZFCP_LOG_DEBUG("unit 0x%016Lx is open\n",
2867 retval = ZFCP_ERP_SUCCEEDED;
2869 ZFCP_LOG_DEBUG("open failed for unit 0x%016Lx\n",
2871 retval = ZFCP_ERP_FAILED;
2876 debug_text_event(adapter->erp_dbf, 3, "u_ust/ret");
2877 debug_event(adapter->erp_dbf, 3, &unit->fcp_lun, sizeof (fcp_lun_t));
2878 debug_event(adapter->erp_dbf, 3, &erp_action->action, sizeof (int));
2879 debug_event(adapter->erp_dbf, 3, &retval, sizeof (int));
2884 zfcp_erp_unit_strategy_clearstati(struct zfcp_unit *unit)
2887 struct zfcp_adapter *adapter = unit->port->adapter;
2889 debug_text_event(adapter->erp_dbf, 5, "u_ustclst");
2890 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun, sizeof (fcp_lun_t));
2892 atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING |
2893 ZFCP_STATUS_COMMON_CLOSING |
2894 ZFCP_STATUS_COMMON_ACCESS_DENIED |
2895 ZFCP_STATUS_UNIT_SHARED |
2896 ZFCP_STATUS_UNIT_READONLY,
2907 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2908 * ZFCP_ERP_FAILED - action finished unsuccessfully
2911 zfcp_erp_unit_strategy_close(struct zfcp_erp_action *erp_action)
2914 struct zfcp_adapter *adapter = erp_action->adapter;
2915 struct zfcp_unit *unit = erp_action->unit;
2917 zfcp_erp_timeout_init(erp_action);
2918 retval = zfcp_fsf_close_unit(erp_action);
2919 if (retval == -ENOMEM) {
2920 debug_text_event(adapter->erp_dbf, 5, "u_ustc_nomem");
2921 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun,
2922 sizeof (fcp_lun_t));
2923 retval = ZFCP_ERP_NOMEM;
2926 erp_action->step = ZFCP_ERP_STEP_UNIT_CLOSING;
2928 debug_text_event(adapter->erp_dbf, 5, "u_ustc_cuf");
2929 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun,
2930 sizeof (fcp_lun_t));
2931 /* could not send 'close', fail */
2932 retval = ZFCP_ERP_FAILED;
2935 debug_text_event(adapter->erp_dbf, 6, "u_ustc_cuok");
2936 debug_event(adapter->erp_dbf, 6, &unit->fcp_lun, sizeof (fcp_lun_t));
2937 retval = ZFCP_ERP_CONTINUES;
2948 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2949 * ZFCP_ERP_FAILED - action finished unsuccessfully
2952 zfcp_erp_unit_strategy_open(struct zfcp_erp_action *erp_action)
2955 struct zfcp_adapter *adapter = erp_action->adapter;
2956 struct zfcp_unit *unit = erp_action->unit;
2958 zfcp_erp_timeout_init(erp_action);
2959 retval = zfcp_fsf_open_unit(erp_action);
2960 if (retval == -ENOMEM) {
2961 debug_text_event(adapter->erp_dbf, 5, "u_usto_nomem");
2962 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun,
2963 sizeof (fcp_lun_t));
2964 retval = ZFCP_ERP_NOMEM;
2967 erp_action->step = ZFCP_ERP_STEP_UNIT_OPENING;
2969 debug_text_event(adapter->erp_dbf, 5, "u_usto_ouf");
2970 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun,
2971 sizeof (fcp_lun_t));
2972 /* could not send 'open', fail */
2973 retval = ZFCP_ERP_FAILED;
2976 debug_text_event(adapter->erp_dbf, 6, "u_usto_ouok");
2977 debug_event(adapter->erp_dbf, 6, &unit->fcp_lun, sizeof (fcp_lun_t));
2978 retval = ZFCP_ERP_CONTINUES;
2984 zfcp_erp_timeout_init(struct zfcp_erp_action *erp_action)
2986 init_timer(&erp_action->timer);
2987 erp_action->timer.function = zfcp_erp_timeout_handler;
2988 erp_action->timer.data = (unsigned long) erp_action;
2989 /* jiffies will be added in zfcp_fsf_req_send */
2990 erp_action->timer.expires = ZFCP_ERP_FSFREQ_TIMEOUT;
2996 * purpose: enqueue the specified error recovery action, if needed
3001 zfcp_erp_action_enqueue(int action,
3002 struct zfcp_adapter *adapter,
3003 struct zfcp_port *port, struct zfcp_unit *unit)
3006 struct zfcp_erp_action *erp_action = NULL;
3007 int stronger_action = 0;
3011 * We need some rules here which check whether we really need
3012 * this action or whether we should just drop it.
3013 * E.g. if there is a unfinished 'Reopen Port' request then we drop a
3014 * 'Reopen Unit' request for an associated unit since we can't
3015 * satisfy this request now. A 'Reopen Port' action will trigger
3016 * 'Reopen Unit' actions when it completes.
3017 * Thus, there are only actions in the queue which can immediately be
3018 * executed. This makes the processing of the action queue more
3022 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP,
3026 debug_event(adapter->erp_dbf, 4, &action, sizeof (int));
3027 /* check whether we really need this */
3029 case ZFCP_ERP_ACTION_REOPEN_UNIT:
3030 if (atomic_test_mask
3031 (ZFCP_STATUS_COMMON_ERP_INUSE, &unit->status)) {
3032 debug_text_event(adapter->erp_dbf, 4, "u_actenq_drp");
3033 debug_event(adapter->erp_dbf, 4, &port->wwpn,
3035 debug_event(adapter->erp_dbf, 4, &unit->fcp_lun,
3036 sizeof (fcp_lun_t));
3039 if (!atomic_test_mask
3040 (ZFCP_STATUS_COMMON_RUNNING, &port->status) ||
3042 (ZFCP_STATUS_COMMON_ERP_FAILED, &port->status)) {
3045 if (!atomic_test_mask
3046 (ZFCP_STATUS_COMMON_UNBLOCKED, &port->status)) {
3047 stronger_action = ZFCP_ERP_ACTION_REOPEN_PORT;
3050 /* fall through !!! */
3052 case ZFCP_ERP_ACTION_REOPEN_PORT:
3053 if (atomic_test_mask
3054 (ZFCP_STATUS_COMMON_ERP_INUSE, &port->status)) {
3055 debug_text_event(adapter->erp_dbf, 4, "p_actenq_drp");
3056 debug_event(adapter->erp_dbf, 4, &port->wwpn,
3060 /* fall through !!! */
3062 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
3063 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_INUSE,
3065 if (port->erp_action.action !=
3066 ZFCP_ERP_ACTION_REOPEN_PORT_FORCED) {
3067 ZFCP_LOG_INFO("dropped erp action %i (port "
3068 "0x%016Lx, action in use: %i)\n",
3070 port->erp_action.action);
3071 debug_text_event(adapter->erp_dbf, 4,
3074 debug_text_event(adapter->erp_dbf, 4,
3076 debug_event(adapter->erp_dbf, 4, &port->wwpn,
3080 if (!atomic_test_mask
3081 (ZFCP_STATUS_COMMON_RUNNING, &adapter->status) ||
3083 (ZFCP_STATUS_COMMON_ERP_FAILED, &adapter->status)) {
3086 if (!atomic_test_mask
3087 (ZFCP_STATUS_COMMON_UNBLOCKED, &adapter->status)) {
3088 stronger_action = ZFCP_ERP_ACTION_REOPEN_ADAPTER;
3091 /* fall through !!! */
3093 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
3094 if (atomic_test_mask
3095 (ZFCP_STATUS_COMMON_ERP_INUSE, &adapter->status)) {
3096 debug_text_event(adapter->erp_dbf, 4, "a_actenq_drp");
3102 debug_text_exception(adapter->erp_dbf, 1, "a_actenq_bug");
3103 debug_event(adapter->erp_dbf, 1, &action, sizeof (int));
3104 ZFCP_LOG_NORMAL("bug: unknown erp action requested "
3105 "on adapter %s (action=%d)\n",
3106 zfcp_get_busid_by_adapter(adapter), action);
3110 /* check whether we need something stronger first */
3111 if (stronger_action) {
3112 debug_text_event(adapter->erp_dbf, 4, "a_actenq_str");
3113 debug_event(adapter->erp_dbf, 4, &stronger_action,
3115 ZFCP_LOG_DEBUG("stronger erp action %d needed before "
3116 "erp action %d on adapter %s\n",
3117 stronger_action, action,
3118 zfcp_get_busid_by_adapter(adapter));
3119 action = stronger_action;
3122 /* mark adapter to have some error recovery pending */
3123 atomic_set_mask(ZFCP_STATUS_ADAPTER_ERP_PENDING, &adapter->status);
3125 /* setup error recovery action */
3128 case ZFCP_ERP_ACTION_REOPEN_UNIT:
3129 zfcp_unit_get(unit);
3130 atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &unit->status);
3131 erp_action = &unit->erp_action;
3132 if (!atomic_test_mask
3133 (ZFCP_STATUS_COMMON_RUNNING, &unit->status))
3134 status = ZFCP_STATUS_ERP_CLOSE_ONLY;
3137 case ZFCP_ERP_ACTION_REOPEN_PORT:
3138 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
3139 zfcp_port_get(port);
3140 zfcp_erp_action_dismiss_port(port);
3141 atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &port->status);
3142 erp_action = &port->erp_action;
3143 if (!atomic_test_mask
3144 (ZFCP_STATUS_COMMON_RUNNING, &port->status))
3145 status = ZFCP_STATUS_ERP_CLOSE_ONLY;
3148 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
3149 zfcp_adapter_get(adapter);
3150 zfcp_erp_action_dismiss_adapter(adapter);
3151 atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &adapter->status);
3152 erp_action = &adapter->erp_action;
3153 if (!atomic_test_mask
3154 (ZFCP_STATUS_COMMON_RUNNING, &adapter->status))
3155 status = ZFCP_STATUS_ERP_CLOSE_ONLY;
3159 debug_text_event(adapter->erp_dbf, 4, "a_actenq");
3161 memset(erp_action, 0, sizeof (struct zfcp_erp_action));
3162 erp_action->adapter = adapter;
3163 erp_action->port = port;
3164 erp_action->unit = unit;
3165 erp_action->action = action;
3166 erp_action->status = status;
3168 ++adapter->erp_total_count;
3170 /* finally put it into 'ready' queue and kick erp thread */
3171 list_add(&erp_action->list, &adapter->erp_ready_head);
3172 up(&adapter->erp_ready_sem);
3179 zfcp_erp_action_dequeue(struct zfcp_erp_action *erp_action)
3182 struct zfcp_adapter *adapter = erp_action->adapter;
3184 --adapter->erp_total_count;
3185 if (erp_action->status & ZFCP_STATUS_ERP_LOWMEM) {
3186 --adapter->erp_low_mem_count;
3187 erp_action->status &= ~ZFCP_STATUS_ERP_LOWMEM;
3190 debug_text_event(adapter->erp_dbf, 4, "a_actdeq");
3191 debug_event(adapter->erp_dbf, 4, &erp_action->action, sizeof (int));
3192 list_del(&erp_action->list);
3193 switch (erp_action->action) {
3194 case ZFCP_ERP_ACTION_REOPEN_UNIT:
3195 atomic_clear_mask(ZFCP_STATUS_COMMON_ERP_INUSE,
3196 &erp_action->unit->status);
3198 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
3199 case ZFCP_ERP_ACTION_REOPEN_PORT:
3200 atomic_clear_mask(ZFCP_STATUS_COMMON_ERP_INUSE,
3201 &erp_action->port->status);
3203 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
3204 atomic_clear_mask(ZFCP_STATUS_COMMON_ERP_INUSE,
3205 &erp_action->adapter->status);
3215 * zfcp_erp_action_cleanup
3217 * Register unit with scsi stack if appropriate and fix reference counts.
3218 * Note: Temporary units are not registered with scsi stack.
3221 zfcp_erp_action_cleanup(int action, struct zfcp_adapter *adapter,
3222 struct zfcp_port *port, struct zfcp_unit *unit,
3226 case ZFCP_ERP_ACTION_REOPEN_UNIT:
3227 if ((result == ZFCP_ERP_SUCCEEDED)
3228 && (!atomic_test_mask(ZFCP_STATUS_UNIT_TEMPORARY,
3232 atomic_set_mask(ZFCP_STATUS_UNIT_REGISTERED,
3234 scsi_scan_target(&port->rport->dev, 0,
3235 port->rport->scsi_target_id,
3238 zfcp_unit_put(unit);
3240 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
3241 case ZFCP_ERP_ACTION_REOPEN_PORT:
3242 if (atomic_test_mask(ZFCP_STATUS_PORT_NO_WWPN,
3244 zfcp_port_put(port);
3248 if ((result == ZFCP_ERP_SUCCEEDED)
3250 struct fc_rport_identifiers ids;
3251 ids.node_name = port->wwnn;
3252 ids.port_name = port->wwpn;
3253 ids.port_id = port->d_id;
3254 ids.roles = FC_RPORT_ROLE_FCP_TARGET;
3256 fc_remote_port_add(adapter->scsi_host, 0, &ids);
3258 ZFCP_LOG_NORMAL("failed registration of rport"
3259 "(adapter %s, wwpn=0x%016Lx)\n",
3260 zfcp_get_busid_by_port(port),
3263 scsi_flush_work(adapter->scsi_host);
3264 port->rport->maxframe_size = port->maxframe_size;
3265 port->rport->supported_classes =
3266 port->supported_classes;
3269 if ((result != ZFCP_ERP_SUCCEEDED) && port->rport) {
3270 fc_remote_port_delete(port->rport);
3273 zfcp_port_put(port);
3275 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
3276 if (result != ZFCP_ERP_SUCCEEDED) {
3277 struct zfcp_port *port;
3278 list_for_each_entry(port, &adapter->port_list_head, list)
3280 !atomic_test_mask(ZFCP_STATUS_PORT_WKA,
3282 fc_remote_port_delete(port->rport);
3286 zfcp_adapter_put(adapter);
3295 zfcp_erp_action_dismiss_adapter(struct zfcp_adapter *adapter)
3298 struct zfcp_port *port;
3300 debug_text_event(adapter->erp_dbf, 5, "a_actab");
3301 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &adapter->status))
3302 zfcp_erp_action_dismiss(&adapter->erp_action);
3304 list_for_each_entry(port, &adapter->port_list_head, list)
3305 zfcp_erp_action_dismiss_port(port);
3311 zfcp_erp_action_dismiss_port(struct zfcp_port *port)
3314 struct zfcp_unit *unit;
3315 struct zfcp_adapter *adapter = port->adapter;
3317 debug_text_event(adapter->erp_dbf, 5, "p_actab");
3318 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
3319 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &port->status))
3320 zfcp_erp_action_dismiss(&port->erp_action);
3322 list_for_each_entry(unit, &port->unit_list_head, list)
3323 zfcp_erp_action_dismiss_unit(unit);
3329 zfcp_erp_action_dismiss_unit(struct zfcp_unit *unit)
3332 struct zfcp_adapter *adapter = unit->port->adapter;
3334 debug_text_event(adapter->erp_dbf, 5, "u_actab");
3335 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun, sizeof (fcp_lun_t));
3336 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &unit->status))
3337 zfcp_erp_action_dismiss(&unit->erp_action);
3343 zfcp_erp_action_to_running(struct zfcp_erp_action *erp_action)
3345 struct zfcp_adapter *adapter = erp_action->adapter;
3347 debug_text_event(adapter->erp_dbf, 6, "a_toru");
3348 debug_event(adapter->erp_dbf, 6, &erp_action->action, sizeof (int));
3349 list_move(&erp_action->list, &erp_action->adapter->erp_running_head);
3353 zfcp_erp_action_to_ready(struct zfcp_erp_action *erp_action)
3355 struct zfcp_adapter *adapter = erp_action->adapter;
3357 debug_text_event(adapter->erp_dbf, 6, "a_tore");
3358 debug_event(adapter->erp_dbf, 6, &erp_action->action, sizeof (int));
3359 list_move(&erp_action->list, &erp_action->adapter->erp_ready_head);
3363 zfcp_erp_port_boxed(struct zfcp_port *port)
3365 struct zfcp_adapter *adapter = port->adapter;
3366 unsigned long flags;
3368 debug_text_event(adapter->erp_dbf, 3, "p_access_boxed");
3369 debug_event(adapter->erp_dbf, 3, &port->wwpn, sizeof(wwn_t));
3370 read_lock_irqsave(&zfcp_data.config_lock, flags);
3371 zfcp_erp_modify_port_status(port,
3372 ZFCP_STATUS_COMMON_ACCESS_BOXED,
3374 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
3375 zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED);
3379 zfcp_erp_unit_boxed(struct zfcp_unit *unit)
3381 struct zfcp_adapter *adapter = unit->port->adapter;
3383 debug_text_event(adapter->erp_dbf, 3, "u_access_boxed");
3384 debug_event(adapter->erp_dbf, 3, &unit->fcp_lun, sizeof(fcp_lun_t));
3385 zfcp_erp_modify_unit_status(unit,
3386 ZFCP_STATUS_COMMON_ACCESS_BOXED,
3388 zfcp_erp_unit_reopen(unit, ZFCP_STATUS_COMMON_ERP_FAILED);
3392 zfcp_erp_port_access_denied(struct zfcp_port *port)
3394 struct zfcp_adapter *adapter = port->adapter;
3395 unsigned long flags;
3397 debug_text_event(adapter->erp_dbf, 3, "p_access_denied");
3398 debug_event(adapter->erp_dbf, 3, &port->wwpn, sizeof(wwn_t));
3399 read_lock_irqsave(&zfcp_data.config_lock, flags);
3400 zfcp_erp_modify_port_status(port,
3401 ZFCP_STATUS_COMMON_ERP_FAILED |
3402 ZFCP_STATUS_COMMON_ACCESS_DENIED,
3404 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
3408 zfcp_erp_unit_access_denied(struct zfcp_unit *unit)
3410 struct zfcp_adapter *adapter = unit->port->adapter;
3412 debug_text_event(adapter->erp_dbf, 3, "u_access_denied");
3413 debug_event(adapter->erp_dbf, 3, &unit->fcp_lun, sizeof(fcp_lun_t));
3414 zfcp_erp_modify_unit_status(unit,
3415 ZFCP_STATUS_COMMON_ERP_FAILED |
3416 ZFCP_STATUS_COMMON_ACCESS_DENIED,
3421 zfcp_erp_adapter_access_changed(struct zfcp_adapter *adapter)
3423 struct zfcp_port *port;
3424 unsigned long flags;
3426 if (adapter->connection_features & FSF_FEATURE_NPIV_MODE)
3429 debug_text_event(adapter->erp_dbf, 3, "a_access_recover");
3430 debug_event(adapter->erp_dbf, 3, zfcp_get_busid_by_adapter(adapter), 8);
3432 read_lock_irqsave(&zfcp_data.config_lock, flags);
3433 if (adapter->nameserver_port)
3434 zfcp_erp_port_access_changed(adapter->nameserver_port);
3435 list_for_each_entry(port, &adapter->port_list_head, list)
3436 if (port != adapter->nameserver_port)
3437 zfcp_erp_port_access_changed(port);
3438 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
3442 zfcp_erp_port_access_changed(struct zfcp_port *port)
3444 struct zfcp_adapter *adapter = port->adapter;
3445 struct zfcp_unit *unit;
3447 debug_text_event(adapter->erp_dbf, 3, "p_access_recover");
3448 debug_event(adapter->erp_dbf, 3, &port->wwpn, sizeof(wwn_t));
3450 if (!atomic_test_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED,
3452 !atomic_test_mask(ZFCP_STATUS_COMMON_ACCESS_BOXED,
3454 if (!atomic_test_mask(ZFCP_STATUS_PORT_WKA, &port->status))
3455 list_for_each_entry(unit, &port->unit_list_head, list)
3456 zfcp_erp_unit_access_changed(unit);
3460 ZFCP_LOG_NORMAL("reopen of port 0x%016Lx on adapter %s "
3461 "(due to ACT update)\n",
3462 port->wwpn, zfcp_get_busid_by_adapter(adapter));
3463 if (zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED) != 0)
3464 ZFCP_LOG_NORMAL("failed reopen of port"
3465 "(adapter %s, wwpn=0x%016Lx)\n",
3466 zfcp_get_busid_by_adapter(adapter), port->wwpn);
3470 zfcp_erp_unit_access_changed(struct zfcp_unit *unit)
3472 struct zfcp_adapter *adapter = unit->port->adapter;
3474 debug_text_event(adapter->erp_dbf, 3, "u_access_recover");
3475 debug_event(adapter->erp_dbf, 3, &unit->fcp_lun, sizeof(fcp_lun_t));
3477 if (!atomic_test_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED,
3479 !atomic_test_mask(ZFCP_STATUS_COMMON_ACCESS_BOXED,
3483 ZFCP_LOG_NORMAL("reopen of unit 0x%016Lx on port 0x%016Lx "
3484 " on adapter %s (due to ACT update)\n",
3485 unit->fcp_lun, unit->port->wwpn,
3486 zfcp_get_busid_by_adapter(adapter));
3487 if (zfcp_erp_unit_reopen(unit, ZFCP_STATUS_COMMON_ERP_FAILED) != 0)
3488 ZFCP_LOG_NORMAL("failed reopen of unit (adapter %s, "
3489 "wwpn=0x%016Lx, fcp_lun=0x%016Lx)\n",
3490 zfcp_get_busid_by_adapter(adapter),
3491 unit->port->wwpn, unit->fcp_lun);
3494 #undef ZFCP_LOG_AREA