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
34 #define ZFCP_ERP_REVISION "$Revision: 1.86 $"
38 static int zfcp_erp_adisc(struct zfcp_port *);
39 static void zfcp_erp_adisc_handler(unsigned long);
41 static int zfcp_erp_adapter_reopen_internal(struct zfcp_adapter *, int);
42 static int zfcp_erp_port_forced_reopen_internal(struct zfcp_port *, int);
43 static int zfcp_erp_port_reopen_internal(struct zfcp_port *, int);
44 static int zfcp_erp_unit_reopen_internal(struct zfcp_unit *, int);
46 static int zfcp_erp_port_reopen_all_internal(struct zfcp_adapter *, int);
47 static int zfcp_erp_unit_reopen_all_internal(struct zfcp_port *, int);
49 static void zfcp_erp_adapter_block(struct zfcp_adapter *, int);
50 static void zfcp_erp_adapter_unblock(struct zfcp_adapter *);
51 static void zfcp_erp_port_block(struct zfcp_port *, int);
52 static void zfcp_erp_port_unblock(struct zfcp_port *);
53 static void zfcp_erp_unit_block(struct zfcp_unit *, int);
54 static void zfcp_erp_unit_unblock(struct zfcp_unit *);
56 static int zfcp_erp_thread(void *);
58 static int zfcp_erp_strategy(struct zfcp_erp_action *);
60 static int zfcp_erp_strategy_do_action(struct zfcp_erp_action *);
61 static int zfcp_erp_strategy_memwait(struct zfcp_erp_action *);
62 static int zfcp_erp_strategy_check_target(struct zfcp_erp_action *, int);
63 static int zfcp_erp_strategy_check_unit(struct zfcp_unit *, int);
64 static int zfcp_erp_strategy_check_port(struct zfcp_port *, int);
65 static int zfcp_erp_strategy_check_adapter(struct zfcp_adapter *, int);
66 static int zfcp_erp_strategy_statechange(int, u32, struct zfcp_adapter *,
68 struct zfcp_unit *, int);
69 static inline int zfcp_erp_strategy_statechange_detected(atomic_t *, u32);
70 static int zfcp_erp_strategy_followup_actions(int, struct zfcp_adapter *,
72 struct zfcp_unit *, int);
73 static int zfcp_erp_strategy_check_queues(struct zfcp_adapter *);
74 static int zfcp_erp_strategy_check_action(struct zfcp_erp_action *, int);
76 static int zfcp_erp_adapter_strategy(struct zfcp_erp_action *);
77 static int zfcp_erp_adapter_strategy_generic(struct zfcp_erp_action *, int);
78 static int zfcp_erp_adapter_strategy_close(struct zfcp_erp_action *);
79 static int zfcp_erp_adapter_strategy_close_qdio(struct zfcp_erp_action *);
80 static int zfcp_erp_adapter_strategy_close_fsf(struct zfcp_erp_action *);
81 static int zfcp_erp_adapter_strategy_open(struct zfcp_erp_action *);
82 static int zfcp_erp_adapter_strategy_open_qdio(struct zfcp_erp_action *);
83 static int zfcp_erp_adapter_strategy_open_fsf(struct zfcp_erp_action *);
84 static int zfcp_erp_adapter_strategy_open_fsf_xconfig(struct zfcp_erp_action *);
85 static int zfcp_erp_adapter_strategy_open_fsf_xport(struct zfcp_erp_action *);
86 static int zfcp_erp_adapter_strategy_open_fsf_statusread(
87 struct zfcp_erp_action *);
89 static int zfcp_erp_port_forced_strategy(struct zfcp_erp_action *);
90 static int zfcp_erp_port_forced_strategy_close(struct zfcp_erp_action *);
92 static int zfcp_erp_port_strategy(struct zfcp_erp_action *);
93 static int zfcp_erp_port_strategy_clearstati(struct zfcp_port *);
94 static int zfcp_erp_port_strategy_close(struct zfcp_erp_action *);
95 static int zfcp_erp_port_strategy_open(struct zfcp_erp_action *);
96 static int zfcp_erp_port_strategy_open_nameserver(struct zfcp_erp_action *);
97 static int zfcp_erp_port_strategy_open_nameserver_wakeup(
98 struct zfcp_erp_action *);
99 static int zfcp_erp_port_strategy_open_common(struct zfcp_erp_action *);
100 static int zfcp_erp_port_strategy_open_common_lookup(struct zfcp_erp_action *);
101 static int zfcp_erp_port_strategy_open_port(struct zfcp_erp_action *);
103 static int zfcp_erp_unit_strategy(struct zfcp_erp_action *);
104 static int zfcp_erp_unit_strategy_clearstati(struct zfcp_unit *);
105 static int zfcp_erp_unit_strategy_close(struct zfcp_erp_action *);
106 static int zfcp_erp_unit_strategy_open(struct zfcp_erp_action *);
108 static int zfcp_erp_action_dismiss_adapter(struct zfcp_adapter *);
109 static int zfcp_erp_action_dismiss_port(struct zfcp_port *);
110 static int zfcp_erp_action_dismiss_unit(struct zfcp_unit *);
111 static int zfcp_erp_action_dismiss(struct zfcp_erp_action *);
113 static int zfcp_erp_action_enqueue(int, struct zfcp_adapter *,
114 struct zfcp_port *, struct zfcp_unit *);
115 static int zfcp_erp_action_dequeue(struct zfcp_erp_action *);
116 static void zfcp_erp_action_cleanup(int, struct zfcp_adapter *,
117 struct zfcp_port *, struct zfcp_unit *,
120 static void zfcp_erp_action_ready(struct zfcp_erp_action *);
121 static int zfcp_erp_action_exists(struct zfcp_erp_action *);
123 static inline void zfcp_erp_action_to_ready(struct zfcp_erp_action *);
124 static inline void zfcp_erp_action_to_running(struct zfcp_erp_action *);
126 static void zfcp_erp_memwait_handler(unsigned long);
127 static void zfcp_erp_timeout_handler(unsigned long);
128 static inline void zfcp_erp_timeout_init(struct zfcp_erp_action *);
131 * zfcp_fsf_request_timeout_handler - called if a request timed out
132 * @data: pointer to adapter for handler function
134 * This function needs to be called if requests (ELS, Generic Service,
135 * or SCSI commands) exceed a certain time limit. The assumption is
136 * that after the time limit the adapter get stuck. So we trigger a reopen of
137 * the adapter. This should not be used for error recovery, SCSI abort
138 * commands and SCSI requests from SCSI mid-layer.
141 zfcp_fsf_request_timeout_handler(unsigned long data)
143 struct zfcp_adapter *adapter;
145 adapter = (struct zfcp_adapter *) data;
147 zfcp_erp_adapter_reopen(adapter, 0);
151 * function: zfcp_fsf_scsi_er_timeout_handler
153 * purpose: This function needs to be called whenever a SCSI error recovery
154 * action (abort/reset) does not return.
155 * Re-opening the adapter means that the command can be returned
156 * by zfcp (it is guarranteed that it does not return via the
157 * adapter anymore). The buffer can then be used again.
162 zfcp_fsf_scsi_er_timeout_handler(unsigned long data)
164 struct zfcp_adapter *adapter = (struct zfcp_adapter *) data;
166 ZFCP_LOG_NORMAL("warning: SCSI error recovery timed out. "
167 "Restarting all operations on the adapter %s\n",
168 zfcp_get_busid_by_adapter(adapter));
169 debug_text_event(adapter->erp_dbf, 1, "eh_lmem_tout");
170 zfcp_erp_adapter_reopen(adapter, 0);
178 * purpose: called if an adapter failed,
179 * initiates adapter recovery which is done
182 * returns: 0 - initiated action succesfully
183 * <0 - failed to initiate action
186 zfcp_erp_adapter_reopen_internal(struct zfcp_adapter *adapter, int clear_mask)
190 debug_text_event(adapter->erp_dbf, 5, "a_ro");
191 ZFCP_LOG_DEBUG("reopen adapter %s\n",
192 zfcp_get_busid_by_adapter(adapter));
194 zfcp_erp_adapter_block(adapter, clear_mask);
196 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED, &adapter->status)) {
197 ZFCP_LOG_DEBUG("skipped reopen of failed adapter %s\n",
198 zfcp_get_busid_by_adapter(adapter));
199 debug_text_event(adapter->erp_dbf, 5, "a_ro_f");
200 /* ensure propagation of failed status to new devices */
201 zfcp_erp_adapter_failed(adapter);
205 retval = zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_ADAPTER,
206 adapter, NULL, NULL);
215 * purpose: Wrappper for zfcp_erp_adapter_reopen_internal
216 * used to ensure the correct locking
218 * returns: 0 - initiated action succesfully
219 * <0 - failed to initiate action
222 zfcp_erp_adapter_reopen(struct zfcp_adapter *adapter, int clear_mask)
227 read_lock_irqsave(&zfcp_data.config_lock, flags);
228 write_lock(&adapter->erp_lock);
229 retval = zfcp_erp_adapter_reopen_internal(adapter, clear_mask);
230 write_unlock(&adapter->erp_lock);
231 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
244 zfcp_erp_adapter_shutdown(struct zfcp_adapter *adapter, int clear_mask)
248 retval = zfcp_erp_adapter_reopen(adapter,
249 ZFCP_STATUS_COMMON_RUNNING |
250 ZFCP_STATUS_COMMON_ERP_FAILED |
264 zfcp_erp_port_shutdown(struct zfcp_port *port, int clear_mask)
268 retval = zfcp_erp_port_reopen(port,
269 ZFCP_STATUS_COMMON_RUNNING |
270 ZFCP_STATUS_COMMON_ERP_FAILED |
284 zfcp_erp_unit_shutdown(struct zfcp_unit *unit, int clear_mask)
288 retval = zfcp_erp_unit_reopen(unit,
289 ZFCP_STATUS_COMMON_RUNNING |
290 ZFCP_STATUS_COMMON_ERP_FAILED |
298 * zfcp_erp_adisc - send ADISC ELS command
299 * @port: port structure
302 zfcp_erp_adisc(struct zfcp_port *port)
304 struct zfcp_adapter *adapter = port->adapter;
305 struct zfcp_send_els *send_els;
306 struct zfcp_ls_adisc *adisc;
307 void *address = NULL;
309 struct timer_list *timer;
311 send_els = kmalloc(sizeof(struct zfcp_send_els), GFP_ATOMIC);
312 if (send_els == NULL)
314 memset(send_els, 0, sizeof(*send_els));
316 send_els->req = kmalloc(sizeof(struct scatterlist), GFP_ATOMIC);
317 if (send_els->req == NULL)
319 memset(send_els->req, 0, sizeof(*send_els->req));
321 send_els->resp = kmalloc(sizeof(struct scatterlist), GFP_ATOMIC);
322 if (send_els->resp == NULL)
324 memset(send_els->resp, 0, sizeof(*send_els->resp));
326 address = (void *) get_zeroed_page(GFP_ATOMIC);
330 zfcp_address_to_sg(address, send_els->req);
331 address += PAGE_SIZE >> 1;
332 zfcp_address_to_sg(address, send_els->resp);
333 send_els->req_count = send_els->resp_count = 1;
335 send_els->adapter = adapter;
336 send_els->port = port;
337 send_els->d_id = port->d_id;
338 send_els->handler = zfcp_erp_adisc_handler;
339 send_els->handler_data = (unsigned long) send_els;
341 adisc = zfcp_sg_to_address(send_els->req);
342 send_els->ls_code = adisc->code = ZFCP_LS_ADISC;
344 send_els->req->length = sizeof(struct zfcp_ls_adisc);
345 send_els->resp->length = sizeof(struct zfcp_ls_adisc_acc);
347 /* acc. to FC-FS, hard_nport_id in ADISC should not be set for ports
348 without FC-AL-2 capability, so we don't set it */
349 adisc->wwpn = fc_host_port_name(adapter->scsi_host);
350 adisc->wwnn = fc_host_node_name(adapter->scsi_host);
351 adisc->nport_id = fc_host_port_id(adapter->scsi_host);
352 ZFCP_LOG_INFO("ADISC request from s_id 0x%08x to d_id 0x%08x "
353 "(wwpn=0x%016Lx, wwnn=0x%016Lx, "
354 "hard_nport_id=0x%08x, nport_id=0x%08x)\n",
355 adisc->nport_id, send_els->d_id, (wwn_t) adisc->wwpn,
356 (wwn_t) adisc->wwnn, adisc->hard_nport_id,
359 timer = kmalloc(sizeof(struct timer_list), GFP_ATOMIC);
364 timer->function = zfcp_fsf_request_timeout_handler;
365 timer->data = (unsigned long) adapter;
366 timer->expires = ZFCP_FSF_REQUEST_TIMEOUT;
367 send_els->timer = timer;
369 retval = zfcp_fsf_send_els(send_els);
371 ZFCP_LOG_NORMAL("error: initiation of Send ELS failed for port "
372 "0x%08x on adapter %s\n", send_els->d_id,
373 zfcp_get_busid_by_adapter(adapter));
374 del_timer(send_els->timer);
384 __free_pages(send_els->req->page, 0);
385 if (send_els != NULL) {
386 kfree(send_els->timer);
387 kfree(send_els->req);
388 kfree(send_els->resp);
397 * zfcp_erp_adisc_handler - handler for ADISC ELS command
398 * @data: pointer to struct zfcp_send_els
400 * If ADISC failed (LS_RJT or timed out) forced reopen of the port is triggered.
403 zfcp_erp_adisc_handler(unsigned long data)
405 struct zfcp_send_els *send_els;
406 struct zfcp_port *port;
407 struct zfcp_adapter *adapter;
409 struct zfcp_ls_adisc_acc *adisc;
411 send_els = (struct zfcp_send_els *) data;
413 del_timer(send_els->timer);
415 adapter = send_els->adapter;
416 port = send_els->port;
417 d_id = send_els->d_id;
419 /* request rejected or timed out */
420 if (send_els->status != 0) {
421 ZFCP_LOG_NORMAL("ELS request rejected/timed out, "
422 "force physical port reopen "
423 "(adapter %s, port d_id=0x%08x)\n",
424 zfcp_get_busid_by_adapter(adapter), d_id);
425 debug_text_event(adapter->erp_dbf, 3, "forcreop");
426 if (zfcp_erp_port_forced_reopen(port, 0))
427 ZFCP_LOG_NORMAL("failed reopen of port "
428 "(adapter %s, wwpn=0x%016Lx)\n",
429 zfcp_get_busid_by_port(port),
434 adisc = zfcp_sg_to_address(send_els->resp);
436 ZFCP_LOG_INFO("ADISC response from d_id 0x%08x to s_id "
437 "0x%08x (wwpn=0x%016Lx, wwnn=0x%016Lx, "
438 "hard_nport_id=0x%08x, nport_id=0x%08x)\n",
439 d_id, fc_host_port_id(adapter->scsi_host),
440 (wwn_t) adisc->wwpn, (wwn_t) adisc->wwnn,
441 adisc->hard_nport_id, adisc->nport_id);
443 /* set wwnn for port */
445 port->wwnn = adisc->wwnn;
447 if (port->wwpn != adisc->wwpn) {
448 ZFCP_LOG_NORMAL("d_id assignment changed, reopening "
449 "port (adapter %s, wwpn=0x%016Lx, "
450 "adisc_resp_wwpn=0x%016Lx)\n",
451 zfcp_get_busid_by_port(port),
452 port->wwpn, (wwn_t) adisc->wwpn);
453 if (zfcp_erp_port_reopen(port, 0))
454 ZFCP_LOG_NORMAL("failed reopen of port "
455 "(adapter %s, wwpn=0x%016Lx)\n",
456 zfcp_get_busid_by_port(port),
462 __free_pages(send_els->req->page, 0);
463 kfree(send_els->timer);
464 kfree(send_els->req);
465 kfree(send_els->resp);
471 * zfcp_test_link - lightweight link test procedure
472 * @port: port to be tested
474 * Test status of a link to a remote port using the ELS command ADISC.
477 zfcp_test_link(struct zfcp_port *port)
482 retval = zfcp_erp_adisc(port);
485 ZFCP_LOG_NORMAL("reopen needed for port 0x%016Lx "
486 "on adapter %s\n ", port->wwpn,
487 zfcp_get_busid_by_port(port));
488 retval = zfcp_erp_port_forced_reopen(port, 0);
490 ZFCP_LOG_NORMAL("reopen of remote port 0x%016Lx "
491 "on adapter %s failed\n", port->wwpn,
492 zfcp_get_busid_by_port(port));
504 * purpose: called if a port failed to be opened normally
505 * initiates Forced Reopen recovery which is done
508 * returns: 0 - initiated action succesfully
509 * <0 - failed to initiate action
512 zfcp_erp_port_forced_reopen_internal(struct zfcp_port *port, int clear_mask)
515 struct zfcp_adapter *adapter = port->adapter;
517 debug_text_event(adapter->erp_dbf, 5, "pf_ro");
518 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
520 ZFCP_LOG_DEBUG("forced reopen of port 0x%016Lx on adapter %s\n",
521 port->wwpn, zfcp_get_busid_by_port(port));
523 zfcp_erp_port_block(port, clear_mask);
525 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED, &port->status)) {
526 ZFCP_LOG_DEBUG("skipped forced reopen of failed port 0x%016Lx "
527 "on adapter %s\n", port->wwpn,
528 zfcp_get_busid_by_port(port));
529 debug_text_event(adapter->erp_dbf, 5, "pf_ro_f");
530 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
535 retval = zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_PORT_FORCED,
536 port->adapter, port, NULL);
545 * purpose: Wrappper for zfcp_erp_port_forced_reopen_internal
546 * used to ensure the correct locking
548 * returns: 0 - initiated action succesfully
549 * <0 - failed to initiate action
552 zfcp_erp_port_forced_reopen(struct zfcp_port *port, int clear_mask)
556 struct zfcp_adapter *adapter;
558 adapter = port->adapter;
559 read_lock_irqsave(&zfcp_data.config_lock, flags);
560 write_lock(&adapter->erp_lock);
561 retval = zfcp_erp_port_forced_reopen_internal(port, clear_mask);
562 write_unlock(&adapter->erp_lock);
563 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
571 * purpose: called if a port is to be opened
572 * initiates Reopen recovery which is done
575 * returns: 0 - initiated action succesfully
576 * <0 - failed to initiate action
579 zfcp_erp_port_reopen_internal(struct zfcp_port *port, int clear_mask)
582 struct zfcp_adapter *adapter = port->adapter;
584 debug_text_event(adapter->erp_dbf, 5, "p_ro");
585 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
587 ZFCP_LOG_DEBUG("reopen of port 0x%016Lx on adapter %s\n",
588 port->wwpn, zfcp_get_busid_by_port(port));
590 zfcp_erp_port_block(port, clear_mask);
592 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED, &port->status)) {
593 ZFCP_LOG_DEBUG("skipped reopen of failed port 0x%016Lx "
594 "on adapter %s\n", port->wwpn,
595 zfcp_get_busid_by_port(port));
596 debug_text_event(adapter->erp_dbf, 5, "p_ro_f");
597 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
598 /* ensure propagation of failed status to new devices */
599 zfcp_erp_port_failed(port);
604 retval = zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_PORT,
605 port->adapter, port, NULL);
612 * zfcp_erp_port_reopen - initiate reopen of a remote port
613 * @port: port to be reopened
614 * @clear_mask: specifies flags in port status to be cleared
615 * Return: 0 on success, < 0 on error
617 * This is a wrappper function for zfcp_erp_port_reopen_internal. It ensures
618 * correct locking. An error recovery task is initiated to do the reopen.
619 * To wait for the completion of the reopen zfcp_erp_wait should be used.
622 zfcp_erp_port_reopen(struct zfcp_port *port, int clear_mask)
626 struct zfcp_adapter *adapter = port->adapter;
628 read_lock_irqsave(&zfcp_data.config_lock, flags);
629 write_lock(&adapter->erp_lock);
630 retval = zfcp_erp_port_reopen_internal(port, clear_mask);
631 write_unlock(&adapter->erp_lock);
632 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
640 * purpose: called if a unit is to be opened
641 * initiates Reopen recovery which is done
644 * returns: 0 - initiated action succesfully
645 * <0 - failed to initiate action
648 zfcp_erp_unit_reopen_internal(struct zfcp_unit *unit, int clear_mask)
651 struct zfcp_adapter *adapter = unit->port->adapter;
653 debug_text_event(adapter->erp_dbf, 5, "u_ro");
654 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun, sizeof (fcp_lun_t));
655 ZFCP_LOG_DEBUG("reopen of unit 0x%016Lx on port 0x%016Lx "
656 "on adapter %s\n", unit->fcp_lun,
657 unit->port->wwpn, zfcp_get_busid_by_unit(unit));
659 zfcp_erp_unit_block(unit, clear_mask);
661 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED, &unit->status)) {
662 ZFCP_LOG_DEBUG("skipped reopen of failed unit 0x%016Lx "
663 "on port 0x%016Lx on adapter %s\n",
664 unit->fcp_lun, unit->port->wwpn,
665 zfcp_get_busid_by_unit(unit));
666 debug_text_event(adapter->erp_dbf, 5, "u_ro_f");
667 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun,
673 retval = zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_UNIT,
674 unit->port->adapter, unit->port, unit);
680 * zfcp_erp_unit_reopen - initiate reopen of a unit
681 * @unit: unit to be reopened
682 * @clear_mask: specifies flags in unit status to be cleared
683 * Return: 0 on success, < 0 on error
685 * This is a wrappper for zfcp_erp_unit_reopen_internal. It ensures correct
686 * locking. An error recovery task is initiated to do the reopen.
687 * To wait for the completion of the reopen zfcp_erp_wait should be used.
690 zfcp_erp_unit_reopen(struct zfcp_unit *unit, int clear_mask)
694 struct zfcp_adapter *adapter;
695 struct zfcp_port *port;
698 adapter = port->adapter;
700 read_lock_irqsave(&zfcp_data.config_lock, flags);
701 write_lock(&adapter->erp_lock);
702 retval = zfcp_erp_unit_reopen_internal(unit, clear_mask);
703 write_unlock(&adapter->erp_lock);
704 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
712 * purpose: disable I/O,
713 * return any open requests and clean them up,
714 * aim: no pending and incoming I/O
719 zfcp_erp_adapter_block(struct zfcp_adapter *adapter, int clear_mask)
721 debug_text_event(adapter->erp_dbf, 6, "a_bl");
722 zfcp_erp_modify_adapter_status(adapter,
723 ZFCP_STATUS_COMMON_UNBLOCKED |
724 clear_mask, ZFCP_CLEAR);
730 * purpose: enable I/O
735 zfcp_erp_adapter_unblock(struct zfcp_adapter *adapter)
737 debug_text_event(adapter->erp_dbf, 6, "a_ubl");
738 atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &adapter->status);
744 * purpose: disable I/O,
745 * return any open requests and clean them up,
746 * aim: no pending and incoming I/O
751 zfcp_erp_port_block(struct zfcp_port *port, int clear_mask)
753 struct zfcp_adapter *adapter = port->adapter;
755 debug_text_event(adapter->erp_dbf, 6, "p_bl");
756 debug_event(adapter->erp_dbf, 6, &port->wwpn, sizeof (wwn_t));
757 zfcp_erp_modify_port_status(port,
758 ZFCP_STATUS_COMMON_UNBLOCKED | clear_mask,
765 * purpose: enable I/O
770 zfcp_erp_port_unblock(struct zfcp_port *port)
772 struct zfcp_adapter *adapter = port->adapter;
774 debug_text_event(adapter->erp_dbf, 6, "p_ubl");
775 debug_event(adapter->erp_dbf, 6, &port->wwpn, sizeof (wwn_t));
776 atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &port->status);
782 * purpose: disable I/O,
783 * return any open requests and clean them up,
784 * aim: no pending and incoming I/O
789 zfcp_erp_unit_block(struct zfcp_unit *unit, int clear_mask)
791 struct zfcp_adapter *adapter = unit->port->adapter;
793 debug_text_event(adapter->erp_dbf, 6, "u_bl");
794 debug_event(adapter->erp_dbf, 6, &unit->fcp_lun, sizeof (fcp_lun_t));
795 zfcp_erp_modify_unit_status(unit,
796 ZFCP_STATUS_COMMON_UNBLOCKED | clear_mask,
803 * purpose: enable I/O
808 zfcp_erp_unit_unblock(struct zfcp_unit *unit)
810 struct zfcp_adapter *adapter = unit->port->adapter;
812 debug_text_event(adapter->erp_dbf, 6, "u_ubl");
813 debug_event(adapter->erp_dbf, 6, &unit->fcp_lun, sizeof (fcp_lun_t));
814 atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &unit->status);
825 zfcp_erp_action_ready(struct zfcp_erp_action *erp_action)
827 struct zfcp_adapter *adapter = erp_action->adapter;
829 debug_text_event(adapter->erp_dbf, 4, "a_ar");
830 debug_event(adapter->erp_dbf, 4, &erp_action->action, sizeof (int));
832 zfcp_erp_action_to_ready(erp_action);
833 up(&adapter->erp_ready_sem);
841 * returns: <0 erp_action not found in any list
842 * ZFCP_ERP_ACTION_READY erp_action is in ready list
843 * ZFCP_ERP_ACTION_RUNNING erp_action is in running list
845 * locks: erp_lock must be held
848 zfcp_erp_action_exists(struct zfcp_erp_action *erp_action)
850 int retval = -EINVAL;
851 struct list_head *entry;
852 struct zfcp_erp_action *entry_erp_action;
853 struct zfcp_adapter *adapter = erp_action->adapter;
855 /* search in running list */
856 list_for_each(entry, &adapter->erp_running_head) {
858 list_entry(entry, struct zfcp_erp_action, list);
859 if (entry_erp_action == erp_action) {
860 retval = ZFCP_ERP_ACTION_RUNNING;
864 /* search in ready list */
865 list_for_each(entry, &adapter->erp_ready_head) {
867 list_entry(entry, struct zfcp_erp_action, list);
868 if (entry_erp_action == erp_action) {
869 retval = ZFCP_ERP_ACTION_READY;
879 * purpose: checks current status of action (timed out, dismissed, ...)
880 * and does appropriate preparations (dismiss fsf request, ...)
882 * locks: called under erp_lock (disabled interrupts)
887 zfcp_erp_strategy_check_fsfreq(struct zfcp_erp_action *erp_action)
890 struct zfcp_fsf_req *fsf_req = NULL;
891 struct zfcp_adapter *adapter = erp_action->adapter;
893 if (erp_action->fsf_req) {
894 /* take lock to ensure that request is not being deleted meanwhile */
895 spin_lock(&adapter->fsf_req_list_lock);
896 /* check whether fsf req does still exist */
897 list_for_each_entry(fsf_req, &adapter->fsf_req_list_head, list)
898 if (fsf_req == erp_action->fsf_req)
900 if (fsf_req && (fsf_req->erp_action == erp_action)) {
901 /* fsf_req still exists */
902 debug_text_event(adapter->erp_dbf, 3, "a_ca_req");
903 debug_event(adapter->erp_dbf, 3, &fsf_req,
904 sizeof (unsigned long));
905 /* dismiss fsf_req of timed out or dismissed erp_action */
906 if (erp_action->status & (ZFCP_STATUS_ERP_DISMISSED |
907 ZFCP_STATUS_ERP_TIMEDOUT)) {
908 debug_text_event(adapter->erp_dbf, 3,
910 fsf_req->status |= ZFCP_STATUS_FSFREQ_DISMISSED;
912 if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT) {
913 ZFCP_LOG_NORMAL("error: erp step timed out "
914 "(action=%d, fsf_req=%p)\n ",
916 erp_action->fsf_req);
919 * If fsf_req is neither dismissed nor completed
920 * then keep it running asynchronously and don't mess
921 * with the association of erp_action and fsf_req.
923 if (fsf_req->status & (ZFCP_STATUS_FSFREQ_COMPLETED |
924 ZFCP_STATUS_FSFREQ_DISMISSED)) {
925 /* forget about association between fsf_req
927 fsf_req->erp_action = NULL;
928 erp_action->fsf_req = NULL;
931 debug_text_event(adapter->erp_dbf, 3, "a_ca_gonereq");
933 * even if this fsf_req has gone, forget about
934 * association between erp_action and fsf_req
936 erp_action->fsf_req = NULL;
938 spin_unlock(&adapter->fsf_req_list_lock);
940 debug_text_event(adapter->erp_dbf, 3, "a_ca_noreq");
946 * purpose: generic handler for asynchronous events related to erp_action events
947 * (normal completion, time-out, dismissing, retry after
948 * low memory condition)
950 * note: deletion of timer is not required (e.g. in case of a time-out),
951 * but a second try does no harm,
952 * we leave it in here to allow for greater simplification
954 * returns: 0 - there was an action to handle
958 zfcp_erp_async_handler_nolock(struct zfcp_erp_action *erp_action,
959 unsigned long set_mask)
962 struct zfcp_adapter *adapter = erp_action->adapter;
964 if (zfcp_erp_action_exists(erp_action) == ZFCP_ERP_ACTION_RUNNING) {
965 debug_text_event(adapter->erp_dbf, 2, "a_asyh_ex");
966 debug_event(adapter->erp_dbf, 2, &erp_action->action,
968 if (!(set_mask & ZFCP_STATUS_ERP_TIMEDOUT))
969 del_timer(&erp_action->timer);
970 erp_action->status |= set_mask;
971 zfcp_erp_action_ready(erp_action);
974 /* action is ready or gone - nothing to do */
975 debug_text_event(adapter->erp_dbf, 3, "a_asyh_gone");
976 debug_event(adapter->erp_dbf, 3, &erp_action->action,
985 * purpose: generic handler for asynchronous events related to erp_action
986 * events (normal completion, time-out, dismissing, retry after
987 * low memory condition)
989 * note: deletion of timer is not required (e.g. in case of a time-out),
990 * but a second try does no harm,
991 * we leave it in here to allow for greater simplification
993 * returns: 0 - there was an action to handle
997 zfcp_erp_async_handler(struct zfcp_erp_action *erp_action,
998 unsigned long set_mask)
1000 struct zfcp_adapter *adapter = erp_action->adapter;
1001 unsigned long flags;
1004 write_lock_irqsave(&adapter->erp_lock, flags);
1005 retval = zfcp_erp_async_handler_nolock(erp_action, set_mask);
1006 write_unlock_irqrestore(&adapter->erp_lock, flags);
1012 * purpose: is called for erp_action which was slept waiting for
1013 * memory becoming avaliable,
1014 * will trigger that this action will be continued
1017 zfcp_erp_memwait_handler(unsigned long data)
1019 struct zfcp_erp_action *erp_action = (struct zfcp_erp_action *) data;
1020 struct zfcp_adapter *adapter = erp_action->adapter;
1022 debug_text_event(adapter->erp_dbf, 2, "a_mwh");
1023 debug_event(adapter->erp_dbf, 2, &erp_action->action, sizeof (int));
1025 zfcp_erp_async_handler(erp_action, 0);
1029 * purpose: is called if an asynchronous erp step timed out,
1030 * action gets an appropriate flag and will be processed
1034 zfcp_erp_timeout_handler(unsigned long data)
1036 struct zfcp_erp_action *erp_action = (struct zfcp_erp_action *) data;
1037 struct zfcp_adapter *adapter = erp_action->adapter;
1039 debug_text_event(adapter->erp_dbf, 2, "a_th");
1040 debug_event(adapter->erp_dbf, 2, &erp_action->action, sizeof (int));
1042 zfcp_erp_async_handler(erp_action, ZFCP_STATUS_ERP_TIMEDOUT);
1046 * purpose: is called for an erp_action which needs to be ended
1047 * though not being done,
1048 * this is usually required if an higher is generated,
1049 * action gets an appropriate flag and will be processed
1052 * locks: erp_lock held (thus we need to call another handler variant)
1055 zfcp_erp_action_dismiss(struct zfcp_erp_action *erp_action)
1057 struct zfcp_adapter *adapter = erp_action->adapter;
1059 debug_text_event(adapter->erp_dbf, 2, "a_adis");
1060 debug_event(adapter->erp_dbf, 2, &erp_action->action, sizeof (int));
1062 zfcp_erp_async_handler_nolock(erp_action, ZFCP_STATUS_ERP_DISMISSED);
1068 zfcp_erp_thread_setup(struct zfcp_adapter *adapter)
1072 atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP, &adapter->status);
1074 retval = kernel_thread(zfcp_erp_thread, adapter, SIGCHLD);
1076 ZFCP_LOG_NORMAL("error: creation of erp thread failed for "
1078 zfcp_get_busid_by_adapter(adapter));
1079 debug_text_event(adapter->erp_dbf, 5, "a_thset_fail");
1081 wait_event(adapter->erp_thread_wqh,
1082 atomic_test_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP,
1084 debug_text_event(adapter->erp_dbf, 5, "a_thset_ok");
1087 return (retval < 0);
1097 * context: process (i.e. proc-fs or rmmod/insmod)
1099 * note: The caller of this routine ensures that the specified
1100 * adapter has been shut down and that this operation
1101 * has been completed. Thus, there are no pending erp_actions
1102 * which would need to be handled here.
1105 zfcp_erp_thread_kill(struct zfcp_adapter *adapter)
1109 atomic_set_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL, &adapter->status);
1110 up(&adapter->erp_ready_sem);
1112 wait_event(adapter->erp_thread_wqh,
1113 !atomic_test_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP,
1116 atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL,
1119 debug_text_event(adapter->erp_dbf, 5, "a_thki_ok");
1125 * purpose: is run as a kernel thread,
1126 * goes through list of error recovery actions of associated adapter
1127 * and delegates single action to execution
1132 zfcp_erp_thread(void *data)
1134 struct zfcp_adapter *adapter = (struct zfcp_adapter *) data;
1135 struct list_head *next;
1136 struct zfcp_erp_action *erp_action;
1137 unsigned long flags;
1139 daemonize("zfcperp%s", zfcp_get_busid_by_adapter(adapter));
1140 /* Block all signals */
1141 siginitsetinv(¤t->blocked, 0);
1142 atomic_set_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP, &adapter->status);
1143 debug_text_event(adapter->erp_dbf, 5, "a_th_run");
1144 wake_up(&adapter->erp_thread_wqh);
1146 while (!atomic_test_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL,
1147 &adapter->status)) {
1149 write_lock_irqsave(&adapter->erp_lock, flags);
1150 next = adapter->erp_ready_head.prev;
1151 write_unlock_irqrestore(&adapter->erp_lock, flags);
1153 if (next != &adapter->erp_ready_head) {
1155 list_entry(next, struct zfcp_erp_action, list);
1157 * process action (incl. [re]moving it
1158 * from 'ready' queue)
1160 zfcp_erp_strategy(erp_action);
1164 * sleep as long as there is nothing to do, i.e.
1165 * no action in 'ready' queue to be processed and
1166 * thread is not to be killed
1168 down_interruptible(&adapter->erp_ready_sem);
1169 debug_text_event(adapter->erp_dbf, 5, "a_th_woken");
1172 atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP, &adapter->status);
1173 debug_text_event(adapter->erp_dbf, 5, "a_th_stop");
1174 wake_up(&adapter->erp_thread_wqh);
1182 * purpose: drives single error recovery action and schedules higher and
1183 * subordinate actions, if necessary
1185 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
1186 * ZFCP_ERP_SUCCEEDED - action finished successfully (deqd)
1187 * ZFCP_ERP_FAILED - action finished unsuccessfully (deqd)
1188 * ZFCP_ERP_EXIT - action finished (dequeued), offline
1189 * ZFCP_ERP_DISMISSED - action canceled (dequeued)
1192 zfcp_erp_strategy(struct zfcp_erp_action *erp_action)
1195 struct zfcp_adapter *adapter = erp_action->adapter;
1196 struct zfcp_port *port = erp_action->port;
1197 struct zfcp_unit *unit = erp_action->unit;
1198 int action = erp_action->action;
1199 u32 status = erp_action->status;
1200 unsigned long flags;
1202 /* serialise dismissing, timing out, moving, enqueueing */
1203 read_lock_irqsave(&zfcp_data.config_lock, flags);
1204 write_lock(&adapter->erp_lock);
1206 /* dequeue dismissed action and leave, if required */
1207 retval = zfcp_erp_strategy_check_action(erp_action, retval);
1208 if (retval == ZFCP_ERP_DISMISSED) {
1209 debug_text_event(adapter->erp_dbf, 4, "a_st_dis1");
1214 * move action to 'running' queue before processing it
1215 * (to avoid a race condition regarding moving the
1216 * action to the 'running' queue and back)
1218 zfcp_erp_action_to_running(erp_action);
1221 * try to process action as far as possible,
1222 * no lock to allow for blocking operations (kmalloc, qdio, ...),
1223 * afterwards the lock is required again for the following reasons:
1224 * - dequeueing of finished action and enqueueing of
1225 * follow-up actions must be atomic so that any other
1226 * reopen-routine does not believe there is nothing to do
1227 * and that it is safe to enqueue something else,
1228 * - we want to force any control thread which is dismissing
1229 * actions to finish this before we decide about
1230 * necessary steps to be taken here further
1232 write_unlock(&adapter->erp_lock);
1233 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
1234 retval = zfcp_erp_strategy_do_action(erp_action);
1235 read_lock_irqsave(&zfcp_data.config_lock, flags);
1236 write_lock(&adapter->erp_lock);
1239 * check for dismissed status again to avoid follow-up actions,
1240 * failing of targets and so on for dismissed actions
1242 retval = zfcp_erp_strategy_check_action(erp_action, retval);
1245 case ZFCP_ERP_DISMISSED:
1246 /* leave since this action has ridden to its ancestors */
1247 debug_text_event(adapter->erp_dbf, 6, "a_st_dis2");
1249 case ZFCP_ERP_NOMEM:
1250 /* no memory to continue immediately, let it sleep */
1251 if (!(erp_action->status & ZFCP_STATUS_ERP_LOWMEM)) {
1252 ++adapter->erp_low_mem_count;
1253 erp_action->status |= ZFCP_STATUS_ERP_LOWMEM;
1255 /* This condition is true if there is no memory available
1256 for any erp_action on this adapter. This implies that there
1257 are no elements in the memory pool(s) left for erp_actions.
1258 This might happen if an erp_action that used a memory pool
1259 element was timed out.
1261 if (adapter->erp_total_count == adapter->erp_low_mem_count) {
1262 debug_text_event(adapter->erp_dbf, 3, "a_st_lowmem");
1263 ZFCP_LOG_NORMAL("error: no mempool elements available, "
1264 "restarting I/O on adapter %s "
1265 "to free mempool\n",
1266 zfcp_get_busid_by_adapter(adapter));
1267 zfcp_erp_adapter_reopen_internal(adapter, 0);
1269 debug_text_event(adapter->erp_dbf, 2, "a_st_memw");
1270 retval = zfcp_erp_strategy_memwait(erp_action);
1273 case ZFCP_ERP_CONTINUES:
1274 /* leave since this action runs asynchronously */
1275 debug_text_event(adapter->erp_dbf, 6, "a_st_cont");
1276 if (erp_action->status & ZFCP_STATUS_ERP_LOWMEM) {
1277 --adapter->erp_low_mem_count;
1278 erp_action->status &= ~ZFCP_STATUS_ERP_LOWMEM;
1282 /* ok, finished action (whatever its result is) */
1284 /* check for unrecoverable targets */
1285 retval = zfcp_erp_strategy_check_target(erp_action, retval);
1287 /* action must be dequeued (here to allow for further ones) */
1288 zfcp_erp_action_dequeue(erp_action);
1291 * put this target through the erp mill again if someone has
1292 * requested to change the status of a target being online
1293 * to offline or the other way around
1294 * (old retval is preserved if nothing has to be done here)
1296 retval = zfcp_erp_strategy_statechange(action, status, adapter,
1297 port, unit, retval);
1300 * leave if target is in permanent error state or if
1301 * action is repeated in order to process state change
1303 if (retval == ZFCP_ERP_EXIT) {
1304 debug_text_event(adapter->erp_dbf, 2, "a_st_exit");
1308 /* trigger follow up actions */
1309 zfcp_erp_strategy_followup_actions(action, adapter, port, unit, retval);
1312 write_unlock(&adapter->erp_lock);
1313 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
1315 if (retval != ZFCP_ERP_CONTINUES)
1316 zfcp_erp_action_cleanup(action, adapter, port, unit, retval);
1319 * a few tasks remain when the erp queues are empty
1320 * (don't do that if the last action evaluated was dismissed
1321 * since this clearly indicates that there is more to come) :
1322 * - close the name server port if it is open yet
1323 * (enqueues another [probably] final action)
1324 * - otherwise, wake up whoever wants to be woken when we are
1327 if (retval != ZFCP_ERP_DISMISSED)
1328 zfcp_erp_strategy_check_queues(adapter);
1330 debug_text_event(adapter->erp_dbf, 6, "a_st_done");
1340 * returns: ZFCP_ERP_DISMISSED - if action has been dismissed
1341 * retval - otherwise
1344 zfcp_erp_strategy_check_action(struct zfcp_erp_action *erp_action, int retval)
1346 struct zfcp_adapter *adapter = erp_action->adapter;
1348 zfcp_erp_strategy_check_fsfreq(erp_action);
1350 debug_event(adapter->erp_dbf, 5, &erp_action->action, sizeof (int));
1351 if (erp_action->status & ZFCP_STATUS_ERP_DISMISSED) {
1352 debug_text_event(adapter->erp_dbf, 3, "a_stcd_dis");
1353 zfcp_erp_action_dequeue(erp_action);
1354 retval = ZFCP_ERP_DISMISSED;
1356 debug_text_event(adapter->erp_dbf, 5, "a_stcd_nodis");
1369 zfcp_erp_strategy_do_action(struct zfcp_erp_action *erp_action)
1371 int retval = ZFCP_ERP_FAILED;
1372 struct zfcp_adapter *adapter = erp_action->adapter;
1375 * try to execute/continue action as far as possible,
1376 * note: no lock in subsequent strategy routines
1377 * (this allows these routine to call schedule, e.g.
1378 * kmalloc with such flags or qdio_initialize & friends)
1379 * Note: in case of timeout, the seperate strategies will fail
1380 * anyhow. No need for a special action. Even worse, a nameserver
1381 * failure would not wake up waiting ports without the call.
1383 switch (erp_action->action) {
1385 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
1386 retval = zfcp_erp_adapter_strategy(erp_action);
1389 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
1390 retval = zfcp_erp_port_forced_strategy(erp_action);
1393 case ZFCP_ERP_ACTION_REOPEN_PORT:
1394 retval = zfcp_erp_port_strategy(erp_action);
1397 case ZFCP_ERP_ACTION_REOPEN_UNIT:
1398 retval = zfcp_erp_unit_strategy(erp_action);
1402 debug_text_exception(adapter->erp_dbf, 1, "a_stda_bug");
1403 debug_event(adapter->erp_dbf, 1, &erp_action->action,
1405 ZFCP_LOG_NORMAL("bug: unknown erp action requested on "
1406 "adapter %s (action=%d)\n",
1407 zfcp_get_busid_by_adapter(erp_action->adapter),
1408 erp_action->action);
1417 * purpose: triggers retry of this action after a certain amount of time
1418 * by means of timer provided by erp_action
1420 * returns: ZFCP_ERP_CONTINUES - erp_action sleeps in erp running queue
1423 zfcp_erp_strategy_memwait(struct zfcp_erp_action *erp_action)
1425 int retval = ZFCP_ERP_CONTINUES;
1426 struct zfcp_adapter *adapter = erp_action->adapter;
1428 debug_text_event(adapter->erp_dbf, 6, "a_mwinit");
1429 debug_event(adapter->erp_dbf, 6, &erp_action->action, sizeof (int));
1430 init_timer(&erp_action->timer);
1431 erp_action->timer.function = zfcp_erp_memwait_handler;
1432 erp_action->timer.data = (unsigned long) erp_action;
1433 erp_action->timer.expires = jiffies + ZFCP_ERP_MEMWAIT_TIMEOUT;
1434 add_timer(&erp_action->timer);
1440 * function: zfcp_erp_adapter_failed
1442 * purpose: sets the adapter and all underlying devices to ERP_FAILED
1446 zfcp_erp_adapter_failed(struct zfcp_adapter *adapter)
1448 zfcp_erp_modify_adapter_status(adapter,
1449 ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET);
1450 ZFCP_LOG_NORMAL("adapter erp failed on adapter %s\n",
1451 zfcp_get_busid_by_adapter(adapter));
1452 debug_text_event(adapter->erp_dbf, 2, "a_afail");
1456 * function: zfcp_erp_port_failed
1458 * purpose: sets the port and all underlying devices to ERP_FAILED
1462 zfcp_erp_port_failed(struct zfcp_port *port)
1464 zfcp_erp_modify_port_status(port,
1465 ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET);
1467 if (atomic_test_mask(ZFCP_STATUS_PORT_WKA, &port->status))
1468 ZFCP_LOG_NORMAL("port erp failed (adapter %s, "
1469 "port d_id=0x%08x)\n",
1470 zfcp_get_busid_by_port(port), port->d_id);
1472 ZFCP_LOG_NORMAL("port erp failed (adapter %s, wwpn=0x%016Lx)\n",
1473 zfcp_get_busid_by_port(port), port->wwpn);
1475 debug_text_event(port->adapter->erp_dbf, 2, "p_pfail");
1476 debug_event(port->adapter->erp_dbf, 2, &port->wwpn, sizeof (wwn_t));
1480 * function: zfcp_erp_unit_failed
1482 * purpose: sets the unit to ERP_FAILED
1486 zfcp_erp_unit_failed(struct zfcp_unit *unit)
1488 zfcp_erp_modify_unit_status(unit,
1489 ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET);
1491 ZFCP_LOG_NORMAL("unit erp failed on unit 0x%016Lx on port 0x%016Lx "
1492 " on adapter %s\n", unit->fcp_lun,
1493 unit->port->wwpn, zfcp_get_busid_by_unit(unit));
1494 debug_text_event(unit->port->adapter->erp_dbf, 2, "u_ufail");
1495 debug_event(unit->port->adapter->erp_dbf, 2,
1496 &unit->fcp_lun, sizeof (fcp_lun_t));
1500 * function: zfcp_erp_strategy_check_target
1502 * purpose: increments the erp action count on the device currently in
1503 * recovery if the action failed or resets the count in case of
1504 * success. If a maximum count is exceeded the device is marked
1506 * The 'blocked' state of a target which has been recovered
1507 * successfully is reset.
1509 * returns: ZFCP_ERP_CONTINUES - action continues (not considered)
1510 * ZFCP_ERP_SUCCEEDED - action finished successfully
1511 * ZFCP_ERP_EXIT - action failed and will not continue
1514 zfcp_erp_strategy_check_target(struct zfcp_erp_action *erp_action, int result)
1516 struct zfcp_adapter *adapter = erp_action->adapter;
1517 struct zfcp_port *port = erp_action->port;
1518 struct zfcp_unit *unit = erp_action->unit;
1520 debug_text_event(adapter->erp_dbf, 5, "a_stct_norm");
1521 debug_event(adapter->erp_dbf, 5, &erp_action->action, sizeof (int));
1522 debug_event(adapter->erp_dbf, 5, &result, sizeof (int));
1524 switch (erp_action->action) {
1526 case ZFCP_ERP_ACTION_REOPEN_UNIT:
1527 result = zfcp_erp_strategy_check_unit(unit, result);
1530 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
1531 case ZFCP_ERP_ACTION_REOPEN_PORT:
1532 result = zfcp_erp_strategy_check_port(port, result);
1535 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
1536 result = zfcp_erp_strategy_check_adapter(adapter, result);
1551 zfcp_erp_strategy_statechange(int action,
1553 struct zfcp_adapter *adapter,
1554 struct zfcp_port *port,
1555 struct zfcp_unit *unit, int retval)
1557 debug_text_event(adapter->erp_dbf, 3, "a_stsc");
1558 debug_event(adapter->erp_dbf, 3, &action, sizeof (int));
1562 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
1563 if (zfcp_erp_strategy_statechange_detected(&adapter->status,
1565 zfcp_erp_adapter_reopen_internal(adapter, ZFCP_STATUS_COMMON_ERP_FAILED);
1566 retval = ZFCP_ERP_EXIT;
1570 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
1571 case ZFCP_ERP_ACTION_REOPEN_PORT:
1572 if (zfcp_erp_strategy_statechange_detected(&port->status,
1574 zfcp_erp_port_reopen_internal(port, ZFCP_STATUS_COMMON_ERP_FAILED);
1575 retval = ZFCP_ERP_EXIT;
1579 case ZFCP_ERP_ACTION_REOPEN_UNIT:
1580 if (zfcp_erp_strategy_statechange_detected(&unit->status,
1582 zfcp_erp_unit_reopen_internal(unit, ZFCP_STATUS_COMMON_ERP_FAILED);
1583 retval = ZFCP_ERP_EXIT;
1599 zfcp_erp_strategy_statechange_detected(atomic_t * target_status, u32 erp_status)
1602 /* take it online */
1603 (atomic_test_mask(ZFCP_STATUS_COMMON_RUNNING, target_status) &&
1604 (ZFCP_STATUS_ERP_CLOSE_ONLY & erp_status)) ||
1605 /* take it offline */
1606 (!atomic_test_mask(ZFCP_STATUS_COMMON_RUNNING, target_status) &&
1607 !(ZFCP_STATUS_ERP_CLOSE_ONLY & erp_status));
1618 zfcp_erp_strategy_check_unit(struct zfcp_unit *unit, int result)
1620 debug_text_event(unit->port->adapter->erp_dbf, 5, "u_stct");
1621 debug_event(unit->port->adapter->erp_dbf, 5, &unit->fcp_lun,
1622 sizeof (fcp_lun_t));
1625 case ZFCP_ERP_SUCCEEDED :
1626 atomic_set(&unit->erp_counter, 0);
1627 zfcp_erp_unit_unblock(unit);
1629 case ZFCP_ERP_FAILED :
1630 atomic_inc(&unit->erp_counter);
1631 if (atomic_read(&unit->erp_counter) > ZFCP_MAX_ERPS)
1632 zfcp_erp_unit_failed(unit);
1634 case ZFCP_ERP_EXIT :
1639 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED, &unit->status)) {
1640 zfcp_erp_unit_block(unit, 0); /* for ZFCP_ERP_SUCCEEDED */
1641 result = ZFCP_ERP_EXIT;
1655 zfcp_erp_strategy_check_port(struct zfcp_port *port, int result)
1657 debug_text_event(port->adapter->erp_dbf, 5, "p_stct");
1658 debug_event(port->adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
1661 case ZFCP_ERP_SUCCEEDED :
1662 atomic_set(&port->erp_counter, 0);
1663 zfcp_erp_port_unblock(port);
1665 case ZFCP_ERP_FAILED :
1666 atomic_inc(&port->erp_counter);
1667 if (atomic_read(&port->erp_counter) > ZFCP_MAX_ERPS)
1668 zfcp_erp_port_failed(port);
1670 case ZFCP_ERP_EXIT :
1675 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED, &port->status)) {
1676 zfcp_erp_port_block(port, 0); /* for ZFCP_ERP_SUCCEEDED */
1677 result = ZFCP_ERP_EXIT;
1691 zfcp_erp_strategy_check_adapter(struct zfcp_adapter *adapter, int result)
1693 debug_text_event(adapter->erp_dbf, 5, "a_stct");
1696 case ZFCP_ERP_SUCCEEDED :
1697 atomic_set(&adapter->erp_counter, 0);
1698 zfcp_erp_adapter_unblock(adapter);
1700 case ZFCP_ERP_FAILED :
1701 atomic_inc(&adapter->erp_counter);
1702 if (atomic_read(&adapter->erp_counter) > ZFCP_MAX_ERPS)
1703 zfcp_erp_adapter_failed(adapter);
1705 case ZFCP_ERP_EXIT :
1710 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED, &adapter->status)) {
1711 zfcp_erp_adapter_block(adapter, 0); /* for ZFCP_ERP_SUCCEEDED */
1712 result = ZFCP_ERP_EXIT;
1721 * purpose: remaining things in good cases,
1722 * escalation in bad cases
1727 zfcp_erp_strategy_followup_actions(int action,
1728 struct zfcp_adapter *adapter,
1729 struct zfcp_port *port,
1730 struct zfcp_unit *unit, int status)
1732 debug_text_event(adapter->erp_dbf, 5, "a_stfol");
1733 debug_event(adapter->erp_dbf, 5, &action, sizeof (int));
1735 /* initiate follow-up actions depending on success of finished action */
1738 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
1739 if (status == ZFCP_ERP_SUCCEEDED)
1740 zfcp_erp_port_reopen_all_internal(adapter, 0);
1742 zfcp_erp_adapter_reopen_internal(adapter, 0);
1745 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
1746 if (status == ZFCP_ERP_SUCCEEDED)
1747 zfcp_erp_port_reopen_internal(port, 0);
1749 zfcp_erp_adapter_reopen_internal(adapter, 0);
1752 case ZFCP_ERP_ACTION_REOPEN_PORT:
1753 if (status == ZFCP_ERP_SUCCEEDED)
1754 zfcp_erp_unit_reopen_all_internal(port, 0);
1756 zfcp_erp_port_forced_reopen_internal(port, 0);
1759 case ZFCP_ERP_ACTION_REOPEN_UNIT:
1760 if (status == ZFCP_ERP_SUCCEEDED) ; /* no further action */
1762 zfcp_erp_port_reopen_internal(unit->port, 0);
1777 zfcp_erp_strategy_check_queues(struct zfcp_adapter *adapter)
1779 unsigned long flags;
1781 read_lock_irqsave(&zfcp_data.config_lock, flags);
1782 read_lock(&adapter->erp_lock);
1783 if (list_empty(&adapter->erp_ready_head) &&
1784 list_empty(&adapter->erp_running_head)) {
1785 debug_text_event(adapter->erp_dbf, 4, "a_cq_wake");
1786 atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_PENDING,
1788 wake_up(&adapter->erp_done_wqh);
1790 debug_text_event(adapter->erp_dbf, 5, "a_cq_notempty");
1791 read_unlock(&adapter->erp_lock);
1792 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
1798 * zfcp_erp_wait - wait for completion of error recovery on an adapter
1799 * @adapter: adapter for which to wait for completion of its error recovery
1803 zfcp_erp_wait(struct zfcp_adapter *adapter)
1807 wait_event(adapter->erp_done_wqh,
1808 !atomic_test_mask(ZFCP_STATUS_ADAPTER_ERP_PENDING,
1815 * function: zfcp_erp_modify_adapter_status
1821 zfcp_erp_modify_adapter_status(struct zfcp_adapter *adapter,
1822 u32 mask, int set_or_clear)
1824 struct zfcp_port *port;
1825 u32 common_mask = mask & ZFCP_COMMON_FLAGS;
1827 if (set_or_clear == ZFCP_SET) {
1828 atomic_set_mask(mask, &adapter->status);
1829 debug_text_event(adapter->erp_dbf, 3, "a_mod_as_s");
1831 atomic_clear_mask(mask, &adapter->status);
1832 if (mask & ZFCP_STATUS_COMMON_ERP_FAILED)
1833 atomic_set(&adapter->erp_counter, 0);
1834 debug_text_event(adapter->erp_dbf, 3, "a_mod_as_c");
1836 debug_event(adapter->erp_dbf, 3, &mask, sizeof (u32));
1838 /* Deal with all underlying devices, only pass common_mask */
1840 list_for_each_entry(port, &adapter->port_list_head, list)
1841 zfcp_erp_modify_port_status(port, common_mask,
1846 * function: zfcp_erp_modify_port_status
1848 * purpose: sets the port and all underlying devices to ERP_FAILED
1852 zfcp_erp_modify_port_status(struct zfcp_port *port, u32 mask, int set_or_clear)
1854 struct zfcp_unit *unit;
1855 u32 common_mask = mask & ZFCP_COMMON_FLAGS;
1857 if (set_or_clear == ZFCP_SET) {
1858 atomic_set_mask(mask, &port->status);
1859 debug_text_event(port->adapter->erp_dbf, 3, "p_mod_ps_s");
1861 atomic_clear_mask(mask, &port->status);
1862 if (mask & ZFCP_STATUS_COMMON_ERP_FAILED)
1863 atomic_set(&port->erp_counter, 0);
1864 debug_text_event(port->adapter->erp_dbf, 3, "p_mod_ps_c");
1866 debug_event(port->adapter->erp_dbf, 3, &port->wwpn, sizeof (wwn_t));
1867 debug_event(port->adapter->erp_dbf, 3, &mask, sizeof (u32));
1869 /* Modify status of all underlying devices, only pass common mask */
1871 list_for_each_entry(unit, &port->unit_list_head, list)
1872 zfcp_erp_modify_unit_status(unit, common_mask,
1877 * function: zfcp_erp_modify_unit_status
1879 * purpose: sets the unit to ERP_FAILED
1883 zfcp_erp_modify_unit_status(struct zfcp_unit *unit, u32 mask, int set_or_clear)
1885 if (set_or_clear == ZFCP_SET) {
1886 atomic_set_mask(mask, &unit->status);
1887 debug_text_event(unit->port->adapter->erp_dbf, 3, "u_mod_us_s");
1889 atomic_clear_mask(mask, &unit->status);
1890 if (mask & ZFCP_STATUS_COMMON_ERP_FAILED) {
1891 atomic_set(&unit->erp_counter, 0);
1893 debug_text_event(unit->port->adapter->erp_dbf, 3, "u_mod_us_c");
1895 debug_event(unit->port->adapter->erp_dbf, 3, &unit->fcp_lun,
1896 sizeof (fcp_lun_t));
1897 debug_event(unit->port->adapter->erp_dbf, 3, &mask, sizeof (u32));
1903 * purpose: Wrappper for zfcp_erp_port_reopen_all_internal
1904 * used to ensure the correct locking
1906 * returns: 0 - initiated action succesfully
1907 * <0 - failed to initiate action
1910 zfcp_erp_port_reopen_all(struct zfcp_adapter *adapter, int clear_mask)
1913 unsigned long flags;
1915 read_lock_irqsave(&zfcp_data.config_lock, flags);
1916 write_lock(&adapter->erp_lock);
1917 retval = zfcp_erp_port_reopen_all_internal(adapter, clear_mask);
1918 write_unlock(&adapter->erp_lock);
1919 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
1932 zfcp_erp_port_reopen_all_internal(struct zfcp_adapter *adapter, int clear_mask)
1935 struct zfcp_port *port;
1937 list_for_each_entry(port, &adapter->port_list_head, list)
1938 if (!atomic_test_mask(ZFCP_STATUS_PORT_WKA, &port->status))
1939 zfcp_erp_port_reopen_internal(port, clear_mask);
1952 zfcp_erp_unit_reopen_all_internal(struct zfcp_port *port, int clear_mask)
1955 struct zfcp_unit *unit;
1957 list_for_each_entry(unit, &port->unit_list_head, list)
1958 zfcp_erp_unit_reopen_internal(unit, clear_mask);
1966 * purpose: this routine executes the 'Reopen Adapter' action
1967 * (the entire action is processed synchronously, since
1968 * there are no actions which might be run concurrently
1971 * returns: ZFCP_ERP_SUCCEEDED - action finished successfully
1972 * ZFCP_ERP_FAILED - action finished unsuccessfully
1975 zfcp_erp_adapter_strategy(struct zfcp_erp_action *erp_action)
1978 struct zfcp_adapter *adapter = erp_action->adapter;
1980 retval = zfcp_erp_adapter_strategy_close(erp_action);
1981 if (erp_action->status & ZFCP_STATUS_ERP_CLOSE_ONLY)
1982 retval = ZFCP_ERP_EXIT;
1984 retval = zfcp_erp_adapter_strategy_open(erp_action);
1986 debug_text_event(adapter->erp_dbf, 3, "a_ast/ret");
1987 debug_event(adapter->erp_dbf, 3, &erp_action->action, sizeof (int));
1988 debug_event(adapter->erp_dbf, 3, &retval, sizeof (int));
1990 if (retval == ZFCP_ERP_FAILED) {
1991 ZFCP_LOG_INFO("Waiting to allow the adapter %s "
1992 "to recover itself\n",
1993 zfcp_get_busid_by_adapter(adapter));
1994 msleep(jiffies_to_msecs(ZFCP_TYPE2_RECOVERY_TIME));
2005 * returns: ZFCP_ERP_SUCCEEDED - action finished successfully
2006 * ZFCP_ERP_FAILED - action finished unsuccessfully
2009 zfcp_erp_adapter_strategy_close(struct zfcp_erp_action *erp_action)
2013 atomic_set_mask(ZFCP_STATUS_COMMON_CLOSING,
2014 &erp_action->adapter->status);
2015 retval = zfcp_erp_adapter_strategy_generic(erp_action, 1);
2016 atomic_clear_mask(ZFCP_STATUS_COMMON_CLOSING,
2017 &erp_action->adapter->status);
2027 * returns: ZFCP_ERP_SUCCEEDED - action finished successfully
2028 * ZFCP_ERP_FAILED - action finished unsuccessfully
2031 zfcp_erp_adapter_strategy_open(struct zfcp_erp_action *erp_action)
2035 atomic_set_mask(ZFCP_STATUS_COMMON_OPENING,
2036 &erp_action->adapter->status);
2037 retval = zfcp_erp_adapter_strategy_generic(erp_action, 0);
2038 atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING,
2039 &erp_action->adapter->status);
2045 * function: zfcp_register_adapter
2047 * purpose: allocate the irq associated with this devno and register
2048 * the FSF adapter with the SCSI stack
2053 zfcp_erp_adapter_strategy_generic(struct zfcp_erp_action *erp_action, int close)
2055 int retval = ZFCP_ERP_SUCCEEDED;
2060 retval = zfcp_erp_adapter_strategy_open_qdio(erp_action);
2061 if (retval != ZFCP_ERP_SUCCEEDED)
2064 retval = zfcp_erp_adapter_strategy_open_fsf(erp_action);
2065 if (retval != ZFCP_ERP_SUCCEEDED)
2066 goto failed_openfcp;
2068 atomic_set_mask(ZFCP_STATUS_COMMON_OPEN, &erp_action->adapter->status);
2072 atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN,
2073 &erp_action->adapter->status);
2076 zfcp_erp_adapter_strategy_close_qdio(erp_action);
2077 zfcp_erp_adapter_strategy_close_fsf(erp_action);
2084 * function: zfcp_qdio_init
2086 * purpose: setup QDIO operation for specified adapter
2088 * returns: 0 - successful setup
2092 zfcp_erp_adapter_strategy_open_qdio(struct zfcp_erp_action *erp_action)
2096 volatile struct qdio_buffer_element *sbale;
2097 struct zfcp_adapter *adapter = erp_action->adapter;
2099 if (atomic_test_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &adapter->status)) {
2100 ZFCP_LOG_NORMAL("bug: second attempt to set up QDIO on "
2102 zfcp_get_busid_by_adapter(adapter));
2106 if (qdio_establish(&adapter->qdio_init_data) != 0) {
2107 ZFCP_LOG_INFO("error: establishment of QDIO queues failed "
2109 zfcp_get_busid_by_adapter(adapter));
2110 goto failed_qdio_establish;
2112 debug_text_event(adapter->erp_dbf, 3, "qdio_est");
2114 if (qdio_activate(adapter->ccw_device, 0) != 0) {
2115 ZFCP_LOG_INFO("error: activation of QDIO queues failed "
2117 zfcp_get_busid_by_adapter(adapter));
2118 goto failed_qdio_activate;
2120 debug_text_event(adapter->erp_dbf, 3, "qdio_act");
2123 * put buffers into response queue,
2125 for (i = 0; i < QDIO_MAX_BUFFERS_PER_Q; i++) {
2126 sbale = &(adapter->response_queue.buffer[i]->element[0]);
2128 sbale->flags = SBAL_FLAGS_LAST_ENTRY;
2132 ZFCP_LOG_TRACE("calling do_QDIO on adapter %s (flags=0x%x, "
2133 "queue_no=%i, index_in_queue=%i, count=%i)\n",
2134 zfcp_get_busid_by_adapter(adapter),
2135 QDIO_FLAG_SYNC_INPUT, 0, 0, QDIO_MAX_BUFFERS_PER_Q);
2137 retval = do_QDIO(adapter->ccw_device,
2138 QDIO_FLAG_SYNC_INPUT,
2139 0, 0, QDIO_MAX_BUFFERS_PER_Q, NULL);
2142 ZFCP_LOG_NORMAL("bug: setup of QDIO failed (retval=%d)\n",
2144 goto failed_do_qdio;
2146 adapter->response_queue.free_index = 0;
2147 atomic_set(&adapter->response_queue.free_count, 0);
2148 ZFCP_LOG_DEBUG("%i buffers successfully enqueued to "
2149 "response queue\n", QDIO_MAX_BUFFERS_PER_Q);
2151 /* set index of first avalable SBALS / number of available SBALS */
2152 adapter->request_queue.free_index = 0;
2153 atomic_set(&adapter->request_queue.free_count, QDIO_MAX_BUFFERS_PER_Q);
2154 adapter->request_queue.distance_from_int = 0;
2156 /* initialize waitqueue used to wait for free SBALs in requests queue */
2157 init_waitqueue_head(&adapter->request_wq);
2159 /* ok, we did it - skip all cleanups for different failures */
2160 atomic_set_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &adapter->status);
2161 retval = ZFCP_ERP_SUCCEEDED;
2167 failed_qdio_activate:
2168 debug_text_event(adapter->erp_dbf, 3, "qdio_down1a");
2169 while (qdio_shutdown(adapter->ccw_device,
2170 QDIO_FLAG_CLEANUP_USING_CLEAR) == -EINPROGRESS)
2172 debug_text_event(adapter->erp_dbf, 3, "qdio_down1b");
2174 failed_qdio_establish:
2176 retval = ZFCP_ERP_FAILED;
2183 * function: zfcp_qdio_cleanup
2185 * purpose: cleans up QDIO operation for the specified adapter
2187 * returns: 0 - successful cleanup
2188 * !0 - failed cleanup
2191 zfcp_erp_adapter_strategy_close_qdio(struct zfcp_erp_action *erp_action)
2193 int retval = ZFCP_ERP_SUCCEEDED;
2196 struct zfcp_adapter *adapter = erp_action->adapter;
2198 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &adapter->status)) {
2199 ZFCP_LOG_DEBUG("error: attempt to shut down inactive QDIO "
2200 "queues on adapter %s\n",
2201 zfcp_get_busid_by_adapter(adapter));
2202 retval = ZFCP_ERP_FAILED;
2207 * Get queue_lock and clear QDIOUP flag. Thus it's guaranteed that
2208 * do_QDIO won't be called while qdio_shutdown is in progress.
2211 write_lock_irq(&adapter->request_queue.queue_lock);
2212 atomic_clear_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &adapter->status);
2213 write_unlock_irq(&adapter->request_queue.queue_lock);
2215 debug_text_event(adapter->erp_dbf, 3, "qdio_down2a");
2216 while (qdio_shutdown(adapter->ccw_device,
2217 QDIO_FLAG_CLEANUP_USING_CLEAR) == -EINPROGRESS)
2219 debug_text_event(adapter->erp_dbf, 3, "qdio_down2b");
2222 * First we had to stop QDIO operation.
2223 * Now it is safe to take the following actions.
2226 /* Cleanup only necessary when there are unacknowledged buffers */
2227 if (atomic_read(&adapter->request_queue.free_count)
2228 < QDIO_MAX_BUFFERS_PER_Q) {
2229 first_used = (adapter->request_queue.free_index +
2230 atomic_read(&adapter->request_queue.free_count))
2231 % QDIO_MAX_BUFFERS_PER_Q;
2232 used_count = QDIO_MAX_BUFFERS_PER_Q -
2233 atomic_read(&adapter->request_queue.free_count);
2234 zfcp_qdio_zero_sbals(adapter->request_queue.buffer,
2235 first_used, used_count);
2237 adapter->response_queue.free_index = 0;
2238 atomic_set(&adapter->response_queue.free_count, 0);
2239 adapter->request_queue.free_index = 0;
2240 atomic_set(&adapter->request_queue.free_count, 0);
2241 adapter->request_queue.distance_from_int = 0;
2247 zfcp_erp_adapter_strategy_open_fsf(struct zfcp_erp_action *erp_action)
2251 if ((atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED,
2252 &erp_action->adapter->status)) &&
2253 (erp_action->adapter->adapter_features &
2254 FSF_FEATURE_HBAAPI_MANAGEMENT)) {
2255 zfcp_erp_adapter_strategy_open_fsf_xport(erp_action);
2256 atomic_set(&erp_action->adapter->erp_counter, 0);
2257 return ZFCP_ERP_FAILED;
2260 retval = zfcp_erp_adapter_strategy_open_fsf_xconfig(erp_action);
2261 if (retval == ZFCP_ERP_FAILED)
2262 return ZFCP_ERP_FAILED;
2264 retval = zfcp_erp_adapter_strategy_open_fsf_xport(erp_action);
2265 if (retval == ZFCP_ERP_FAILED)
2266 return ZFCP_ERP_FAILED;
2268 return zfcp_erp_adapter_strategy_open_fsf_statusread(erp_action);
2279 zfcp_erp_adapter_strategy_open_fsf_xconfig(struct zfcp_erp_action *erp_action)
2281 int retval = ZFCP_ERP_SUCCEEDED;
2283 int sleep = ZFCP_EXCHANGE_CONFIG_DATA_FIRST_SLEEP;
2284 struct zfcp_adapter *adapter = erp_action->adapter;
2286 atomic_clear_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK, &adapter->status);
2288 for (retries = ZFCP_EXCHANGE_CONFIG_DATA_RETRIES; retries; retries--) {
2289 atomic_clear_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT,
2291 ZFCP_LOG_DEBUG("Doing exchange config data\n");
2292 write_lock(&adapter->erp_lock);
2293 zfcp_erp_action_to_running(erp_action);
2294 write_unlock(&adapter->erp_lock);
2295 zfcp_erp_timeout_init(erp_action);
2296 if (zfcp_fsf_exchange_config_data(erp_action)) {
2297 retval = ZFCP_ERP_FAILED;
2298 debug_text_event(adapter->erp_dbf, 5, "a_fstx_xf");
2299 ZFCP_LOG_INFO("error: initiation of exchange of "
2300 "configuration data failed for "
2302 zfcp_get_busid_by_adapter(adapter));
2305 debug_text_event(adapter->erp_dbf, 6, "a_fstx_xok");
2306 ZFCP_LOG_DEBUG("Xchange underway\n");
2310 * Both the normal completion handler as well as the timeout
2311 * handler will do an 'up' when the 'exchange config data'
2312 * request completes or times out. Thus, the signal to go on
2313 * won't be lost utilizing this semaphore.
2314 * Furthermore, this 'adapter_reopen' action is
2315 * guaranteed to be the only action being there (highest action
2316 * which prevents other actions from being created).
2317 * Resulting from that, the wake signal recognized here
2318 * _must_ be the one belonging to the 'exchange config
2321 down(&adapter->erp_ready_sem);
2322 if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT) {
2323 ZFCP_LOG_INFO("error: exchange of configuration data "
2324 "for adapter %s timed out\n",
2325 zfcp_get_busid_by_adapter(adapter));
2329 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT,
2333 ZFCP_LOG_DEBUG("host connection still initialising... "
2334 "waiting and retrying...\n");
2335 /* sleep a little bit before retry */
2336 msleep(jiffies_to_msecs(sleep));
2340 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK,
2341 &adapter->status)) {
2342 ZFCP_LOG_INFO("error: exchange of configuration data for "
2343 "adapter %s failed\n",
2344 zfcp_get_busid_by_adapter(adapter));
2345 retval = ZFCP_ERP_FAILED;
2352 zfcp_erp_adapter_strategy_open_fsf_xport(struct zfcp_erp_action *erp_action)
2357 struct zfcp_adapter *adapter = erp_action->adapter;
2359 atomic_clear_mask(ZFCP_STATUS_ADAPTER_XPORT_OK, &adapter->status);
2363 write_lock(&adapter->erp_lock);
2364 zfcp_erp_action_to_running(erp_action);
2365 write_unlock(&adapter->erp_lock);
2366 zfcp_erp_timeout_init(erp_action);
2367 ret = zfcp_fsf_exchange_port_data(erp_action, adapter, NULL);
2368 if (ret == -EOPNOTSUPP) {
2369 debug_text_event(adapter->erp_dbf, 3, "a_xport_notsupp");
2370 return ZFCP_ERP_SUCCEEDED;
2372 debug_text_event(adapter->erp_dbf, 3, "a_xport_failed");
2373 return ZFCP_ERP_FAILED;
2375 debug_text_event(adapter->erp_dbf, 6, "a_xport_ok");
2377 down(&adapter->erp_ready_sem);
2378 if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT) {
2379 ZFCP_LOG_INFO("error: exchange of port data "
2380 "for adapter %s timed out\n",
2381 zfcp_get_busid_by_adapter(adapter));
2384 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED,
2388 if (retries < ZFCP_EXCHANGE_PORT_DATA_SHORT_RETRIES) {
2389 sleep = ZFCP_EXCHANGE_PORT_DATA_SHORT_SLEEP;
2392 sleep = ZFCP_EXCHANGE_PORT_DATA_LONG_SLEEP;
2393 schedule_timeout(sleep);
2396 return ZFCP_ERP_SUCCEEDED;
2407 zfcp_erp_adapter_strategy_open_fsf_statusread(struct zfcp_erp_action
2410 int retval = ZFCP_ERP_SUCCEEDED;
2412 struct zfcp_adapter *adapter = erp_action->adapter;
2415 adapter->status_read_failed = 0;
2416 for (i = 0; i < ZFCP_STATUS_READS_RECOM; i++) {
2417 temp_ret = zfcp_fsf_status_read(adapter, ZFCP_WAIT_FOR_SBAL);
2419 ZFCP_LOG_INFO("error: set-up of unsolicited status "
2420 "notification failed on adapter %s\n",
2421 zfcp_get_busid_by_adapter(adapter));
2422 retval = ZFCP_ERP_FAILED;
2432 * function: zfcp_fsf_cleanup
2434 * purpose: cleanup FSF operation for specified adapter
2436 * returns: 0 - FSF operation successfully cleaned up
2437 * !0 - failed to cleanup FSF operation for this adapter
2440 zfcp_erp_adapter_strategy_close_fsf(struct zfcp_erp_action *erp_action)
2442 int retval = ZFCP_ERP_SUCCEEDED;
2443 struct zfcp_adapter *adapter = erp_action->adapter;
2446 * wake waiting initiators of requests,
2447 * return SCSI commands (with error status),
2448 * clean up all requests (synchronously)
2450 zfcp_fsf_req_dismiss_all(adapter);
2451 /* reset FSF request sequence number */
2452 adapter->fsf_req_seq_no = 0;
2453 /* all ports and units are closed */
2454 zfcp_erp_modify_adapter_status(adapter,
2455 ZFCP_STATUS_COMMON_OPEN, ZFCP_CLEAR);
2463 * purpose: this routine executes the 'Reopen Physical Port' action
2465 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2466 * ZFCP_ERP_SUCCEEDED - action finished successfully
2467 * ZFCP_ERP_FAILED - action finished unsuccessfully
2470 zfcp_erp_port_forced_strategy(struct zfcp_erp_action *erp_action)
2472 int retval = ZFCP_ERP_FAILED;
2473 struct zfcp_port *port = erp_action->port;
2474 struct zfcp_adapter *adapter = erp_action->adapter;
2476 switch (erp_action->step) {
2480 * the ULP spec. begs for waiting for oustanding commands
2482 case ZFCP_ERP_STEP_UNINITIALIZED:
2483 zfcp_erp_port_strategy_clearstati(port);
2485 * it would be sufficient to test only the normal open flag
2486 * since the phys. open flag cannot be set if the normal
2487 * open flag is unset - however, this is for readabilty ...
2489 if (atomic_test_mask((ZFCP_STATUS_PORT_PHYS_OPEN |
2490 ZFCP_STATUS_COMMON_OPEN),
2492 ZFCP_LOG_DEBUG("port 0x%016Lx is open -> trying "
2493 "close physical\n", port->wwpn);
2495 zfcp_erp_port_forced_strategy_close(erp_action);
2497 retval = ZFCP_ERP_FAILED;
2500 case ZFCP_ERP_STEP_PHYS_PORT_CLOSING:
2501 if (atomic_test_mask(ZFCP_STATUS_PORT_PHYS_OPEN,
2503 ZFCP_LOG_DEBUG("close physical failed for port "
2504 "0x%016Lx\n", port->wwpn);
2505 retval = ZFCP_ERP_FAILED;
2507 retval = ZFCP_ERP_SUCCEEDED;
2511 debug_text_event(adapter->erp_dbf, 3, "p_pfst/ret");
2512 debug_event(adapter->erp_dbf, 3, &port->wwpn, sizeof (wwn_t));
2513 debug_event(adapter->erp_dbf, 3, &erp_action->action, sizeof (int));
2514 debug_event(adapter->erp_dbf, 3, &retval, sizeof (int));
2522 * purpose: this routine executes the 'Reopen Port' action
2524 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2525 * ZFCP_ERP_SUCCEEDED - action finished successfully
2526 * ZFCP_ERP_FAILED - action finished unsuccessfully
2529 zfcp_erp_port_strategy(struct zfcp_erp_action *erp_action)
2531 int retval = ZFCP_ERP_FAILED;
2532 struct zfcp_port *port = erp_action->port;
2533 struct zfcp_adapter *adapter = erp_action->adapter;
2535 switch (erp_action->step) {
2539 * the ULP spec. begs for waiting for oustanding commands
2541 case ZFCP_ERP_STEP_UNINITIALIZED:
2542 zfcp_erp_port_strategy_clearstati(port);
2543 if (atomic_test_mask(ZFCP_STATUS_COMMON_OPEN, &port->status)) {
2544 ZFCP_LOG_DEBUG("port 0x%016Lx is open -> trying "
2545 "close\n", port->wwpn);
2546 retval = zfcp_erp_port_strategy_close(erp_action);
2548 } /* else it's already closed, open it */
2551 case ZFCP_ERP_STEP_PORT_CLOSING:
2552 if (atomic_test_mask(ZFCP_STATUS_COMMON_OPEN, &port->status)) {
2553 ZFCP_LOG_DEBUG("close failed for port 0x%016Lx\n",
2555 retval = ZFCP_ERP_FAILED;
2557 } /* else it's closed now, open it */
2560 if (erp_action->status & ZFCP_STATUS_ERP_CLOSE_ONLY)
2561 retval = ZFCP_ERP_EXIT;
2563 retval = zfcp_erp_port_strategy_open(erp_action);
2566 debug_text_event(adapter->erp_dbf, 3, "p_pst/ret");
2567 debug_event(adapter->erp_dbf, 3, &port->wwpn, sizeof (wwn_t));
2568 debug_event(adapter->erp_dbf, 3, &erp_action->action, sizeof (int));
2569 debug_event(adapter->erp_dbf, 3, &retval, sizeof (int));
2582 zfcp_erp_port_strategy_open(struct zfcp_erp_action *erp_action)
2586 if (atomic_test_mask(ZFCP_STATUS_PORT_WKA,
2587 &erp_action->port->status))
2588 retval = zfcp_erp_port_strategy_open_nameserver(erp_action);
2590 retval = zfcp_erp_port_strategy_open_common(erp_action);
2602 * FIXME(design): currently only prepared for fabric (nameserver!)
2605 zfcp_erp_port_strategy_open_common(struct zfcp_erp_action *erp_action)
2608 struct zfcp_adapter *adapter = erp_action->adapter;
2609 struct zfcp_port *port = erp_action->port;
2611 switch (erp_action->step) {
2613 case ZFCP_ERP_STEP_UNINITIALIZED:
2614 case ZFCP_ERP_STEP_PHYS_PORT_CLOSING:
2615 case ZFCP_ERP_STEP_PORT_CLOSING:
2616 if (adapter->fc_topology == FSF_TOPO_P2P) {
2617 if (port->wwpn != adapter->peer_wwpn) {
2618 ZFCP_LOG_NORMAL("Failed to open port 0x%016Lx "
2619 "on adapter %s.\nPeer WWPN "
2620 "0x%016Lx does not match\n",
2622 zfcp_get_busid_by_adapter(adapter),
2623 adapter->peer_wwpn);
2624 zfcp_erp_port_failed(port);
2625 retval = ZFCP_ERP_FAILED;
2628 port->d_id = adapter->peer_d_id;
2629 atomic_set_mask(ZFCP_STATUS_PORT_DID_DID, &port->status);
2630 retval = zfcp_erp_port_strategy_open_port(erp_action);
2633 if (!(adapter->nameserver_port)) {
2634 retval = zfcp_nameserver_enqueue(adapter);
2636 ZFCP_LOG_NORMAL("error: nameserver port "
2637 "unavailable for adapter %s\n",
2638 zfcp_get_busid_by_adapter(adapter));
2639 retval = ZFCP_ERP_FAILED;
2643 if (!atomic_test_mask(ZFCP_STATUS_COMMON_UNBLOCKED,
2644 &adapter->nameserver_port->status)) {
2645 ZFCP_LOG_DEBUG("nameserver port is not open -> open "
2646 "nameserver port\n");
2647 /* nameserver port may live again */
2648 atomic_set_mask(ZFCP_STATUS_COMMON_RUNNING,
2649 &adapter->nameserver_port->status);
2650 if (zfcp_erp_port_reopen(adapter->nameserver_port, 0)
2653 ZFCP_ERP_STEP_NAMESERVER_OPEN;
2654 retval = ZFCP_ERP_CONTINUES;
2656 retval = ZFCP_ERP_FAILED;
2659 /* else nameserver port is already open, fall through */
2660 case ZFCP_ERP_STEP_NAMESERVER_OPEN:
2661 if (!atomic_test_mask(ZFCP_STATUS_COMMON_OPEN,
2662 &adapter->nameserver_port->status)) {
2663 ZFCP_LOG_DEBUG("open failed for nameserver port\n");
2664 retval = ZFCP_ERP_FAILED;
2666 ZFCP_LOG_DEBUG("nameserver port is open -> "
2667 "nameserver look-up for port 0x%016Lx\n",
2669 retval = zfcp_erp_port_strategy_open_common_lookup
2674 case ZFCP_ERP_STEP_NAMESERVER_LOOKUP:
2675 if (!atomic_test_mask(ZFCP_STATUS_PORT_DID_DID, &port->status)) {
2676 if (atomic_test_mask
2677 (ZFCP_STATUS_PORT_INVALID_WWPN, &port->status)) {
2678 ZFCP_LOG_DEBUG("nameserver look-up failed "
2679 "for port 0x%016Lx "
2680 "(misconfigured WWPN?)\n",
2682 zfcp_erp_port_failed(port);
2683 retval = ZFCP_ERP_EXIT;
2685 ZFCP_LOG_DEBUG("nameserver look-up failed for "
2686 "port 0x%016Lx\n", port->wwpn);
2687 retval = ZFCP_ERP_FAILED;
2690 ZFCP_LOG_DEBUG("port 0x%016Lx has d_id=0x%08x -> "
2691 "trying open\n", port->wwpn, port->d_id);
2692 retval = zfcp_erp_port_strategy_open_port(erp_action);
2696 case ZFCP_ERP_STEP_PORT_OPENING:
2697 /* D_ID might have changed during open */
2698 if (atomic_test_mask((ZFCP_STATUS_COMMON_OPEN |
2699 ZFCP_STATUS_PORT_DID_DID),
2701 ZFCP_LOG_DEBUG("port 0x%016Lx is open\n", port->wwpn);
2702 retval = ZFCP_ERP_SUCCEEDED;
2704 ZFCP_LOG_DEBUG("open failed for port 0x%016Lx\n",
2706 retval = ZFCP_ERP_FAILED;
2711 ZFCP_LOG_NORMAL("bug: unknown erp step 0x%08x\n",
2713 retval = ZFCP_ERP_FAILED;
2727 zfcp_erp_port_strategy_open_nameserver(struct zfcp_erp_action *erp_action)
2730 struct zfcp_port *port = erp_action->port;
2732 switch (erp_action->step) {
2734 case ZFCP_ERP_STEP_UNINITIALIZED:
2735 case ZFCP_ERP_STEP_PHYS_PORT_CLOSING:
2736 case ZFCP_ERP_STEP_PORT_CLOSING:
2737 ZFCP_LOG_DEBUG("port 0x%016Lx has d_id=0x%08x -> trying open\n",
2738 port->wwpn, port->d_id);
2739 retval = zfcp_erp_port_strategy_open_port(erp_action);
2742 case ZFCP_ERP_STEP_PORT_OPENING:
2743 if (atomic_test_mask(ZFCP_STATUS_COMMON_OPEN, &port->status)) {
2744 ZFCP_LOG_DEBUG("WKA port is open\n");
2745 retval = ZFCP_ERP_SUCCEEDED;
2747 ZFCP_LOG_DEBUG("open failed for WKA port\n");
2748 retval = ZFCP_ERP_FAILED;
2750 /* this is needed anyway (dont care for retval of wakeup) */
2751 ZFCP_LOG_DEBUG("continue other open port operations\n");
2752 zfcp_erp_port_strategy_open_nameserver_wakeup(erp_action);
2756 ZFCP_LOG_NORMAL("bug: unknown erp step 0x%08x\n",
2758 retval = ZFCP_ERP_FAILED;
2767 * purpose: makes the erp thread continue with reopen (physical) port
2768 * actions which have been paused until the name server port
2769 * is opened (or failed)
2771 * returns: 0 (a kind of void retval, its not used)
2774 zfcp_erp_port_strategy_open_nameserver_wakeup(struct zfcp_erp_action
2778 unsigned long flags;
2779 struct zfcp_adapter *adapter = ns_erp_action->adapter;
2780 struct zfcp_erp_action *erp_action, *tmp;
2782 read_lock_irqsave(&adapter->erp_lock, flags);
2783 list_for_each_entry_safe(erp_action, tmp, &adapter->erp_running_head,
2785 debug_text_event(adapter->erp_dbf, 4, "p_pstnsw_n");
2786 debug_event(adapter->erp_dbf, 4, &erp_action->port->wwpn,
2788 if (erp_action->step == ZFCP_ERP_STEP_NAMESERVER_OPEN) {
2789 debug_text_event(adapter->erp_dbf, 3, "p_pstnsw_w");
2790 debug_event(adapter->erp_dbf, 3,
2791 &erp_action->port->wwpn, sizeof (wwn_t));
2792 if (atomic_test_mask(
2793 ZFCP_STATUS_COMMON_ERP_FAILED,
2794 &adapter->nameserver_port->status))
2795 zfcp_erp_port_failed(erp_action->port);
2796 zfcp_erp_action_ready(erp_action);
2799 read_unlock_irqrestore(&adapter->erp_lock, flags);
2809 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2810 * ZFCP_ERP_FAILED - action finished unsuccessfully
2813 zfcp_erp_port_forced_strategy_close(struct zfcp_erp_action *erp_action)
2816 struct zfcp_adapter *adapter = erp_action->adapter;
2817 struct zfcp_port *port = erp_action->port;
2819 zfcp_erp_timeout_init(erp_action);
2820 retval = zfcp_fsf_close_physical_port(erp_action);
2821 if (retval == -ENOMEM) {
2822 debug_text_event(adapter->erp_dbf, 5, "o_pfstc_nomem");
2823 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2824 retval = ZFCP_ERP_NOMEM;
2827 erp_action->step = ZFCP_ERP_STEP_PHYS_PORT_CLOSING;
2829 debug_text_event(adapter->erp_dbf, 5, "o_pfstc_cpf");
2830 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2831 /* could not send 'open', fail */
2832 retval = ZFCP_ERP_FAILED;
2835 debug_text_event(adapter->erp_dbf, 6, "o_pfstc_cpok");
2836 debug_event(adapter->erp_dbf, 6, &port->wwpn, sizeof (wwn_t));
2837 retval = ZFCP_ERP_CONTINUES;
2850 zfcp_erp_port_strategy_clearstati(struct zfcp_port *port)
2853 struct zfcp_adapter *adapter = port->adapter;
2855 debug_text_event(adapter->erp_dbf, 5, "p_pstclst");
2856 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2858 atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING |
2859 ZFCP_STATUS_COMMON_CLOSING |
2860 ZFCP_STATUS_COMMON_ACCESS_DENIED |
2861 ZFCP_STATUS_PORT_DID_DID |
2862 ZFCP_STATUS_PORT_PHYS_CLOSING |
2863 ZFCP_STATUS_PORT_INVALID_WWPN,
2873 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2874 * ZFCP_ERP_FAILED - action finished unsuccessfully
2877 zfcp_erp_port_strategy_close(struct zfcp_erp_action *erp_action)
2880 struct zfcp_adapter *adapter = erp_action->adapter;
2881 struct zfcp_port *port = erp_action->port;
2883 zfcp_erp_timeout_init(erp_action);
2884 retval = zfcp_fsf_close_port(erp_action);
2885 if (retval == -ENOMEM) {
2886 debug_text_event(adapter->erp_dbf, 5, "p_pstc_nomem");
2887 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2888 retval = ZFCP_ERP_NOMEM;
2891 erp_action->step = ZFCP_ERP_STEP_PORT_CLOSING;
2893 debug_text_event(adapter->erp_dbf, 5, "p_pstc_cpf");
2894 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2895 /* could not send 'close', fail */
2896 retval = ZFCP_ERP_FAILED;
2899 debug_text_event(adapter->erp_dbf, 6, "p_pstc_cpok");
2900 debug_event(adapter->erp_dbf, 6, &port->wwpn, sizeof (wwn_t));
2901 retval = ZFCP_ERP_CONTINUES;
2911 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2912 * ZFCP_ERP_FAILED - action finished unsuccessfully
2915 zfcp_erp_port_strategy_open_port(struct zfcp_erp_action *erp_action)
2918 struct zfcp_adapter *adapter = erp_action->adapter;
2919 struct zfcp_port *port = erp_action->port;
2921 zfcp_erp_timeout_init(erp_action);
2922 retval = zfcp_fsf_open_port(erp_action);
2923 if (retval == -ENOMEM) {
2924 debug_text_event(adapter->erp_dbf, 5, "p_psto_nomem");
2925 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2926 retval = ZFCP_ERP_NOMEM;
2929 erp_action->step = ZFCP_ERP_STEP_PORT_OPENING;
2931 debug_text_event(adapter->erp_dbf, 5, "p_psto_opf");
2932 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2933 /* could not send 'open', fail */
2934 retval = ZFCP_ERP_FAILED;
2937 debug_text_event(adapter->erp_dbf, 6, "p_psto_opok");
2938 debug_event(adapter->erp_dbf, 6, &port->wwpn, sizeof (wwn_t));
2939 retval = ZFCP_ERP_CONTINUES;
2949 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2950 * ZFCP_ERP_FAILED - action finished unsuccessfully
2953 zfcp_erp_port_strategy_open_common_lookup(struct zfcp_erp_action *erp_action)
2956 struct zfcp_adapter *adapter = erp_action->adapter;
2957 struct zfcp_port *port = erp_action->port;
2959 zfcp_erp_timeout_init(erp_action);
2960 retval = zfcp_ns_gid_pn_request(erp_action);
2961 if (retval == -ENOMEM) {
2962 debug_text_event(adapter->erp_dbf, 5, "p_pstn_nomem");
2963 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2964 retval = ZFCP_ERP_NOMEM;
2967 erp_action->step = ZFCP_ERP_STEP_NAMESERVER_LOOKUP;
2969 debug_text_event(adapter->erp_dbf, 5, "p_pstn_ref");
2970 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2971 /* could not send nameserver request, fail */
2972 retval = ZFCP_ERP_FAILED;
2975 debug_text_event(adapter->erp_dbf, 6, "p_pstn_reok");
2976 debug_event(adapter->erp_dbf, 6, &port->wwpn, sizeof (wwn_t));
2977 retval = ZFCP_ERP_CONTINUES;
2985 * purpose: this routine executes the 'Reopen Unit' action
2986 * currently no retries
2988 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2989 * ZFCP_ERP_SUCCEEDED - action finished successfully
2990 * ZFCP_ERP_FAILED - action finished unsuccessfully
2993 zfcp_erp_unit_strategy(struct zfcp_erp_action *erp_action)
2995 int retval = ZFCP_ERP_FAILED;
2996 struct zfcp_unit *unit = erp_action->unit;
2997 struct zfcp_adapter *adapter = erp_action->adapter;
2999 switch (erp_action->step) {
3003 * the ULP spec. begs for waiting for oustanding commands
3005 case ZFCP_ERP_STEP_UNINITIALIZED:
3006 zfcp_erp_unit_strategy_clearstati(unit);
3007 if (atomic_test_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status)) {
3008 ZFCP_LOG_DEBUG("unit 0x%016Lx is open -> "
3009 "trying close\n", unit->fcp_lun);
3010 retval = zfcp_erp_unit_strategy_close(erp_action);
3013 /* else it's already closed, fall through */
3014 case ZFCP_ERP_STEP_UNIT_CLOSING:
3015 if (atomic_test_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status)) {
3016 ZFCP_LOG_DEBUG("close failed for unit 0x%016Lx\n",
3018 retval = ZFCP_ERP_FAILED;
3020 if (erp_action->status & ZFCP_STATUS_ERP_CLOSE_ONLY)
3021 retval = ZFCP_ERP_EXIT;
3023 ZFCP_LOG_DEBUG("unit 0x%016Lx is not open -> "
3024 "trying open\n", unit->fcp_lun);
3026 zfcp_erp_unit_strategy_open(erp_action);
3031 case ZFCP_ERP_STEP_UNIT_OPENING:
3032 if (atomic_test_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status)) {
3033 ZFCP_LOG_DEBUG("unit 0x%016Lx is open\n",
3035 retval = ZFCP_ERP_SUCCEEDED;
3037 ZFCP_LOG_DEBUG("open failed for unit 0x%016Lx\n",
3039 retval = ZFCP_ERP_FAILED;
3044 debug_text_event(adapter->erp_dbf, 3, "u_ust/ret");
3045 debug_event(adapter->erp_dbf, 3, &unit->fcp_lun, sizeof (fcp_lun_t));
3046 debug_event(adapter->erp_dbf, 3, &erp_action->action, sizeof (int));
3047 debug_event(adapter->erp_dbf, 3, &retval, sizeof (int));
3059 zfcp_erp_unit_strategy_clearstati(struct zfcp_unit *unit)
3062 struct zfcp_adapter *adapter = unit->port->adapter;
3064 debug_text_event(adapter->erp_dbf, 5, "u_ustclst");
3065 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun, sizeof (fcp_lun_t));
3067 atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING |
3068 ZFCP_STATUS_COMMON_CLOSING |
3069 ZFCP_STATUS_COMMON_ACCESS_DENIED |
3070 ZFCP_STATUS_UNIT_SHARED |
3071 ZFCP_STATUS_UNIT_READONLY,
3082 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
3083 * ZFCP_ERP_FAILED - action finished unsuccessfully
3086 zfcp_erp_unit_strategy_close(struct zfcp_erp_action *erp_action)
3089 struct zfcp_adapter *adapter = erp_action->adapter;
3090 struct zfcp_unit *unit = erp_action->unit;
3092 zfcp_erp_timeout_init(erp_action);
3093 retval = zfcp_fsf_close_unit(erp_action);
3094 if (retval == -ENOMEM) {
3095 debug_text_event(adapter->erp_dbf, 5, "u_ustc_nomem");
3096 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun,
3097 sizeof (fcp_lun_t));
3098 retval = ZFCP_ERP_NOMEM;
3101 erp_action->step = ZFCP_ERP_STEP_UNIT_CLOSING;
3103 debug_text_event(adapter->erp_dbf, 5, "u_ustc_cuf");
3104 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun,
3105 sizeof (fcp_lun_t));
3106 /* could not send 'close', fail */
3107 retval = ZFCP_ERP_FAILED;
3110 debug_text_event(adapter->erp_dbf, 6, "u_ustc_cuok");
3111 debug_event(adapter->erp_dbf, 6, &unit->fcp_lun, sizeof (fcp_lun_t));
3112 retval = ZFCP_ERP_CONTINUES;
3123 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
3124 * ZFCP_ERP_FAILED - action finished unsuccessfully
3127 zfcp_erp_unit_strategy_open(struct zfcp_erp_action *erp_action)
3130 struct zfcp_adapter *adapter = erp_action->adapter;
3131 struct zfcp_unit *unit = erp_action->unit;
3133 zfcp_erp_timeout_init(erp_action);
3134 retval = zfcp_fsf_open_unit(erp_action);
3135 if (retval == -ENOMEM) {
3136 debug_text_event(adapter->erp_dbf, 5, "u_usto_nomem");
3137 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun,
3138 sizeof (fcp_lun_t));
3139 retval = ZFCP_ERP_NOMEM;
3142 erp_action->step = ZFCP_ERP_STEP_UNIT_OPENING;
3144 debug_text_event(adapter->erp_dbf, 5, "u_usto_ouf");
3145 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun,
3146 sizeof (fcp_lun_t));
3147 /* could not send 'open', fail */
3148 retval = ZFCP_ERP_FAILED;
3151 debug_text_event(adapter->erp_dbf, 6, "u_usto_ouok");
3152 debug_event(adapter->erp_dbf, 6, &unit->fcp_lun, sizeof (fcp_lun_t));
3153 retval = ZFCP_ERP_CONTINUES;
3166 zfcp_erp_timeout_init(struct zfcp_erp_action *erp_action)
3168 init_timer(&erp_action->timer);
3169 erp_action->timer.function = zfcp_erp_timeout_handler;
3170 erp_action->timer.data = (unsigned long) erp_action;
3171 /* jiffies will be added in zfcp_fsf_req_send */
3172 erp_action->timer.expires = ZFCP_ERP_FSFREQ_TIMEOUT;
3178 * purpose: enqueue the specified error recovery action, if needed
3183 zfcp_erp_action_enqueue(int action,
3184 struct zfcp_adapter *adapter,
3185 struct zfcp_port *port, struct zfcp_unit *unit)
3188 struct zfcp_erp_action *erp_action = NULL;
3189 int stronger_action = 0;
3193 * We need some rules here which check whether we really need
3194 * this action or whether we should just drop it.
3195 * E.g. if there is a unfinished 'Reopen Port' request then we drop a
3196 * 'Reopen Unit' request for an associated unit since we can't
3197 * satisfy this request now. A 'Reopen Port' action will trigger
3198 * 'Reopen Unit' actions when it completes.
3199 * Thus, there are only actions in the queue which can immediately be
3200 * executed. This makes the processing of the action queue more
3204 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP,
3208 debug_event(adapter->erp_dbf, 4, &action, sizeof (int));
3209 /* check whether we really need this */
3211 case ZFCP_ERP_ACTION_REOPEN_UNIT:
3212 if (atomic_test_mask
3213 (ZFCP_STATUS_COMMON_ERP_INUSE, &unit->status)) {
3214 debug_text_event(adapter->erp_dbf, 4, "u_actenq_drp");
3215 debug_event(adapter->erp_dbf, 4, &port->wwpn,
3217 debug_event(adapter->erp_dbf, 4, &unit->fcp_lun,
3218 sizeof (fcp_lun_t));
3221 if (!atomic_test_mask
3222 (ZFCP_STATUS_COMMON_RUNNING, &port->status) ||
3224 (ZFCP_STATUS_COMMON_ERP_FAILED, &port->status)) {
3227 if (!atomic_test_mask
3228 (ZFCP_STATUS_COMMON_UNBLOCKED, &port->status)) {
3229 stronger_action = ZFCP_ERP_ACTION_REOPEN_PORT;
3232 /* fall through !!! */
3234 case ZFCP_ERP_ACTION_REOPEN_PORT:
3235 if (atomic_test_mask
3236 (ZFCP_STATUS_COMMON_ERP_INUSE, &port->status)) {
3237 debug_text_event(adapter->erp_dbf, 4, "p_actenq_drp");
3238 debug_event(adapter->erp_dbf, 4, &port->wwpn,
3242 /* fall through !!! */
3244 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
3245 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_INUSE,
3247 if (port->erp_action.action !=
3248 ZFCP_ERP_ACTION_REOPEN_PORT_FORCED) {
3249 ZFCP_LOG_INFO("dropped erp action %i (port "
3250 "0x%016Lx, action in use: %i)\n",
3252 port->erp_action.action);
3253 debug_text_event(adapter->erp_dbf, 4,
3256 debug_text_event(adapter->erp_dbf, 4,
3258 debug_event(adapter->erp_dbf, 4, &port->wwpn,
3262 if (!atomic_test_mask
3263 (ZFCP_STATUS_COMMON_RUNNING, &adapter->status) ||
3265 (ZFCP_STATUS_COMMON_ERP_FAILED, &adapter->status)) {
3268 if (!atomic_test_mask
3269 (ZFCP_STATUS_COMMON_UNBLOCKED, &adapter->status)) {
3270 stronger_action = ZFCP_ERP_ACTION_REOPEN_ADAPTER;
3273 /* fall through !!! */
3275 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
3276 if (atomic_test_mask
3277 (ZFCP_STATUS_COMMON_ERP_INUSE, &adapter->status)) {
3278 debug_text_event(adapter->erp_dbf, 4, "a_actenq_drp");
3284 debug_text_exception(adapter->erp_dbf, 1, "a_actenq_bug");
3285 debug_event(adapter->erp_dbf, 1, &action, sizeof (int));
3286 ZFCP_LOG_NORMAL("bug: unknown erp action requested "
3287 "on adapter %s (action=%d)\n",
3288 zfcp_get_busid_by_adapter(adapter), action);
3292 /* check whether we need something stronger first */
3293 if (stronger_action) {
3294 debug_text_event(adapter->erp_dbf, 4, "a_actenq_str");
3295 debug_event(adapter->erp_dbf, 4, &stronger_action,
3297 ZFCP_LOG_DEBUG("stronger erp action %d needed before "
3298 "erp action %d on adapter %s\n",
3299 stronger_action, action,
3300 zfcp_get_busid_by_adapter(adapter));
3301 action = stronger_action;
3304 /* mark adapter to have some error recovery pending */
3305 atomic_set_mask(ZFCP_STATUS_ADAPTER_ERP_PENDING, &adapter->status);
3307 /* setup error recovery action */
3310 case ZFCP_ERP_ACTION_REOPEN_UNIT:
3311 zfcp_unit_get(unit);
3312 atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &unit->status);
3313 erp_action = &unit->erp_action;
3314 if (!atomic_test_mask
3315 (ZFCP_STATUS_COMMON_RUNNING, &unit->status))
3316 status = ZFCP_STATUS_ERP_CLOSE_ONLY;
3319 case ZFCP_ERP_ACTION_REOPEN_PORT:
3320 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
3321 zfcp_port_get(port);
3322 zfcp_erp_action_dismiss_port(port);
3323 atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &port->status);
3324 erp_action = &port->erp_action;
3325 if (!atomic_test_mask
3326 (ZFCP_STATUS_COMMON_RUNNING, &port->status))
3327 status = ZFCP_STATUS_ERP_CLOSE_ONLY;
3330 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
3331 zfcp_adapter_get(adapter);
3332 zfcp_erp_action_dismiss_adapter(adapter);
3333 atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &adapter->status);
3334 erp_action = &adapter->erp_action;
3335 if (!atomic_test_mask
3336 (ZFCP_STATUS_COMMON_RUNNING, &adapter->status))
3337 status = ZFCP_STATUS_ERP_CLOSE_ONLY;
3341 debug_text_event(adapter->erp_dbf, 4, "a_actenq");
3343 memset(erp_action, 0, sizeof (struct zfcp_erp_action));
3344 erp_action->adapter = adapter;
3345 erp_action->port = port;
3346 erp_action->unit = unit;
3347 erp_action->action = action;
3348 erp_action->status = status;
3350 ++adapter->erp_total_count;
3352 /* finally put it into 'ready' queue and kick erp thread */
3353 list_add(&erp_action->list, &adapter->erp_ready_head);
3354 up(&adapter->erp_ready_sem);
3368 zfcp_erp_action_dequeue(struct zfcp_erp_action *erp_action)
3371 struct zfcp_adapter *adapter = erp_action->adapter;
3373 --adapter->erp_total_count;
3374 if (erp_action->status & ZFCP_STATUS_ERP_LOWMEM) {
3375 --adapter->erp_low_mem_count;
3376 erp_action->status &= ~ZFCP_STATUS_ERP_LOWMEM;
3379 debug_text_event(adapter->erp_dbf, 4, "a_actdeq");
3380 debug_event(adapter->erp_dbf, 4, &erp_action->action, sizeof (int));
3381 list_del(&erp_action->list);
3382 switch (erp_action->action) {
3383 case ZFCP_ERP_ACTION_REOPEN_UNIT:
3384 atomic_clear_mask(ZFCP_STATUS_COMMON_ERP_INUSE,
3385 &erp_action->unit->status);
3387 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
3388 case ZFCP_ERP_ACTION_REOPEN_PORT:
3389 atomic_clear_mask(ZFCP_STATUS_COMMON_ERP_INUSE,
3390 &erp_action->port->status);
3392 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
3393 atomic_clear_mask(ZFCP_STATUS_COMMON_ERP_INUSE,
3394 &erp_action->adapter->status);
3404 * zfcp_erp_action_cleanup
3406 * Register unit with scsi stack if appropiate and fix reference counts.
3407 * Note: Temporary units are not registered with scsi stack.
3410 zfcp_erp_action_cleanup(int action, struct zfcp_adapter *adapter,
3411 struct zfcp_port *port, struct zfcp_unit *unit,
3415 case ZFCP_ERP_ACTION_REOPEN_UNIT:
3416 if ((result == ZFCP_ERP_SUCCEEDED)
3417 && (!atomic_test_mask(ZFCP_STATUS_UNIT_TEMPORARY,
3421 scsi_add_device(port->adapter->scsi_host, 0,
3422 port->rport->scsi_target_id,
3424 zfcp_unit_put(unit);
3426 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
3427 case ZFCP_ERP_ACTION_REOPEN_PORT:
3428 if ((result == ZFCP_ERP_SUCCEEDED)
3429 && !atomic_test_mask(ZFCP_STATUS_PORT_NO_WWPN,
3432 struct fc_rport_identifiers ids;
3433 ids.node_name = port->wwnn;
3434 ids.port_name = port->wwpn;
3435 ids.port_id = port->d_id;
3436 ids.roles = FC_RPORT_ROLE_FCP_TARGET;
3438 fc_remote_port_add(adapter->scsi_host, 0, &ids);
3440 ZFCP_LOG_NORMAL("failed registration of rport"
3441 "(adapter %s, wwpn=0x%016Lx)\n",
3442 zfcp_get_busid_by_port(port),
3445 zfcp_port_put(port);
3447 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
3448 zfcp_adapter_put(adapter);
3464 zfcp_erp_action_dismiss_adapter(struct zfcp_adapter *adapter)
3467 struct zfcp_port *port;
3469 debug_text_event(adapter->erp_dbf, 5, "a_actab");
3470 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &adapter->status))
3471 zfcp_erp_action_dismiss(&adapter->erp_action);
3473 list_for_each_entry(port, &adapter->port_list_head, list)
3474 zfcp_erp_action_dismiss_port(port);
3487 zfcp_erp_action_dismiss_port(struct zfcp_port *port)
3490 struct zfcp_unit *unit;
3491 struct zfcp_adapter *adapter = port->adapter;
3493 debug_text_event(adapter->erp_dbf, 5, "p_actab");
3494 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
3495 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &port->status))
3496 zfcp_erp_action_dismiss(&port->erp_action);
3498 list_for_each_entry(unit, &port->unit_list_head, list)
3499 zfcp_erp_action_dismiss_unit(unit);
3512 zfcp_erp_action_dismiss_unit(struct zfcp_unit *unit)
3515 struct zfcp_adapter *adapter = unit->port->adapter;
3517 debug_text_event(adapter->erp_dbf, 5, "u_actab");
3518 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun, sizeof (fcp_lun_t));
3519 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &unit->status))
3520 zfcp_erp_action_dismiss(&unit->erp_action);
3528 * purpose: moves erp_action to 'erp running list'
3533 zfcp_erp_action_to_running(struct zfcp_erp_action *erp_action)
3535 struct zfcp_adapter *adapter = erp_action->adapter;
3537 debug_text_event(adapter->erp_dbf, 6, "a_toru");
3538 debug_event(adapter->erp_dbf, 6, &erp_action->action, sizeof (int));
3539 list_move(&erp_action->list, &erp_action->adapter->erp_running_head);
3545 * purpose: moves erp_action to 'erp ready list'
3550 zfcp_erp_action_to_ready(struct zfcp_erp_action *erp_action)
3552 struct zfcp_adapter *adapter = erp_action->adapter;
3554 debug_text_event(adapter->erp_dbf, 6, "a_tore");
3555 debug_event(adapter->erp_dbf, 6, &erp_action->action, sizeof (int));
3556 list_move(&erp_action->list, &erp_action->adapter->erp_ready_head);
3560 * function: zfcp_erp_port_boxed
3565 zfcp_erp_port_boxed(struct zfcp_port *port)
3567 struct zfcp_adapter *adapter = port->adapter;
3568 unsigned long flags;
3570 debug_text_event(adapter->erp_dbf, 3, "p_access_boxed");
3571 debug_event(adapter->erp_dbf, 3, &port->wwpn, sizeof(wwn_t));
3572 read_lock_irqsave(&zfcp_data.config_lock, flags);
3573 zfcp_erp_modify_port_status(port,
3574 ZFCP_STATUS_COMMON_ACCESS_BOXED,
3576 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
3577 zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED);
3581 * function: zfcp_erp_unit_boxed
3586 zfcp_erp_unit_boxed(struct zfcp_unit *unit)
3588 struct zfcp_adapter *adapter = unit->port->adapter;
3590 debug_text_event(adapter->erp_dbf, 3, "u_access_boxed");
3591 debug_event(adapter->erp_dbf, 3, &unit->fcp_lun, sizeof(fcp_lun_t));
3592 zfcp_erp_modify_unit_status(unit,
3593 ZFCP_STATUS_COMMON_ACCESS_BOXED,
3595 zfcp_erp_unit_reopen(unit, ZFCP_STATUS_COMMON_ERP_FAILED);
3599 * function: zfcp_erp_port_access_denied
3604 zfcp_erp_port_access_denied(struct zfcp_port *port)
3606 struct zfcp_adapter *adapter = port->adapter;
3607 unsigned long flags;
3609 debug_text_event(adapter->erp_dbf, 3, "p_access_denied");
3610 debug_event(adapter->erp_dbf, 3, &port->wwpn, sizeof(wwn_t));
3611 read_lock_irqsave(&zfcp_data.config_lock, flags);
3612 zfcp_erp_modify_port_status(port,
3613 ZFCP_STATUS_COMMON_ERP_FAILED |
3614 ZFCP_STATUS_COMMON_ACCESS_DENIED,
3616 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
3620 * function: zfcp_erp_unit_access_denied
3625 zfcp_erp_unit_access_denied(struct zfcp_unit *unit)
3627 struct zfcp_adapter *adapter = unit->port->adapter;
3629 debug_text_event(adapter->erp_dbf, 3, "u_access_denied");
3630 debug_event(adapter->erp_dbf, 3, &unit->fcp_lun, sizeof(fcp_lun_t));
3631 zfcp_erp_modify_unit_status(unit,
3632 ZFCP_STATUS_COMMON_ERP_FAILED |
3633 ZFCP_STATUS_COMMON_ACCESS_DENIED,
3638 * function: zfcp_erp_adapter_access_changed
3643 zfcp_erp_adapter_access_changed(struct zfcp_adapter *adapter)
3645 struct zfcp_port *port;
3646 unsigned long flags;
3648 if (adapter->connection_features & FSF_FEATURE_NPIV_MODE)
3651 debug_text_event(adapter->erp_dbf, 3, "a_access_recover");
3652 debug_event(adapter->erp_dbf, 3, &adapter->name, 8);
3654 read_lock_irqsave(&zfcp_data.config_lock, flags);
3655 if (adapter->nameserver_port)
3656 zfcp_erp_port_access_changed(adapter->nameserver_port);
3657 list_for_each_entry(port, &adapter->port_list_head, list)
3658 if (port != adapter->nameserver_port)
3659 zfcp_erp_port_access_changed(port);
3660 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
3664 * function: zfcp_erp_port_access_changed
3669 zfcp_erp_port_access_changed(struct zfcp_port *port)
3671 struct zfcp_adapter *adapter = port->adapter;
3672 struct zfcp_unit *unit;
3674 debug_text_event(adapter->erp_dbf, 3, "p_access_recover");
3675 debug_event(adapter->erp_dbf, 3, &port->wwpn, sizeof(wwn_t));
3677 if (!atomic_test_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED,
3679 !atomic_test_mask(ZFCP_STATUS_COMMON_ACCESS_BOXED,
3681 if (!atomic_test_mask(ZFCP_STATUS_PORT_WKA, &port->status))
3682 list_for_each_entry(unit, &port->unit_list_head, list)
3683 zfcp_erp_unit_access_changed(unit);
3687 ZFCP_LOG_NORMAL("reopen of port 0x%016Lx on adapter %s "
3688 "(due to ACT update)\n",
3689 port->wwpn, zfcp_get_busid_by_adapter(adapter));
3690 if (zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED) != 0)
3691 ZFCP_LOG_NORMAL("failed reopen of port"
3692 "(adapter %s, wwpn=0x%016Lx)\n",
3693 zfcp_get_busid_by_adapter(adapter), port->wwpn);
3697 * function: zfcp_erp_unit_access_changed
3702 zfcp_erp_unit_access_changed(struct zfcp_unit *unit)
3704 struct zfcp_adapter *adapter = unit->port->adapter;
3706 debug_text_event(adapter->erp_dbf, 3, "u_access_recover");
3707 debug_event(adapter->erp_dbf, 3, &unit->fcp_lun, sizeof(fcp_lun_t));
3709 if (!atomic_test_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED,
3711 !atomic_test_mask(ZFCP_STATUS_COMMON_ACCESS_BOXED,
3715 ZFCP_LOG_NORMAL("reopen of unit 0x%016Lx on port 0x%016Lx "
3716 " on adapter %s (due to ACT update)\n",
3717 unit->fcp_lun, unit->port->wwpn,
3718 zfcp_get_busid_by_adapter(adapter));
3719 if (zfcp_erp_unit_reopen(unit, ZFCP_STATUS_COMMON_ERP_FAILED) != 0)
3720 ZFCP_LOG_NORMAL("failed reopen of unit (adapter %s, "
3721 "wwpn=0x%016Lx, fcp_lun=0x%016Lx)\n",
3722 zfcp_get_busid_by_adapter(adapter),
3723 unit->port->wwpn, unit->fcp_lun);
3726 #undef ZFCP_LOG_AREA