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_adapter
*, fc_id_t
);
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_statusread(
86 struct zfcp_erp_action
*);
88 static int zfcp_erp_port_forced_strategy(struct zfcp_erp_action
*);
89 static int zfcp_erp_port_forced_strategy_close(struct zfcp_erp_action
*);
91 static int zfcp_erp_port_strategy(struct zfcp_erp_action
*);
92 static int zfcp_erp_port_strategy_clearstati(struct zfcp_port
*);
93 static int zfcp_erp_port_strategy_close(struct zfcp_erp_action
*);
94 static int zfcp_erp_port_strategy_open(struct zfcp_erp_action
*);
95 static int zfcp_erp_port_strategy_open_nameserver(struct zfcp_erp_action
*);
96 static int zfcp_erp_port_strategy_open_nameserver_wakeup(
97 struct zfcp_erp_action
*);
98 static int zfcp_erp_port_strategy_open_common(struct zfcp_erp_action
*);
99 static int zfcp_erp_port_strategy_open_common_lookup(struct zfcp_erp_action
*);
100 static int zfcp_erp_port_strategy_open_port(struct zfcp_erp_action
*);
102 static int zfcp_erp_unit_strategy(struct zfcp_erp_action
*);
103 static int zfcp_erp_unit_strategy_clearstati(struct zfcp_unit
*);
104 static int zfcp_erp_unit_strategy_close(struct zfcp_erp_action
*);
105 static int zfcp_erp_unit_strategy_open(struct zfcp_erp_action
*);
107 static int zfcp_erp_action_dismiss_adapter(struct zfcp_adapter
*);
108 static int zfcp_erp_action_dismiss_port(struct zfcp_port
*);
109 static int zfcp_erp_action_dismiss_unit(struct zfcp_unit
*);
110 static int zfcp_erp_action_dismiss(struct zfcp_erp_action
*);
112 static int zfcp_erp_action_enqueue(int, struct zfcp_adapter
*,
113 struct zfcp_port
*, struct zfcp_unit
*);
114 static int zfcp_erp_action_dequeue(struct zfcp_erp_action
*);
115 static void zfcp_erp_action_cleanup(int, struct zfcp_adapter
*,
116 struct zfcp_port
*, struct zfcp_unit
*,
119 static void zfcp_erp_action_ready(struct zfcp_erp_action
*);
120 static int zfcp_erp_action_exists(struct zfcp_erp_action
*);
122 static inline void zfcp_erp_action_to_ready(struct zfcp_erp_action
*);
123 static inline void zfcp_erp_action_to_running(struct zfcp_erp_action
*);
125 static void zfcp_erp_memwait_handler(unsigned long);
126 static void zfcp_erp_timeout_handler(unsigned long);
127 static inline void zfcp_erp_timeout_init(struct zfcp_erp_action
*);
130 * zfcp_fsf_request_timeout_handler - called if a request timed out
131 * @data: pointer to adapter for handler function
133 * This function needs to be called if requests (ELS, Generic Service,
134 * or SCSI commands) exceed a certain time limit. The assumption is
135 * that after the time limit the adapter get stuck. So we trigger a reopen of
136 * the adapter. This should not be used for error recovery, SCSI abort
137 * commands and SCSI requests from SCSI mid-layer.
140 zfcp_fsf_request_timeout_handler(unsigned long data
)
142 struct zfcp_adapter
*adapter
;
144 adapter
= (struct zfcp_adapter
*) data
;
146 zfcp_erp_adapter_reopen(adapter
, 0);
150 * function: zfcp_fsf_scsi_er_timeout_handler
152 * purpose: This function needs to be called whenever a SCSI error recovery
153 * action (abort/reset) does not return.
154 * Re-opening the adapter means that the command can be returned
155 * by zfcp (it is guarranteed that it does not return via the
156 * adapter anymore). The buffer can then be used again.
161 zfcp_fsf_scsi_er_timeout_handler(unsigned long data
)
163 struct zfcp_adapter
*adapter
= (struct zfcp_adapter
*) data
;
165 ZFCP_LOG_NORMAL("warning: SCSI error recovery timed out. "
166 "Restarting all operations on the adapter %s\n",
167 zfcp_get_busid_by_adapter(adapter
));
168 debug_text_event(adapter
->erp_dbf
, 1, "eh_lmem_tout");
169 zfcp_erp_adapter_reopen(adapter
, 0);
177 * purpose: called if an adapter failed,
178 * initiates adapter recovery which is done
181 * returns: 0 - initiated action succesfully
182 * <0 - failed to initiate action
185 zfcp_erp_adapter_reopen_internal(struct zfcp_adapter
*adapter
, int clear_mask
)
189 debug_text_event(adapter
->erp_dbf
, 5, "a_ro");
190 ZFCP_LOG_DEBUG("reopen adapter %s\n",
191 zfcp_get_busid_by_adapter(adapter
));
193 zfcp_erp_adapter_block(adapter
, clear_mask
);
195 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED
, &adapter
->status
)) {
196 ZFCP_LOG_DEBUG("skipped reopen of failed adapter %s\n",
197 zfcp_get_busid_by_adapter(adapter
));
198 debug_text_event(adapter
->erp_dbf
, 5, "a_ro_f");
199 /* ensure propagation of failed status to new devices */
200 zfcp_erp_adapter_failed(adapter
);
204 retval
= zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_ADAPTER
,
205 adapter
, NULL
, NULL
);
214 * purpose: Wrappper for zfcp_erp_adapter_reopen_internal
215 * used to ensure the correct locking
217 * returns: 0 - initiated action succesfully
218 * <0 - failed to initiate action
221 zfcp_erp_adapter_reopen(struct zfcp_adapter
*adapter
, int clear_mask
)
226 read_lock_irqsave(&zfcp_data
.config_lock
, flags
);
227 write_lock(&adapter
->erp_lock
);
228 retval
= zfcp_erp_adapter_reopen_internal(adapter
, clear_mask
);
229 write_unlock(&adapter
->erp_lock
);
230 read_unlock_irqrestore(&zfcp_data
.config_lock
, flags
);
243 zfcp_erp_adapter_shutdown(struct zfcp_adapter
*adapter
, int clear_mask
)
247 retval
= zfcp_erp_adapter_reopen(adapter
,
248 ZFCP_STATUS_COMMON_RUNNING
|
249 ZFCP_STATUS_COMMON_ERP_FAILED
|
263 zfcp_erp_port_shutdown(struct zfcp_port
*port
, int clear_mask
)
267 retval
= zfcp_erp_port_reopen(port
,
268 ZFCP_STATUS_COMMON_RUNNING
|
269 ZFCP_STATUS_COMMON_ERP_FAILED
|
283 zfcp_erp_unit_shutdown(struct zfcp_unit
*unit
, int clear_mask
)
287 retval
= zfcp_erp_unit_reopen(unit
,
288 ZFCP_STATUS_COMMON_RUNNING
|
289 ZFCP_STATUS_COMMON_ERP_FAILED
|
297 * zfcp_erp_adisc - send ADISC ELS command
298 * @adapter: adapter structure
299 * @d_id: d_id of port where ADISC is sent to
302 zfcp_erp_adisc(struct zfcp_adapter
*adapter
, fc_id_t d_id
)
304 struct zfcp_send_els
*send_els
;
305 struct zfcp_ls_adisc
*adisc
;
306 void *address
= NULL
;
308 struct timer_list
*timer
;
310 send_els
= kmalloc(sizeof(struct zfcp_send_els
), GFP_ATOMIC
);
311 if (send_els
== NULL
)
313 memset(send_els
, 0, sizeof(*send_els
));
315 send_els
->req
= kmalloc(sizeof(struct scatterlist
), GFP_ATOMIC
);
316 if (send_els
->req
== NULL
)
318 memset(send_els
->req
, 0, sizeof(*send_els
->req
));
320 send_els
->resp
= kmalloc(sizeof(struct scatterlist
), GFP_ATOMIC
);
321 if (send_els
->resp
== NULL
)
323 memset(send_els
->resp
, 0, sizeof(*send_els
->resp
));
325 address
= (void *) get_zeroed_page(GFP_ATOMIC
);
329 zfcp_address_to_sg(address
, send_els
->req
);
330 address
+= PAGE_SIZE
>> 1;
331 zfcp_address_to_sg(address
, send_els
->resp
);
332 send_els
->req_count
= send_els
->resp_count
= 1;
334 send_els
->adapter
= adapter
;
335 send_els
->d_id
= d_id
;
336 send_els
->handler
= zfcp_erp_adisc_handler
;
337 send_els
->handler_data
= (unsigned long) send_els
;
339 adisc
= zfcp_sg_to_address(send_els
->req
);
340 send_els
->ls_code
= adisc
->code
= ZFCP_LS_ADISC
;
342 send_els
->req
->length
= sizeof(struct zfcp_ls_adisc
);
343 send_els
->resp
->length
= sizeof(struct zfcp_ls_adisc_acc
);
345 /* acc. to FC-FS, hard_nport_id in ADISC should not be set for ports
346 without FC-AL-2 capability, so we don't set it */
347 adisc
->wwpn
= adapter
->wwpn
;
348 adisc
->wwnn
= adapter
->wwnn
;
349 adisc
->nport_id
= adapter
->s_id
;
350 ZFCP_LOG_INFO("ADISC request from s_id 0x%08x to d_id 0x%08x "
351 "(wwpn=0x%016Lx, wwnn=0x%016Lx, "
352 "hard_nport_id=0x%08x, nport_id=0x%08x)\n",
353 adapter
->s_id
, d_id
, (wwn_t
) adisc
->wwpn
,
354 (wwn_t
) adisc
->wwnn
, adisc
->hard_nport_id
,
357 timer
= kmalloc(sizeof(struct timer_list
), GFP_ATOMIC
);
362 timer
->function
= zfcp_fsf_request_timeout_handler
;
363 timer
->data
= (unsigned long) adapter
;
364 timer
->expires
= ZFCP_FSF_REQUEST_TIMEOUT
;
365 send_els
->timer
= timer
;
367 retval
= zfcp_fsf_send_els(send_els
);
369 ZFCP_LOG_NORMAL("error: initiation of Send ELS failed for port "
370 "0x%08x on adapter %s\n", d_id
,
371 zfcp_get_busid_by_adapter(adapter
));
372 del_timer(send_els
->timer
);
382 __free_pages(send_els
->req
->page
, 0);
383 if (send_els
!= NULL
) {
384 kfree(send_els
->timer
);
385 kfree(send_els
->req
);
386 kfree(send_els
->resp
);
395 * zfcp_erp_adisc_handler - handler for ADISC ELS command
396 * @data: pointer to struct zfcp_send_els
398 * If ADISC failed (LS_RJT or timed out) forced reopen of the port is triggered.
401 zfcp_erp_adisc_handler(unsigned long data
)
403 struct zfcp_send_els
*send_els
;
404 struct zfcp_port
*port
;
405 struct zfcp_adapter
*adapter
;
407 struct zfcp_ls_adisc_acc
*adisc
;
409 send_els
= (struct zfcp_send_els
*) data
;
411 del_timer(send_els
->timer
);
413 adapter
= send_els
->adapter
;
414 d_id
= send_els
->d_id
;
416 read_lock(&zfcp_data
.config_lock
);
417 port
= zfcp_get_port_by_did(send_els
->adapter
, send_els
->d_id
);
418 read_unlock(&zfcp_data
.config_lock
);
420 BUG_ON(port
== NULL
);
422 /* request rejected or timed out */
423 if (send_els
->status
!= 0) {
424 ZFCP_LOG_NORMAL("ELS request rejected/timed out, "
425 "force physical port reopen "
426 "(adapter %s, port d_id=0x%08x)\n",
427 zfcp_get_busid_by_adapter(adapter
), d_id
);
428 debug_text_event(adapter
->erp_dbf
, 3, "forcreop");
429 if (zfcp_erp_port_forced_reopen(port
, 0))
430 ZFCP_LOG_NORMAL("failed reopen of port "
431 "(adapter %s, wwpn=0x%016Lx)\n",
432 zfcp_get_busid_by_port(port
),
437 adisc
= zfcp_sg_to_address(send_els
->resp
);
439 ZFCP_LOG_INFO("ADISC response from d_id 0x%08x to s_id "
440 "0x%08x (wwpn=0x%016Lx, wwnn=0x%016Lx, "
441 "hard_nport_id=0x%08x, nport_id=0x%08x)\n",
442 d_id
, adapter
->s_id
, (wwn_t
) adisc
->wwpn
,
443 (wwn_t
) adisc
->wwnn
, adisc
->hard_nport_id
,
446 /* set wwnn for port */
448 port
->wwnn
= adisc
->wwnn
;
450 if (port
->wwpn
!= adisc
->wwpn
) {
451 ZFCP_LOG_NORMAL("d_id assignment changed, reopening "
452 "port (adapter %s, wwpn=0x%016Lx, "
453 "adisc_resp_wwpn=0x%016Lx)\n",
454 zfcp_get_busid_by_port(port
),
455 port
->wwpn
, (wwn_t
) adisc
->wwpn
);
456 if (zfcp_erp_port_reopen(port
, 0))
457 ZFCP_LOG_NORMAL("failed reopen of port "
458 "(adapter %s, wwpn=0x%016Lx)\n",
459 zfcp_get_busid_by_port(port
),
465 __free_pages(send_els
->req
->page
, 0);
466 kfree(send_els
->timer
);
467 kfree(send_els
->req
);
468 kfree(send_els
->resp
);
474 * zfcp_test_link - lightweight link test procedure
475 * @port: port to be tested
477 * Test status of a link to a remote port using the ELS command ADISC.
480 zfcp_test_link(struct zfcp_port
*port
)
485 retval
= zfcp_erp_adisc(port
->adapter
, port
->d_id
);
488 ZFCP_LOG_NORMAL("reopen needed for port 0x%016Lx "
489 "on adapter %s\n ", port
->wwpn
,
490 zfcp_get_busid_by_port(port
));
491 retval
= zfcp_erp_port_forced_reopen(port
, 0);
493 ZFCP_LOG_NORMAL("reopen of remote port 0x%016Lx "
494 "on adapter %s failed\n", port
->wwpn
,
495 zfcp_get_busid_by_port(port
));
507 * purpose: called if a port failed to be opened normally
508 * initiates Forced Reopen recovery which is done
511 * returns: 0 - initiated action succesfully
512 * <0 - failed to initiate action
515 zfcp_erp_port_forced_reopen_internal(struct zfcp_port
*port
, int clear_mask
)
518 struct zfcp_adapter
*adapter
= port
->adapter
;
520 debug_text_event(adapter
->erp_dbf
, 5, "pf_ro");
521 debug_event(adapter
->erp_dbf
, 5, &port
->wwpn
, sizeof (wwn_t
));
523 ZFCP_LOG_DEBUG("forced reopen of port 0x%016Lx on adapter %s\n",
524 port
->wwpn
, zfcp_get_busid_by_port(port
));
526 zfcp_erp_port_block(port
, clear_mask
);
528 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED
, &port
->status
)) {
529 ZFCP_LOG_DEBUG("skipped forced reopen of failed port 0x%016Lx "
530 "on adapter %s\n", port
->wwpn
,
531 zfcp_get_busid_by_port(port
));
532 debug_text_event(adapter
->erp_dbf
, 5, "pf_ro_f");
533 debug_event(adapter
->erp_dbf
, 5, &port
->wwpn
, sizeof (wwn_t
));
538 retval
= zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_PORT_FORCED
,
539 port
->adapter
, port
, NULL
);
548 * purpose: Wrappper for zfcp_erp_port_forced_reopen_internal
549 * used to ensure the correct locking
551 * returns: 0 - initiated action succesfully
552 * <0 - failed to initiate action
555 zfcp_erp_port_forced_reopen(struct zfcp_port
*port
, int clear_mask
)
559 struct zfcp_adapter
*adapter
;
561 adapter
= port
->adapter
;
562 read_lock_irqsave(&zfcp_data
.config_lock
, flags
);
563 write_lock(&adapter
->erp_lock
);
564 retval
= zfcp_erp_port_forced_reopen_internal(port
, clear_mask
);
565 write_unlock(&adapter
->erp_lock
);
566 read_unlock_irqrestore(&zfcp_data
.config_lock
, flags
);
574 * purpose: called if a port is to be opened
575 * initiates Reopen recovery which is done
578 * returns: 0 - initiated action succesfully
579 * <0 - failed to initiate action
582 zfcp_erp_port_reopen_internal(struct zfcp_port
*port
, int clear_mask
)
585 struct zfcp_adapter
*adapter
= port
->adapter
;
587 debug_text_event(adapter
->erp_dbf
, 5, "p_ro");
588 debug_event(adapter
->erp_dbf
, 5, &port
->wwpn
, sizeof (wwn_t
));
590 ZFCP_LOG_DEBUG("reopen of port 0x%016Lx on adapter %s\n",
591 port
->wwpn
, zfcp_get_busid_by_port(port
));
593 zfcp_erp_port_block(port
, clear_mask
);
595 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED
, &port
->status
)) {
596 ZFCP_LOG_DEBUG("skipped reopen of failed port 0x%016Lx "
597 "on adapter %s\n", port
->wwpn
,
598 zfcp_get_busid_by_port(port
));
599 debug_text_event(adapter
->erp_dbf
, 5, "p_ro_f");
600 debug_event(adapter
->erp_dbf
, 5, &port
->wwpn
, sizeof (wwn_t
));
601 /* ensure propagation of failed status to new devices */
602 zfcp_erp_port_failed(port
);
607 retval
= zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_PORT
,
608 port
->adapter
, port
, NULL
);
615 * zfcp_erp_port_reopen - initiate reopen of a remote port
616 * @port: port to be reopened
617 * @clear_mask: specifies flags in port status to be cleared
618 * Return: 0 on success, < 0 on error
620 * This is a wrappper function for zfcp_erp_port_reopen_internal. It ensures
621 * correct locking. An error recovery task is initiated to do the reopen.
622 * To wait for the completion of the reopen zfcp_erp_wait should be used.
625 zfcp_erp_port_reopen(struct zfcp_port
*port
, int clear_mask
)
629 struct zfcp_adapter
*adapter
= port
->adapter
;
631 read_lock_irqsave(&zfcp_data
.config_lock
, flags
);
632 write_lock(&adapter
->erp_lock
);
633 retval
= zfcp_erp_port_reopen_internal(port
, clear_mask
);
634 write_unlock(&adapter
->erp_lock
);
635 read_unlock_irqrestore(&zfcp_data
.config_lock
, flags
);
643 * purpose: called if a unit is to be opened
644 * initiates Reopen recovery which is done
647 * returns: 0 - initiated action succesfully
648 * <0 - failed to initiate action
651 zfcp_erp_unit_reopen_internal(struct zfcp_unit
*unit
, int clear_mask
)
654 struct zfcp_adapter
*adapter
= unit
->port
->adapter
;
656 debug_text_event(adapter
->erp_dbf
, 5, "u_ro");
657 debug_event(adapter
->erp_dbf
, 5, &unit
->fcp_lun
, sizeof (fcp_lun_t
));
658 ZFCP_LOG_DEBUG("reopen of unit 0x%016Lx on port 0x%016Lx "
659 "on adapter %s\n", unit
->fcp_lun
,
660 unit
->port
->wwpn
, zfcp_get_busid_by_unit(unit
));
662 zfcp_erp_unit_block(unit
, clear_mask
);
664 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED
, &unit
->status
)) {
665 ZFCP_LOG_DEBUG("skipped reopen of failed unit 0x%016Lx "
666 "on port 0x%016Lx on adapter %s\n",
667 unit
->fcp_lun
, unit
->port
->wwpn
,
668 zfcp_get_busid_by_unit(unit
));
669 debug_text_event(adapter
->erp_dbf
, 5, "u_ro_f");
670 debug_event(adapter
->erp_dbf
, 5, &unit
->fcp_lun
,
676 retval
= zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_UNIT
,
677 unit
->port
->adapter
, unit
->port
, unit
);
683 * zfcp_erp_unit_reopen - initiate reopen of a unit
684 * @unit: unit to be reopened
685 * @clear_mask: specifies flags in unit status to be cleared
686 * Return: 0 on success, < 0 on error
688 * This is a wrappper for zfcp_erp_unit_reopen_internal. It ensures correct
689 * locking. An error recovery task is initiated to do the reopen.
690 * To wait for the completion of the reopen zfcp_erp_wait should be used.
693 zfcp_erp_unit_reopen(struct zfcp_unit
*unit
, int clear_mask
)
697 struct zfcp_adapter
*adapter
;
698 struct zfcp_port
*port
;
701 adapter
= port
->adapter
;
703 read_lock_irqsave(&zfcp_data
.config_lock
, flags
);
704 write_lock(&adapter
->erp_lock
);
705 retval
= zfcp_erp_unit_reopen_internal(unit
, clear_mask
);
706 write_unlock(&adapter
->erp_lock
);
707 read_unlock_irqrestore(&zfcp_data
.config_lock
, flags
);
715 * purpose: disable I/O,
716 * return any open requests and clean them up,
717 * aim: no pending and incoming I/O
722 zfcp_erp_adapter_block(struct zfcp_adapter
*adapter
, int clear_mask
)
724 debug_text_event(adapter
->erp_dbf
, 6, "a_bl");
725 zfcp_erp_modify_adapter_status(adapter
,
726 ZFCP_STATUS_COMMON_UNBLOCKED
|
727 clear_mask
, ZFCP_CLEAR
);
733 * purpose: enable I/O
738 zfcp_erp_adapter_unblock(struct zfcp_adapter
*adapter
)
740 debug_text_event(adapter
->erp_dbf
, 6, "a_ubl");
741 atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED
, &adapter
->status
);
747 * purpose: disable I/O,
748 * return any open requests and clean them up,
749 * aim: no pending and incoming I/O
754 zfcp_erp_port_block(struct zfcp_port
*port
, int clear_mask
)
756 struct zfcp_adapter
*adapter
= port
->adapter
;
758 debug_text_event(adapter
->erp_dbf
, 6, "p_bl");
759 debug_event(adapter
->erp_dbf
, 6, &port
->wwpn
, sizeof (wwn_t
));
760 zfcp_erp_modify_port_status(port
,
761 ZFCP_STATUS_COMMON_UNBLOCKED
| clear_mask
,
768 * purpose: enable I/O
773 zfcp_erp_port_unblock(struct zfcp_port
*port
)
775 struct zfcp_adapter
*adapter
= port
->adapter
;
777 debug_text_event(adapter
->erp_dbf
, 6, "p_ubl");
778 debug_event(adapter
->erp_dbf
, 6, &port
->wwpn
, sizeof (wwn_t
));
779 atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED
, &port
->status
);
785 * purpose: disable I/O,
786 * return any open requests and clean them up,
787 * aim: no pending and incoming I/O
792 zfcp_erp_unit_block(struct zfcp_unit
*unit
, int clear_mask
)
794 struct zfcp_adapter
*adapter
= unit
->port
->adapter
;
796 debug_text_event(adapter
->erp_dbf
, 6, "u_bl");
797 debug_event(adapter
->erp_dbf
, 6, &unit
->fcp_lun
, sizeof (fcp_lun_t
));
798 zfcp_erp_modify_unit_status(unit
,
799 ZFCP_STATUS_COMMON_UNBLOCKED
| clear_mask
,
806 * purpose: enable I/O
811 zfcp_erp_unit_unblock(struct zfcp_unit
*unit
)
813 struct zfcp_adapter
*adapter
= unit
->port
->adapter
;
815 debug_text_event(adapter
->erp_dbf
, 6, "u_ubl");
816 debug_event(adapter
->erp_dbf
, 6, &unit
->fcp_lun
, sizeof (fcp_lun_t
));
817 atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED
, &unit
->status
);
828 zfcp_erp_action_ready(struct zfcp_erp_action
*erp_action
)
830 struct zfcp_adapter
*adapter
= erp_action
->adapter
;
832 debug_text_event(adapter
->erp_dbf
, 4, "a_ar");
833 debug_event(adapter
->erp_dbf
, 4, &erp_action
->action
, sizeof (int));
835 zfcp_erp_action_to_ready(erp_action
);
836 up(&adapter
->erp_ready_sem
);
844 * returns: <0 erp_action not found in any list
845 * ZFCP_ERP_ACTION_READY erp_action is in ready list
846 * ZFCP_ERP_ACTION_RUNNING erp_action is in running list
848 * locks: erp_lock must be held
851 zfcp_erp_action_exists(struct zfcp_erp_action
*erp_action
)
853 int retval
= -EINVAL
;
854 struct list_head
*entry
;
855 struct zfcp_erp_action
*entry_erp_action
;
856 struct zfcp_adapter
*adapter
= erp_action
->adapter
;
858 /* search in running list */
859 list_for_each(entry
, &adapter
->erp_running_head
) {
861 list_entry(entry
, struct zfcp_erp_action
, list
);
862 if (entry_erp_action
== erp_action
) {
863 retval
= ZFCP_ERP_ACTION_RUNNING
;
867 /* search in ready list */
868 list_for_each(entry
, &adapter
->erp_ready_head
) {
870 list_entry(entry
, struct zfcp_erp_action
, list
);
871 if (entry_erp_action
== erp_action
) {
872 retval
= ZFCP_ERP_ACTION_READY
;
882 * purpose: checks current status of action (timed out, dismissed, ...)
883 * and does appropriate preparations (dismiss fsf request, ...)
885 * locks: called under erp_lock (disabled interrupts)
890 zfcp_erp_strategy_check_fsfreq(struct zfcp_erp_action
*erp_action
)
893 struct zfcp_fsf_req
*fsf_req
;
894 struct zfcp_adapter
*adapter
= erp_action
->adapter
;
896 if (erp_action
->fsf_req
) {
897 /* take lock to ensure that request is not being deleted meanwhile */
898 write_lock(&adapter
->fsf_req_list_lock
);
899 /* check whether fsf req does still exist */
900 list_for_each_entry(fsf_req
, &adapter
->fsf_req_list_head
, list
)
901 if (fsf_req
== erp_action
->fsf_req
)
903 if (fsf_req
== erp_action
->fsf_req
) {
904 /* fsf_req still exists */
905 debug_text_event(adapter
->erp_dbf
, 3, "a_ca_req");
906 debug_event(adapter
->erp_dbf
, 3, &fsf_req
,
907 sizeof (unsigned long));
908 /* dismiss fsf_req of timed out or dismissed erp_action */
909 if (erp_action
->status
& (ZFCP_STATUS_ERP_DISMISSED
|
910 ZFCP_STATUS_ERP_TIMEDOUT
)) {
911 debug_text_event(adapter
->erp_dbf
, 3,
913 fsf_req
->status
|= ZFCP_STATUS_FSFREQ_DISMISSED
;
915 if (erp_action
->status
& ZFCP_STATUS_ERP_TIMEDOUT
) {
916 ZFCP_LOG_NORMAL("error: erp step timed out "
917 "(action=%d, fsf_req=%p)\n ",
919 erp_action
->fsf_req
);
922 * If fsf_req is neither dismissed nor completed
923 * then keep it running asynchronously and don't mess
924 * with the association of erp_action and fsf_req.
926 if (fsf_req
->status
& (ZFCP_STATUS_FSFREQ_COMPLETED
|
927 ZFCP_STATUS_FSFREQ_DISMISSED
)) {
928 /* forget about association between fsf_req
930 fsf_req
->erp_action
= NULL
;
931 erp_action
->fsf_req
= NULL
;
934 debug_text_event(adapter
->erp_dbf
, 3, "a_ca_gonereq");
936 * even if this fsf_req has gone, forget about
937 * association between erp_action and fsf_req
939 erp_action
->fsf_req
= NULL
;
941 write_unlock(&adapter
->fsf_req_list_lock
);
943 debug_text_event(adapter
->erp_dbf
, 3, "a_ca_noreq");
949 * purpose: generic handler for asynchronous events related to erp_action events
950 * (normal completion, time-out, dismissing, retry after
951 * low memory condition)
953 * note: deletion of timer is not required (e.g. in case of a time-out),
954 * but a second try does no harm,
955 * we leave it in here to allow for greater simplification
957 * returns: 0 - there was an action to handle
961 zfcp_erp_async_handler_nolock(struct zfcp_erp_action
*erp_action
,
962 unsigned long set_mask
)
965 struct zfcp_adapter
*adapter
= erp_action
->adapter
;
967 if (zfcp_erp_action_exists(erp_action
) == ZFCP_ERP_ACTION_RUNNING
) {
968 debug_text_event(adapter
->erp_dbf
, 2, "a_asyh_ex");
969 debug_event(adapter
->erp_dbf
, 2, &erp_action
->action
,
971 if (!(set_mask
& ZFCP_STATUS_ERP_TIMEDOUT
))
972 del_timer(&erp_action
->timer
);
973 erp_action
->status
|= set_mask
;
974 zfcp_erp_action_ready(erp_action
);
977 /* action is ready or gone - nothing to do */
978 debug_text_event(adapter
->erp_dbf
, 3, "a_asyh_gone");
979 debug_event(adapter
->erp_dbf
, 3, &erp_action
->action
,
988 * purpose: generic handler for asynchronous events related to erp_action
989 * events (normal completion, time-out, dismissing, retry after
990 * low memory condition)
992 * note: deletion of timer is not required (e.g. in case of a time-out),
993 * but a second try does no harm,
994 * we leave it in here to allow for greater simplification
996 * returns: 0 - there was an action to handle
1000 zfcp_erp_async_handler(struct zfcp_erp_action
*erp_action
,
1001 unsigned long set_mask
)
1003 struct zfcp_adapter
*adapter
= erp_action
->adapter
;
1004 unsigned long flags
;
1007 write_lock_irqsave(&adapter
->erp_lock
, flags
);
1008 retval
= zfcp_erp_async_handler_nolock(erp_action
, set_mask
);
1009 write_unlock_irqrestore(&adapter
->erp_lock
, flags
);
1015 * purpose: is called for erp_action which was slept waiting for
1016 * memory becoming avaliable,
1017 * will trigger that this action will be continued
1020 zfcp_erp_memwait_handler(unsigned long data
)
1022 struct zfcp_erp_action
*erp_action
= (struct zfcp_erp_action
*) data
;
1023 struct zfcp_adapter
*adapter
= erp_action
->adapter
;
1025 debug_text_event(adapter
->erp_dbf
, 2, "a_mwh");
1026 debug_event(adapter
->erp_dbf
, 2, &erp_action
->action
, sizeof (int));
1028 zfcp_erp_async_handler(erp_action
, 0);
1032 * purpose: is called if an asynchronous erp step timed out,
1033 * action gets an appropriate flag and will be processed
1037 zfcp_erp_timeout_handler(unsigned long data
)
1039 struct zfcp_erp_action
*erp_action
= (struct zfcp_erp_action
*) data
;
1040 struct zfcp_adapter
*adapter
= erp_action
->adapter
;
1042 debug_text_event(adapter
->erp_dbf
, 2, "a_th");
1043 debug_event(adapter
->erp_dbf
, 2, &erp_action
->action
, sizeof (int));
1045 zfcp_erp_async_handler(erp_action
, ZFCP_STATUS_ERP_TIMEDOUT
);
1049 * purpose: is called for an erp_action which needs to be ended
1050 * though not being done,
1051 * this is usually required if an higher is generated,
1052 * action gets an appropriate flag and will be processed
1055 * locks: erp_lock held (thus we need to call another handler variant)
1058 zfcp_erp_action_dismiss(struct zfcp_erp_action
*erp_action
)
1060 struct zfcp_adapter
*adapter
= erp_action
->adapter
;
1062 debug_text_event(adapter
->erp_dbf
, 2, "a_adis");
1063 debug_event(adapter
->erp_dbf
, 2, &erp_action
->action
, sizeof (int));
1065 zfcp_erp_async_handler_nolock(erp_action
, ZFCP_STATUS_ERP_DISMISSED
);
1071 zfcp_erp_thread_setup(struct zfcp_adapter
*adapter
)
1075 atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP
, &adapter
->status
);
1077 rwlock_init(&adapter
->erp_lock
);
1078 INIT_LIST_HEAD(&adapter
->erp_ready_head
);
1079 INIT_LIST_HEAD(&adapter
->erp_running_head
);
1080 sema_init(&adapter
->erp_ready_sem
, 0);
1082 retval
= kernel_thread(zfcp_erp_thread
, adapter
, SIGCHLD
);
1084 ZFCP_LOG_NORMAL("error: creation of erp thread failed for "
1086 zfcp_get_busid_by_adapter(adapter
));
1087 debug_text_event(adapter
->erp_dbf
, 5, "a_thset_fail");
1089 wait_event(adapter
->erp_thread_wqh
,
1090 atomic_test_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP
,
1092 debug_text_event(adapter
->erp_dbf
, 5, "a_thset_ok");
1095 return (retval
< 0);
1105 * context: process (i.e. proc-fs or rmmod/insmod)
1107 * note: The caller of this routine ensures that the specified
1108 * adapter has been shut down and that this operation
1109 * has been completed. Thus, there are no pending erp_actions
1110 * which would need to be handled here.
1113 zfcp_erp_thread_kill(struct zfcp_adapter
*adapter
)
1117 atomic_set_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL
, &adapter
->status
);
1118 up(&adapter
->erp_ready_sem
);
1120 wait_event(adapter
->erp_thread_wqh
,
1121 !atomic_test_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP
,
1124 atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL
,
1127 debug_text_event(adapter
->erp_dbf
, 5, "a_thki_ok");
1133 * purpose: is run as a kernel thread,
1134 * goes through list of error recovery actions of associated adapter
1135 * and delegates single action to execution
1140 zfcp_erp_thread(void *data
)
1142 struct zfcp_adapter
*adapter
= (struct zfcp_adapter
*) data
;
1143 struct list_head
*next
;
1144 struct zfcp_erp_action
*erp_action
;
1145 unsigned long flags
;
1147 daemonize("zfcperp%s", zfcp_get_busid_by_adapter(adapter
));
1148 /* Block all signals */
1149 siginitsetinv(¤t
->blocked
, 0);
1150 atomic_set_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP
, &adapter
->status
);
1151 debug_text_event(adapter
->erp_dbf
, 5, "a_th_run");
1152 wake_up(&adapter
->erp_thread_wqh
);
1154 while (!atomic_test_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL
,
1155 &adapter
->status
)) {
1157 write_lock_irqsave(&adapter
->erp_lock
, flags
);
1158 next
= adapter
->erp_ready_head
.prev
;
1159 write_unlock_irqrestore(&adapter
->erp_lock
, flags
);
1161 if (next
!= &adapter
->erp_ready_head
) {
1163 list_entry(next
, struct zfcp_erp_action
, list
);
1165 * process action (incl. [re]moving it
1166 * from 'ready' queue)
1168 zfcp_erp_strategy(erp_action
);
1172 * sleep as long as there is nothing to do, i.e.
1173 * no action in 'ready' queue to be processed and
1174 * thread is not to be killed
1176 down_interruptible(&adapter
->erp_ready_sem
);
1177 debug_text_event(adapter
->erp_dbf
, 5, "a_th_woken");
1180 atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP
, &adapter
->status
);
1181 debug_text_event(adapter
->erp_dbf
, 5, "a_th_stop");
1182 wake_up(&adapter
->erp_thread_wqh
);
1190 * purpose: drives single error recovery action and schedules higher and
1191 * subordinate actions, if necessary
1193 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
1194 * ZFCP_ERP_SUCCEEDED - action finished successfully (deqd)
1195 * ZFCP_ERP_FAILED - action finished unsuccessfully (deqd)
1196 * ZFCP_ERP_EXIT - action finished (dequeued), offline
1197 * ZFCP_ERP_DISMISSED - action canceled (dequeued)
1200 zfcp_erp_strategy(struct zfcp_erp_action
*erp_action
)
1203 struct zfcp_adapter
*adapter
= erp_action
->adapter
;
1204 struct zfcp_port
*port
= erp_action
->port
;
1205 struct zfcp_unit
*unit
= erp_action
->unit
;
1206 int action
= erp_action
->action
;
1207 u32 status
= erp_action
->status
;
1208 unsigned long flags
;
1210 /* serialise dismissing, timing out, moving, enqueueing */
1211 read_lock_irqsave(&zfcp_data
.config_lock
, flags
);
1212 write_lock(&adapter
->erp_lock
);
1214 /* dequeue dismissed action and leave, if required */
1215 retval
= zfcp_erp_strategy_check_action(erp_action
, retval
);
1216 if (retval
== ZFCP_ERP_DISMISSED
) {
1217 debug_text_event(adapter
->erp_dbf
, 4, "a_st_dis1");
1222 * move action to 'running' queue before processing it
1223 * (to avoid a race condition regarding moving the
1224 * action to the 'running' queue and back)
1226 zfcp_erp_action_to_running(erp_action
);
1229 * try to process action as far as possible,
1230 * no lock to allow for blocking operations (kmalloc, qdio, ...),
1231 * afterwards the lock is required again for the following reasons:
1232 * - dequeueing of finished action and enqueueing of
1233 * follow-up actions must be atomic so that any other
1234 * reopen-routine does not believe there is nothing to do
1235 * and that it is safe to enqueue something else,
1236 * - we want to force any control thread which is dismissing
1237 * actions to finish this before we decide about
1238 * necessary steps to be taken here further
1240 write_unlock(&adapter
->erp_lock
);
1241 read_unlock_irqrestore(&zfcp_data
.config_lock
, flags
);
1242 retval
= zfcp_erp_strategy_do_action(erp_action
);
1243 read_lock_irqsave(&zfcp_data
.config_lock
, flags
);
1244 write_lock(&adapter
->erp_lock
);
1247 * check for dismissed status again to avoid follow-up actions,
1248 * failing of targets and so on for dismissed actions
1250 retval
= zfcp_erp_strategy_check_action(erp_action
, retval
);
1253 case ZFCP_ERP_DISMISSED
:
1254 /* leave since this action has ridden to its ancestors */
1255 debug_text_event(adapter
->erp_dbf
, 6, "a_st_dis2");
1257 case ZFCP_ERP_NOMEM
:
1258 /* no memory to continue immediately, let it sleep */
1259 if (!(erp_action
->status
& ZFCP_STATUS_ERP_LOWMEM
)) {
1260 ++adapter
->erp_low_mem_count
;
1261 erp_action
->status
|= ZFCP_STATUS_ERP_LOWMEM
;
1263 /* This condition is true if there is no memory available
1264 for any erp_action on this adapter. This implies that there
1265 are no elements in the memory pool(s) left for erp_actions.
1266 This might happen if an erp_action that used a memory pool
1267 element was timed out.
1269 if (adapter
->erp_total_count
== adapter
->erp_low_mem_count
) {
1270 debug_text_event(adapter
->erp_dbf
, 3, "a_st_lowmem");
1271 ZFCP_LOG_NORMAL("error: no mempool elements available, "
1272 "restarting I/O on adapter %s "
1273 "to free mempool\n",
1274 zfcp_get_busid_by_adapter(adapter
));
1275 zfcp_erp_adapter_reopen_internal(adapter
, 0);
1277 debug_text_event(adapter
->erp_dbf
, 2, "a_st_memw");
1278 retval
= zfcp_erp_strategy_memwait(erp_action
);
1281 case ZFCP_ERP_CONTINUES
:
1282 /* leave since this action runs asynchronously */
1283 debug_text_event(adapter
->erp_dbf
, 6, "a_st_cont");
1284 if (erp_action
->status
& ZFCP_STATUS_ERP_LOWMEM
) {
1285 --adapter
->erp_low_mem_count
;
1286 erp_action
->status
&= ~ZFCP_STATUS_ERP_LOWMEM
;
1290 /* ok, finished action (whatever its result is) */
1292 /* check for unrecoverable targets */
1293 retval
= zfcp_erp_strategy_check_target(erp_action
, retval
);
1295 /* action must be dequeued (here to allow for further ones) */
1296 zfcp_erp_action_dequeue(erp_action
);
1299 * put this target through the erp mill again if someone has
1300 * requested to change the status of a target being online
1301 * to offline or the other way around
1302 * (old retval is preserved if nothing has to be done here)
1304 retval
= zfcp_erp_strategy_statechange(action
, status
, adapter
,
1305 port
, unit
, retval
);
1308 * leave if target is in permanent error state or if
1309 * action is repeated in order to process state change
1311 if (retval
== ZFCP_ERP_EXIT
) {
1312 debug_text_event(adapter
->erp_dbf
, 2, "a_st_exit");
1316 /* trigger follow up actions */
1317 zfcp_erp_strategy_followup_actions(action
, adapter
, port
, unit
, retval
);
1320 write_unlock(&adapter
->erp_lock
);
1321 read_unlock_irqrestore(&zfcp_data
.config_lock
, flags
);
1323 if (retval
!= ZFCP_ERP_CONTINUES
)
1324 zfcp_erp_action_cleanup(action
, adapter
, port
, unit
, retval
);
1327 * a few tasks remain when the erp queues are empty
1328 * (don't do that if the last action evaluated was dismissed
1329 * since this clearly indicates that there is more to come) :
1330 * - close the name server port if it is open yet
1331 * (enqueues another [probably] final action)
1332 * - otherwise, wake up whoever wants to be woken when we are
1335 if (retval
!= ZFCP_ERP_DISMISSED
)
1336 zfcp_erp_strategy_check_queues(adapter
);
1338 debug_text_event(adapter
->erp_dbf
, 6, "a_st_done");
1348 * returns: ZFCP_ERP_DISMISSED - if action has been dismissed
1349 * retval - otherwise
1352 zfcp_erp_strategy_check_action(struct zfcp_erp_action
*erp_action
, int retval
)
1354 struct zfcp_adapter
*adapter
= erp_action
->adapter
;
1356 zfcp_erp_strategy_check_fsfreq(erp_action
);
1358 debug_event(adapter
->erp_dbf
, 5, &erp_action
->action
, sizeof (int));
1359 if (erp_action
->status
& ZFCP_STATUS_ERP_DISMISSED
) {
1360 debug_text_event(adapter
->erp_dbf
, 3, "a_stcd_dis");
1361 zfcp_erp_action_dequeue(erp_action
);
1362 retval
= ZFCP_ERP_DISMISSED
;
1364 debug_text_event(adapter
->erp_dbf
, 5, "a_stcd_nodis");
1377 zfcp_erp_strategy_do_action(struct zfcp_erp_action
*erp_action
)
1379 int retval
= ZFCP_ERP_FAILED
;
1380 struct zfcp_adapter
*adapter
= erp_action
->adapter
;
1383 * try to execute/continue action as far as possible,
1384 * note: no lock in subsequent strategy routines
1385 * (this allows these routine to call schedule, e.g.
1386 * kmalloc with such flags or qdio_initialize & friends)
1387 * Note: in case of timeout, the seperate strategies will fail
1388 * anyhow. No need for a special action. Even worse, a nameserver
1389 * failure would not wake up waiting ports without the call.
1391 switch (erp_action
->action
) {
1393 case ZFCP_ERP_ACTION_REOPEN_ADAPTER
:
1394 retval
= zfcp_erp_adapter_strategy(erp_action
);
1397 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED
:
1398 retval
= zfcp_erp_port_forced_strategy(erp_action
);
1401 case ZFCP_ERP_ACTION_REOPEN_PORT
:
1402 retval
= zfcp_erp_port_strategy(erp_action
);
1405 case ZFCP_ERP_ACTION_REOPEN_UNIT
:
1406 retval
= zfcp_erp_unit_strategy(erp_action
);
1410 debug_text_exception(adapter
->erp_dbf
, 1, "a_stda_bug");
1411 debug_event(adapter
->erp_dbf
, 1, &erp_action
->action
,
1413 ZFCP_LOG_NORMAL("bug: unknown erp action requested on "
1414 "adapter %s (action=%d)\n",
1415 zfcp_get_busid_by_adapter(erp_action
->adapter
),
1416 erp_action
->action
);
1425 * purpose: triggers retry of this action after a certain amount of time
1426 * by means of timer provided by erp_action
1428 * returns: ZFCP_ERP_CONTINUES - erp_action sleeps in erp running queue
1431 zfcp_erp_strategy_memwait(struct zfcp_erp_action
*erp_action
)
1433 int retval
= ZFCP_ERP_CONTINUES
;
1434 struct zfcp_adapter
*adapter
= erp_action
->adapter
;
1436 debug_text_event(adapter
->erp_dbf
, 6, "a_mwinit");
1437 debug_event(adapter
->erp_dbf
, 6, &erp_action
->action
, sizeof (int));
1438 init_timer(&erp_action
->timer
);
1439 erp_action
->timer
.function
= zfcp_erp_memwait_handler
;
1440 erp_action
->timer
.data
= (unsigned long) erp_action
;
1441 erp_action
->timer
.expires
= jiffies
+ ZFCP_ERP_MEMWAIT_TIMEOUT
;
1442 add_timer(&erp_action
->timer
);
1448 * function: zfcp_erp_adapter_failed
1450 * purpose: sets the adapter and all underlying devices to ERP_FAILED
1454 zfcp_erp_adapter_failed(struct zfcp_adapter
*adapter
)
1456 zfcp_erp_modify_adapter_status(adapter
,
1457 ZFCP_STATUS_COMMON_ERP_FAILED
, ZFCP_SET
);
1458 ZFCP_LOG_NORMAL("adapter erp failed on adapter %s\n",
1459 zfcp_get_busid_by_adapter(adapter
));
1460 debug_text_event(adapter
->erp_dbf
, 2, "a_afail");
1464 * function: zfcp_erp_port_failed
1466 * purpose: sets the port and all underlying devices to ERP_FAILED
1470 zfcp_erp_port_failed(struct zfcp_port
*port
)
1472 zfcp_erp_modify_port_status(port
,
1473 ZFCP_STATUS_COMMON_ERP_FAILED
, ZFCP_SET
);
1475 if (atomic_test_mask(ZFCP_STATUS_PORT_WKA
, &port
->status
))
1476 ZFCP_LOG_NORMAL("port erp failed (adapter %s, "
1477 "port d_id=0x%08x)\n",
1478 zfcp_get_busid_by_port(port
), port
->d_id
);
1480 ZFCP_LOG_NORMAL("port erp failed (adapter %s, wwpn=0x%016Lx)\n",
1481 zfcp_get_busid_by_port(port
), port
->wwpn
);
1483 debug_text_event(port
->adapter
->erp_dbf
, 2, "p_pfail");
1484 debug_event(port
->adapter
->erp_dbf
, 2, &port
->wwpn
, sizeof (wwn_t
));
1488 * function: zfcp_erp_unit_failed
1490 * purpose: sets the unit to ERP_FAILED
1494 zfcp_erp_unit_failed(struct zfcp_unit
*unit
)
1496 zfcp_erp_modify_unit_status(unit
,
1497 ZFCP_STATUS_COMMON_ERP_FAILED
, ZFCP_SET
);
1499 ZFCP_LOG_NORMAL("unit erp failed on unit 0x%016Lx on port 0x%016Lx "
1500 " on adapter %s\n", unit
->fcp_lun
,
1501 unit
->port
->wwpn
, zfcp_get_busid_by_unit(unit
));
1502 debug_text_event(unit
->port
->adapter
->erp_dbf
, 2, "u_ufail");
1503 debug_event(unit
->port
->adapter
->erp_dbf
, 2,
1504 &unit
->fcp_lun
, sizeof (fcp_lun_t
));
1508 * function: zfcp_erp_strategy_check_target
1510 * purpose: increments the erp action count on the device currently in
1511 * recovery if the action failed or resets the count in case of
1512 * success. If a maximum count is exceeded the device is marked
1514 * The 'blocked' state of a target which has been recovered
1515 * successfully is reset.
1517 * returns: ZFCP_ERP_CONTINUES - action continues (not considered)
1518 * ZFCP_ERP_SUCCEEDED - action finished successfully
1519 * ZFCP_ERP_EXIT - action failed and will not continue
1522 zfcp_erp_strategy_check_target(struct zfcp_erp_action
*erp_action
, int result
)
1524 struct zfcp_adapter
*adapter
= erp_action
->adapter
;
1525 struct zfcp_port
*port
= erp_action
->port
;
1526 struct zfcp_unit
*unit
= erp_action
->unit
;
1528 debug_text_event(adapter
->erp_dbf
, 5, "a_stct_norm");
1529 debug_event(adapter
->erp_dbf
, 5, &erp_action
->action
, sizeof (int));
1530 debug_event(adapter
->erp_dbf
, 5, &result
, sizeof (int));
1532 switch (erp_action
->action
) {
1534 case ZFCP_ERP_ACTION_REOPEN_UNIT
:
1535 result
= zfcp_erp_strategy_check_unit(unit
, result
);
1538 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED
:
1539 case ZFCP_ERP_ACTION_REOPEN_PORT
:
1540 result
= zfcp_erp_strategy_check_port(port
, result
);
1543 case ZFCP_ERP_ACTION_REOPEN_ADAPTER
:
1544 result
= zfcp_erp_strategy_check_adapter(adapter
, result
);
1559 zfcp_erp_strategy_statechange(int action
,
1561 struct zfcp_adapter
*adapter
,
1562 struct zfcp_port
*port
,
1563 struct zfcp_unit
*unit
, int retval
)
1565 debug_text_event(adapter
->erp_dbf
, 3, "a_stsc");
1566 debug_event(adapter
->erp_dbf
, 3, &action
, sizeof (int));
1570 case ZFCP_ERP_ACTION_REOPEN_ADAPTER
:
1571 if (zfcp_erp_strategy_statechange_detected(&adapter
->status
,
1573 zfcp_erp_adapter_reopen_internal(adapter
, ZFCP_STATUS_COMMON_ERP_FAILED
);
1574 retval
= ZFCP_ERP_EXIT
;
1578 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED
:
1579 case ZFCP_ERP_ACTION_REOPEN_PORT
:
1580 if (zfcp_erp_strategy_statechange_detected(&port
->status
,
1582 zfcp_erp_port_reopen_internal(port
, ZFCP_STATUS_COMMON_ERP_FAILED
);
1583 retval
= ZFCP_ERP_EXIT
;
1587 case ZFCP_ERP_ACTION_REOPEN_UNIT
:
1588 if (zfcp_erp_strategy_statechange_detected(&unit
->status
,
1590 zfcp_erp_unit_reopen_internal(unit
, ZFCP_STATUS_COMMON_ERP_FAILED
);
1591 retval
= ZFCP_ERP_EXIT
;
1607 zfcp_erp_strategy_statechange_detected(atomic_t
* target_status
, u32 erp_status
)
1610 /* take it online */
1611 (atomic_test_mask(ZFCP_STATUS_COMMON_RUNNING
, target_status
) &&
1612 (ZFCP_STATUS_ERP_CLOSE_ONLY
& erp_status
)) ||
1613 /* take it offline */
1614 (!atomic_test_mask(ZFCP_STATUS_COMMON_RUNNING
, target_status
) &&
1615 !(ZFCP_STATUS_ERP_CLOSE_ONLY
& erp_status
));
1626 zfcp_erp_strategy_check_unit(struct zfcp_unit
*unit
, int result
)
1628 debug_text_event(unit
->port
->adapter
->erp_dbf
, 5, "u_stct");
1629 debug_event(unit
->port
->adapter
->erp_dbf
, 5, &unit
->fcp_lun
,
1630 sizeof (fcp_lun_t
));
1633 case ZFCP_ERP_SUCCEEDED
:
1634 atomic_set(&unit
->erp_counter
, 0);
1635 zfcp_erp_unit_unblock(unit
);
1637 case ZFCP_ERP_FAILED
:
1638 atomic_inc(&unit
->erp_counter
);
1639 if (atomic_read(&unit
->erp_counter
) > ZFCP_MAX_ERPS
)
1640 zfcp_erp_unit_failed(unit
);
1642 case ZFCP_ERP_EXIT
:
1647 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED
, &unit
->status
)) {
1648 zfcp_erp_unit_block(unit
, 0); /* for ZFCP_ERP_SUCCEEDED */
1649 result
= ZFCP_ERP_EXIT
;
1663 zfcp_erp_strategy_check_port(struct zfcp_port
*port
, int result
)
1665 debug_text_event(port
->adapter
->erp_dbf
, 5, "p_stct");
1666 debug_event(port
->adapter
->erp_dbf
, 5, &port
->wwpn
, sizeof (wwn_t
));
1669 case ZFCP_ERP_SUCCEEDED
:
1670 atomic_set(&port
->erp_counter
, 0);
1671 zfcp_erp_port_unblock(port
);
1673 case ZFCP_ERP_FAILED
:
1674 atomic_inc(&port
->erp_counter
);
1675 if (atomic_read(&port
->erp_counter
) > ZFCP_MAX_ERPS
)
1676 zfcp_erp_port_failed(port
);
1678 case ZFCP_ERP_EXIT
:
1683 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED
, &port
->status
)) {
1684 zfcp_erp_port_block(port
, 0); /* for ZFCP_ERP_SUCCEEDED */
1685 result
= ZFCP_ERP_EXIT
;
1699 zfcp_erp_strategy_check_adapter(struct zfcp_adapter
*adapter
, int result
)
1701 debug_text_event(adapter
->erp_dbf
, 5, "a_stct");
1704 case ZFCP_ERP_SUCCEEDED
:
1705 atomic_set(&adapter
->erp_counter
, 0);
1706 zfcp_erp_adapter_unblock(adapter
);
1708 case ZFCP_ERP_FAILED
:
1709 atomic_inc(&adapter
->erp_counter
);
1710 if (atomic_read(&adapter
->erp_counter
) > ZFCP_MAX_ERPS
)
1711 zfcp_erp_adapter_failed(adapter
);
1713 case ZFCP_ERP_EXIT
:
1718 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED
, &adapter
->status
)) {
1719 zfcp_erp_adapter_block(adapter
, 0); /* for ZFCP_ERP_SUCCEEDED */
1720 result
= ZFCP_ERP_EXIT
;
1729 * purpose: remaining things in good cases,
1730 * escalation in bad cases
1735 zfcp_erp_strategy_followup_actions(int action
,
1736 struct zfcp_adapter
*adapter
,
1737 struct zfcp_port
*port
,
1738 struct zfcp_unit
*unit
, int status
)
1740 debug_text_event(adapter
->erp_dbf
, 5, "a_stfol");
1741 debug_event(adapter
->erp_dbf
, 5, &action
, sizeof (int));
1743 /* initiate follow-up actions depending on success of finished action */
1746 case ZFCP_ERP_ACTION_REOPEN_ADAPTER
:
1747 if (status
== ZFCP_ERP_SUCCEEDED
)
1748 zfcp_erp_port_reopen_all_internal(adapter
, 0);
1750 zfcp_erp_adapter_reopen_internal(adapter
, 0);
1753 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED
:
1754 if (status
== ZFCP_ERP_SUCCEEDED
)
1755 zfcp_erp_port_reopen_internal(port
, 0);
1757 zfcp_erp_adapter_reopen_internal(adapter
, 0);
1760 case ZFCP_ERP_ACTION_REOPEN_PORT
:
1761 if (status
== ZFCP_ERP_SUCCEEDED
)
1762 zfcp_erp_unit_reopen_all_internal(port
, 0);
1764 zfcp_erp_port_forced_reopen_internal(port
, 0);
1767 case ZFCP_ERP_ACTION_REOPEN_UNIT
:
1768 if (status
== ZFCP_ERP_SUCCEEDED
) ; /* no further action */
1770 zfcp_erp_port_reopen_internal(unit
->port
, 0);
1785 zfcp_erp_strategy_check_queues(struct zfcp_adapter
*adapter
)
1787 unsigned long flags
;
1789 read_lock_irqsave(&zfcp_data
.config_lock
, flags
);
1790 read_lock(&adapter
->erp_lock
);
1791 if (list_empty(&adapter
->erp_ready_head
) &&
1792 list_empty(&adapter
->erp_running_head
)) {
1793 debug_text_event(adapter
->erp_dbf
, 4, "a_cq_wake");
1794 atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_PENDING
,
1796 wake_up(&adapter
->erp_done_wqh
);
1798 debug_text_event(adapter
->erp_dbf
, 5, "a_cq_notempty");
1799 read_unlock(&adapter
->erp_lock
);
1800 read_unlock_irqrestore(&zfcp_data
.config_lock
, flags
);
1806 * zfcp_erp_wait - wait for completion of error recovery on an adapter
1807 * @adapter: adapter for which to wait for completion of its error recovery
1811 zfcp_erp_wait(struct zfcp_adapter
*adapter
)
1815 wait_event(adapter
->erp_done_wqh
,
1816 !atomic_test_mask(ZFCP_STATUS_ADAPTER_ERP_PENDING
,
1823 * function: zfcp_erp_modify_adapter_status
1829 zfcp_erp_modify_adapter_status(struct zfcp_adapter
*adapter
,
1830 u32 mask
, int set_or_clear
)
1832 struct zfcp_port
*port
;
1833 u32 common_mask
= mask
& ZFCP_COMMON_FLAGS
;
1835 if (set_or_clear
== ZFCP_SET
) {
1836 atomic_set_mask(mask
, &adapter
->status
);
1837 debug_text_event(adapter
->erp_dbf
, 3, "a_mod_as_s");
1839 atomic_clear_mask(mask
, &adapter
->status
);
1840 if (mask
& ZFCP_STATUS_COMMON_ERP_FAILED
)
1841 atomic_set(&adapter
->erp_counter
, 0);
1842 debug_text_event(adapter
->erp_dbf
, 3, "a_mod_as_c");
1844 debug_event(adapter
->erp_dbf
, 3, &mask
, sizeof (u32
));
1846 /* Deal with all underlying devices, only pass common_mask */
1848 list_for_each_entry(port
, &adapter
->port_list_head
, list
)
1849 zfcp_erp_modify_port_status(port
, common_mask
,
1854 * function: zfcp_erp_modify_port_status
1856 * purpose: sets the port and all underlying devices to ERP_FAILED
1860 zfcp_erp_modify_port_status(struct zfcp_port
*port
, u32 mask
, int set_or_clear
)
1862 struct zfcp_unit
*unit
;
1863 u32 common_mask
= mask
& ZFCP_COMMON_FLAGS
;
1865 if (set_or_clear
== ZFCP_SET
) {
1866 atomic_set_mask(mask
, &port
->status
);
1867 debug_text_event(port
->adapter
->erp_dbf
, 3, "p_mod_ps_s");
1869 atomic_clear_mask(mask
, &port
->status
);
1870 if (mask
& ZFCP_STATUS_COMMON_ERP_FAILED
)
1871 atomic_set(&port
->erp_counter
, 0);
1872 debug_text_event(port
->adapter
->erp_dbf
, 3, "p_mod_ps_c");
1874 debug_event(port
->adapter
->erp_dbf
, 3, &port
->wwpn
, sizeof (wwn_t
));
1875 debug_event(port
->adapter
->erp_dbf
, 3, &mask
, sizeof (u32
));
1877 /* Modify status of all underlying devices, only pass common mask */
1879 list_for_each_entry(unit
, &port
->unit_list_head
, list
)
1880 zfcp_erp_modify_unit_status(unit
, common_mask
,
1885 * function: zfcp_erp_modify_unit_status
1887 * purpose: sets the unit to ERP_FAILED
1891 zfcp_erp_modify_unit_status(struct zfcp_unit
*unit
, u32 mask
, int set_or_clear
)
1893 if (set_or_clear
== ZFCP_SET
) {
1894 atomic_set_mask(mask
, &unit
->status
);
1895 debug_text_event(unit
->port
->adapter
->erp_dbf
, 3, "u_mod_us_s");
1897 atomic_clear_mask(mask
, &unit
->status
);
1898 if (mask
& ZFCP_STATUS_COMMON_ERP_FAILED
) {
1899 atomic_set(&unit
->erp_counter
, 0);
1901 debug_text_event(unit
->port
->adapter
->erp_dbf
, 3, "u_mod_us_c");
1903 debug_event(unit
->port
->adapter
->erp_dbf
, 3, &unit
->fcp_lun
,
1904 sizeof (fcp_lun_t
));
1905 debug_event(unit
->port
->adapter
->erp_dbf
, 3, &mask
, sizeof (u32
));
1911 * purpose: Wrappper for zfcp_erp_port_reopen_all_internal
1912 * used to ensure the correct locking
1914 * returns: 0 - initiated action succesfully
1915 * <0 - failed to initiate action
1918 zfcp_erp_port_reopen_all(struct zfcp_adapter
*adapter
, int clear_mask
)
1921 unsigned long flags
;
1923 read_lock_irqsave(&zfcp_data
.config_lock
, flags
);
1924 write_lock(&adapter
->erp_lock
);
1925 retval
= zfcp_erp_port_reopen_all_internal(adapter
, clear_mask
);
1926 write_unlock(&adapter
->erp_lock
);
1927 read_unlock_irqrestore(&zfcp_data
.config_lock
, flags
);
1940 zfcp_erp_port_reopen_all_internal(struct zfcp_adapter
*adapter
, int clear_mask
)
1943 struct zfcp_port
*port
;
1945 list_for_each_entry(port
, &adapter
->port_list_head
, list
)
1946 if (!atomic_test_mask(ZFCP_STATUS_PORT_WKA
, &port
->status
))
1947 zfcp_erp_port_reopen_internal(port
, clear_mask
);
1960 zfcp_erp_unit_reopen_all_internal(struct zfcp_port
*port
, int clear_mask
)
1963 struct zfcp_unit
*unit
;
1965 list_for_each_entry(unit
, &port
->unit_list_head
, list
)
1966 zfcp_erp_unit_reopen_internal(unit
, clear_mask
);
1974 * purpose: this routine executes the 'Reopen Adapter' action
1975 * (the entire action is processed synchronously, since
1976 * there are no actions which might be run concurrently
1979 * returns: ZFCP_ERP_SUCCEEDED - action finished successfully
1980 * ZFCP_ERP_FAILED - action finished unsuccessfully
1983 zfcp_erp_adapter_strategy(struct zfcp_erp_action
*erp_action
)
1986 struct zfcp_adapter
*adapter
= erp_action
->adapter
;
1988 retval
= zfcp_erp_adapter_strategy_close(erp_action
);
1989 if (erp_action
->status
& ZFCP_STATUS_ERP_CLOSE_ONLY
)
1990 retval
= ZFCP_ERP_EXIT
;
1992 retval
= zfcp_erp_adapter_strategy_open(erp_action
);
1994 debug_text_event(adapter
->erp_dbf
, 3, "a_ast/ret");
1995 debug_event(adapter
->erp_dbf
, 3, &erp_action
->action
, sizeof (int));
1996 debug_event(adapter
->erp_dbf
, 3, &retval
, sizeof (int));
1998 if (retval
== ZFCP_ERP_FAILED
) {
1999 ZFCP_LOG_INFO("Waiting to allow the adapter %s "
2000 "to recover itself\n",
2001 zfcp_get_busid_by_adapter(adapter
));
2002 msleep(jiffies_to_msecs(ZFCP_TYPE2_RECOVERY_TIME
));
2013 * returns: ZFCP_ERP_SUCCEEDED - action finished successfully
2014 * ZFCP_ERP_FAILED - action finished unsuccessfully
2017 zfcp_erp_adapter_strategy_close(struct zfcp_erp_action
*erp_action
)
2021 atomic_set_mask(ZFCP_STATUS_COMMON_CLOSING
,
2022 &erp_action
->adapter
->status
);
2023 retval
= zfcp_erp_adapter_strategy_generic(erp_action
, 1);
2024 atomic_clear_mask(ZFCP_STATUS_COMMON_CLOSING
,
2025 &erp_action
->adapter
->status
);
2035 * returns: ZFCP_ERP_SUCCEEDED - action finished successfully
2036 * ZFCP_ERP_FAILED - action finished unsuccessfully
2039 zfcp_erp_adapter_strategy_open(struct zfcp_erp_action
*erp_action
)
2043 atomic_set_mask(ZFCP_STATUS_COMMON_OPENING
,
2044 &erp_action
->adapter
->status
);
2045 retval
= zfcp_erp_adapter_strategy_generic(erp_action
, 0);
2046 atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING
,
2047 &erp_action
->adapter
->status
);
2053 * function: zfcp_register_adapter
2055 * purpose: allocate the irq associated with this devno and register
2056 * the FSF adapter with the SCSI stack
2061 zfcp_erp_adapter_strategy_generic(struct zfcp_erp_action
*erp_action
, int close
)
2063 int retval
= ZFCP_ERP_SUCCEEDED
;
2068 retval
= zfcp_erp_adapter_strategy_open_qdio(erp_action
);
2069 if (retval
!= ZFCP_ERP_SUCCEEDED
)
2072 retval
= zfcp_erp_adapter_strategy_open_fsf(erp_action
);
2073 if (retval
!= ZFCP_ERP_SUCCEEDED
)
2074 goto failed_openfcp
;
2076 atomic_set_mask(ZFCP_STATUS_COMMON_OPEN
, &erp_action
->adapter
->status
);
2080 atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN
,
2081 &erp_action
->adapter
->status
);
2084 zfcp_erp_adapter_strategy_close_qdio(erp_action
);
2085 zfcp_erp_adapter_strategy_close_fsf(erp_action
);
2092 * function: zfcp_qdio_init
2094 * purpose: setup QDIO operation for specified adapter
2096 * returns: 0 - successful setup
2100 zfcp_erp_adapter_strategy_open_qdio(struct zfcp_erp_action
*erp_action
)
2104 volatile struct qdio_buffer_element
*sbale
;
2105 struct zfcp_adapter
*adapter
= erp_action
->adapter
;
2107 if (atomic_test_mask(ZFCP_STATUS_ADAPTER_QDIOUP
, &adapter
->status
)) {
2108 ZFCP_LOG_NORMAL("bug: second attempt to set up QDIO on "
2110 zfcp_get_busid_by_adapter(adapter
));
2114 if (qdio_establish(&adapter
->qdio_init_data
) != 0) {
2115 ZFCP_LOG_INFO("error: establishment of QDIO queues failed "
2117 zfcp_get_busid_by_adapter(adapter
));
2118 goto failed_qdio_establish
;
2120 debug_text_event(adapter
->erp_dbf
, 3, "qdio_est");
2122 if (qdio_activate(adapter
->ccw_device
, 0) != 0) {
2123 ZFCP_LOG_INFO("error: activation of QDIO queues failed "
2125 zfcp_get_busid_by_adapter(adapter
));
2126 goto failed_qdio_activate
;
2128 debug_text_event(adapter
->erp_dbf
, 3, "qdio_act");
2131 * put buffers into response queue,
2133 for (i
= 0; i
< QDIO_MAX_BUFFERS_PER_Q
; i
++) {
2134 sbale
= &(adapter
->response_queue
.buffer
[i
]->element
[0]);
2136 sbale
->flags
= SBAL_FLAGS_LAST_ENTRY
;
2140 ZFCP_LOG_TRACE("calling do_QDIO on adapter %s (flags=0x%x, "
2141 "queue_no=%i, index_in_queue=%i, count=%i)\n",
2142 zfcp_get_busid_by_adapter(adapter
),
2143 QDIO_FLAG_SYNC_INPUT
, 0, 0, QDIO_MAX_BUFFERS_PER_Q
);
2145 retval
= do_QDIO(adapter
->ccw_device
,
2146 QDIO_FLAG_SYNC_INPUT
,
2147 0, 0, QDIO_MAX_BUFFERS_PER_Q
, NULL
);
2150 ZFCP_LOG_NORMAL("bug: setup of QDIO failed (retval=%d)\n",
2152 goto failed_do_qdio
;
2154 adapter
->response_queue
.free_index
= 0;
2155 atomic_set(&adapter
->response_queue
.free_count
, 0);
2156 ZFCP_LOG_DEBUG("%i buffers successfully enqueued to "
2157 "response queue\n", QDIO_MAX_BUFFERS_PER_Q
);
2159 /* set index of first avalable SBALS / number of available SBALS */
2160 adapter
->request_queue
.free_index
= 0;
2161 atomic_set(&adapter
->request_queue
.free_count
, QDIO_MAX_BUFFERS_PER_Q
);
2162 adapter
->request_queue
.distance_from_int
= 0;
2164 /* initialize waitqueue used to wait for free SBALs in requests queue */
2165 init_waitqueue_head(&adapter
->request_wq
);
2167 /* ok, we did it - skip all cleanups for different failures */
2168 atomic_set_mask(ZFCP_STATUS_ADAPTER_QDIOUP
, &adapter
->status
);
2169 retval
= ZFCP_ERP_SUCCEEDED
;
2175 failed_qdio_activate
:
2176 debug_text_event(adapter
->erp_dbf
, 3, "qdio_down1a");
2177 while (qdio_shutdown(adapter
->ccw_device
,
2178 QDIO_FLAG_CLEANUP_USING_CLEAR
) == -EINPROGRESS
)
2180 debug_text_event(adapter
->erp_dbf
, 3, "qdio_down1b");
2182 failed_qdio_establish
:
2184 retval
= ZFCP_ERP_FAILED
;
2191 * function: zfcp_qdio_cleanup
2193 * purpose: cleans up QDIO operation for the specified adapter
2195 * returns: 0 - successful cleanup
2196 * !0 - failed cleanup
2199 zfcp_erp_adapter_strategy_close_qdio(struct zfcp_erp_action
*erp_action
)
2201 int retval
= ZFCP_ERP_SUCCEEDED
;
2204 struct zfcp_adapter
*adapter
= erp_action
->adapter
;
2206 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_QDIOUP
, &adapter
->status
)) {
2207 ZFCP_LOG_DEBUG("error: attempt to shut down inactive QDIO "
2208 "queues on adapter %s\n",
2209 zfcp_get_busid_by_adapter(adapter
));
2210 retval
= ZFCP_ERP_FAILED
;
2215 * Get queue_lock and clear QDIOUP flag. Thus it's guaranteed that
2216 * do_QDIO won't be called while qdio_shutdown is in progress.
2219 write_lock_irq(&adapter
->request_queue
.queue_lock
);
2220 atomic_clear_mask(ZFCP_STATUS_ADAPTER_QDIOUP
, &adapter
->status
);
2221 write_unlock_irq(&adapter
->request_queue
.queue_lock
);
2223 debug_text_event(adapter
->erp_dbf
, 3, "qdio_down2a");
2224 while (qdio_shutdown(adapter
->ccw_device
,
2225 QDIO_FLAG_CLEANUP_USING_CLEAR
) == -EINPROGRESS
)
2227 debug_text_event(adapter
->erp_dbf
, 3, "qdio_down2b");
2230 * First we had to stop QDIO operation.
2231 * Now it is safe to take the following actions.
2234 /* Cleanup only necessary when there are unacknowledged buffers */
2235 if (atomic_read(&adapter
->request_queue
.free_count
)
2236 < QDIO_MAX_BUFFERS_PER_Q
) {
2237 first_used
= (adapter
->request_queue
.free_index
+
2238 atomic_read(&adapter
->request_queue
.free_count
))
2239 % QDIO_MAX_BUFFERS_PER_Q
;
2240 used_count
= QDIO_MAX_BUFFERS_PER_Q
-
2241 atomic_read(&adapter
->request_queue
.free_count
);
2242 zfcp_qdio_zero_sbals(adapter
->request_queue
.buffer
,
2243 first_used
, used_count
);
2245 adapter
->response_queue
.free_index
= 0;
2246 atomic_set(&adapter
->response_queue
.free_count
, 0);
2247 adapter
->request_queue
.free_index
= 0;
2248 atomic_set(&adapter
->request_queue
.free_count
, 0);
2249 adapter
->request_queue
.distance_from_int
= 0;
2255 * function: zfcp_fsf_init
2257 * purpose: initializes FSF operation for the specified adapter
2259 * returns: 0 - succesful initialization of FSF operation
2260 * !0 - failed to initialize FSF operation
2263 zfcp_erp_adapter_strategy_open_fsf(struct zfcp_erp_action
*erp_action
)
2267 /* do 'exchange configuration data' */
2268 retval
= zfcp_erp_adapter_strategy_open_fsf_xconfig(erp_action
);
2269 if (retval
== ZFCP_ERP_FAILED
)
2272 /* start the desired number of Status Reads */
2273 retval
= zfcp_erp_adapter_strategy_open_fsf_statusread(erp_action
);
2285 zfcp_erp_adapter_strategy_open_fsf_xconfig(struct zfcp_erp_action
*erp_action
)
2287 int retval
= ZFCP_ERP_SUCCEEDED
;
2289 struct zfcp_adapter
*adapter
= erp_action
->adapter
;
2291 atomic_clear_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK
, &adapter
->status
);
2292 retries
= ZFCP_EXCHANGE_CONFIG_DATA_RETRIES
;
2295 atomic_clear_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT
,
2297 ZFCP_LOG_DEBUG("Doing exchange config data\n");
2298 zfcp_erp_action_to_running(erp_action
);
2299 zfcp_erp_timeout_init(erp_action
);
2300 if (zfcp_fsf_exchange_config_data(erp_action
)) {
2301 retval
= ZFCP_ERP_FAILED
;
2302 debug_text_event(adapter
->erp_dbf
, 5, "a_fstx_xf");
2303 ZFCP_LOG_INFO("error: initiation of exchange of "
2304 "configuration data failed for "
2306 zfcp_get_busid_by_adapter(adapter
));
2309 debug_text_event(adapter
->erp_dbf
, 6, "a_fstx_xok");
2310 ZFCP_LOG_DEBUG("Xchange underway\n");
2314 * Both the normal completion handler as well as the timeout
2315 * handler will do an 'up' when the 'exchange config data'
2316 * request completes or times out. Thus, the signal to go on
2317 * won't be lost utilizing this semaphore.
2318 * Furthermore, this 'adapter_reopen' action is
2319 * guaranteed to be the only action being there (highest action
2320 * which prevents other actions from being created).
2321 * Resulting from that, the wake signal recognized here
2322 * _must_ be the one belonging to the 'exchange config
2325 down(&adapter
->erp_ready_sem
);
2326 if (erp_action
->status
& ZFCP_STATUS_ERP_TIMEDOUT
) {
2327 ZFCP_LOG_INFO("error: exchange of configuration data "
2328 "for adapter %s timed out\n",
2329 zfcp_get_busid_by_adapter(adapter
));
2332 if (atomic_test_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT
,
2333 &adapter
->status
)) {
2334 ZFCP_LOG_DEBUG("host connection still initialising... "
2335 "waiting and retrying...\n");
2336 /* sleep a little bit before retry */
2337 msleep(jiffies_to_msecs(ZFCP_EXCHANGE_CONFIG_DATA_SLEEP
));
2339 } while ((retries
--) &&
2340 atomic_test_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT
,
2343 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK
,
2344 &adapter
->status
)) {
2345 ZFCP_LOG_INFO("error: exchange of configuration data for "
2346 "adapter %s failed\n",
2347 zfcp_get_busid_by_adapter(adapter
));
2348 retval
= ZFCP_ERP_FAILED
;
2362 zfcp_erp_adapter_strategy_open_fsf_statusread(struct zfcp_erp_action
2365 int retval
= ZFCP_ERP_SUCCEEDED
;
2367 struct zfcp_adapter
*adapter
= erp_action
->adapter
;
2370 adapter
->status_read_failed
= 0;
2371 for (i
= 0; i
< ZFCP_STATUS_READS_RECOM
; i
++) {
2372 temp_ret
= zfcp_fsf_status_read(adapter
, ZFCP_WAIT_FOR_SBAL
);
2374 ZFCP_LOG_INFO("error: set-up of unsolicited status "
2375 "notification failed on adapter %s\n",
2376 zfcp_get_busid_by_adapter(adapter
));
2377 retval
= ZFCP_ERP_FAILED
;
2387 * function: zfcp_fsf_cleanup
2389 * purpose: cleanup FSF operation for specified adapter
2391 * returns: 0 - FSF operation successfully cleaned up
2392 * !0 - failed to cleanup FSF operation for this adapter
2395 zfcp_erp_adapter_strategy_close_fsf(struct zfcp_erp_action
*erp_action
)
2397 int retval
= ZFCP_ERP_SUCCEEDED
;
2398 struct zfcp_adapter
*adapter
= erp_action
->adapter
;
2401 * wake waiting initiators of requests,
2402 * return SCSI commands (with error status),
2403 * clean up all requests (synchronously)
2405 zfcp_fsf_req_dismiss_all(adapter
);
2406 /* reset FSF request sequence number */
2407 adapter
->fsf_req_seq_no
= 0;
2408 /* all ports and units are closed */
2409 zfcp_erp_modify_adapter_status(adapter
,
2410 ZFCP_STATUS_COMMON_OPEN
, ZFCP_CLEAR
);
2418 * purpose: this routine executes the 'Reopen Physical Port' action
2420 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2421 * ZFCP_ERP_SUCCEEDED - action finished successfully
2422 * ZFCP_ERP_FAILED - action finished unsuccessfully
2425 zfcp_erp_port_forced_strategy(struct zfcp_erp_action
*erp_action
)
2427 int retval
= ZFCP_ERP_FAILED
;
2428 struct zfcp_port
*port
= erp_action
->port
;
2429 struct zfcp_adapter
*adapter
= erp_action
->adapter
;
2431 switch (erp_action
->step
) {
2435 * the ULP spec. begs for waiting for oustanding commands
2437 case ZFCP_ERP_STEP_UNINITIALIZED
:
2438 zfcp_erp_port_strategy_clearstati(port
);
2440 * it would be sufficient to test only the normal open flag
2441 * since the phys. open flag cannot be set if the normal
2442 * open flag is unset - however, this is for readabilty ...
2444 if (atomic_test_mask((ZFCP_STATUS_PORT_PHYS_OPEN
|
2445 ZFCP_STATUS_COMMON_OPEN
),
2447 ZFCP_LOG_DEBUG("port 0x%016Lx is open -> trying "
2448 "close physical\n", port
->wwpn
);
2450 zfcp_erp_port_forced_strategy_close(erp_action
);
2452 retval
= ZFCP_ERP_FAILED
;
2455 case ZFCP_ERP_STEP_PHYS_PORT_CLOSING
:
2456 if (atomic_test_mask(ZFCP_STATUS_PORT_PHYS_OPEN
,
2458 ZFCP_LOG_DEBUG("close physical failed for port "
2459 "0x%016Lx\n", port
->wwpn
);
2460 retval
= ZFCP_ERP_FAILED
;
2462 retval
= ZFCP_ERP_SUCCEEDED
;
2466 debug_text_event(adapter
->erp_dbf
, 3, "p_pfst/ret");
2467 debug_event(adapter
->erp_dbf
, 3, &port
->wwpn
, sizeof (wwn_t
));
2468 debug_event(adapter
->erp_dbf
, 3, &erp_action
->action
, sizeof (int));
2469 debug_event(adapter
->erp_dbf
, 3, &retval
, sizeof (int));
2477 * purpose: this routine executes the 'Reopen Port' action
2479 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2480 * ZFCP_ERP_SUCCEEDED - action finished successfully
2481 * ZFCP_ERP_FAILED - action finished unsuccessfully
2484 zfcp_erp_port_strategy(struct zfcp_erp_action
*erp_action
)
2486 int retval
= ZFCP_ERP_FAILED
;
2487 struct zfcp_port
*port
= erp_action
->port
;
2488 struct zfcp_adapter
*adapter
= erp_action
->adapter
;
2490 switch (erp_action
->step
) {
2494 * the ULP spec. begs for waiting for oustanding commands
2496 case ZFCP_ERP_STEP_UNINITIALIZED
:
2497 zfcp_erp_port_strategy_clearstati(port
);
2498 if (atomic_test_mask(ZFCP_STATUS_COMMON_OPEN
, &port
->status
)) {
2499 ZFCP_LOG_DEBUG("port 0x%016Lx is open -> trying "
2500 "close\n", port
->wwpn
);
2501 retval
= zfcp_erp_port_strategy_close(erp_action
);
2503 } /* else it's already closed, open it */
2506 case ZFCP_ERP_STEP_PORT_CLOSING
:
2507 if (atomic_test_mask(ZFCP_STATUS_COMMON_OPEN
, &port
->status
)) {
2508 ZFCP_LOG_DEBUG("close failed for port 0x%016Lx\n",
2510 retval
= ZFCP_ERP_FAILED
;
2512 } /* else it's closed now, open it */
2515 if (erp_action
->status
& ZFCP_STATUS_ERP_CLOSE_ONLY
)
2516 retval
= ZFCP_ERP_EXIT
;
2518 retval
= zfcp_erp_port_strategy_open(erp_action
);
2521 debug_text_event(adapter
->erp_dbf
, 3, "p_pst/ret");
2522 debug_event(adapter
->erp_dbf
, 3, &port
->wwpn
, sizeof (wwn_t
));
2523 debug_event(adapter
->erp_dbf
, 3, &erp_action
->action
, sizeof (int));
2524 debug_event(adapter
->erp_dbf
, 3, &retval
, sizeof (int));
2537 zfcp_erp_port_strategy_open(struct zfcp_erp_action
*erp_action
)
2541 if (atomic_test_mask(ZFCP_STATUS_PORT_WKA
,
2542 &erp_action
->port
->status
))
2543 retval
= zfcp_erp_port_strategy_open_nameserver(erp_action
);
2545 retval
= zfcp_erp_port_strategy_open_common(erp_action
);
2557 * FIXME(design): currently only prepared for fabric (nameserver!)
2560 zfcp_erp_port_strategy_open_common(struct zfcp_erp_action
*erp_action
)
2563 struct zfcp_adapter
*adapter
= erp_action
->adapter
;
2564 struct zfcp_port
*port
= erp_action
->port
;
2566 switch (erp_action
->step
) {
2568 case ZFCP_ERP_STEP_UNINITIALIZED
:
2569 case ZFCP_ERP_STEP_PHYS_PORT_CLOSING
:
2570 case ZFCP_ERP_STEP_PORT_CLOSING
:
2571 if (adapter
->fc_topology
== FSF_TOPO_P2P
) {
2572 if (port
->wwpn
!= adapter
->peer_wwpn
) {
2573 ZFCP_LOG_NORMAL("Failed to open port 0x%016Lx "
2574 "on adapter %s.\nPeer WWPN "
2575 "0x%016Lx does not match\n",
2577 zfcp_get_busid_by_adapter(adapter
),
2578 adapter
->peer_wwpn
);
2579 zfcp_erp_port_failed(port
);
2580 retval
= ZFCP_ERP_FAILED
;
2583 port
->d_id
= adapter
->peer_d_id
;
2584 atomic_set_mask(ZFCP_STATUS_PORT_DID_DID
, &port
->status
);
2585 retval
= zfcp_erp_port_strategy_open_port(erp_action
);
2588 if (!(adapter
->nameserver_port
)) {
2589 retval
= zfcp_nameserver_enqueue(adapter
);
2591 ZFCP_LOG_NORMAL("error: nameserver port "
2592 "unavailable for adapter %s\n",
2593 zfcp_get_busid_by_adapter(adapter
));
2594 retval
= ZFCP_ERP_FAILED
;
2598 if (!atomic_test_mask(ZFCP_STATUS_COMMON_UNBLOCKED
,
2599 &adapter
->nameserver_port
->status
)) {
2600 ZFCP_LOG_DEBUG("nameserver port is not open -> open "
2601 "nameserver port\n");
2602 /* nameserver port may live again */
2603 atomic_set_mask(ZFCP_STATUS_COMMON_RUNNING
,
2604 &adapter
->nameserver_port
->status
);
2605 if (zfcp_erp_port_reopen(adapter
->nameserver_port
, 0)
2608 ZFCP_ERP_STEP_NAMESERVER_OPEN
;
2609 retval
= ZFCP_ERP_CONTINUES
;
2611 retval
= ZFCP_ERP_FAILED
;
2614 /* else nameserver port is already open, fall through */
2615 case ZFCP_ERP_STEP_NAMESERVER_OPEN
:
2616 if (!atomic_test_mask(ZFCP_STATUS_COMMON_OPEN
,
2617 &adapter
->nameserver_port
->status
)) {
2618 ZFCP_LOG_DEBUG("open failed for nameserver port\n");
2619 retval
= ZFCP_ERP_FAILED
;
2621 ZFCP_LOG_DEBUG("nameserver port is open -> "
2622 "nameserver look-up for port 0x%016Lx\n",
2624 retval
= zfcp_erp_port_strategy_open_common_lookup
2629 case ZFCP_ERP_STEP_NAMESERVER_LOOKUP
:
2630 if (!atomic_test_mask(ZFCP_STATUS_PORT_DID_DID
, &port
->status
)) {
2631 if (atomic_test_mask
2632 (ZFCP_STATUS_PORT_INVALID_WWPN
, &port
->status
)) {
2633 ZFCP_LOG_DEBUG("nameserver look-up failed "
2634 "for port 0x%016Lx "
2635 "(misconfigured WWPN?)\n",
2637 zfcp_erp_port_failed(port
);
2638 retval
= ZFCP_ERP_EXIT
;
2640 ZFCP_LOG_DEBUG("nameserver look-up failed for "
2641 "port 0x%016Lx\n", port
->wwpn
);
2642 retval
= ZFCP_ERP_FAILED
;
2645 ZFCP_LOG_DEBUG("port 0x%016Lx has d_id=0x%08x -> "
2646 "trying open\n", port
->wwpn
, port
->d_id
);
2647 retval
= zfcp_erp_port_strategy_open_port(erp_action
);
2651 case ZFCP_ERP_STEP_PORT_OPENING
:
2652 /* D_ID might have changed during open */
2653 if (atomic_test_mask((ZFCP_STATUS_COMMON_OPEN
|
2654 ZFCP_STATUS_PORT_DID_DID
),
2656 ZFCP_LOG_DEBUG("port 0x%016Lx is open\n", port
->wwpn
);
2657 retval
= ZFCP_ERP_SUCCEEDED
;
2659 ZFCP_LOG_DEBUG("open failed for port 0x%016Lx\n",
2661 retval
= ZFCP_ERP_FAILED
;
2666 ZFCP_LOG_NORMAL("bug: unknown erp step 0x%08x\n",
2668 retval
= ZFCP_ERP_FAILED
;
2682 zfcp_erp_port_strategy_open_nameserver(struct zfcp_erp_action
*erp_action
)
2685 struct zfcp_port
*port
= erp_action
->port
;
2687 switch (erp_action
->step
) {
2689 case ZFCP_ERP_STEP_UNINITIALIZED
:
2690 case ZFCP_ERP_STEP_PHYS_PORT_CLOSING
:
2691 case ZFCP_ERP_STEP_PORT_CLOSING
:
2692 ZFCP_LOG_DEBUG("port 0x%016Lx has d_id=0x%08x -> trying open\n",
2693 port
->wwpn
, port
->d_id
);
2694 retval
= zfcp_erp_port_strategy_open_port(erp_action
);
2697 case ZFCP_ERP_STEP_PORT_OPENING
:
2698 if (atomic_test_mask(ZFCP_STATUS_COMMON_OPEN
, &port
->status
)) {
2699 ZFCP_LOG_DEBUG("WKA port is open\n");
2700 retval
= ZFCP_ERP_SUCCEEDED
;
2702 ZFCP_LOG_DEBUG("open failed for WKA port\n");
2703 retval
= ZFCP_ERP_FAILED
;
2705 /* this is needed anyway (dont care for retval of wakeup) */
2706 ZFCP_LOG_DEBUG("continue other open port operations\n");
2707 zfcp_erp_port_strategy_open_nameserver_wakeup(erp_action
);
2711 ZFCP_LOG_NORMAL("bug: unknown erp step 0x%08x\n",
2713 retval
= ZFCP_ERP_FAILED
;
2722 * purpose: makes the erp thread continue with reopen (physical) port
2723 * actions which have been paused until the name server port
2724 * is opened (or failed)
2726 * returns: 0 (a kind of void retval, its not used)
2729 zfcp_erp_port_strategy_open_nameserver_wakeup(struct zfcp_erp_action
2733 unsigned long flags
;
2734 struct zfcp_adapter
*adapter
= ns_erp_action
->adapter
;
2735 struct zfcp_erp_action
*erp_action
, *tmp
;
2737 read_lock_irqsave(&adapter
->erp_lock
, flags
);
2738 list_for_each_entry_safe(erp_action
, tmp
, &adapter
->erp_running_head
,
2740 debug_text_event(adapter
->erp_dbf
, 4, "p_pstnsw_n");
2741 debug_event(adapter
->erp_dbf
, 4, &erp_action
->port
->wwpn
,
2743 if (erp_action
->step
== ZFCP_ERP_STEP_NAMESERVER_OPEN
) {
2744 debug_text_event(adapter
->erp_dbf
, 3, "p_pstnsw_w");
2745 debug_event(adapter
->erp_dbf
, 3,
2746 &erp_action
->port
->wwpn
, sizeof (wwn_t
));
2747 if (atomic_test_mask(
2748 ZFCP_STATUS_COMMON_ERP_FAILED
,
2749 &adapter
->nameserver_port
->status
))
2750 zfcp_erp_port_failed(erp_action
->port
);
2751 zfcp_erp_action_ready(erp_action
);
2754 read_unlock_irqrestore(&adapter
->erp_lock
, flags
);
2764 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2765 * ZFCP_ERP_FAILED - action finished unsuccessfully
2768 zfcp_erp_port_forced_strategy_close(struct zfcp_erp_action
*erp_action
)
2771 struct zfcp_adapter
*adapter
= erp_action
->adapter
;
2772 struct zfcp_port
*port
= erp_action
->port
;
2774 zfcp_erp_timeout_init(erp_action
);
2775 retval
= zfcp_fsf_close_physical_port(erp_action
);
2776 if (retval
== -ENOMEM
) {
2777 debug_text_event(adapter
->erp_dbf
, 5, "o_pfstc_nomem");
2778 debug_event(adapter
->erp_dbf
, 5, &port
->wwpn
, sizeof (wwn_t
));
2779 retval
= ZFCP_ERP_NOMEM
;
2782 erp_action
->step
= ZFCP_ERP_STEP_PHYS_PORT_CLOSING
;
2784 debug_text_event(adapter
->erp_dbf
, 5, "o_pfstc_cpf");
2785 debug_event(adapter
->erp_dbf
, 5, &port
->wwpn
, sizeof (wwn_t
));
2786 /* could not send 'open', fail */
2787 retval
= ZFCP_ERP_FAILED
;
2790 debug_text_event(adapter
->erp_dbf
, 6, "o_pfstc_cpok");
2791 debug_event(adapter
->erp_dbf
, 6, &port
->wwpn
, sizeof (wwn_t
));
2792 retval
= ZFCP_ERP_CONTINUES
;
2805 zfcp_erp_port_strategy_clearstati(struct zfcp_port
*port
)
2808 struct zfcp_adapter
*adapter
= port
->adapter
;
2810 debug_text_event(adapter
->erp_dbf
, 5, "p_pstclst");
2811 debug_event(adapter
->erp_dbf
, 5, &port
->wwpn
, sizeof (wwn_t
));
2813 atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING
|
2814 ZFCP_STATUS_COMMON_CLOSING
|
2815 ZFCP_STATUS_COMMON_ACCESS_DENIED
|
2816 ZFCP_STATUS_PORT_DID_DID
|
2817 ZFCP_STATUS_PORT_PHYS_CLOSING
|
2818 ZFCP_STATUS_PORT_INVALID_WWPN
,
2828 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2829 * ZFCP_ERP_FAILED - action finished unsuccessfully
2832 zfcp_erp_port_strategy_close(struct zfcp_erp_action
*erp_action
)
2835 struct zfcp_adapter
*adapter
= erp_action
->adapter
;
2836 struct zfcp_port
*port
= erp_action
->port
;
2838 zfcp_erp_timeout_init(erp_action
);
2839 retval
= zfcp_fsf_close_port(erp_action
);
2840 if (retval
== -ENOMEM
) {
2841 debug_text_event(adapter
->erp_dbf
, 5, "p_pstc_nomem");
2842 debug_event(adapter
->erp_dbf
, 5, &port
->wwpn
, sizeof (wwn_t
));
2843 retval
= ZFCP_ERP_NOMEM
;
2846 erp_action
->step
= ZFCP_ERP_STEP_PORT_CLOSING
;
2848 debug_text_event(adapter
->erp_dbf
, 5, "p_pstc_cpf");
2849 debug_event(adapter
->erp_dbf
, 5, &port
->wwpn
, sizeof (wwn_t
));
2850 /* could not send 'close', fail */
2851 retval
= ZFCP_ERP_FAILED
;
2854 debug_text_event(adapter
->erp_dbf
, 6, "p_pstc_cpok");
2855 debug_event(adapter
->erp_dbf
, 6, &port
->wwpn
, sizeof (wwn_t
));
2856 retval
= ZFCP_ERP_CONTINUES
;
2866 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2867 * ZFCP_ERP_FAILED - action finished unsuccessfully
2870 zfcp_erp_port_strategy_open_port(struct zfcp_erp_action
*erp_action
)
2873 struct zfcp_adapter
*adapter
= erp_action
->adapter
;
2874 struct zfcp_port
*port
= erp_action
->port
;
2876 zfcp_erp_timeout_init(erp_action
);
2877 retval
= zfcp_fsf_open_port(erp_action
);
2878 if (retval
== -ENOMEM
) {
2879 debug_text_event(adapter
->erp_dbf
, 5, "p_psto_nomem");
2880 debug_event(adapter
->erp_dbf
, 5, &port
->wwpn
, sizeof (wwn_t
));
2881 retval
= ZFCP_ERP_NOMEM
;
2884 erp_action
->step
= ZFCP_ERP_STEP_PORT_OPENING
;
2886 debug_text_event(adapter
->erp_dbf
, 5, "p_psto_opf");
2887 debug_event(adapter
->erp_dbf
, 5, &port
->wwpn
, sizeof (wwn_t
));
2888 /* could not send 'open', fail */
2889 retval
= ZFCP_ERP_FAILED
;
2892 debug_text_event(adapter
->erp_dbf
, 6, "p_psto_opok");
2893 debug_event(adapter
->erp_dbf
, 6, &port
->wwpn
, sizeof (wwn_t
));
2894 retval
= ZFCP_ERP_CONTINUES
;
2904 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2905 * ZFCP_ERP_FAILED - action finished unsuccessfully
2908 zfcp_erp_port_strategy_open_common_lookup(struct zfcp_erp_action
*erp_action
)
2911 struct zfcp_adapter
*adapter
= erp_action
->adapter
;
2912 struct zfcp_port
*port
= erp_action
->port
;
2914 zfcp_erp_timeout_init(erp_action
);
2915 retval
= zfcp_ns_gid_pn_request(erp_action
);
2916 if (retval
== -ENOMEM
) {
2917 debug_text_event(adapter
->erp_dbf
, 5, "p_pstn_nomem");
2918 debug_event(adapter
->erp_dbf
, 5, &port
->wwpn
, sizeof (wwn_t
));
2919 retval
= ZFCP_ERP_NOMEM
;
2922 erp_action
->step
= ZFCP_ERP_STEP_NAMESERVER_LOOKUP
;
2924 debug_text_event(adapter
->erp_dbf
, 5, "p_pstn_ref");
2925 debug_event(adapter
->erp_dbf
, 5, &port
->wwpn
, sizeof (wwn_t
));
2926 /* could not send nameserver request, fail */
2927 retval
= ZFCP_ERP_FAILED
;
2930 debug_text_event(adapter
->erp_dbf
, 6, "p_pstn_reok");
2931 debug_event(adapter
->erp_dbf
, 6, &port
->wwpn
, sizeof (wwn_t
));
2932 retval
= ZFCP_ERP_CONTINUES
;
2940 * purpose: this routine executes the 'Reopen Unit' action
2941 * currently no retries
2943 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
2944 * ZFCP_ERP_SUCCEEDED - action finished successfully
2945 * ZFCP_ERP_FAILED - action finished unsuccessfully
2948 zfcp_erp_unit_strategy(struct zfcp_erp_action
*erp_action
)
2950 int retval
= ZFCP_ERP_FAILED
;
2951 struct zfcp_unit
*unit
= erp_action
->unit
;
2952 struct zfcp_adapter
*adapter
= erp_action
->adapter
;
2954 switch (erp_action
->step
) {
2958 * the ULP spec. begs for waiting for oustanding commands
2960 case ZFCP_ERP_STEP_UNINITIALIZED
:
2961 zfcp_erp_unit_strategy_clearstati(unit
);
2962 if (atomic_test_mask(ZFCP_STATUS_COMMON_OPEN
, &unit
->status
)) {
2963 ZFCP_LOG_DEBUG("unit 0x%016Lx is open -> "
2964 "trying close\n", unit
->fcp_lun
);
2965 retval
= zfcp_erp_unit_strategy_close(erp_action
);
2968 /* else it's already closed, fall through */
2969 case ZFCP_ERP_STEP_UNIT_CLOSING
:
2970 if (atomic_test_mask(ZFCP_STATUS_COMMON_OPEN
, &unit
->status
)) {
2971 ZFCP_LOG_DEBUG("close failed for unit 0x%016Lx\n",
2973 retval
= ZFCP_ERP_FAILED
;
2975 if (erp_action
->status
& ZFCP_STATUS_ERP_CLOSE_ONLY
)
2976 retval
= ZFCP_ERP_EXIT
;
2978 ZFCP_LOG_DEBUG("unit 0x%016Lx is not open -> "
2979 "trying open\n", unit
->fcp_lun
);
2981 zfcp_erp_unit_strategy_open(erp_action
);
2986 case ZFCP_ERP_STEP_UNIT_OPENING
:
2987 if (atomic_test_mask(ZFCP_STATUS_COMMON_OPEN
, &unit
->status
)) {
2988 ZFCP_LOG_DEBUG("unit 0x%016Lx is open\n",
2990 retval
= ZFCP_ERP_SUCCEEDED
;
2992 ZFCP_LOG_DEBUG("open failed for unit 0x%016Lx\n",
2994 retval
= ZFCP_ERP_FAILED
;
2999 debug_text_event(adapter
->erp_dbf
, 3, "u_ust/ret");
3000 debug_event(adapter
->erp_dbf
, 3, &unit
->fcp_lun
, sizeof (fcp_lun_t
));
3001 debug_event(adapter
->erp_dbf
, 3, &erp_action
->action
, sizeof (int));
3002 debug_event(adapter
->erp_dbf
, 3, &retval
, sizeof (int));
3014 zfcp_erp_unit_strategy_clearstati(struct zfcp_unit
*unit
)
3017 struct zfcp_adapter
*adapter
= unit
->port
->adapter
;
3019 debug_text_event(adapter
->erp_dbf
, 5, "u_ustclst");
3020 debug_event(adapter
->erp_dbf
, 5, &unit
->fcp_lun
, sizeof (fcp_lun_t
));
3022 atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING
|
3023 ZFCP_STATUS_COMMON_CLOSING
|
3024 ZFCP_STATUS_COMMON_ACCESS_DENIED
|
3025 ZFCP_STATUS_UNIT_SHARED
|
3026 ZFCP_STATUS_UNIT_READONLY
,
3037 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
3038 * ZFCP_ERP_FAILED - action finished unsuccessfully
3041 zfcp_erp_unit_strategy_close(struct zfcp_erp_action
*erp_action
)
3044 struct zfcp_adapter
*adapter
= erp_action
->adapter
;
3045 struct zfcp_unit
*unit
= erp_action
->unit
;
3047 zfcp_erp_timeout_init(erp_action
);
3048 retval
= zfcp_fsf_close_unit(erp_action
);
3049 if (retval
== -ENOMEM
) {
3050 debug_text_event(adapter
->erp_dbf
, 5, "u_ustc_nomem");
3051 debug_event(adapter
->erp_dbf
, 5, &unit
->fcp_lun
,
3052 sizeof (fcp_lun_t
));
3053 retval
= ZFCP_ERP_NOMEM
;
3056 erp_action
->step
= ZFCP_ERP_STEP_UNIT_CLOSING
;
3058 debug_text_event(adapter
->erp_dbf
, 5, "u_ustc_cuf");
3059 debug_event(adapter
->erp_dbf
, 5, &unit
->fcp_lun
,
3060 sizeof (fcp_lun_t
));
3061 /* could not send 'close', fail */
3062 retval
= ZFCP_ERP_FAILED
;
3065 debug_text_event(adapter
->erp_dbf
, 6, "u_ustc_cuok");
3066 debug_event(adapter
->erp_dbf
, 6, &unit
->fcp_lun
, sizeof (fcp_lun_t
));
3067 retval
= ZFCP_ERP_CONTINUES
;
3078 * returns: ZFCP_ERP_CONTINUES - action continues (asynchronously)
3079 * ZFCP_ERP_FAILED - action finished unsuccessfully
3082 zfcp_erp_unit_strategy_open(struct zfcp_erp_action
*erp_action
)
3085 struct zfcp_adapter
*adapter
= erp_action
->adapter
;
3086 struct zfcp_unit
*unit
= erp_action
->unit
;
3088 zfcp_erp_timeout_init(erp_action
);
3089 retval
= zfcp_fsf_open_unit(erp_action
);
3090 if (retval
== -ENOMEM
) {
3091 debug_text_event(adapter
->erp_dbf
, 5, "u_usto_nomem");
3092 debug_event(adapter
->erp_dbf
, 5, &unit
->fcp_lun
,
3093 sizeof (fcp_lun_t
));
3094 retval
= ZFCP_ERP_NOMEM
;
3097 erp_action
->step
= ZFCP_ERP_STEP_UNIT_OPENING
;
3099 debug_text_event(adapter
->erp_dbf
, 5, "u_usto_ouf");
3100 debug_event(adapter
->erp_dbf
, 5, &unit
->fcp_lun
,
3101 sizeof (fcp_lun_t
));
3102 /* could not send 'open', fail */
3103 retval
= ZFCP_ERP_FAILED
;
3106 debug_text_event(adapter
->erp_dbf
, 6, "u_usto_ouok");
3107 debug_event(adapter
->erp_dbf
, 6, &unit
->fcp_lun
, sizeof (fcp_lun_t
));
3108 retval
= ZFCP_ERP_CONTINUES
;
3121 zfcp_erp_timeout_init(struct zfcp_erp_action
*erp_action
)
3123 init_timer(&erp_action
->timer
);
3124 erp_action
->timer
.function
= zfcp_erp_timeout_handler
;
3125 erp_action
->timer
.data
= (unsigned long) erp_action
;
3126 /* jiffies will be added in zfcp_fsf_req_send */
3127 erp_action
->timer
.expires
= ZFCP_ERP_FSFREQ_TIMEOUT
;
3133 * purpose: enqueue the specified error recovery action, if needed
3138 zfcp_erp_action_enqueue(int action
,
3139 struct zfcp_adapter
*adapter
,
3140 struct zfcp_port
*port
, struct zfcp_unit
*unit
)
3143 struct zfcp_erp_action
*erp_action
= NULL
;
3144 int stronger_action
= 0;
3148 * We need some rules here which check whether we really need
3149 * this action or whether we should just drop it.
3150 * E.g. if there is a unfinished 'Reopen Port' request then we drop a
3151 * 'Reopen Unit' request for an associated unit since we can't
3152 * satisfy this request now. A 'Reopen Port' action will trigger
3153 * 'Reopen Unit' actions when it completes.
3154 * Thus, there are only actions in the queue which can immediately be
3155 * executed. This makes the processing of the action queue more
3159 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP
,
3163 debug_event(adapter
->erp_dbf
, 4, &action
, sizeof (int));
3164 /* check whether we really need this */
3166 case ZFCP_ERP_ACTION_REOPEN_UNIT
:
3167 if (atomic_test_mask
3168 (ZFCP_STATUS_COMMON_ERP_INUSE
, &unit
->status
)) {
3169 debug_text_event(adapter
->erp_dbf
, 4, "u_actenq_drp");
3170 debug_event(adapter
->erp_dbf
, 4, &port
->wwpn
,
3172 debug_event(adapter
->erp_dbf
, 4, &unit
->fcp_lun
,
3173 sizeof (fcp_lun_t
));
3176 if (!atomic_test_mask
3177 (ZFCP_STATUS_COMMON_RUNNING
, &port
->status
) ||
3179 (ZFCP_STATUS_COMMON_ERP_FAILED
, &port
->status
)) {
3182 if (!atomic_test_mask
3183 (ZFCP_STATUS_COMMON_UNBLOCKED
, &port
->status
)) {
3184 stronger_action
= ZFCP_ERP_ACTION_REOPEN_PORT
;
3187 /* fall through !!! */
3189 case ZFCP_ERP_ACTION_REOPEN_PORT
:
3190 if (atomic_test_mask
3191 (ZFCP_STATUS_COMMON_ERP_INUSE
, &port
->status
)) {
3192 debug_text_event(adapter
->erp_dbf
, 4, "p_actenq_drp");
3193 debug_event(adapter
->erp_dbf
, 4, &port
->wwpn
,
3197 /* fall through !!! */
3199 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED
:
3200 if (atomic_test_mask
3201 (ZFCP_STATUS_COMMON_ERP_INUSE
, &port
->status
)
3202 && port
->erp_action
.action
==
3203 ZFCP_ERP_ACTION_REOPEN_PORT_FORCED
) {
3204 debug_text_event(adapter
->erp_dbf
, 4, "pf_actenq_drp");
3205 debug_event(adapter
->erp_dbf
, 4, &port
->wwpn
,
3209 if (!atomic_test_mask
3210 (ZFCP_STATUS_COMMON_RUNNING
, &adapter
->status
) ||
3212 (ZFCP_STATUS_COMMON_ERP_FAILED
, &adapter
->status
)) {
3215 if (!atomic_test_mask
3216 (ZFCP_STATUS_COMMON_UNBLOCKED
, &adapter
->status
)) {
3217 stronger_action
= ZFCP_ERP_ACTION_REOPEN_ADAPTER
;
3220 /* fall through !!! */
3222 case ZFCP_ERP_ACTION_REOPEN_ADAPTER
:
3223 if (atomic_test_mask
3224 (ZFCP_STATUS_COMMON_ERP_INUSE
, &adapter
->status
)) {
3225 debug_text_event(adapter
->erp_dbf
, 4, "a_actenq_drp");
3231 debug_text_exception(adapter
->erp_dbf
, 1, "a_actenq_bug");
3232 debug_event(adapter
->erp_dbf
, 1, &action
, sizeof (int));
3233 ZFCP_LOG_NORMAL("bug: unknown erp action requested "
3234 "on adapter %s (action=%d)\n",
3235 zfcp_get_busid_by_adapter(adapter
), action
);
3239 /* check whether we need something stronger first */
3240 if (stronger_action
) {
3241 debug_text_event(adapter
->erp_dbf
, 4, "a_actenq_str");
3242 debug_event(adapter
->erp_dbf
, 4, &stronger_action
,
3244 ZFCP_LOG_DEBUG("stronger erp action %d needed before "
3245 "erp action %d on adapter %s\n",
3246 stronger_action
, action
,
3247 zfcp_get_busid_by_adapter(adapter
));
3248 action
= stronger_action
;
3251 /* mark adapter to have some error recovery pending */
3252 atomic_set_mask(ZFCP_STATUS_ADAPTER_ERP_PENDING
, &adapter
->status
);
3254 /* setup error recovery action */
3257 case ZFCP_ERP_ACTION_REOPEN_UNIT
:
3258 zfcp_unit_get(unit
);
3259 atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE
, &unit
->status
);
3260 erp_action
= &unit
->erp_action
;
3261 if (!atomic_test_mask
3262 (ZFCP_STATUS_COMMON_RUNNING
, &unit
->status
))
3263 status
= ZFCP_STATUS_ERP_CLOSE_ONLY
;
3266 case ZFCP_ERP_ACTION_REOPEN_PORT
:
3267 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED
:
3268 zfcp_port_get(port
);
3269 zfcp_erp_action_dismiss_port(port
);
3270 atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE
, &port
->status
);
3271 erp_action
= &port
->erp_action
;
3272 if (!atomic_test_mask
3273 (ZFCP_STATUS_COMMON_RUNNING
, &port
->status
))
3274 status
= ZFCP_STATUS_ERP_CLOSE_ONLY
;
3277 case ZFCP_ERP_ACTION_REOPEN_ADAPTER
:
3278 zfcp_adapter_get(adapter
);
3279 zfcp_erp_action_dismiss_adapter(adapter
);
3280 atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE
, &adapter
->status
);
3281 erp_action
= &adapter
->erp_action
;
3282 if (!atomic_test_mask
3283 (ZFCP_STATUS_COMMON_RUNNING
, &adapter
->status
))
3284 status
= ZFCP_STATUS_ERP_CLOSE_ONLY
;
3288 debug_text_event(adapter
->erp_dbf
, 4, "a_actenq");
3290 memset(erp_action
, 0, sizeof (struct zfcp_erp_action
));
3291 erp_action
->adapter
= adapter
;
3292 erp_action
->port
= port
;
3293 erp_action
->unit
= unit
;
3294 erp_action
->action
= action
;
3295 erp_action
->status
= status
;
3297 ++adapter
->erp_total_count
;
3299 /* finally put it into 'ready' queue and kick erp thread */
3300 list_add(&erp_action
->list
, &adapter
->erp_ready_head
);
3301 up(&adapter
->erp_ready_sem
);
3315 zfcp_erp_action_dequeue(struct zfcp_erp_action
*erp_action
)
3318 struct zfcp_adapter
*adapter
= erp_action
->adapter
;
3320 --adapter
->erp_total_count
;
3321 if (erp_action
->status
& ZFCP_STATUS_ERP_LOWMEM
) {
3322 --adapter
->erp_low_mem_count
;
3323 erp_action
->status
&= ~ZFCP_STATUS_ERP_LOWMEM
;
3326 debug_text_event(adapter
->erp_dbf
, 4, "a_actdeq");
3327 debug_event(adapter
->erp_dbf
, 4, &erp_action
->action
, sizeof (int));
3328 list_del(&erp_action
->list
);
3329 switch (erp_action
->action
) {
3330 case ZFCP_ERP_ACTION_REOPEN_UNIT
:
3331 atomic_clear_mask(ZFCP_STATUS_COMMON_ERP_INUSE
,
3332 &erp_action
->unit
->status
);
3334 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED
:
3335 case ZFCP_ERP_ACTION_REOPEN_PORT
:
3336 atomic_clear_mask(ZFCP_STATUS_COMMON_ERP_INUSE
,
3337 &erp_action
->port
->status
);
3339 case ZFCP_ERP_ACTION_REOPEN_ADAPTER
:
3340 atomic_clear_mask(ZFCP_STATUS_COMMON_ERP_INUSE
,
3341 &erp_action
->adapter
->status
);
3351 * zfcp_erp_action_cleanup
3353 * Register unit with scsi stack if appropiate and fix reference counts.
3354 * Note: Temporary units are not registered with scsi stack.
3357 zfcp_erp_action_cleanup(int action
, struct zfcp_adapter
*adapter
,
3358 struct zfcp_port
*port
, struct zfcp_unit
*unit
,
3362 case ZFCP_ERP_ACTION_REOPEN_UNIT
:
3363 if ((result
== ZFCP_ERP_SUCCEEDED
)
3364 && (!atomic_test_mask(ZFCP_STATUS_UNIT_TEMPORARY
,
3367 scsi_add_device(unit
->port
->adapter
->scsi_host
, 0,
3368 unit
->port
->scsi_id
, unit
->scsi_lun
);
3369 zfcp_unit_put(unit
);
3371 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED
:
3372 case ZFCP_ERP_ACTION_REOPEN_PORT
:
3373 zfcp_port_put(port
);
3375 case ZFCP_ERP_ACTION_REOPEN_ADAPTER
:
3376 zfcp_adapter_put(adapter
);
3392 zfcp_erp_action_dismiss_adapter(struct zfcp_adapter
*adapter
)
3395 struct zfcp_port
*port
;
3397 debug_text_event(adapter
->erp_dbf
, 5, "a_actab");
3398 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_INUSE
, &adapter
->status
))
3399 zfcp_erp_action_dismiss(&adapter
->erp_action
);
3401 list_for_each_entry(port
, &adapter
->port_list_head
, list
)
3402 zfcp_erp_action_dismiss_port(port
);
3415 zfcp_erp_action_dismiss_port(struct zfcp_port
*port
)
3418 struct zfcp_unit
*unit
;
3419 struct zfcp_adapter
*adapter
= port
->adapter
;
3421 debug_text_event(adapter
->erp_dbf
, 5, "p_actab");
3422 debug_event(adapter
->erp_dbf
, 5, &port
->wwpn
, sizeof (wwn_t
));
3423 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_INUSE
, &port
->status
))
3424 zfcp_erp_action_dismiss(&port
->erp_action
);
3426 list_for_each_entry(unit
, &port
->unit_list_head
, list
)
3427 zfcp_erp_action_dismiss_unit(unit
);
3440 zfcp_erp_action_dismiss_unit(struct zfcp_unit
*unit
)
3443 struct zfcp_adapter
*adapter
= unit
->port
->adapter
;
3445 debug_text_event(adapter
->erp_dbf
, 5, "u_actab");
3446 debug_event(adapter
->erp_dbf
, 5, &unit
->fcp_lun
, sizeof (fcp_lun_t
));
3447 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_INUSE
, &unit
->status
))
3448 zfcp_erp_action_dismiss(&unit
->erp_action
);
3456 * purpose: moves erp_action to 'erp running list'
3461 zfcp_erp_action_to_running(struct zfcp_erp_action
*erp_action
)
3463 struct zfcp_adapter
*adapter
= erp_action
->adapter
;
3465 debug_text_event(adapter
->erp_dbf
, 6, "a_toru");
3466 debug_event(adapter
->erp_dbf
, 6, &erp_action
->action
, sizeof (int));
3467 list_move(&erp_action
->list
, &erp_action
->adapter
->erp_running_head
);
3473 * purpose: moves erp_action to 'erp ready list'
3478 zfcp_erp_action_to_ready(struct zfcp_erp_action
*erp_action
)
3480 struct zfcp_adapter
*adapter
= erp_action
->adapter
;
3482 debug_text_event(adapter
->erp_dbf
, 6, "a_tore");
3483 debug_event(adapter
->erp_dbf
, 6, &erp_action
->action
, sizeof (int));
3484 list_move(&erp_action
->list
, &erp_action
->adapter
->erp_ready_head
);
3488 * function: zfcp_erp_port_access_denied
3493 zfcp_erp_port_access_denied(struct zfcp_port
*port
)
3495 struct zfcp_adapter
*adapter
= port
->adapter
;
3496 unsigned long flags
;
3498 debug_text_event(adapter
->erp_dbf
, 3, "p_access_block");
3499 debug_event(adapter
->erp_dbf
, 3, &port
->wwpn
, sizeof(wwn_t
));
3500 read_lock_irqsave(&zfcp_data
.config_lock
, flags
);
3501 zfcp_erp_modify_port_status(port
, ZFCP_STATUS_COMMON_ERP_FAILED
|
3502 ZFCP_STATUS_COMMON_ACCESS_DENIED
, ZFCP_SET
);
3503 read_unlock_irqrestore(&zfcp_data
.config_lock
, flags
);
3507 * function: zfcp_erp_unit_access_denied
3512 zfcp_erp_unit_access_denied(struct zfcp_unit
*unit
)
3514 struct zfcp_adapter
*adapter
= unit
->port
->adapter
;
3516 debug_text_event(adapter
->erp_dbf
, 3, "u_access_block");
3517 debug_event(adapter
->erp_dbf
, 3, &unit
->fcp_lun
, sizeof(fcp_lun_t
));
3518 zfcp_erp_modify_unit_status(unit
, ZFCP_STATUS_COMMON_ERP_FAILED
|
3519 ZFCP_STATUS_COMMON_ACCESS_DENIED
, ZFCP_SET
);
3523 * function: zfcp_erp_adapter_access_changed
3528 zfcp_erp_adapter_access_changed(struct zfcp_adapter
*adapter
)
3530 struct zfcp_port
*port
;
3531 unsigned long flags
;
3533 debug_text_event(adapter
->erp_dbf
, 3, "a_access_unblock");
3534 debug_event(adapter
->erp_dbf
, 3, &adapter
->name
, 8);
3536 read_lock_irqsave(&zfcp_data
.config_lock
, flags
);
3537 if (adapter
->nameserver_port
)
3538 zfcp_erp_port_access_changed(adapter
->nameserver_port
);
3539 list_for_each_entry(port
, &adapter
->port_list_head
, list
)
3540 if (port
!= adapter
->nameserver_port
)
3541 zfcp_erp_port_access_changed(port
);
3542 read_unlock_irqrestore(&zfcp_data
.config_lock
, flags
);
3546 * function: zfcp_erp_port_access_changed
3551 zfcp_erp_port_access_changed(struct zfcp_port
*port
)
3553 struct zfcp_adapter
*adapter
= port
->adapter
;
3554 struct zfcp_unit
*unit
;
3556 debug_text_event(adapter
->erp_dbf
, 3, "p_access_unblock");
3557 debug_event(adapter
->erp_dbf
, 3, &port
->wwpn
, sizeof(wwn_t
));
3559 if (!atomic_test_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED
,
3561 if (!atomic_test_mask(ZFCP_STATUS_PORT_WKA
, &port
->status
))
3562 list_for_each_entry(unit
, &port
->unit_list_head
, list
)
3563 zfcp_erp_unit_access_changed(unit
);
3567 ZFCP_LOG_NORMAL("reopen of port 0x%016Lx on adapter %s "
3568 "(due to ACT update)\n",
3569 port
->wwpn
, zfcp_get_busid_by_adapter(adapter
));
3570 if (zfcp_erp_port_reopen(port
, ZFCP_STATUS_COMMON_ERP_FAILED
) != 0)
3571 ZFCP_LOG_NORMAL("failed reopen of port"
3572 "(adapter %s, wwpn=0x%016Lx)\n",
3573 zfcp_get_busid_by_adapter(adapter
), port
->wwpn
);
3577 * function: zfcp_erp_unit_access_changed
3582 zfcp_erp_unit_access_changed(struct zfcp_unit
*unit
)
3584 struct zfcp_adapter
*adapter
= unit
->port
->adapter
;
3586 debug_text_event(adapter
->erp_dbf
, 3, "u_access_unblock");
3587 debug_event(adapter
->erp_dbf
, 3, &unit
->fcp_lun
, sizeof(fcp_lun_t
));
3589 if (!atomic_test_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED
, &unit
->status
))
3592 ZFCP_LOG_NORMAL("reopen of unit 0x%016Lx on port 0x%016Lx "
3593 " on adapter %s (due to ACT update)\n",
3594 unit
->fcp_lun
, unit
->port
->wwpn
,
3595 zfcp_get_busid_by_adapter(adapter
));
3596 if (zfcp_erp_unit_reopen(unit
, ZFCP_STATUS_COMMON_ERP_FAILED
) != 0)
3597 ZFCP_LOG_NORMAL("failed reopen of unit (adapter %s, "
3598 "wwpn=0x%016Lx, fcp_lun=0x%016Lx)\n",
3599 zfcp_get_busid_by_adapter(adapter
),
3600 unit
->port
->wwpn
, unit
->fcp_lun
);
3603 #undef ZFCP_LOG_AREA