3 * linux/drivers/s390/scsi/zfcp_erp.c
5 * FCP adapter driver for IBM eServer zSeries
7 * (C) Copyright IBM Corp. 2002, 2004
9 * Author(s): Martin Peschke <mpeschke@de.ibm.com>
10 * Raimund Schroeder <raimund.schroeder@de.ibm.com>
13 * Stefan Bader <stefan.bader@de.ibm.com>
14 * Heiko Carstens <heiko.carstens@de.ibm.com>
15 * Andreas Herrmann <aherrman@de.ibm.com>
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2, or (at your option)
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
32 #define ZFCP_LOG_AREA ZFCP_LOG_AREA_ERP
36 static int zfcp_erp_adisc(struct zfcp_port *);
37 static void zfcp_erp_adisc_handler(unsigned long);
39 static int zfcp_erp_adapter_reopen_internal(struct zfcp_adapter *, int);
40 static int zfcp_erp_port_forced_reopen_internal(struct zfcp_port *, int);
41 static int zfcp_erp_port_reopen_internal(struct zfcp_port *, int);
42 static int zfcp_erp_unit_reopen_internal(struct zfcp_unit *, int);
44 static int zfcp_erp_port_reopen_all_internal(struct zfcp_adapter *, int);
45 static int zfcp_erp_unit_reopen_all_internal(struct zfcp_port *, int);
47 static void zfcp_erp_adapter_block(struct zfcp_adapter *, int);
48 static void zfcp_erp_adapter_unblock(struct zfcp_adapter *);
49 static void zfcp_erp_port_block(struct zfcp_port *, int);
50 static void zfcp_erp_port_unblock(struct zfcp_port *);
51 static void zfcp_erp_unit_block(struct zfcp_unit *, int);
52 static void zfcp_erp_unit_unblock(struct zfcp_unit *);
54 static int zfcp_erp_thread(void *);
56 static int zfcp_erp_strategy(struct zfcp_erp_action *);
58 static int zfcp_erp_strategy_do_action(struct zfcp_erp_action *);
59 static int zfcp_erp_strategy_memwait(struct zfcp_erp_action *);
60 static int zfcp_erp_strategy_check_target(struct zfcp_erp_action *, int);
61 static int zfcp_erp_strategy_check_unit(struct zfcp_unit *, int);
62 static int zfcp_erp_strategy_check_port(struct zfcp_port *, int);
63 static int zfcp_erp_strategy_check_adapter(struct zfcp_adapter *, int);
64 static int zfcp_erp_strategy_statechange(int, u32, struct zfcp_adapter *,
66 struct zfcp_unit *, int);
67 static inline int zfcp_erp_strategy_statechange_detected(atomic_t *, u32);
68 static int zfcp_erp_strategy_followup_actions(int, struct zfcp_adapter *,
70 struct zfcp_unit *, int);
71 static int zfcp_erp_strategy_check_queues(struct zfcp_adapter *);
72 static int zfcp_erp_strategy_check_action(struct zfcp_erp_action *, int);
74 static int zfcp_erp_adapter_strategy(struct zfcp_erp_action *);
75 static int zfcp_erp_adapter_strategy_generic(struct zfcp_erp_action *, int);
76 static int zfcp_erp_adapter_strategy_close(struct zfcp_erp_action *);
77 static int zfcp_erp_adapter_strategy_close_qdio(struct zfcp_erp_action *);
78 static int zfcp_erp_adapter_strategy_close_fsf(struct zfcp_erp_action *);
79 static int zfcp_erp_adapter_strategy_open(struct zfcp_erp_action *);
80 static int zfcp_erp_adapter_strategy_open_qdio(struct zfcp_erp_action *);
81 static int zfcp_erp_adapter_strategy_open_fsf(struct zfcp_erp_action *);
82 static int zfcp_erp_adapter_strategy_open_fsf_xconfig(struct zfcp_erp_action *);
83 static int zfcp_erp_adapter_strategy_open_fsf_xport(struct zfcp_erp_action *);
84 static int zfcp_erp_adapter_strategy_open_fsf_statusread(
85 struct zfcp_erp_action *);
87 static int zfcp_erp_port_forced_strategy(struct zfcp_erp_action *);
88 static int zfcp_erp_port_forced_strategy_close(struct zfcp_erp_action *);
90 static int zfcp_erp_port_strategy(struct zfcp_erp_action *);
91 static int zfcp_erp_port_strategy_clearstati(struct zfcp_port *);
92 static int zfcp_erp_port_strategy_close(struct zfcp_erp_action *);
93 static int zfcp_erp_port_strategy_open(struct zfcp_erp_action *);
94 static int zfcp_erp_port_strategy_open_nameserver(struct zfcp_erp_action *);
95 static int zfcp_erp_port_strategy_open_nameserver_wakeup(
96 struct zfcp_erp_action *);
97 static int zfcp_erp_port_strategy_open_common(struct zfcp_erp_action *);
98 static int zfcp_erp_port_strategy_open_common_lookup(struct zfcp_erp_action *);
99 static int zfcp_erp_port_strategy_open_port(struct zfcp_erp_action *);
101 static int zfcp_erp_unit_strategy(struct zfcp_erp_action *);
102 static int zfcp_erp_unit_strategy_clearstati(struct zfcp_unit *);
103 static int zfcp_erp_unit_strategy_close(struct zfcp_erp_action *);
104 static int zfcp_erp_unit_strategy_open(struct zfcp_erp_action *);
106 static int zfcp_erp_action_dismiss_adapter(struct zfcp_adapter *);
107 static int zfcp_erp_action_dismiss_port(struct zfcp_port *);
108 static int zfcp_erp_action_dismiss_unit(struct zfcp_unit *);
109 static int zfcp_erp_action_dismiss(struct zfcp_erp_action *);
111 static int zfcp_erp_action_enqueue(int, struct zfcp_adapter *,
112 struct zfcp_port *, struct zfcp_unit *);
113 static int zfcp_erp_action_dequeue(struct zfcp_erp_action *);
114 static void zfcp_erp_action_cleanup(int, struct zfcp_adapter *,
115 struct zfcp_port *, struct zfcp_unit *,
118 static void zfcp_erp_action_ready(struct zfcp_erp_action *);
119 static int zfcp_erp_action_exists(struct zfcp_erp_action *);
121 static inline void zfcp_erp_action_to_ready(struct zfcp_erp_action *);
122 static inline void zfcp_erp_action_to_running(struct zfcp_erp_action *);
124 static void zfcp_erp_memwait_handler(unsigned long);
125 static void zfcp_erp_timeout_handler(unsigned long);
126 static inline void zfcp_erp_timeout_init(struct zfcp_erp_action *);
129 * zfcp_fsf_request_timeout_handler - called if a request timed out
130 * @data: pointer to adapter for handler function
132 * This function needs to be called if requests (ELS, Generic Service,
133 * or SCSI commands) exceed a certain time limit. The assumption is
134 * that after the time limit the adapter get stuck. So we trigger a reopen of
135 * the adapter. This should not be used for error recovery, SCSI abort
136 * commands and SCSI requests from SCSI mid-layer.
139 zfcp_fsf_request_timeout_handler(unsigned long data)
141 struct zfcp_adapter *adapter;
143 adapter = (struct zfcp_adapter *) data;
145 zfcp_erp_adapter_reopen(adapter, 0);
149 * function: zfcp_fsf_scsi_er_timeout_handler
151 * purpose: This function needs to be called whenever a SCSI error recovery
152 * action (abort/reset) does not return.
153 * Re-opening the adapter means that the command can be returned
154 * by zfcp (it is guarranteed that it does not return via the
155 * adapter anymore). The buffer can then be used again.
160 zfcp_fsf_scsi_er_timeout_handler(unsigned long data)
162 struct zfcp_adapter *adapter = (struct zfcp_adapter *) data;
164 ZFCP_LOG_NORMAL("warning: SCSI error recovery timed out. "
165 "Restarting all operations on the adapter %s\n",
166 zfcp_get_busid_by_adapter(adapter));
167 debug_text_event(adapter->erp_dbf, 1, "eh_lmem_tout");
168 zfcp_erp_adapter_reopen(adapter, 0);
176 * purpose: called if an adapter failed,
177 * initiates adapter recovery which is done
180 * returns: 0 - initiated action succesfully
181 * <0 - failed to initiate action
184 zfcp_erp_adapter_reopen_internal(struct zfcp_adapter *adapter, int clear_mask)
188 debug_text_event(adapter->erp_dbf, 5, "a_ro");
189 ZFCP_LOG_DEBUG("reopen adapter %s\n",
190 zfcp_get_busid_by_adapter(adapter));
192 zfcp_erp_adapter_block(adapter, clear_mask);
194 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED, &adapter->status)) {
195 ZFCP_LOG_DEBUG("skipped reopen of failed adapter %s\n",
196 zfcp_get_busid_by_adapter(adapter));
197 debug_text_event(adapter->erp_dbf, 5, "a_ro_f");
198 /* ensure propagation of failed status to new devices */
199 zfcp_erp_adapter_failed(adapter);
203 retval = zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_ADAPTER,
204 adapter, NULL, NULL);
213 * purpose: Wrappper for zfcp_erp_adapter_reopen_internal
214 * used to ensure the correct locking
216 * returns: 0 - initiated action succesfully
217 * <0 - failed to initiate action
220 zfcp_erp_adapter_reopen(struct zfcp_adapter *adapter, int clear_mask)
225 read_lock_irqsave(&zfcp_data.config_lock, flags);
226 write_lock(&adapter->erp_lock);
227 retval = zfcp_erp_adapter_reopen_internal(adapter, clear_mask);
228 write_unlock(&adapter->erp_lock);
229 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
242 zfcp_erp_adapter_shutdown(struct zfcp_adapter *adapter, int clear_mask)
246 retval = zfcp_erp_adapter_reopen(adapter,
247 ZFCP_STATUS_COMMON_RUNNING |
248 ZFCP_STATUS_COMMON_ERP_FAILED |
262 zfcp_erp_port_shutdown(struct zfcp_port *port, int clear_mask)
266 retval = zfcp_erp_port_reopen(port,
267 ZFCP_STATUS_COMMON_RUNNING |
268 ZFCP_STATUS_COMMON_ERP_FAILED |
282 zfcp_erp_unit_shutdown(struct zfcp_unit *unit, int clear_mask)
286 retval = zfcp_erp_unit_reopen(unit,
287 ZFCP_STATUS_COMMON_RUNNING |
288 ZFCP_STATUS_COMMON_ERP_FAILED |
296 * zfcp_erp_adisc - send ADISC ELS command
297 * @port: port structure
300 zfcp_erp_adisc(struct zfcp_port *port)
302 struct zfcp_adapter *adapter = port->adapter;
303 struct zfcp_send_els *send_els;
304 struct zfcp_ls_adisc *adisc;
305 void *address = NULL;
307 struct timer_list *timer;
309 send_els = kmalloc(sizeof(struct zfcp_send_els), GFP_ATOMIC);
310 if (send_els == NULL)
312 memset(send_els, 0, sizeof(*send_els));
314 send_els->req = kmalloc(sizeof(struct scatterlist), GFP_ATOMIC);
315 if (send_els->req == NULL)
317 memset(send_els->req, 0, sizeof(*send_els->req));
319 send_els->resp = kmalloc(sizeof(struct scatterlist), GFP_ATOMIC);
320 if (send_els->resp == NULL)
322 memset(send_els->resp, 0, sizeof(*send_els->resp));
324 address = (void *) get_zeroed_page(GFP_ATOMIC);
328 zfcp_address_to_sg(address, send_els->req);
329 address += PAGE_SIZE >> 1;
330 zfcp_address_to_sg(address, send_els->resp);
331 send_els->req_count = send_els->resp_count = 1;
333 send_els->adapter = adapter;
334 send_els->port = port;
335 send_els->d_id = port->d_id;
336 send_els->handler = zfcp_erp_adisc_handler;
337 send_els->handler_data = (unsigned long) send_els;
339 adisc = zfcp_sg_to_address(send_els->req);
340 send_els->ls_code = adisc->code = ZFCP_LS_ADISC;
342 send_els->req->length = sizeof(struct zfcp_ls_adisc);
343 send_els->resp->length = sizeof(struct zfcp_ls_adisc_acc);
345 /* acc. to FC-FS, hard_nport_id in ADISC should not be set for ports
346 without FC-AL-2 capability, so we don't set it */
347 adisc->wwpn = fc_host_port_name(adapter->scsi_host);
348 adisc->wwnn = fc_host_node_name(adapter->scsi_host);
349 adisc->nport_id = fc_host_port_id(adapter->scsi_host);
350 ZFCP_LOG_INFO("ADISC request from s_id 0x%08x to d_id 0x%08x "
351 "(wwpn=0x%016Lx, wwnn=0x%016Lx, "
352 "hard_nport_id=0x%08x, nport_id=0x%08x)\n",
353 adisc->nport_id, send_els->d_id, (wwn_t) adisc->wwpn,
354 (wwn_t) adisc->wwnn, adisc->hard_nport_id,
357 timer = kmalloc(sizeof(struct timer_list), GFP_ATOMIC);
362 timer->function = zfcp_fsf_request_timeout_handler;
363 timer->data = (unsigned long) adapter;
364 timer->expires = ZFCP_FSF_REQUEST_TIMEOUT;
365 send_els->timer = timer;
367 retval = zfcp_fsf_send_els(send_els);
369 ZFCP_LOG_NORMAL("error: initiation of Send ELS failed for port "
370 "0x%08x on adapter %s\n", send_els->d_id,
371 zfcp_get_busid_by_adapter(adapter));
372 del_timer(send_els->timer);
382 __free_pages(send_els->req->page, 0);
383 if (send_els != NULL) {
384 kfree(send_els->timer);
385 kfree(send_els->req);
386 kfree(send_els->resp);
395 * zfcp_erp_adisc_handler - handler for ADISC ELS command
396 * @data: pointer to struct zfcp_send_els
398 * If ADISC failed (LS_RJT or timed out) forced reopen of the port is triggered.
401 zfcp_erp_adisc_handler(unsigned long data)
403 struct zfcp_send_els *send_els;
404 struct zfcp_port *port;
405 struct zfcp_adapter *adapter;
407 struct zfcp_ls_adisc_acc *adisc;
409 send_els = (struct zfcp_send_els *) data;
411 del_timer(send_els->timer);
413 adapter = send_els->adapter;
414 port = send_els->port;
415 d_id = send_els->d_id;
417 /* request rejected or timed out */
418 if (send_els->status != 0) {
419 ZFCP_LOG_NORMAL("ELS request rejected/timed out, "
420 "force physical port reopen "
421 "(adapter %s, port d_id=0x%08x)\n",
422 zfcp_get_busid_by_adapter(adapter), d_id);
423 debug_text_event(adapter->erp_dbf, 3, "forcreop");
424 if (zfcp_erp_port_forced_reopen(port, 0))
425 ZFCP_LOG_NORMAL("failed reopen of port "
426 "(adapter %s, wwpn=0x%016Lx)\n",
427 zfcp_get_busid_by_port(port),
432 adisc = zfcp_sg_to_address(send_els->resp);
434 ZFCP_LOG_INFO("ADISC response from d_id 0x%08x to s_id "
435 "0x%08x (wwpn=0x%016Lx, wwnn=0x%016Lx, "
436 "hard_nport_id=0x%08x, nport_id=0x%08x)\n",
437 d_id, fc_host_port_id(adapter->scsi_host),
438 (wwn_t) adisc->wwpn, (wwn_t) adisc->wwnn,
439 adisc->hard_nport_id, adisc->nport_id);
441 /* set wwnn for port */
443 port->wwnn = adisc->wwnn;
445 if (port->wwpn != adisc->wwpn) {
446 ZFCP_LOG_NORMAL("d_id assignment changed, reopening "
447 "port (adapter %s, wwpn=0x%016Lx, "
448 "adisc_resp_wwpn=0x%016Lx)\n",
449 zfcp_get_busid_by_port(port),
450 port->wwpn, (wwn_t) adisc->wwpn);
451 if (zfcp_erp_port_reopen(port, 0))
452 ZFCP_LOG_NORMAL("failed reopen of port "
453 "(adapter %s, wwpn=0x%016Lx)\n",
454 zfcp_get_busid_by_port(port),
460 __free_pages(send_els->req->page, 0);
461 kfree(send_els->timer);
462 kfree(send_els->req);
463 kfree(send_els->resp);
469 * zfcp_test_link - lightweight link test procedure
470 * @port: port to be tested
472 * Test status of a link to a remote port using the ELS command ADISC.
475 zfcp_test_link(struct zfcp_port *port)
480 retval = zfcp_erp_adisc(port);
483 ZFCP_LOG_NORMAL("reopen needed for port 0x%016Lx "
484 "on adapter %s\n ", port->wwpn,
485 zfcp_get_busid_by_port(port));
486 retval = zfcp_erp_port_forced_reopen(port, 0);
488 ZFCP_LOG_NORMAL("reopen of remote port 0x%016Lx "
489 "on adapter %s failed\n", port->wwpn,
490 zfcp_get_busid_by_port(port));
502 * purpose: called if a port failed to be opened normally
503 * initiates Forced Reopen recovery which is done
506 * returns: 0 - initiated action succesfully
507 * <0 - failed to initiate action
510 zfcp_erp_port_forced_reopen_internal(struct zfcp_port *port, int clear_mask)
513 struct zfcp_adapter *adapter = port->adapter;
515 debug_text_event(adapter->erp_dbf, 5, "pf_ro");
516 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
518 ZFCP_LOG_DEBUG("forced reopen of port 0x%016Lx on adapter %s\n",
519 port->wwpn, zfcp_get_busid_by_port(port));
521 zfcp_erp_port_block(port, clear_mask);
523 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED, &port->status)) {
524 ZFCP_LOG_DEBUG("skipped forced reopen of failed port 0x%016Lx "
525 "on adapter %s\n", port->wwpn,
526 zfcp_get_busid_by_port(port));
527 debug_text_event(adapter->erp_dbf, 5, "pf_ro_f");
528 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
533 retval = zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_PORT_FORCED,
534 port->adapter, port, NULL);
543 * purpose: Wrappper for zfcp_erp_port_forced_reopen_internal
544 * used to ensure the correct locking
546 * returns: 0 - initiated action succesfully
547 * <0 - failed to initiate action
550 zfcp_erp_port_forced_reopen(struct zfcp_port *port, int clear_mask)
554 struct zfcp_adapter *adapter;
556 adapter = port->adapter;
557 read_lock_irqsave(&zfcp_data.config_lock, flags);
558 write_lock(&adapter->erp_lock);
559 retval = zfcp_erp_port_forced_reopen_internal(port, clear_mask);
560 write_unlock(&adapter->erp_lock);
561 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
569 * purpose: called if a port is to be opened
570 * initiates Reopen recovery which is done
573 * returns: 0 - initiated action succesfully
574 * <0 - failed to initiate action
577 zfcp_erp_port_reopen_internal(struct zfcp_port *port, int clear_mask)
580 struct zfcp_adapter *adapter = port->adapter;
582 debug_text_event(adapter->erp_dbf, 5, "p_ro");
583 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
585 ZFCP_LOG_DEBUG("reopen of port 0x%016Lx on adapter %s\n",
586 port->wwpn, zfcp_get_busid_by_port(port));
588 zfcp_erp_port_block(port, clear_mask);
590 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED, &port->status)) {
591 ZFCP_LOG_DEBUG("skipped reopen of failed port 0x%016Lx "
592 "on adapter %s\n", port->wwpn,
593 zfcp_get_busid_by_port(port));
594 debug_text_event(adapter->erp_dbf, 5, "p_ro_f");
595 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
596 /* ensure propagation of failed status to new devices */
597 zfcp_erp_port_failed(port);
602 retval = zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_PORT,
603 port->adapter, port, NULL);
610 * zfcp_erp_port_reopen - initiate reopen of a remote port
611 * @port: port to be reopened
612 * @clear_mask: specifies flags in port status to be cleared
613 * Return: 0 on success, < 0 on error
615 * This is a wrappper function for zfcp_erp_port_reopen_internal. It ensures
616 * correct locking. An error recovery task is initiated to do the reopen.
617 * To wait for the completion of the reopen zfcp_erp_wait should be used.
620 zfcp_erp_port_reopen(struct zfcp_port *port, int clear_mask)
624 struct zfcp_adapter *adapter = port->adapter;
626 read_lock_irqsave(&zfcp_data.config_lock, flags);
627 write_lock(&adapter->erp_lock);
628 retval = zfcp_erp_port_reopen_internal(port, clear_mask);
629 write_unlock(&adapter->erp_lock);
630 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
638 * purpose: called if a unit is to be opened
639 * initiates Reopen recovery which is done
642 * returns: 0 - initiated action succesfully
643 * <0 - failed to initiate action
646 zfcp_erp_unit_reopen_internal(struct zfcp_unit *unit, int clear_mask)
649 struct zfcp_adapter *adapter = unit->port->adapter;
651 debug_text_event(adapter->erp_dbf, 5, "u_ro");
652 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun, sizeof (fcp_lun_t));
653 ZFCP_LOG_DEBUG("reopen of unit 0x%016Lx on port 0x%016Lx "
654 "on adapter %s\n", unit->fcp_lun,
655 unit->port->wwpn, zfcp_get_busid_by_unit(unit));
657 zfcp_erp_unit_block(unit, clear_mask);
659 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED, &unit->status)) {
660 ZFCP_LOG_DEBUG("skipped reopen of failed unit 0x%016Lx "
661 "on port 0x%016Lx on adapter %s\n",
662 unit->fcp_lun, unit->port->wwpn,
663 zfcp_get_busid_by_unit(unit));
664 debug_text_event(adapter->erp_dbf, 5, "u_ro_f");
665 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun,
671 retval = zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_UNIT,
672 unit->port->adapter, unit->port, unit);
678 * zfcp_erp_unit_reopen - initiate reopen of a unit
679 * @unit: unit to be reopened
680 * @clear_mask: specifies flags in unit status to be cleared
681 * Return: 0 on success, < 0 on error
683 * This is a wrappper for zfcp_erp_unit_reopen_internal. It ensures correct
684 * locking. An error recovery task is initiated to do the reopen.
685 * To wait for the completion of the reopen zfcp_erp_wait should be used.
688 zfcp_erp_unit_reopen(struct zfcp_unit *unit, int clear_mask)
692 struct zfcp_adapter *adapter;
693 struct zfcp_port *port;
696 adapter = port->adapter;
698 read_lock_irqsave(&zfcp_data.config_lock, flags);
699 write_lock(&adapter->erp_lock);
700 retval = zfcp_erp_unit_reopen_internal(unit, clear_mask);
701 write_unlock(&adapter->erp_lock);
702 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
710 * purpose: disable I/O,
711 * return any open requests and clean them up,
712 * aim: no pending and incoming I/O
717 zfcp_erp_adapter_block(struct zfcp_adapter *adapter, int clear_mask)
719 debug_text_event(adapter->erp_dbf, 6, "a_bl");
720 zfcp_erp_modify_adapter_status(adapter,
721 ZFCP_STATUS_COMMON_UNBLOCKED |
722 clear_mask, ZFCP_CLEAR);
728 * purpose: enable I/O
733 zfcp_erp_adapter_unblock(struct zfcp_adapter *adapter)
735 debug_text_event(adapter->erp_dbf, 6, "a_ubl");
736 atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &adapter->status);
742 * purpose: disable I/O,
743 * return any open requests and clean them up,
744 * aim: no pending and incoming I/O
749 zfcp_erp_port_block(struct zfcp_port *port, int clear_mask)
751 struct zfcp_adapter *adapter = port->adapter;
753 debug_text_event(adapter->erp_dbf, 6, "p_bl");
754 debug_event(adapter->erp_dbf, 6, &port->wwpn, sizeof (wwn_t));
755 zfcp_erp_modify_port_status(port,
756 ZFCP_STATUS_COMMON_UNBLOCKED | clear_mask,
763 * purpose: enable I/O
768 zfcp_erp_port_unblock(struct zfcp_port *port)
770 struct zfcp_adapter *adapter = port->adapter;
772 debug_text_event(adapter->erp_dbf, 6, "p_ubl");
773 debug_event(adapter->erp_dbf, 6, &port->wwpn, sizeof (wwn_t));
774 atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &port->status);
780 * purpose: disable I/O,
781 * return any open requests and clean them up,
782 * aim: no pending and incoming I/O
787 zfcp_erp_unit_block(struct zfcp_unit *unit, int clear_mask)
789 struct zfcp_adapter *adapter = unit->port->adapter;
791 debug_text_event(adapter->erp_dbf, 6, "u_bl");
792 debug_event(adapter->erp_dbf, 6, &unit->fcp_lun, sizeof (fcp_lun_t));
793 zfcp_erp_modify_unit_status(unit,
794 ZFCP_STATUS_COMMON_UNBLOCKED | clear_mask,
801 * purpose: enable I/O
806 zfcp_erp_unit_unblock(struct zfcp_unit *unit)
808 struct zfcp_adapter *adapter = unit->port->adapter;
810 debug_text_event(adapter->erp_dbf, 6, "u_ubl");
811 debug_event(adapter->erp_dbf, 6, &unit->fcp_lun, sizeof (fcp_lun_t));
812 atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &unit->status);
823 zfcp_erp_action_ready(struct zfcp_erp_action *erp_action)
825 struct zfcp_adapter *adapter = erp_action->adapter;
827 debug_text_event(adapter->erp_dbf, 4, "a_ar");
828 debug_event(adapter->erp_dbf, 4, &erp_action->action, sizeof (int));
830 zfcp_erp_action_to_ready(erp_action);
831 up(&adapter->erp_ready_sem);
839 * returns: <0 erp_action not found in any list
840 * ZFCP_ERP_ACTION_READY erp_action is in ready list
841 * ZFCP_ERP_ACTION_RUNNING erp_action is in running list
843 * locks: erp_lock must be held
846 zfcp_erp_action_exists(struct zfcp_erp_action *erp_action)
848 int retval = -EINVAL;
849 struct list_head *entry;
850 struct zfcp_erp_action *entry_erp_action;
851 struct zfcp_adapter *adapter = erp_action->adapter;
853 /* search in running list */
854 list_for_each(entry, &adapter->erp_running_head) {
856 list_entry(entry, struct zfcp_erp_action, list);
857 if (entry_erp_action == erp_action) {
858 retval = ZFCP_ERP_ACTION_RUNNING;
862 /* search in ready list */
863 list_for_each(entry, &adapter->erp_ready_head) {
865 list_entry(entry, struct zfcp_erp_action, list);
866 if (entry_erp_action == erp_action) {
867 retval = ZFCP_ERP_ACTION_READY;
877 * purpose: checks current status of action (timed out, dismissed, ...)
878 * and does appropriate preparations (dismiss fsf request, ...)
880 * locks: called under erp_lock (disabled interrupts)
885 zfcp_erp_strategy_check_fsfreq(struct zfcp_erp_action *erp_action)
888 struct zfcp_fsf_req *fsf_req = NULL;
889 struct zfcp_adapter *adapter = erp_action->adapter;
891 if (erp_action->fsf_req) {
892 /* take lock to ensure that request is not being deleted meanwhile */
893 spin_lock(&adapter->fsf_req_list_lock);
894 /* check whether fsf req does still exist */
895 list_for_each_entry(fsf_req, &adapter->fsf_req_list_head, list)
896 if (fsf_req == erp_action->fsf_req)
898 if (fsf_req && (fsf_req->erp_action == erp_action)) {
899 /* fsf_req still exists */
900 debug_text_event(adapter->erp_dbf, 3, "a_ca_req");
901 debug_event(adapter->erp_dbf, 3, &fsf_req,
902 sizeof (unsigned long));
903 /* dismiss fsf_req of timed out or dismissed erp_action */
904 if (erp_action->status & (ZFCP_STATUS_ERP_DISMISSED |
905 ZFCP_STATUS_ERP_TIMEDOUT)) {
906 debug_text_event(adapter->erp_dbf, 3,
908 fsf_req->status |= ZFCP_STATUS_FSFREQ_DISMISSED;
910 if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT) {
911 ZFCP_LOG_NORMAL("error: erp step timed out "
912 "(action=%d, fsf_req=%p)\n ",
914 erp_action->fsf_req);
917 * If fsf_req is neither dismissed nor completed
918 * then keep it running asynchronously and don't mess
919 * with the association of erp_action and fsf_req.
921 if (fsf_req->status & (ZFCP_STATUS_FSFREQ_COMPLETED |
922 ZFCP_STATUS_FSFREQ_DISMISSED)) {
923 /* forget about association between fsf_req
925 fsf_req->erp_action = NULL;
926 erp_action->fsf_req = NULL;
929 debug_text_event(adapter->erp_dbf, 3, "a_ca_gonereq");
931 * even if this fsf_req has gone, forget about
932 * association between erp_action and fsf_req
934 erp_action->fsf_req = NULL;
936 spin_unlock(&adapter->fsf_req_list_lock);
938 debug_text_event(adapter->erp_dbf, 3, "a_ca_noreq");
944 * purpose: generic handler for asynchronous events related to erp_action events
945 * (normal completion, time-out, dismissing, retry after
946 * low memory condition)
948 * note: deletion of timer is not required (e.g. in case of a time-out),
949 * but a second try does no harm,
950 * we leave it in here to allow for greater simplification
952 * returns: 0 - there was an action to handle
956 zfcp_erp_async_handler_nolock(struct zfcp_erp_action *erp_action,
957 unsigned long set_mask)
960 struct zfcp_adapter *adapter = erp_action->adapter;
962 if (zfcp_erp_action_exists(erp_action) == ZFCP_ERP_ACTION_RUNNING) {
963 debug_text_event(adapter->erp_dbf, 2, "a_asyh_ex");
964 debug_event(adapter->erp_dbf, 2, &erp_action->action,
966 if (!(set_mask & ZFCP_STATUS_ERP_TIMEDOUT))
967 del_timer(&erp_action->timer);
968 erp_action->status |= set_mask;
969 zfcp_erp_action_ready(erp_action);
972 /* action is ready or gone - nothing to do */
973 debug_text_event(adapter->erp_dbf, 3, "a_asyh_gone");
974 debug_event(adapter->erp_dbf, 3, &erp_action->action,
983 * purpose: generic handler for asynchronous events related to erp_action
984 * events (normal completion, time-out, dismissing, retry after
985 * low memory condition)
987 * note: deletion of timer is not required (e.g. in case of a time-out),
988 * but a second try does no harm,
989 * we leave it in here to allow for greater simplification
991 * returns: 0 - there was an action to handle
995 zfcp_erp_async_handler(struct zfcp_erp_action *erp_action,
996 unsigned long set_mask)
998 struct zfcp_adapter *adapter = erp_action->adapter;
1002 write_lock_irqsave(&adapter->erp_lock, flags);
1003 retval = zfcp_erp_async_handler_nolock(erp_action, set_mask);
1004 write_unlock_irqrestore(&adapter->erp_lock, flags);
1010 * purpose: is called for erp_action which was slept waiting for
1011 * memory becoming avaliable,
1012 * will trigger that this action will be continued
1015 zfcp_erp_memwait_handler(unsigned long data)
1017 struct zfcp_erp_action *erp_action = (struct zfcp_erp_action *) data;
1018 struct zfcp_adapter *adapter = erp_action->adapter;
1020 debug_text_event(adapter->erp_dbf, 2, "a_mwh");
1021 debug_event(adapter->erp_dbf, 2, &erp_action->action, sizeof (int));
1023 zfcp_erp_async_handler(erp_action, 0);
1027 * purpose: is called if an asynchronous erp step timed out,
1028 * action gets an appropriate flag and will be processed
1032 zfcp_erp_timeout_handler(unsigned long data)
1034 struct zfcp_erp_action *erp_action = (struct zfcp_erp_action *) data;
1035 struct zfcp_adapter *adapter = erp_action->adapter;
1037 debug_text_event(adapter->erp_dbf, 2, "a_th");
1038 debug_event(adapter->erp_dbf, 2, &erp_action->action, sizeof (int));
1040 zfcp_erp_async_handler(erp_action, ZFCP_STATUS_ERP_TIMEDOUT);
1044 * purpose: is called for an erp_action which needs to be ended
1045 * though not being done,
1046 * this is usually required if an higher is generated,
1047 * action gets an appropriate flag and will be processed
1050 * locks: erp_lock held (thus we need to call another handler variant)
1053 zfcp_erp_action_dismiss(struct zfcp_erp_action *erp_action)
1055 struct zfcp_adapter *adapter = erp_action->adapter;
1057 debug_text_event(adapter->erp_dbf, 2, "a_adis");
1058 debug_event(adapter->erp_dbf, 2, &erp_action->action, sizeof (int));
1060 zfcp_erp_async_handler_nolock(erp_action, ZFCP_STATUS_ERP_DISMISSED);
1066 zfcp_erp_thread_setup(struct zfcp_adapter *adapter)
1070 atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP, &adapter->status);
1072 retval = kernel_thread(zfcp_erp_thread, adapter, SIGCHLD);
1074 ZFCP_LOG_NORMAL("error: creation of erp thread failed for "
1076 zfcp_get_busid_by_adapter(adapter));
1077 debug_text_event(adapter->erp_dbf, 5, "a_thset_fail");
1079 wait_event(adapter->erp_thread_wqh,
1080 atomic_test_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP,
1082 debug_text_event(adapter->erp_dbf, 5, "a_thset_ok");
1085 return (retval < 0);
1095 * context: process (i.e. proc-fs or rmmod/insmod)
1097 * note: The caller of this routine ensures that the specified
1098 * adapter has been shut down and that this operation
1099 * has been completed. Thus, there are no pending erp_actions
1100 * which would need to be handled here.
1103 zfcp_erp_thread_kill(struct zfcp_adapter *adapter)
1107 atomic_set_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL, &adapter->status);
1108 up(&adapter->erp_ready_sem);
1110 wait_event(adapter->erp_thread_wqh,
1111 !atomic_test_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP,
1114 atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL,
1117 debug_text_event(adapter->erp_dbf, 5, "a_thki_ok");
1123 * purpose: is run as a kernel thread,
1124 * goes through list of error recovery actions of associated adapter
1125 * and delegates single action to execution
1130 zfcp_erp_thread(void *data)
1132 struct zfcp_adapter *adapter = (struct zfcp_adapter *) data;
1133 struct list_head *next;
1134 struct zfcp_erp_action *erp_action;
1135 unsigned long flags;
1137 daemonize("zfcperp%s", zfcp_get_busid_by_adapter(adapter));
1138 /* Block all signals */
1139 siginitsetinv(¤t->blocked, 0);
1140 atomic_set_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP, &adapter->status);
1141 debug_text_event(adapter->erp_dbf, 5, "a_th_run");
1142 wake_up(&adapter->erp_thread_wqh);
1144 while (!atomic_test_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL,
1145 &adapter->status)) {
1147 write_lock_irqsave(&adapter->erp_lock, flags);
1148 next = adapter->erp_ready_head.prev;
1149 write_unlock_irqrestore(&adapter->erp_lock, flags);
1151 if (next != &adapter->erp_ready_head) {
1153 list_entry(next, struct zfcp_erp_action, list);
1155 * process action (incl. [re]moving it
1156 * from 'ready' queue)
1158 zfcp_erp_strategy(erp_action);
1162 * sleep as long as there is nothing to do, i.e.
1163 * no action in 'ready' queue to be processed and
1164 * thread is not to be killed
1166 down_interruptible(&adapter->erp_ready_sem);
1167 debug_text_event(adapter->erp_dbf, 5, "a_th_woken");
1170 atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP, &adapter->status);
1171 debug_text_event(adapter->erp_dbf, 5, "a_th_stop");
1172 wake_up(&adapter->erp_thread_wqh);
1180 * purpose: drives single error recovery action and schedules higher and
1181 * subordinate actions, if necessary
1183 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
1184 * ZFCP_ERP_SUCCEEDED - action finished successfully (deqd)
1185 * ZFCP_ERP_FAILED - action finished unsuccessfully (deqd)
1186 * ZFCP_ERP_EXIT - action finished (dequeued), offline
1187 * ZFCP_ERP_DISMISSED - action canceled (dequeued)
1190 zfcp_erp_strategy(struct zfcp_erp_action *erp_action)
1193 struct zfcp_adapter *adapter = erp_action->adapter;
1194 struct zfcp_port *port = erp_action->port;
1195 struct zfcp_unit *unit = erp_action->unit;
1196 int action = erp_action->action;
1197 u32 status = erp_action->status;
1198 unsigned long flags;
1200 /* serialise dismissing, timing out, moving, enqueueing */
1201 read_lock_irqsave(&zfcp_data.config_lock, flags);
1202 write_lock(&adapter->erp_lock);
1204 /* dequeue dismissed action and leave, if required */
1205 retval = zfcp_erp_strategy_check_action(erp_action, retval);
1206 if (retval == ZFCP_ERP_DISMISSED) {
1207 debug_text_event(adapter->erp_dbf, 4, "a_st_dis1");
1212 * move action to 'running' queue before processing it
1213 * (to avoid a race condition regarding moving the
1214 * action to the 'running' queue and back)
1216 zfcp_erp_action_to_running(erp_action);
1219 * try to process action as far as possible,
1220 * no lock to allow for blocking operations (kmalloc, qdio, ...),
1221 * afterwards the lock is required again for the following reasons:
1222 * - dequeueing of finished action and enqueueing of
1223 * follow-up actions must be atomic so that any other
1224 * reopen-routine does not believe there is nothing to do
1225 * and that it is safe to enqueue something else,
1226 * - we want to force any control thread which is dismissing
1227 * actions to finish this before we decide about
1228 * necessary steps to be taken here further
1230 write_unlock(&adapter->erp_lock);
1231 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
1232 retval = zfcp_erp_strategy_do_action(erp_action);
1233 read_lock_irqsave(&zfcp_data.config_lock, flags);
1234 write_lock(&adapter->erp_lock);
1237 * check for dismissed status again to avoid follow-up actions,
1238 * failing of targets and so on for dismissed actions
1240 retval = zfcp_erp_strategy_check_action(erp_action, retval);
1243 case ZFCP_ERP_DISMISSED:
1244 /* leave since this action has ridden to its ancestors */
1245 debug_text_event(adapter->erp_dbf, 6, "a_st_dis2");
1247 case ZFCP_ERP_NOMEM:
1248 /* no memory to continue immediately, let it sleep */
1249 if (!(erp_action->status & ZFCP_STATUS_ERP_LOWMEM)) {
1250 ++adapter->erp_low_mem_count;
1251 erp_action->status |= ZFCP_STATUS_ERP_LOWMEM;
1253 /* This condition is true if there is no memory available
1254 for any erp_action on this adapter. This implies that there
1255 are no elements in the memory pool(s) left for erp_actions.
1256 This might happen if an erp_action that used a memory pool
1257 element was timed out.
1259 if (adapter->erp_total_count == adapter->erp_low_mem_count) {
1260 debug_text_event(adapter->erp_dbf, 3, "a_st_lowmem");
1261 ZFCP_LOG_NORMAL("error: no mempool elements available, "
1262 "restarting I/O on adapter %s "
1263 "to free mempool\n",
1264 zfcp_get_busid_by_adapter(adapter));
1265 zfcp_erp_adapter_reopen_internal(adapter, 0);
1267 debug_text_event(adapter->erp_dbf, 2, "a_st_memw");
1268 retval = zfcp_erp_strategy_memwait(erp_action);
1271 case ZFCP_ERP_CONTINUES:
1272 /* leave since this action runs asynchronously */
1273 debug_text_event(adapter->erp_dbf, 6, "a_st_cont");
1274 if (erp_action->status & ZFCP_STATUS_ERP_LOWMEM) {
1275 --adapter->erp_low_mem_count;
1276 erp_action->status &= ~ZFCP_STATUS_ERP_LOWMEM;
1280 /* ok, finished action (whatever its result is) */
1282 /* check for unrecoverable targets */
1283 retval = zfcp_erp_strategy_check_target(erp_action, retval);
1285 /* action must be dequeued (here to allow for further ones) */
1286 zfcp_erp_action_dequeue(erp_action);
1289 * put this target through the erp mill again if someone has
1290 * requested to change the status of a target being online
1291 * to offline or the other way around
1292 * (old retval is preserved if nothing has to be done here)
1294 retval = zfcp_erp_strategy_statechange(action, status, adapter,
1295 port, unit, retval);
1298 * leave if target is in permanent error state or if
1299 * action is repeated in order to process state change
1301 if (retval == ZFCP_ERP_EXIT) {
1302 debug_text_event(adapter->erp_dbf, 2, "a_st_exit");
1306 /* trigger follow up actions */
1307 zfcp_erp_strategy_followup_actions(action, adapter, port, unit, retval);
1310 write_unlock(&adapter->erp_lock);
1311 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
1313 if (retval != ZFCP_ERP_CONTINUES)
1314 zfcp_erp_action_cleanup(action, adapter, port, unit, retval);
1317 * a few tasks remain when the erp queues are empty
1318 * (don't do that if the last action evaluated was dismissed
1319 * since this clearly indicates that there is more to come) :
1320 * - close the name server port if it is open yet
1321 * (enqueues another [probably] final action)
1322 * - otherwise, wake up whoever wants to be woken when we are
1325 if (retval != ZFCP_ERP_DISMISSED)
1326 zfcp_erp_strategy_check_queues(adapter);
1328 debug_text_event(adapter->erp_dbf, 6, "a_st_done");
1338 * returns: ZFCP_ERP_DISMISSED - if action has been dismissed
1339 * retval - otherwise
1342 zfcp_erp_strategy_check_action(struct zfcp_erp_action *erp_action, int retval)
1344 struct zfcp_adapter *adapter = erp_action->adapter;
1346 zfcp_erp_strategy_check_fsfreq(erp_action);
1348 debug_event(adapter->erp_dbf, 5, &erp_action->action, sizeof (int));
1349 if (erp_action->status & ZFCP_STATUS_ERP_DISMISSED) {
1350 debug_text_event(adapter->erp_dbf, 3, "a_stcd_dis");
1351 zfcp_erp_action_dequeue(erp_action);
1352 retval = ZFCP_ERP_DISMISSED;
1354 debug_text_event(adapter->erp_dbf, 5, "a_stcd_nodis");
1367 zfcp_erp_strategy_do_action(struct zfcp_erp_action *erp_action)
1369 int retval = ZFCP_ERP_FAILED;
1370 struct zfcp_adapter *adapter = erp_action->adapter;
1373 * try to execute/continue action as far as possible,
1374 * note: no lock in subsequent strategy routines
1375 * (this allows these routine to call schedule, e.g.
1376 * kmalloc with such flags or qdio_initialize & friends)
1377 * Note: in case of timeout, the seperate strategies will fail
1378 * anyhow. No need for a special action. Even worse, a nameserver
1379 * failure would not wake up waiting ports without the call.
1381 switch (erp_action->action) {
1383 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
1384 retval = zfcp_erp_adapter_strategy(erp_action);
1387 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
1388 retval = zfcp_erp_port_forced_strategy(erp_action);
1391 case ZFCP_ERP_ACTION_REOPEN_PORT:
1392 retval = zfcp_erp_port_strategy(erp_action);
1395 case ZFCP_ERP_ACTION_REOPEN_UNIT:
1396 retval = zfcp_erp_unit_strategy(erp_action);
1400 debug_text_exception(adapter->erp_dbf, 1, "a_stda_bug");
1401 debug_event(adapter->erp_dbf, 1, &erp_action->action,
1403 ZFCP_LOG_NORMAL("bug: unknown erp action requested on "
1404 "adapter %s (action=%d)\n",
1405 zfcp_get_busid_by_adapter(erp_action->adapter),
1406 erp_action->action);
1415 * purpose: triggers retry of this action after a certain amount of time
1416 * by means of timer provided by erp_action
1418 * returns: ZFCP_ERP_CONTINUES - erp_action sleeps in erp running queue
1421 zfcp_erp_strategy_memwait(struct zfcp_erp_action *erp_action)
1423 int retval = ZFCP_ERP_CONTINUES;
1424 struct zfcp_adapter *adapter = erp_action->adapter;
1426 debug_text_event(adapter->erp_dbf, 6, "a_mwinit");
1427 debug_event(adapter->erp_dbf, 6, &erp_action->action, sizeof (int));
1428 init_timer(&erp_action->timer);
1429 erp_action->timer.function = zfcp_erp_memwait_handler;
1430 erp_action->timer.data = (unsigned long) erp_action;
1431 erp_action->timer.expires = jiffies + ZFCP_ERP_MEMWAIT_TIMEOUT;
1432 add_timer(&erp_action->timer);
1438 * function: zfcp_erp_adapter_failed
1440 * purpose: sets the adapter and all underlying devices to ERP_FAILED
1444 zfcp_erp_adapter_failed(struct zfcp_adapter *adapter)
1446 zfcp_erp_modify_adapter_status(adapter,
1447 ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET);
1448 ZFCP_LOG_NORMAL("adapter erp failed on adapter %s\n",
1449 zfcp_get_busid_by_adapter(adapter));
1450 debug_text_event(adapter->erp_dbf, 2, "a_afail");
1454 * function: zfcp_erp_port_failed
1456 * purpose: sets the port and all underlying devices to ERP_FAILED
1460 zfcp_erp_port_failed(struct zfcp_port *port)
1462 zfcp_erp_modify_port_status(port,
1463 ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET);
1465 if (atomic_test_mask(ZFCP_STATUS_PORT_WKA, &port->status))
1466 ZFCP_LOG_NORMAL("port erp failed (adapter %s, "
1467 "port d_id=0x%08x)\n",
1468 zfcp_get_busid_by_port(port), port->d_id);
1470 ZFCP_LOG_NORMAL("port erp failed (adapter %s, wwpn=0x%016Lx)\n",
1471 zfcp_get_busid_by_port(port), port->wwpn);
1473 debug_text_event(port->adapter->erp_dbf, 2, "p_pfail");
1474 debug_event(port->adapter->erp_dbf, 2, &port->wwpn, sizeof (wwn_t));
1478 * function: zfcp_erp_unit_failed
1480 * purpose: sets the unit to ERP_FAILED
1484 zfcp_erp_unit_failed(struct zfcp_unit *unit)
1486 zfcp_erp_modify_unit_status(unit,
1487 ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET);
1489 ZFCP_LOG_NORMAL("unit erp failed on unit 0x%016Lx on port 0x%016Lx "
1490 " on adapter %s\n", unit->fcp_lun,
1491 unit->port->wwpn, zfcp_get_busid_by_unit(unit));
1492 debug_text_event(unit->port->adapter->erp_dbf, 2, "u_ufail");
1493 debug_event(unit->port->adapter->erp_dbf, 2,
1494 &unit->fcp_lun, sizeof (fcp_lun_t));
1498 * function: zfcp_erp_strategy_check_target
1500 * purpose: increments the erp action count on the device currently in
1501 * recovery if the action failed or resets the count in case of
1502 * success. If a maximum count is exceeded the device is marked
1504 * The 'blocked' state of a target which has been recovered
1505 * successfully is reset.
1507 * returns: ZFCP_ERP_CONTINUES - action continues (not considered)
1508 * ZFCP_ERP_SUCCEEDED - action finished successfully
1509 * ZFCP_ERP_EXIT - action failed and will not continue
1512 zfcp_erp_strategy_check_target(struct zfcp_erp_action *erp_action, int result)
1514 struct zfcp_adapter *adapter = erp_action->adapter;
1515 struct zfcp_port *port = erp_action->port;
1516 struct zfcp_unit *unit = erp_action->unit;
1518 debug_text_event(adapter->erp_dbf, 5, "a_stct_norm");
1519 debug_event(adapter->erp_dbf, 5, &erp_action->action, sizeof (int));
1520 debug_event(adapter->erp_dbf, 5, &result, sizeof (int));
1522 switch (erp_action->action) {
1524 case ZFCP_ERP_ACTION_REOPEN_UNIT:
1525 result = zfcp_erp_strategy_check_unit(unit, result);
1528 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
1529 case ZFCP_ERP_ACTION_REOPEN_PORT:
1530 result = zfcp_erp_strategy_check_port(port, result);
1533 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
1534 result = zfcp_erp_strategy_check_adapter(adapter, result);
1549 zfcp_erp_strategy_statechange(int action,
1551 struct zfcp_adapter *adapter,
1552 struct zfcp_port *port,
1553 struct zfcp_unit *unit, int retval)
1555 debug_text_event(adapter->erp_dbf, 3, "a_stsc");
1556 debug_event(adapter->erp_dbf, 3, &action, sizeof (int));
1560 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
1561 if (zfcp_erp_strategy_statechange_detected(&adapter->status,
1563 zfcp_erp_adapter_reopen_internal(adapter, ZFCP_STATUS_COMMON_ERP_FAILED);
1564 retval = ZFCP_ERP_EXIT;
1568 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
1569 case ZFCP_ERP_ACTION_REOPEN_PORT:
1570 if (zfcp_erp_strategy_statechange_detected(&port->status,
1572 zfcp_erp_port_reopen_internal(port, ZFCP_STATUS_COMMON_ERP_FAILED);
1573 retval = ZFCP_ERP_EXIT;
1577 case ZFCP_ERP_ACTION_REOPEN_UNIT:
1578 if (zfcp_erp_strategy_statechange_detected(&unit->status,
1580 zfcp_erp_unit_reopen_internal(unit, ZFCP_STATUS_COMMON_ERP_FAILED);
1581 retval = ZFCP_ERP_EXIT;
1597 zfcp_erp_strategy_statechange_detected(atomic_t * target_status, u32 erp_status)
1600 /* take it online */
1601 (atomic_test_mask(ZFCP_STATUS_COMMON_RUNNING, target_status) &&
1602 (ZFCP_STATUS_ERP_CLOSE_ONLY & erp_status)) ||
1603 /* take it offline */
1604 (!atomic_test_mask(ZFCP_STATUS_COMMON_RUNNING, target_status) &&
1605 !(ZFCP_STATUS_ERP_CLOSE_ONLY & erp_status));
1616 zfcp_erp_strategy_check_unit(struct zfcp_unit *unit, int result)
1618 debug_text_event(unit->port->adapter->erp_dbf, 5, "u_stct");
1619 debug_event(unit->port->adapter->erp_dbf, 5, &unit->fcp_lun,
1620 sizeof (fcp_lun_t));
1623 case ZFCP_ERP_SUCCEEDED :
1624 atomic_set(&unit->erp_counter, 0);
1625 zfcp_erp_unit_unblock(unit);
1627 case ZFCP_ERP_FAILED :
1628 atomic_inc(&unit->erp_counter);
1629 if (atomic_read(&unit->erp_counter) > ZFCP_MAX_ERPS)
1630 zfcp_erp_unit_failed(unit);
1632 case ZFCP_ERP_EXIT :
1637 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED, &unit->status)) {
1638 zfcp_erp_unit_block(unit, 0); /* for ZFCP_ERP_SUCCEEDED */
1639 result = ZFCP_ERP_EXIT;
1653 zfcp_erp_strategy_check_port(struct zfcp_port *port, int result)
1655 debug_text_event(port->adapter->erp_dbf, 5, "p_stct");
1656 debug_event(port->adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
1659 case ZFCP_ERP_SUCCEEDED :
1660 atomic_set(&port->erp_counter, 0);
1661 zfcp_erp_port_unblock(port);
1663 case ZFCP_ERP_FAILED :
1664 atomic_inc(&port->erp_counter);
1665 if (atomic_read(&port->erp_counter) > ZFCP_MAX_ERPS)
1666 zfcp_erp_port_failed(port);
1668 case ZFCP_ERP_EXIT :
1673 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED, &port->status)) {
1674 zfcp_erp_port_block(port, 0); /* for ZFCP_ERP_SUCCEEDED */
1675 result = ZFCP_ERP_EXIT;
1689 zfcp_erp_strategy_check_adapter(struct zfcp_adapter *adapter, int result)
1691 debug_text_event(adapter->erp_dbf, 5, "a_stct");
1694 case ZFCP_ERP_SUCCEEDED :
1695 atomic_set(&adapter->erp_counter, 0);
1696 zfcp_erp_adapter_unblock(adapter);
1698 case ZFCP_ERP_FAILED :
1699 atomic_inc(&adapter->erp_counter);
1700 if (atomic_read(&adapter->erp_counter) > ZFCP_MAX_ERPS)
1701 zfcp_erp_adapter_failed(adapter);
1703 case ZFCP_ERP_EXIT :
1708 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED, &adapter->status)) {
1709 zfcp_erp_adapter_block(adapter, 0); /* for ZFCP_ERP_SUCCEEDED */
1710 result = ZFCP_ERP_EXIT;
1719 * purpose: remaining things in good cases,
1720 * escalation in bad cases
1725 zfcp_erp_strategy_followup_actions(int action,
1726 struct zfcp_adapter *adapter,
1727 struct zfcp_port *port,
1728 struct zfcp_unit *unit, int status)
1730 debug_text_event(adapter->erp_dbf, 5, "a_stfol");
1731 debug_event(adapter->erp_dbf, 5, &action, sizeof (int));
1733 /* initiate follow-up actions depending on success of finished action */
1736 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
1737 if (status == ZFCP_ERP_SUCCEEDED)
1738 zfcp_erp_port_reopen_all_internal(adapter, 0);
1740 zfcp_erp_adapter_reopen_internal(adapter, 0);
1743 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
1744 if (status == ZFCP_ERP_SUCCEEDED)
1745 zfcp_erp_port_reopen_internal(port, 0);
1747 zfcp_erp_adapter_reopen_internal(adapter, 0);
1750 case ZFCP_ERP_ACTION_REOPEN_PORT:
1751 if (status == ZFCP_ERP_SUCCEEDED)
1752 zfcp_erp_unit_reopen_all_internal(port, 0);
1754 zfcp_erp_port_forced_reopen_internal(port, 0);
1757 case ZFCP_ERP_ACTION_REOPEN_UNIT:
1758 if (status == ZFCP_ERP_SUCCEEDED) ; /* no further action */
1760 zfcp_erp_port_reopen_internal(unit->port, 0);
1775 zfcp_erp_strategy_check_queues(struct zfcp_adapter *adapter)
1777 unsigned long flags;
1779 read_lock_irqsave(&zfcp_data.config_lock, flags);
1780 read_lock(&adapter->erp_lock);
1781 if (list_empty(&adapter->erp_ready_head) &&
1782 list_empty(&adapter->erp_running_head)) {
1783 debug_text_event(adapter->erp_dbf, 4, "a_cq_wake");
1784 atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_PENDING,
1786 wake_up(&adapter->erp_done_wqh);
1788 debug_text_event(adapter->erp_dbf, 5, "a_cq_notempty");
1789 read_unlock(&adapter->erp_lock);
1790 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
1796 * zfcp_erp_wait - wait for completion of error recovery on an adapter
1797 * @adapter: adapter for which to wait for completion of its error recovery
1801 zfcp_erp_wait(struct zfcp_adapter *adapter)
1805 wait_event(adapter->erp_done_wqh,
1806 !atomic_test_mask(ZFCP_STATUS_ADAPTER_ERP_PENDING,
1813 * function: zfcp_erp_modify_adapter_status
1819 zfcp_erp_modify_adapter_status(struct zfcp_adapter *adapter,
1820 u32 mask, int set_or_clear)
1822 struct zfcp_port *port;
1823 u32 common_mask = mask & ZFCP_COMMON_FLAGS;
1825 if (set_or_clear == ZFCP_SET) {
1826 atomic_set_mask(mask, &adapter->status);
1827 debug_text_event(adapter->erp_dbf, 3, "a_mod_as_s");
1829 atomic_clear_mask(mask, &adapter->status);
1830 if (mask & ZFCP_STATUS_COMMON_ERP_FAILED)
1831 atomic_set(&adapter->erp_counter, 0);
1832 debug_text_event(adapter->erp_dbf, 3, "a_mod_as_c");
1834 debug_event(adapter->erp_dbf, 3, &mask, sizeof (u32));
1836 /* Deal with all underlying devices, only pass common_mask */
1838 list_for_each_entry(port, &adapter->port_list_head, list)
1839 zfcp_erp_modify_port_status(port, common_mask,
1844 * function: zfcp_erp_modify_port_status
1846 * purpose: sets the port and all underlying devices to ERP_FAILED
1850 zfcp_erp_modify_port_status(struct zfcp_port *port, u32 mask, int set_or_clear)
1852 struct zfcp_unit *unit;
1853 u32 common_mask = mask & ZFCP_COMMON_FLAGS;
1855 if (set_or_clear == ZFCP_SET) {
1856 atomic_set_mask(mask, &port->status);
1857 debug_text_event(port->adapter->erp_dbf, 3, "p_mod_ps_s");
1859 atomic_clear_mask(mask, &port->status);
1860 if (mask & ZFCP_STATUS_COMMON_ERP_FAILED)
1861 atomic_set(&port->erp_counter, 0);
1862 debug_text_event(port->adapter->erp_dbf, 3, "p_mod_ps_c");
1864 debug_event(port->adapter->erp_dbf, 3, &port->wwpn, sizeof (wwn_t));
1865 debug_event(port->adapter->erp_dbf, 3, &mask, sizeof (u32));
1867 /* Modify status of all underlying devices, only pass common mask */
1869 list_for_each_entry(unit, &port->unit_list_head, list)
1870 zfcp_erp_modify_unit_status(unit, common_mask,
1875 * function: zfcp_erp_modify_unit_status
1877 * purpose: sets the unit to ERP_FAILED
1881 zfcp_erp_modify_unit_status(struct zfcp_unit *unit, u32 mask, int set_or_clear)
1883 if (set_or_clear == ZFCP_SET) {
1884 atomic_set_mask(mask, &unit->status);
1885 debug_text_event(unit->port->adapter->erp_dbf, 3, "u_mod_us_s");
1887 atomic_clear_mask(mask, &unit->status);
1888 if (mask & ZFCP_STATUS_COMMON_ERP_FAILED) {
1889 atomic_set(&unit->erp_counter, 0);
1891 debug_text_event(unit->port->adapter->erp_dbf, 3, "u_mod_us_c");
1893 debug_event(unit->port->adapter->erp_dbf, 3, &unit->fcp_lun,
1894 sizeof (fcp_lun_t));
1895 debug_event(unit->port->adapter->erp_dbf, 3, &mask, sizeof (u32));
1901 * purpose: Wrappper for zfcp_erp_port_reopen_all_internal
1902 * used to ensure the correct locking
1904 * returns: 0 - initiated action succesfully
1905 * <0 - failed to initiate action
1908 zfcp_erp_port_reopen_all(struct zfcp_adapter *adapter, int clear_mask)
1911 unsigned long flags;
1913 read_lock_irqsave(&zfcp_data.config_lock, flags);
1914 write_lock(&adapter->erp_lock);
1915 retval = zfcp_erp_port_reopen_all_internal(adapter, clear_mask);
1916 write_unlock(&adapter->erp_lock);
1917 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
1930 zfcp_erp_port_reopen_all_internal(struct zfcp_adapter *adapter, int clear_mask)
1933 struct zfcp_port *port;
1935 list_for_each_entry(port, &adapter->port_list_head, list)
1936 if (!atomic_test_mask(ZFCP_STATUS_PORT_WKA, &port->status))
1937 zfcp_erp_port_reopen_internal(port, clear_mask);
1950 zfcp_erp_unit_reopen_all_internal(struct zfcp_port *port, int clear_mask)
1953 struct zfcp_unit *unit;
1955 list_for_each_entry(unit, &port->unit_list_head, list)
1956 zfcp_erp_unit_reopen_internal(unit, clear_mask);
1964 * purpose: this routine executes the 'Reopen Adapter' action
1965 * (the entire action is processed synchronously, since
1966 * there are no actions which might be run concurrently
1969 * returns: ZFCP_ERP_SUCCEEDED - action finished successfully
1970 * ZFCP_ERP_FAILED - action finished unsuccessfully
1973 zfcp_erp_adapter_strategy(struct zfcp_erp_action *erp_action)
1976 struct zfcp_adapter *adapter = erp_action->adapter;
1978 retval = zfcp_erp_adapter_strategy_close(erp_action);
1979 if (erp_action->status & ZFCP_STATUS_ERP_CLOSE_ONLY)
1980 retval = ZFCP_ERP_EXIT;
1982 retval = zfcp_erp_adapter_strategy_open(erp_action);
1984 debug_text_event(adapter->erp_dbf, 3, "a_ast/ret");
1985 debug_event(adapter->erp_dbf, 3, &erp_action->action, sizeof (int));
1986 debug_event(adapter->erp_dbf, 3, &retval, sizeof (int));
1988 if (retval == ZFCP_ERP_FAILED) {
1989 ZFCP_LOG_INFO("Waiting to allow the adapter %s "
1990 "to recover itself\n",
1991 zfcp_get_busid_by_adapter(adapter));
1992 msleep(jiffies_to_msecs(ZFCP_TYPE2_RECOVERY_TIME));
2003 * returns: ZFCP_ERP_SUCCEEDED - action finished successfully
2004 * ZFCP_ERP_FAILED - action finished unsuccessfully
2007 zfcp_erp_adapter_strategy_close(struct zfcp_erp_action *erp_action)
2011 atomic_set_mask(ZFCP_STATUS_COMMON_CLOSING,
2012 &erp_action->adapter->status);
2013 retval = zfcp_erp_adapter_strategy_generic(erp_action, 1);
2014 atomic_clear_mask(ZFCP_STATUS_COMMON_CLOSING,
2015 &erp_action->adapter->status);
2025 * returns: ZFCP_ERP_SUCCEEDED - action finished successfully
2026 * ZFCP_ERP_FAILED - action finished unsuccessfully
2029 zfcp_erp_adapter_strategy_open(struct zfcp_erp_action *erp_action)
2033 atomic_set_mask(ZFCP_STATUS_COMMON_OPENING,
2034 &erp_action->adapter->status);
2035 retval = zfcp_erp_adapter_strategy_generic(erp_action, 0);
2036 atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING,
2037 &erp_action->adapter->status);
2043 * function: zfcp_register_adapter
2045 * purpose: allocate the irq associated with this devno and register
2046 * the FSF adapter with the SCSI stack
2051 zfcp_erp_adapter_strategy_generic(struct zfcp_erp_action *erp_action, int close)
2053 int retval = ZFCP_ERP_SUCCEEDED;
2058 retval = zfcp_erp_adapter_strategy_open_qdio(erp_action);
2059 if (retval != ZFCP_ERP_SUCCEEDED)
2062 retval = zfcp_erp_adapter_strategy_open_fsf(erp_action);
2063 if (retval != ZFCP_ERP_SUCCEEDED)
2064 goto failed_openfcp;
2066 atomic_set_mask(ZFCP_STATUS_COMMON_OPEN, &erp_action->adapter->status);
2070 atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN,
2071 &erp_action->adapter->status);
2074 zfcp_erp_adapter_strategy_close_qdio(erp_action);
2075 zfcp_erp_adapter_strategy_close_fsf(erp_action);
2082 * function: zfcp_qdio_init
2084 * purpose: setup QDIO operation for specified adapter
2086 * returns: 0 - successful setup
2090 zfcp_erp_adapter_strategy_open_qdio(struct zfcp_erp_action *erp_action)
2094 volatile struct qdio_buffer_element *sbale;
2095 struct zfcp_adapter *adapter = erp_action->adapter;
2097 if (atomic_test_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &adapter->status)) {
2098 ZFCP_LOG_NORMAL("bug: second attempt to set up QDIO on "
2100 zfcp_get_busid_by_adapter(adapter));
2104 if (qdio_establish(&adapter->qdio_init_data) != 0) {
2105 ZFCP_LOG_INFO("error: establishment of QDIO queues failed "
2107 zfcp_get_busid_by_adapter(adapter));
2108 goto failed_qdio_establish;
2110 debug_text_event(adapter->erp_dbf, 3, "qdio_est");
2112 if (qdio_activate(adapter->ccw_device, 0) != 0) {
2113 ZFCP_LOG_INFO("error: activation of QDIO queues failed "
2115 zfcp_get_busid_by_adapter(adapter));
2116 goto failed_qdio_activate;
2118 debug_text_event(adapter->erp_dbf, 3, "qdio_act");
2121 * put buffers into response queue,
2123 for (i = 0; i < QDIO_MAX_BUFFERS_PER_Q; i++) {
2124 sbale = &(adapter->response_queue.buffer[i]->element[0]);
2126 sbale->flags = SBAL_FLAGS_LAST_ENTRY;
2130 ZFCP_LOG_TRACE("calling do_QDIO on adapter %s (flags=0x%x, "
2131 "queue_no=%i, index_in_queue=%i, count=%i)\n",
2132 zfcp_get_busid_by_adapter(adapter),
2133 QDIO_FLAG_SYNC_INPUT, 0, 0, QDIO_MAX_BUFFERS_PER_Q);
2135 retval = do_QDIO(adapter->ccw_device,
2136 QDIO_FLAG_SYNC_INPUT,
2137 0, 0, QDIO_MAX_BUFFERS_PER_Q, NULL);
2140 ZFCP_LOG_NORMAL("bug: setup of QDIO failed (retval=%d)\n",
2142 goto failed_do_qdio;
2144 adapter->response_queue.free_index = 0;
2145 atomic_set(&adapter->response_queue.free_count, 0);
2146 ZFCP_LOG_DEBUG("%i buffers successfully enqueued to "
2147 "response queue\n", QDIO_MAX_BUFFERS_PER_Q);
2149 /* set index of first avalable SBALS / number of available SBALS */
2150 adapter->request_queue.free_index = 0;
2151 atomic_set(&adapter->request_queue.free_count, QDIO_MAX_BUFFERS_PER_Q);
2152 adapter->request_queue.distance_from_int = 0;
2154 /* initialize waitqueue used to wait for free SBALs in requests queue */
2155 init_waitqueue_head(&adapter->request_wq);
2157 /* ok, we did it - skip all cleanups for different failures */
2158 atomic_set_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &adapter->status);
2159 retval = ZFCP_ERP_SUCCEEDED;
2165 failed_qdio_activate:
2166 debug_text_event(adapter->erp_dbf, 3, "qdio_down1a");
2167 while (qdio_shutdown(adapter->ccw_device,
2168 QDIO_FLAG_CLEANUP_USING_CLEAR) == -EINPROGRESS)
2170 debug_text_event(adapter->erp_dbf, 3, "qdio_down1b");
2172 failed_qdio_establish:
2174 retval = ZFCP_ERP_FAILED;
2181 * function: zfcp_qdio_cleanup
2183 * purpose: cleans up QDIO operation for the specified adapter
2185 * returns: 0 - successful cleanup
2186 * !0 - failed cleanup
2189 zfcp_erp_adapter_strategy_close_qdio(struct zfcp_erp_action *erp_action)
2191 int retval = ZFCP_ERP_SUCCEEDED;
2194 struct zfcp_adapter *adapter = erp_action->adapter;
2196 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &adapter->status)) {
2197 ZFCP_LOG_DEBUG("error: attempt to shut down inactive QDIO "
2198 "queues on adapter %s\n",
2199 zfcp_get_busid_by_adapter(adapter));
2200 retval = ZFCP_ERP_FAILED;
2205 * Get queue_lock and clear QDIOUP flag. Thus it's guaranteed that
2206 * do_QDIO won't be called while qdio_shutdown is in progress.
2209 write_lock_irq(&adapter->request_queue.queue_lock);
2210 atomic_clear_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &adapter->status);
2211 write_unlock_irq(&adapter->request_queue.queue_lock);
2213 debug_text_event(adapter->erp_dbf, 3, "qdio_down2a");
2214 while (qdio_shutdown(adapter->ccw_device,
2215 QDIO_FLAG_CLEANUP_USING_CLEAR) == -EINPROGRESS)
2217 debug_text_event(adapter->erp_dbf, 3, "qdio_down2b");
2220 * First we had to stop QDIO operation.
2221 * Now it is safe to take the following actions.
2224 /* Cleanup only necessary when there are unacknowledged buffers */
2225 if (atomic_read(&adapter->request_queue.free_count)
2226 < QDIO_MAX_BUFFERS_PER_Q) {
2227 first_used = (adapter->request_queue.free_index +
2228 atomic_read(&adapter->request_queue.free_count))
2229 % QDIO_MAX_BUFFERS_PER_Q;
2230 used_count = QDIO_MAX_BUFFERS_PER_Q -
2231 atomic_read(&adapter->request_queue.free_count);
2232 zfcp_qdio_zero_sbals(adapter->request_queue.buffer,
2233 first_used, used_count);
2235 adapter->response_queue.free_index = 0;
2236 atomic_set(&adapter->response_queue.free_count, 0);
2237 adapter->request_queue.free_index = 0;
2238 atomic_set(&adapter->request_queue.free_count, 0);
2239 adapter->request_queue.distance_from_int = 0;
2245 zfcp_erp_adapter_strategy_open_fsf(struct zfcp_erp_action *erp_action)
2249 if ((atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED,
2250 &erp_action->adapter->status)) &&
2251 (erp_action->adapter->adapter_features &
2252 FSF_FEATURE_HBAAPI_MANAGEMENT)) {
2253 zfcp_erp_adapter_strategy_open_fsf_xport(erp_action);
2254 atomic_set(&erp_action->adapter->erp_counter, 0);
2255 return ZFCP_ERP_FAILED;
2258 retval = zfcp_erp_adapter_strategy_open_fsf_xconfig(erp_action);
2259 if (retval == ZFCP_ERP_FAILED)
2260 return ZFCP_ERP_FAILED;
2262 retval = zfcp_erp_adapter_strategy_open_fsf_xport(erp_action);
2263 if (retval == ZFCP_ERP_FAILED)
2264 return ZFCP_ERP_FAILED;
2266 return zfcp_erp_adapter_strategy_open_fsf_statusread(erp_action);
2277 zfcp_erp_adapter_strategy_open_fsf_xconfig(struct zfcp_erp_action *erp_action)
2279 int retval = ZFCP_ERP_SUCCEEDED;
2281 int sleep = ZFCP_EXCHANGE_CONFIG_DATA_FIRST_SLEEP;
2282 struct zfcp_adapter *adapter = erp_action->adapter;
2284 atomic_clear_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK, &adapter->status);
2286 for (retries = ZFCP_EXCHANGE_CONFIG_DATA_RETRIES; retries; retries--) {
2287 atomic_clear_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT,
2289 ZFCP_LOG_DEBUG("Doing exchange config data\n");
2290 write_lock(&adapter->erp_lock);
2291 zfcp_erp_action_to_running(erp_action);
2292 write_unlock(&adapter->erp_lock);
2293 zfcp_erp_timeout_init(erp_action);
2294 if (zfcp_fsf_exchange_config_data(erp_action)) {
2295 retval = ZFCP_ERP_FAILED;
2296 debug_text_event(adapter->erp_dbf, 5, "a_fstx_xf");
2297 ZFCP_LOG_INFO("error: initiation of exchange of "
2298 "configuration data failed for "
2300 zfcp_get_busid_by_adapter(adapter));
2303 debug_text_event(adapter->erp_dbf, 6, "a_fstx_xok");
2304 ZFCP_LOG_DEBUG("Xchange underway\n");
2308 * Both the normal completion handler as well as the timeout
2309 * handler will do an 'up' when the 'exchange config data'
2310 * request completes or times out. Thus, the signal to go on
2311 * won't be lost utilizing this semaphore.
2312 * Furthermore, this 'adapter_reopen' action is
2313 * guaranteed to be the only action being there (highest action
2314 * which prevents other actions from being created).
2315 * Resulting from that, the wake signal recognized here
2316 * _must_ be the one belonging to the 'exchange config
2319 down(&adapter->erp_ready_sem);
2320 if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT) {
2321 ZFCP_LOG_INFO("error: exchange of configuration data "
2322 "for adapter %s timed out\n",
2323 zfcp_get_busid_by_adapter(adapter));
2327 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT,
2331 ZFCP_LOG_DEBUG("host connection still initialising... "
2332 "waiting and retrying...\n");
2333 /* sleep a little bit before retry */
2334 msleep(jiffies_to_msecs(sleep));
2338 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK,
2339 &adapter->status)) {
2340 ZFCP_LOG_INFO("error: exchange of configuration data for "
2341 "adapter %s failed\n",
2342 zfcp_get_busid_by_adapter(adapter));
2343 retval = ZFCP_ERP_FAILED;
2350 zfcp_erp_adapter_strategy_open_fsf_xport(struct zfcp_erp_action *erp_action)
2355 struct zfcp_adapter *adapter = erp_action->adapter;
2357 atomic_clear_mask(ZFCP_STATUS_ADAPTER_XPORT_OK, &adapter->status);
2361 write_lock(&adapter->erp_lock);
2362 zfcp_erp_action_to_running(erp_action);
2363 write_unlock(&adapter->erp_lock);
2364 zfcp_erp_timeout_init(erp_action);
2365 ret = zfcp_fsf_exchange_port_data(erp_action, adapter, NULL);
2366 if (ret == -EOPNOTSUPP) {
2367 debug_text_event(adapter->erp_dbf, 3, "a_xport_notsupp");
2368 return ZFCP_ERP_SUCCEEDED;
2370 debug_text_event(adapter->erp_dbf, 3, "a_xport_failed");
2371 return ZFCP_ERP_FAILED;
2373 debug_text_event(adapter->erp_dbf, 6, "a_xport_ok");
2375 down(&adapter->erp_ready_sem);
2376 if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT) {
2377 ZFCP_LOG_INFO("error: exchange of port data "
2378 "for adapter %s timed out\n",
2379 zfcp_get_busid_by_adapter(adapter));
2382 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED,
2386 if (retries < ZFCP_EXCHANGE_PORT_DATA_SHORT_RETRIES) {
2387 sleep = ZFCP_EXCHANGE_PORT_DATA_SHORT_SLEEP;
2390 sleep = ZFCP_EXCHANGE_PORT_DATA_LONG_SLEEP;
2391 schedule_timeout(sleep);
2394 return ZFCP_ERP_SUCCEEDED;
2405 zfcp_erp_adapter_strategy_open_fsf_statusread(struct zfcp_erp_action
2408 int retval = ZFCP_ERP_SUCCEEDED;
2410 struct zfcp_adapter *adapter = erp_action->adapter;
2413 adapter->status_read_failed = 0;
2414 for (i = 0; i < ZFCP_STATUS_READS_RECOM; i++) {
2415 temp_ret = zfcp_fsf_status_read(adapter, ZFCP_WAIT_FOR_SBAL);
2417 ZFCP_LOG_INFO("error: set-up of unsolicited status "
2418 "notification failed on adapter %s\n",
2419 zfcp_get_busid_by_adapter(adapter));
2420 retval = ZFCP_ERP_FAILED;
2430 * function: zfcp_fsf_cleanup
2432 * purpose: cleanup FSF operation for specified adapter
2434 * returns: 0 - FSF operation successfully cleaned up
2435 * !0 - failed to cleanup FSF operation for this adapter
2438 zfcp_erp_adapter_strategy_close_fsf(struct zfcp_erp_action *erp_action)
2440 int retval = ZFCP_ERP_SUCCEEDED;
2441 struct zfcp_adapter *adapter = erp_action->adapter;
2444 * wake waiting initiators of requests,
2445 * return SCSI commands (with error status),
2446 * clean up all requests (synchronously)
2448 zfcp_fsf_req_dismiss_all(adapter);
2449 /* reset FSF request sequence number */
2450 adapter->fsf_req_seq_no = 0;
2451 /* all ports and units are closed */
2452 zfcp_erp_modify_adapter_status(adapter,
2453 ZFCP_STATUS_COMMON_OPEN, ZFCP_CLEAR);
2461 * purpose: this routine executes the 'Reopen Physical Port' action
2463 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2464 * ZFCP_ERP_SUCCEEDED - action finished successfully
2465 * ZFCP_ERP_FAILED - action finished unsuccessfully
2468 zfcp_erp_port_forced_strategy(struct zfcp_erp_action *erp_action)
2470 int retval = ZFCP_ERP_FAILED;
2471 struct zfcp_port *port = erp_action->port;
2472 struct zfcp_adapter *adapter = erp_action->adapter;
2474 switch (erp_action->step) {
2478 * the ULP spec. begs for waiting for oustanding commands
2480 case ZFCP_ERP_STEP_UNINITIALIZED:
2481 zfcp_erp_port_strategy_clearstati(port);
2483 * it would be sufficient to test only the normal open flag
2484 * since the phys. open flag cannot be set if the normal
2485 * open flag is unset - however, this is for readabilty ...
2487 if (atomic_test_mask((ZFCP_STATUS_PORT_PHYS_OPEN |
2488 ZFCP_STATUS_COMMON_OPEN),
2490 ZFCP_LOG_DEBUG("port 0x%016Lx is open -> trying "
2491 "close physical\n", port->wwpn);
2493 zfcp_erp_port_forced_strategy_close(erp_action);
2495 retval = ZFCP_ERP_FAILED;
2498 case ZFCP_ERP_STEP_PHYS_PORT_CLOSING:
2499 if (atomic_test_mask(ZFCP_STATUS_PORT_PHYS_OPEN,
2501 ZFCP_LOG_DEBUG("close physical failed for port "
2502 "0x%016Lx\n", port->wwpn);
2503 retval = ZFCP_ERP_FAILED;
2505 retval = ZFCP_ERP_SUCCEEDED;
2509 debug_text_event(adapter->erp_dbf, 3, "p_pfst/ret");
2510 debug_event(adapter->erp_dbf, 3, &port->wwpn, sizeof (wwn_t));
2511 debug_event(adapter->erp_dbf, 3, &erp_action->action, sizeof (int));
2512 debug_event(adapter->erp_dbf, 3, &retval, sizeof (int));
2520 * purpose: this routine executes the 'Reopen Port' action
2522 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2523 * ZFCP_ERP_SUCCEEDED - action finished successfully
2524 * ZFCP_ERP_FAILED - action finished unsuccessfully
2527 zfcp_erp_port_strategy(struct zfcp_erp_action *erp_action)
2529 int retval = ZFCP_ERP_FAILED;
2530 struct zfcp_port *port = erp_action->port;
2531 struct zfcp_adapter *adapter = erp_action->adapter;
2533 switch (erp_action->step) {
2537 * the ULP spec. begs for waiting for oustanding commands
2539 case ZFCP_ERP_STEP_UNINITIALIZED:
2540 zfcp_erp_port_strategy_clearstati(port);
2541 if (atomic_test_mask(ZFCP_STATUS_COMMON_OPEN, &port->status)) {
2542 ZFCP_LOG_DEBUG("port 0x%016Lx is open -> trying "
2543 "close\n", port->wwpn);
2544 retval = zfcp_erp_port_strategy_close(erp_action);
2546 } /* else it's already closed, open it */
2549 case ZFCP_ERP_STEP_PORT_CLOSING:
2550 if (atomic_test_mask(ZFCP_STATUS_COMMON_OPEN, &port->status)) {
2551 ZFCP_LOG_DEBUG("close failed for port 0x%016Lx\n",
2553 retval = ZFCP_ERP_FAILED;
2555 } /* else it's closed now, open it */
2558 if (erp_action->status & ZFCP_STATUS_ERP_CLOSE_ONLY)
2559 retval = ZFCP_ERP_EXIT;
2561 retval = zfcp_erp_port_strategy_open(erp_action);
2564 debug_text_event(adapter->erp_dbf, 3, "p_pst/ret");
2565 debug_event(adapter->erp_dbf, 3, &port->wwpn, sizeof (wwn_t));
2566 debug_event(adapter->erp_dbf, 3, &erp_action->action, sizeof (int));
2567 debug_event(adapter->erp_dbf, 3, &retval, sizeof (int));
2580 zfcp_erp_port_strategy_open(struct zfcp_erp_action *erp_action)
2584 if (atomic_test_mask(ZFCP_STATUS_PORT_WKA,
2585 &erp_action->port->status))
2586 retval = zfcp_erp_port_strategy_open_nameserver(erp_action);
2588 retval = zfcp_erp_port_strategy_open_common(erp_action);
2600 * FIXME(design): currently only prepared for fabric (nameserver!)
2603 zfcp_erp_port_strategy_open_common(struct zfcp_erp_action *erp_action)
2606 struct zfcp_adapter *adapter = erp_action->adapter;
2607 struct zfcp_port *port = erp_action->port;
2609 switch (erp_action->step) {
2611 case ZFCP_ERP_STEP_UNINITIALIZED:
2612 case ZFCP_ERP_STEP_PHYS_PORT_CLOSING:
2613 case ZFCP_ERP_STEP_PORT_CLOSING:
2614 if (fc_host_port_type(adapter->scsi_host) == FC_PORTTYPE_PTP) {
2615 if (port->wwpn != adapter->peer_wwpn) {
2616 ZFCP_LOG_NORMAL("Failed to open port 0x%016Lx "
2617 "on adapter %s.\nPeer WWPN "
2618 "0x%016Lx does not match\n",
2620 zfcp_get_busid_by_adapter(adapter),
2621 adapter->peer_wwpn);
2622 zfcp_erp_port_failed(port);
2623 retval = ZFCP_ERP_FAILED;
2626 port->d_id = adapter->peer_d_id;
2627 atomic_set_mask(ZFCP_STATUS_PORT_DID_DID, &port->status);
2628 retval = zfcp_erp_port_strategy_open_port(erp_action);
2631 if (!(adapter->nameserver_port)) {
2632 retval = zfcp_nameserver_enqueue(adapter);
2634 ZFCP_LOG_NORMAL("error: nameserver port "
2635 "unavailable for adapter %s\n",
2636 zfcp_get_busid_by_adapter(adapter));
2637 retval = ZFCP_ERP_FAILED;
2641 if (!atomic_test_mask(ZFCP_STATUS_COMMON_UNBLOCKED,
2642 &adapter->nameserver_port->status)) {
2643 ZFCP_LOG_DEBUG("nameserver port is not open -> open "
2644 "nameserver port\n");
2645 /* nameserver port may live again */
2646 atomic_set_mask(ZFCP_STATUS_COMMON_RUNNING,
2647 &adapter->nameserver_port->status);
2648 if (zfcp_erp_port_reopen(adapter->nameserver_port, 0)
2651 ZFCP_ERP_STEP_NAMESERVER_OPEN;
2652 retval = ZFCP_ERP_CONTINUES;
2654 retval = ZFCP_ERP_FAILED;
2657 /* else nameserver port is already open, fall through */
2658 case ZFCP_ERP_STEP_NAMESERVER_OPEN:
2659 if (!atomic_test_mask(ZFCP_STATUS_COMMON_OPEN,
2660 &adapter->nameserver_port->status)) {
2661 ZFCP_LOG_DEBUG("open failed for nameserver port\n");
2662 retval = ZFCP_ERP_FAILED;
2664 ZFCP_LOG_DEBUG("nameserver port is open -> "
2665 "nameserver look-up for port 0x%016Lx\n",
2667 retval = zfcp_erp_port_strategy_open_common_lookup
2672 case ZFCP_ERP_STEP_NAMESERVER_LOOKUP:
2673 if (!atomic_test_mask(ZFCP_STATUS_PORT_DID_DID, &port->status)) {
2674 if (atomic_test_mask
2675 (ZFCP_STATUS_PORT_INVALID_WWPN, &port->status)) {
2676 ZFCP_LOG_DEBUG("nameserver look-up failed "
2677 "for port 0x%016Lx "
2678 "(misconfigured WWPN?)\n",
2680 zfcp_erp_port_failed(port);
2681 retval = ZFCP_ERP_EXIT;
2683 ZFCP_LOG_DEBUG("nameserver look-up failed for "
2684 "port 0x%016Lx\n", port->wwpn);
2685 retval = ZFCP_ERP_FAILED;
2688 ZFCP_LOG_DEBUG("port 0x%016Lx has d_id=0x%08x -> "
2689 "trying open\n", port->wwpn, port->d_id);
2690 retval = zfcp_erp_port_strategy_open_port(erp_action);
2694 case ZFCP_ERP_STEP_PORT_OPENING:
2695 /* D_ID might have changed during open */
2696 if (atomic_test_mask((ZFCP_STATUS_COMMON_OPEN |
2697 ZFCP_STATUS_PORT_DID_DID),
2699 ZFCP_LOG_DEBUG("port 0x%016Lx is open\n", port->wwpn);
2700 retval = ZFCP_ERP_SUCCEEDED;
2702 ZFCP_LOG_DEBUG("open failed for port 0x%016Lx\n",
2704 retval = ZFCP_ERP_FAILED;
2709 ZFCP_LOG_NORMAL("bug: unknown erp step 0x%08x\n",
2711 retval = ZFCP_ERP_FAILED;
2725 zfcp_erp_port_strategy_open_nameserver(struct zfcp_erp_action *erp_action)
2728 struct zfcp_port *port = erp_action->port;
2730 switch (erp_action->step) {
2732 case ZFCP_ERP_STEP_UNINITIALIZED:
2733 case ZFCP_ERP_STEP_PHYS_PORT_CLOSING:
2734 case ZFCP_ERP_STEP_PORT_CLOSING:
2735 ZFCP_LOG_DEBUG("port 0x%016Lx has d_id=0x%08x -> trying open\n",
2736 port->wwpn, port->d_id);
2737 retval = zfcp_erp_port_strategy_open_port(erp_action);
2740 case ZFCP_ERP_STEP_PORT_OPENING:
2741 if (atomic_test_mask(ZFCP_STATUS_COMMON_OPEN, &port->status)) {
2742 ZFCP_LOG_DEBUG("WKA port is open\n");
2743 retval = ZFCP_ERP_SUCCEEDED;
2745 ZFCP_LOG_DEBUG("open failed for WKA port\n");
2746 retval = ZFCP_ERP_FAILED;
2748 /* this is needed anyway (dont care for retval of wakeup) */
2749 ZFCP_LOG_DEBUG("continue other open port operations\n");
2750 zfcp_erp_port_strategy_open_nameserver_wakeup(erp_action);
2754 ZFCP_LOG_NORMAL("bug: unknown erp step 0x%08x\n",
2756 retval = ZFCP_ERP_FAILED;
2765 * purpose: makes the erp thread continue with reopen (physical) port
2766 * actions which have been paused until the name server port
2767 * is opened (or failed)
2769 * returns: 0 (a kind of void retval, its not used)
2772 zfcp_erp_port_strategy_open_nameserver_wakeup(struct zfcp_erp_action
2776 unsigned long flags;
2777 struct zfcp_adapter *adapter = ns_erp_action->adapter;
2778 struct zfcp_erp_action *erp_action, *tmp;
2780 read_lock_irqsave(&adapter->erp_lock, flags);
2781 list_for_each_entry_safe(erp_action, tmp, &adapter->erp_running_head,
2783 debug_text_event(adapter->erp_dbf, 4, "p_pstnsw_n");
2784 debug_event(adapter->erp_dbf, 4, &erp_action->port->wwpn,
2786 if (erp_action->step == ZFCP_ERP_STEP_NAMESERVER_OPEN) {
2787 debug_text_event(adapter->erp_dbf, 3, "p_pstnsw_w");
2788 debug_event(adapter->erp_dbf, 3,
2789 &erp_action->port->wwpn, sizeof (wwn_t));
2790 if (atomic_test_mask(
2791 ZFCP_STATUS_COMMON_ERP_FAILED,
2792 &adapter->nameserver_port->status))
2793 zfcp_erp_port_failed(erp_action->port);
2794 zfcp_erp_action_ready(erp_action);
2797 read_unlock_irqrestore(&adapter->erp_lock, flags);
2807 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2808 * ZFCP_ERP_FAILED - action finished unsuccessfully
2811 zfcp_erp_port_forced_strategy_close(struct zfcp_erp_action *erp_action)
2814 struct zfcp_adapter *adapter = erp_action->adapter;
2815 struct zfcp_port *port = erp_action->port;
2817 zfcp_erp_timeout_init(erp_action);
2818 retval = zfcp_fsf_close_physical_port(erp_action);
2819 if (retval == -ENOMEM) {
2820 debug_text_event(adapter->erp_dbf, 5, "o_pfstc_nomem");
2821 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2822 retval = ZFCP_ERP_NOMEM;
2825 erp_action->step = ZFCP_ERP_STEP_PHYS_PORT_CLOSING;
2827 debug_text_event(adapter->erp_dbf, 5, "o_pfstc_cpf");
2828 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2829 /* could not send 'open', fail */
2830 retval = ZFCP_ERP_FAILED;
2833 debug_text_event(adapter->erp_dbf, 6, "o_pfstc_cpok");
2834 debug_event(adapter->erp_dbf, 6, &port->wwpn, sizeof (wwn_t));
2835 retval = ZFCP_ERP_CONTINUES;
2848 zfcp_erp_port_strategy_clearstati(struct zfcp_port *port)
2851 struct zfcp_adapter *adapter = port->adapter;
2853 debug_text_event(adapter->erp_dbf, 5, "p_pstclst");
2854 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2856 atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING |
2857 ZFCP_STATUS_COMMON_CLOSING |
2858 ZFCP_STATUS_COMMON_ACCESS_DENIED |
2859 ZFCP_STATUS_PORT_DID_DID |
2860 ZFCP_STATUS_PORT_PHYS_CLOSING |
2861 ZFCP_STATUS_PORT_INVALID_WWPN,
2871 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2872 * ZFCP_ERP_FAILED - action finished unsuccessfully
2875 zfcp_erp_port_strategy_close(struct zfcp_erp_action *erp_action)
2878 struct zfcp_adapter *adapter = erp_action->adapter;
2879 struct zfcp_port *port = erp_action->port;
2881 zfcp_erp_timeout_init(erp_action);
2882 retval = zfcp_fsf_close_port(erp_action);
2883 if (retval == -ENOMEM) {
2884 debug_text_event(adapter->erp_dbf, 5, "p_pstc_nomem");
2885 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2886 retval = ZFCP_ERP_NOMEM;
2889 erp_action->step = ZFCP_ERP_STEP_PORT_CLOSING;
2891 debug_text_event(adapter->erp_dbf, 5, "p_pstc_cpf");
2892 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2893 /* could not send 'close', fail */
2894 retval = ZFCP_ERP_FAILED;
2897 debug_text_event(adapter->erp_dbf, 6, "p_pstc_cpok");
2898 debug_event(adapter->erp_dbf, 6, &port->wwpn, sizeof (wwn_t));
2899 retval = ZFCP_ERP_CONTINUES;
2909 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2910 * ZFCP_ERP_FAILED - action finished unsuccessfully
2913 zfcp_erp_port_strategy_open_port(struct zfcp_erp_action *erp_action)
2916 struct zfcp_adapter *adapter = erp_action->adapter;
2917 struct zfcp_port *port = erp_action->port;
2919 zfcp_erp_timeout_init(erp_action);
2920 retval = zfcp_fsf_open_port(erp_action);
2921 if (retval == -ENOMEM) {
2922 debug_text_event(adapter->erp_dbf, 5, "p_psto_nomem");
2923 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2924 retval = ZFCP_ERP_NOMEM;
2927 erp_action->step = ZFCP_ERP_STEP_PORT_OPENING;
2929 debug_text_event(adapter->erp_dbf, 5, "p_psto_opf");
2930 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2931 /* could not send 'open', fail */
2932 retval = ZFCP_ERP_FAILED;
2935 debug_text_event(adapter->erp_dbf, 6, "p_psto_opok");
2936 debug_event(adapter->erp_dbf, 6, &port->wwpn, sizeof (wwn_t));
2937 retval = ZFCP_ERP_CONTINUES;
2947 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2948 * ZFCP_ERP_FAILED - action finished unsuccessfully
2951 zfcp_erp_port_strategy_open_common_lookup(struct zfcp_erp_action *erp_action)
2954 struct zfcp_adapter *adapter = erp_action->adapter;
2955 struct zfcp_port *port = erp_action->port;
2957 zfcp_erp_timeout_init(erp_action);
2958 retval = zfcp_ns_gid_pn_request(erp_action);
2959 if (retval == -ENOMEM) {
2960 debug_text_event(adapter->erp_dbf, 5, "p_pstn_nomem");
2961 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2962 retval = ZFCP_ERP_NOMEM;
2965 erp_action->step = ZFCP_ERP_STEP_NAMESERVER_LOOKUP;
2967 debug_text_event(adapter->erp_dbf, 5, "p_pstn_ref");
2968 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2969 /* could not send nameserver request, fail */
2970 retval = ZFCP_ERP_FAILED;
2973 debug_text_event(adapter->erp_dbf, 6, "p_pstn_reok");
2974 debug_event(adapter->erp_dbf, 6, &port->wwpn, sizeof (wwn_t));
2975 retval = ZFCP_ERP_CONTINUES;
2983 * purpose: this routine executes the 'Reopen Unit' action
2984 * currently no retries
2986 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2987 * ZFCP_ERP_SUCCEEDED - action finished successfully
2988 * ZFCP_ERP_FAILED - action finished unsuccessfully
2991 zfcp_erp_unit_strategy(struct zfcp_erp_action *erp_action)
2993 int retval = ZFCP_ERP_FAILED;
2994 struct zfcp_unit *unit = erp_action->unit;
2995 struct zfcp_adapter *adapter = erp_action->adapter;
2997 switch (erp_action->step) {
3001 * the ULP spec. begs for waiting for oustanding commands
3003 case ZFCP_ERP_STEP_UNINITIALIZED:
3004 zfcp_erp_unit_strategy_clearstati(unit);
3005 if (atomic_test_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status)) {
3006 ZFCP_LOG_DEBUG("unit 0x%016Lx is open -> "
3007 "trying close\n", unit->fcp_lun);
3008 retval = zfcp_erp_unit_strategy_close(erp_action);
3011 /* else it's already closed, fall through */
3012 case ZFCP_ERP_STEP_UNIT_CLOSING:
3013 if (atomic_test_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status)) {
3014 ZFCP_LOG_DEBUG("close failed for unit 0x%016Lx\n",
3016 retval = ZFCP_ERP_FAILED;
3018 if (erp_action->status & ZFCP_STATUS_ERP_CLOSE_ONLY)
3019 retval = ZFCP_ERP_EXIT;
3021 ZFCP_LOG_DEBUG("unit 0x%016Lx is not open -> "
3022 "trying open\n", unit->fcp_lun);
3024 zfcp_erp_unit_strategy_open(erp_action);
3029 case ZFCP_ERP_STEP_UNIT_OPENING:
3030 if (atomic_test_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status)) {
3031 ZFCP_LOG_DEBUG("unit 0x%016Lx is open\n",
3033 retval = ZFCP_ERP_SUCCEEDED;
3035 ZFCP_LOG_DEBUG("open failed for unit 0x%016Lx\n",
3037 retval = ZFCP_ERP_FAILED;
3042 debug_text_event(adapter->erp_dbf, 3, "u_ust/ret");
3043 debug_event(adapter->erp_dbf, 3, &unit->fcp_lun, sizeof (fcp_lun_t));
3044 debug_event(adapter->erp_dbf, 3, &erp_action->action, sizeof (int));
3045 debug_event(adapter->erp_dbf, 3, &retval, sizeof (int));
3057 zfcp_erp_unit_strategy_clearstati(struct zfcp_unit *unit)
3060 struct zfcp_adapter *adapter = unit->port->adapter;
3062 debug_text_event(adapter->erp_dbf, 5, "u_ustclst");
3063 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun, sizeof (fcp_lun_t));
3065 atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING |
3066 ZFCP_STATUS_COMMON_CLOSING |
3067 ZFCP_STATUS_COMMON_ACCESS_DENIED |
3068 ZFCP_STATUS_UNIT_SHARED |
3069 ZFCP_STATUS_UNIT_READONLY,
3080 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
3081 * ZFCP_ERP_FAILED - action finished unsuccessfully
3084 zfcp_erp_unit_strategy_close(struct zfcp_erp_action *erp_action)
3087 struct zfcp_adapter *adapter = erp_action->adapter;
3088 struct zfcp_unit *unit = erp_action->unit;
3090 zfcp_erp_timeout_init(erp_action);
3091 retval = zfcp_fsf_close_unit(erp_action);
3092 if (retval == -ENOMEM) {
3093 debug_text_event(adapter->erp_dbf, 5, "u_ustc_nomem");
3094 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun,
3095 sizeof (fcp_lun_t));
3096 retval = ZFCP_ERP_NOMEM;
3099 erp_action->step = ZFCP_ERP_STEP_UNIT_CLOSING;
3101 debug_text_event(adapter->erp_dbf, 5, "u_ustc_cuf");
3102 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun,
3103 sizeof (fcp_lun_t));
3104 /* could not send 'close', fail */
3105 retval = ZFCP_ERP_FAILED;
3108 debug_text_event(adapter->erp_dbf, 6, "u_ustc_cuok");
3109 debug_event(adapter->erp_dbf, 6, &unit->fcp_lun, sizeof (fcp_lun_t));
3110 retval = ZFCP_ERP_CONTINUES;
3121 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
3122 * ZFCP_ERP_FAILED - action finished unsuccessfully
3125 zfcp_erp_unit_strategy_open(struct zfcp_erp_action *erp_action)
3128 struct zfcp_adapter *adapter = erp_action->adapter;
3129 struct zfcp_unit *unit = erp_action->unit;
3131 zfcp_erp_timeout_init(erp_action);
3132 retval = zfcp_fsf_open_unit(erp_action);
3133 if (retval == -ENOMEM) {
3134 debug_text_event(adapter->erp_dbf, 5, "u_usto_nomem");
3135 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun,
3136 sizeof (fcp_lun_t));
3137 retval = ZFCP_ERP_NOMEM;
3140 erp_action->step = ZFCP_ERP_STEP_UNIT_OPENING;
3142 debug_text_event(adapter->erp_dbf, 5, "u_usto_ouf");
3143 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun,
3144 sizeof (fcp_lun_t));
3145 /* could not send 'open', fail */
3146 retval = ZFCP_ERP_FAILED;
3149 debug_text_event(adapter->erp_dbf, 6, "u_usto_ouok");
3150 debug_event(adapter->erp_dbf, 6, &unit->fcp_lun, sizeof (fcp_lun_t));
3151 retval = ZFCP_ERP_CONTINUES;
3164 zfcp_erp_timeout_init(struct zfcp_erp_action *erp_action)
3166 init_timer(&erp_action->timer);
3167 erp_action->timer.function = zfcp_erp_timeout_handler;
3168 erp_action->timer.data = (unsigned long) erp_action;
3169 /* jiffies will be added in zfcp_fsf_req_send */
3170 erp_action->timer.expires = ZFCP_ERP_FSFREQ_TIMEOUT;
3176 * purpose: enqueue the specified error recovery action, if needed
3181 zfcp_erp_action_enqueue(int action,
3182 struct zfcp_adapter *adapter,
3183 struct zfcp_port *port, struct zfcp_unit *unit)
3186 struct zfcp_erp_action *erp_action = NULL;
3187 int stronger_action = 0;
3191 * We need some rules here which check whether we really need
3192 * this action or whether we should just drop it.
3193 * E.g. if there is a unfinished 'Reopen Port' request then we drop a
3194 * 'Reopen Unit' request for an associated unit since we can't
3195 * satisfy this request now. A 'Reopen Port' action will trigger
3196 * 'Reopen Unit' actions when it completes.
3197 * Thus, there are only actions in the queue which can immediately be
3198 * executed. This makes the processing of the action queue more
3202 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP,
3206 debug_event(adapter->erp_dbf, 4, &action, sizeof (int));
3207 /* check whether we really need this */
3209 case ZFCP_ERP_ACTION_REOPEN_UNIT:
3210 if (atomic_test_mask
3211 (ZFCP_STATUS_COMMON_ERP_INUSE, &unit->status)) {
3212 debug_text_event(adapter->erp_dbf, 4, "u_actenq_drp");
3213 debug_event(adapter->erp_dbf, 4, &port->wwpn,
3215 debug_event(adapter->erp_dbf, 4, &unit->fcp_lun,
3216 sizeof (fcp_lun_t));
3219 if (!atomic_test_mask
3220 (ZFCP_STATUS_COMMON_RUNNING, &port->status) ||
3222 (ZFCP_STATUS_COMMON_ERP_FAILED, &port->status)) {
3225 if (!atomic_test_mask
3226 (ZFCP_STATUS_COMMON_UNBLOCKED, &port->status)) {
3227 stronger_action = ZFCP_ERP_ACTION_REOPEN_PORT;
3230 /* fall through !!! */
3232 case ZFCP_ERP_ACTION_REOPEN_PORT:
3233 if (atomic_test_mask
3234 (ZFCP_STATUS_COMMON_ERP_INUSE, &port->status)) {
3235 debug_text_event(adapter->erp_dbf, 4, "p_actenq_drp");
3236 debug_event(adapter->erp_dbf, 4, &port->wwpn,
3240 /* fall through !!! */
3242 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
3243 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_INUSE,
3245 if (port->erp_action.action !=
3246 ZFCP_ERP_ACTION_REOPEN_PORT_FORCED) {
3247 ZFCP_LOG_INFO("dropped erp action %i (port "
3248 "0x%016Lx, action in use: %i)\n",
3250 port->erp_action.action);
3251 debug_text_event(adapter->erp_dbf, 4,
3254 debug_text_event(adapter->erp_dbf, 4,
3256 debug_event(adapter->erp_dbf, 4, &port->wwpn,
3260 if (!atomic_test_mask
3261 (ZFCP_STATUS_COMMON_RUNNING, &adapter->status) ||
3263 (ZFCP_STATUS_COMMON_ERP_FAILED, &adapter->status)) {
3266 if (!atomic_test_mask
3267 (ZFCP_STATUS_COMMON_UNBLOCKED, &adapter->status)) {
3268 stronger_action = ZFCP_ERP_ACTION_REOPEN_ADAPTER;
3271 /* fall through !!! */
3273 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
3274 if (atomic_test_mask
3275 (ZFCP_STATUS_COMMON_ERP_INUSE, &adapter->status)) {
3276 debug_text_event(adapter->erp_dbf, 4, "a_actenq_drp");
3282 debug_text_exception(adapter->erp_dbf, 1, "a_actenq_bug");
3283 debug_event(adapter->erp_dbf, 1, &action, sizeof (int));
3284 ZFCP_LOG_NORMAL("bug: unknown erp action requested "
3285 "on adapter %s (action=%d)\n",
3286 zfcp_get_busid_by_adapter(adapter), action);
3290 /* check whether we need something stronger first */
3291 if (stronger_action) {
3292 debug_text_event(adapter->erp_dbf, 4, "a_actenq_str");
3293 debug_event(adapter->erp_dbf, 4, &stronger_action,
3295 ZFCP_LOG_DEBUG("stronger erp action %d needed before "
3296 "erp action %d on adapter %s\n",
3297 stronger_action, action,
3298 zfcp_get_busid_by_adapter(adapter));
3299 action = stronger_action;
3302 /* mark adapter to have some error recovery pending */
3303 atomic_set_mask(ZFCP_STATUS_ADAPTER_ERP_PENDING, &adapter->status);
3305 /* setup error recovery action */
3308 case ZFCP_ERP_ACTION_REOPEN_UNIT:
3309 zfcp_unit_get(unit);
3310 atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &unit->status);
3311 erp_action = &unit->erp_action;
3312 if (!atomic_test_mask
3313 (ZFCP_STATUS_COMMON_RUNNING, &unit->status))
3314 status = ZFCP_STATUS_ERP_CLOSE_ONLY;
3317 case ZFCP_ERP_ACTION_REOPEN_PORT:
3318 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
3319 zfcp_port_get(port);
3320 zfcp_erp_action_dismiss_port(port);
3321 atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &port->status);
3322 erp_action = &port->erp_action;
3323 if (!atomic_test_mask
3324 (ZFCP_STATUS_COMMON_RUNNING, &port->status))
3325 status = ZFCP_STATUS_ERP_CLOSE_ONLY;
3328 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
3329 zfcp_adapter_get(adapter);
3330 zfcp_erp_action_dismiss_adapter(adapter);
3331 atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &adapter->status);
3332 erp_action = &adapter->erp_action;
3333 if (!atomic_test_mask
3334 (ZFCP_STATUS_COMMON_RUNNING, &adapter->status))
3335 status = ZFCP_STATUS_ERP_CLOSE_ONLY;
3339 debug_text_event(adapter->erp_dbf, 4, "a_actenq");
3341 memset(erp_action, 0, sizeof (struct zfcp_erp_action));
3342 erp_action->adapter = adapter;
3343 erp_action->port = port;
3344 erp_action->unit = unit;
3345 erp_action->action = action;
3346 erp_action->status = status;
3348 ++adapter->erp_total_count;
3350 /* finally put it into 'ready' queue and kick erp thread */
3351 list_add(&erp_action->list, &adapter->erp_ready_head);
3352 up(&adapter->erp_ready_sem);
3366 zfcp_erp_action_dequeue(struct zfcp_erp_action *erp_action)
3369 struct zfcp_adapter *adapter = erp_action->adapter;
3371 --adapter->erp_total_count;
3372 if (erp_action->status & ZFCP_STATUS_ERP_LOWMEM) {
3373 --adapter->erp_low_mem_count;
3374 erp_action->status &= ~ZFCP_STATUS_ERP_LOWMEM;
3377 debug_text_event(adapter->erp_dbf, 4, "a_actdeq");
3378 debug_event(adapter->erp_dbf, 4, &erp_action->action, sizeof (int));
3379 list_del(&erp_action->list);
3380 switch (erp_action->action) {
3381 case ZFCP_ERP_ACTION_REOPEN_UNIT:
3382 atomic_clear_mask(ZFCP_STATUS_COMMON_ERP_INUSE,
3383 &erp_action->unit->status);
3385 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
3386 case ZFCP_ERP_ACTION_REOPEN_PORT:
3387 atomic_clear_mask(ZFCP_STATUS_COMMON_ERP_INUSE,
3388 &erp_action->port->status);
3390 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
3391 atomic_clear_mask(ZFCP_STATUS_COMMON_ERP_INUSE,
3392 &erp_action->adapter->status);
3402 * zfcp_erp_action_cleanup
3404 * Register unit with scsi stack if appropriate and fix reference counts.
3405 * Note: Temporary units are not registered with scsi stack.
3408 zfcp_erp_action_cleanup(int action, struct zfcp_adapter *adapter,
3409 struct zfcp_port *port, struct zfcp_unit *unit,
3413 case ZFCP_ERP_ACTION_REOPEN_UNIT:
3414 if ((result == ZFCP_ERP_SUCCEEDED)
3415 && (!atomic_test_mask(ZFCP_STATUS_UNIT_TEMPORARY,
3419 scsi_add_device(port->adapter->scsi_host, 0,
3420 port->rport->scsi_target_id,
3422 zfcp_unit_put(unit);
3424 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
3425 case ZFCP_ERP_ACTION_REOPEN_PORT:
3426 if ((result == ZFCP_ERP_SUCCEEDED)
3427 && !atomic_test_mask(ZFCP_STATUS_PORT_NO_WWPN,
3430 struct fc_rport_identifiers ids;
3431 ids.node_name = port->wwnn;
3432 ids.port_name = port->wwpn;
3433 ids.port_id = port->d_id;
3434 ids.roles = FC_RPORT_ROLE_FCP_TARGET;
3436 fc_remote_port_add(adapter->scsi_host, 0, &ids);
3438 ZFCP_LOG_NORMAL("failed registration of rport"
3439 "(adapter %s, wwpn=0x%016Lx)\n",
3440 zfcp_get_busid_by_port(port),
3443 zfcp_port_put(port);
3445 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
3446 zfcp_adapter_put(adapter);
3462 zfcp_erp_action_dismiss_adapter(struct zfcp_adapter *adapter)
3465 struct zfcp_port *port;
3467 debug_text_event(adapter->erp_dbf, 5, "a_actab");
3468 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &adapter->status))
3469 zfcp_erp_action_dismiss(&adapter->erp_action);
3471 list_for_each_entry(port, &adapter->port_list_head, list)
3472 zfcp_erp_action_dismiss_port(port);
3485 zfcp_erp_action_dismiss_port(struct zfcp_port *port)
3488 struct zfcp_unit *unit;
3489 struct zfcp_adapter *adapter = port->adapter;
3491 debug_text_event(adapter->erp_dbf, 5, "p_actab");
3492 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
3493 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &port->status))
3494 zfcp_erp_action_dismiss(&port->erp_action);
3496 list_for_each_entry(unit, &port->unit_list_head, list)
3497 zfcp_erp_action_dismiss_unit(unit);
3510 zfcp_erp_action_dismiss_unit(struct zfcp_unit *unit)
3513 struct zfcp_adapter *adapter = unit->port->adapter;
3515 debug_text_event(adapter->erp_dbf, 5, "u_actab");
3516 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun, sizeof (fcp_lun_t));
3517 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &unit->status))
3518 zfcp_erp_action_dismiss(&unit->erp_action);
3526 * purpose: moves erp_action to 'erp running list'
3531 zfcp_erp_action_to_running(struct zfcp_erp_action *erp_action)
3533 struct zfcp_adapter *adapter = erp_action->adapter;
3535 debug_text_event(adapter->erp_dbf, 6, "a_toru");
3536 debug_event(adapter->erp_dbf, 6, &erp_action->action, sizeof (int));
3537 list_move(&erp_action->list, &erp_action->adapter->erp_running_head);
3543 * purpose: moves erp_action to 'erp ready list'
3548 zfcp_erp_action_to_ready(struct zfcp_erp_action *erp_action)
3550 struct zfcp_adapter *adapter = erp_action->adapter;
3552 debug_text_event(adapter->erp_dbf, 6, "a_tore");
3553 debug_event(adapter->erp_dbf, 6, &erp_action->action, sizeof (int));
3554 list_move(&erp_action->list, &erp_action->adapter->erp_ready_head);
3558 * function: zfcp_erp_port_boxed
3563 zfcp_erp_port_boxed(struct zfcp_port *port)
3565 struct zfcp_adapter *adapter = port->adapter;
3566 unsigned long flags;
3568 debug_text_event(adapter->erp_dbf, 3, "p_access_boxed");
3569 debug_event(adapter->erp_dbf, 3, &port->wwpn, sizeof(wwn_t));
3570 read_lock_irqsave(&zfcp_data.config_lock, flags);
3571 zfcp_erp_modify_port_status(port,
3572 ZFCP_STATUS_COMMON_ACCESS_BOXED,
3574 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
3575 zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED);
3579 * function: zfcp_erp_unit_boxed
3584 zfcp_erp_unit_boxed(struct zfcp_unit *unit)
3586 struct zfcp_adapter *adapter = unit->port->adapter;
3588 debug_text_event(adapter->erp_dbf, 3, "u_access_boxed");
3589 debug_event(adapter->erp_dbf, 3, &unit->fcp_lun, sizeof(fcp_lun_t));
3590 zfcp_erp_modify_unit_status(unit,
3591 ZFCP_STATUS_COMMON_ACCESS_BOXED,
3593 zfcp_erp_unit_reopen(unit, ZFCP_STATUS_COMMON_ERP_FAILED);
3597 * function: zfcp_erp_port_access_denied
3602 zfcp_erp_port_access_denied(struct zfcp_port *port)
3604 struct zfcp_adapter *adapter = port->adapter;
3605 unsigned long flags;
3607 debug_text_event(adapter->erp_dbf, 3, "p_access_denied");
3608 debug_event(adapter->erp_dbf, 3, &port->wwpn, sizeof(wwn_t));
3609 read_lock_irqsave(&zfcp_data.config_lock, flags);
3610 zfcp_erp_modify_port_status(port,
3611 ZFCP_STATUS_COMMON_ERP_FAILED |
3612 ZFCP_STATUS_COMMON_ACCESS_DENIED,
3614 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
3618 * function: zfcp_erp_unit_access_denied
3623 zfcp_erp_unit_access_denied(struct zfcp_unit *unit)
3625 struct zfcp_adapter *adapter = unit->port->adapter;
3627 debug_text_event(adapter->erp_dbf, 3, "u_access_denied");
3628 debug_event(adapter->erp_dbf, 3, &unit->fcp_lun, sizeof(fcp_lun_t));
3629 zfcp_erp_modify_unit_status(unit,
3630 ZFCP_STATUS_COMMON_ERP_FAILED |
3631 ZFCP_STATUS_COMMON_ACCESS_DENIED,
3636 * function: zfcp_erp_adapter_access_changed
3641 zfcp_erp_adapter_access_changed(struct zfcp_adapter *adapter)
3643 struct zfcp_port *port;
3644 unsigned long flags;
3646 if (adapter->connection_features & FSF_FEATURE_NPIV_MODE)
3649 debug_text_event(adapter->erp_dbf, 3, "a_access_recover");
3650 debug_event(adapter->erp_dbf, 3, &adapter->name, 8);
3652 read_lock_irqsave(&zfcp_data.config_lock, flags);
3653 if (adapter->nameserver_port)
3654 zfcp_erp_port_access_changed(adapter->nameserver_port);
3655 list_for_each_entry(port, &adapter->port_list_head, list)
3656 if (port != adapter->nameserver_port)
3657 zfcp_erp_port_access_changed(port);
3658 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
3662 * function: zfcp_erp_port_access_changed
3667 zfcp_erp_port_access_changed(struct zfcp_port *port)
3669 struct zfcp_adapter *adapter = port->adapter;
3670 struct zfcp_unit *unit;
3672 debug_text_event(adapter->erp_dbf, 3, "p_access_recover");
3673 debug_event(adapter->erp_dbf, 3, &port->wwpn, sizeof(wwn_t));
3675 if (!atomic_test_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED,
3677 !atomic_test_mask(ZFCP_STATUS_COMMON_ACCESS_BOXED,
3679 if (!atomic_test_mask(ZFCP_STATUS_PORT_WKA, &port->status))
3680 list_for_each_entry(unit, &port->unit_list_head, list)
3681 zfcp_erp_unit_access_changed(unit);
3685 ZFCP_LOG_NORMAL("reopen of port 0x%016Lx on adapter %s "
3686 "(due to ACT update)\n",
3687 port->wwpn, zfcp_get_busid_by_adapter(adapter));
3688 if (zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED) != 0)
3689 ZFCP_LOG_NORMAL("failed reopen of port"
3690 "(adapter %s, wwpn=0x%016Lx)\n",
3691 zfcp_get_busid_by_adapter(adapter), port->wwpn);
3695 * function: zfcp_erp_unit_access_changed
3700 zfcp_erp_unit_access_changed(struct zfcp_unit *unit)
3702 struct zfcp_adapter *adapter = unit->port->adapter;
3704 debug_text_event(adapter->erp_dbf, 3, "u_access_recover");
3705 debug_event(adapter->erp_dbf, 3, &unit->fcp_lun, sizeof(fcp_lun_t));
3707 if (!atomic_test_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED,
3709 !atomic_test_mask(ZFCP_STATUS_COMMON_ACCESS_BOXED,
3713 ZFCP_LOG_NORMAL("reopen of unit 0x%016Lx on port 0x%016Lx "
3714 " on adapter %s (due to ACT update)\n",
3715 unit->fcp_lun, unit->port->wwpn,
3716 zfcp_get_busid_by_adapter(adapter));
3717 if (zfcp_erp_unit_reopen(unit, ZFCP_STATUS_COMMON_ERP_FAILED) != 0)
3718 ZFCP_LOG_NORMAL("failed reopen of unit (adapter %s, "
3719 "wwpn=0x%016Lx, fcp_lun=0x%016Lx)\n",
3720 zfcp_get_busid_by_adapter(adapter),
3721 unit->port->wwpn, unit->fcp_lun);
3724 #undef ZFCP_LOG_AREA