aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/scsi/zfcp_erp.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-04-18 14:25:31 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-18 14:25:31 -0400
commit2cca775baecbfede2fec20c99add709232311fe7 (patch)
treeb0eefe80881d263ba7976174144ae4e9cf238425 /drivers/s390/scsi/zfcp_erp.c
parenteddeb0e2d863e3941d8768e70cb50c6120e61fa0 (diff)
parent94795b61e84994a3b058f92d041d1fb3d869c7d5 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6: (137 commits) [SCSI] iscsi: bidi support for iscsi_tcp [SCSI] iscsi: bidi support at the generic libiscsi level [SCSI] iscsi: extended cdb support [SCSI] zfcp: Fix error handling for blocked unit for send FCP command [SCSI] zfcp: Remove zfcp_erp_wait from slave destory handler to fix deadlock [SCSI] zfcp: fix 31 bit compile warnings [SCSI] bsg: no need to set BSG_F_BLOCK bit in bsg_complete_all_commands [SCSI] bsg: remove minor in struct bsg_device [SCSI] bsg: use better helper list functions [SCSI] bsg: replace kobject_get with blk_get_queue [SCSI] bsg: takes a ref to struct device in fops->open [SCSI] qla1280: remove version check [SCSI] libsas: fix endianness bug in sas_ata [SCSI] zfcp: fix compiler warning caused by poking inside new semaphore (linux-next) [SCSI] aacraid: Do not describe check_reset parameter with its value [SCSI] aacraid: Fix down_interruptible() to check the return value [SCSI] sun3_scsi_vme: add MODULE_LICENSE [SCSI] st: rename flush_write_buffer() [SCSI] tgt: use KMEM_CACHE macro [SCSI] initio: fix big endian problems for auto request sense ...
Diffstat (limited to 'drivers/s390/scsi/zfcp_erp.c')
-rw-r--r--drivers/s390/scsi/zfcp_erp.c688
1 files changed, 222 insertions, 466 deletions
diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c
index 2dc8110ebf74..805484658dd9 100644
--- a/drivers/s390/scsi/zfcp_erp.c
+++ b/drivers/s390/scsi/zfcp_erp.c
@@ -26,13 +26,17 @@
26static int zfcp_erp_adisc(struct zfcp_port *); 26static int zfcp_erp_adisc(struct zfcp_port *);
27static void zfcp_erp_adisc_handler(unsigned long); 27static void zfcp_erp_adisc_handler(unsigned long);
28 28
29static int zfcp_erp_adapter_reopen_internal(struct zfcp_adapter *, int); 29static int zfcp_erp_adapter_reopen_internal(struct zfcp_adapter *, int, u8,
30static int zfcp_erp_port_forced_reopen_internal(struct zfcp_port *, int); 30 void *);
31static int zfcp_erp_port_reopen_internal(struct zfcp_port *, int); 31static int zfcp_erp_port_forced_reopen_internal(struct zfcp_port *, int, u8,
32static int zfcp_erp_unit_reopen_internal(struct zfcp_unit *, int); 32 void *);
33 33static int zfcp_erp_port_reopen_internal(struct zfcp_port *, int, u8, void *);
34static int zfcp_erp_port_reopen_all_internal(struct zfcp_adapter *, int); 34static int zfcp_erp_unit_reopen_internal(struct zfcp_unit *, int, u8, void *);
35static int zfcp_erp_unit_reopen_all_internal(struct zfcp_port *, int); 35
36static int zfcp_erp_port_reopen_all_internal(struct zfcp_adapter *, int, u8,
37 void *);
38static int zfcp_erp_unit_reopen_all_internal(struct zfcp_port *, int, u8,
39 void *);
36 40
37static void zfcp_erp_adapter_block(struct zfcp_adapter *, int); 41static void zfcp_erp_adapter_block(struct zfcp_adapter *, int);
38static void zfcp_erp_adapter_unblock(struct zfcp_adapter *); 42static void zfcp_erp_adapter_unblock(struct zfcp_adapter *);
@@ -97,7 +101,8 @@ static void zfcp_erp_action_dismiss_unit(struct zfcp_unit *);
97static void zfcp_erp_action_dismiss(struct zfcp_erp_action *); 101static void zfcp_erp_action_dismiss(struct zfcp_erp_action *);
98 102
99static int zfcp_erp_action_enqueue(int, struct zfcp_adapter *, 103static int zfcp_erp_action_enqueue(int, struct zfcp_adapter *,
100 struct zfcp_port *, struct zfcp_unit *); 104 struct zfcp_port *, struct zfcp_unit *,
105 u8 id, void *ref);
101static int zfcp_erp_action_dequeue(struct zfcp_erp_action *); 106static int zfcp_erp_action_dequeue(struct zfcp_erp_action *);
102static void zfcp_erp_action_cleanup(int, struct zfcp_adapter *, 107static void zfcp_erp_action_cleanup(int, struct zfcp_adapter *,
103 struct zfcp_port *, struct zfcp_unit *, 108 struct zfcp_port *, struct zfcp_unit *,
@@ -128,11 +133,9 @@ static void zfcp_close_qdio(struct zfcp_adapter *adapter)
128 atomic_clear_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &adapter->status); 133 atomic_clear_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &adapter->status);
129 write_unlock_irq(&req_queue->queue_lock); 134 write_unlock_irq(&req_queue->queue_lock);
130 135
131 debug_text_event(adapter->erp_dbf, 3, "qdio_down2a");
132 while (qdio_shutdown(adapter->ccw_device, 136 while (qdio_shutdown(adapter->ccw_device,
133 QDIO_FLAG_CLEANUP_USING_CLEAR) == -EINPROGRESS) 137 QDIO_FLAG_CLEANUP_USING_CLEAR) == -EINPROGRESS)
134 ssleep(1); 138 ssleep(1);
135 debug_text_event(adapter->erp_dbf, 3, "qdio_down2b");
136 139
137 /* cleanup used outbound sbals */ 140 /* cleanup used outbound sbals */
138 count = atomic_read(&req_queue->free_count); 141 count = atomic_read(&req_queue->free_count);
@@ -163,7 +166,7 @@ static void zfcp_close_fsf(struct zfcp_adapter *adapter)
163 /* reset FSF request sequence number */ 166 /* reset FSF request sequence number */
164 adapter->fsf_req_seq_no = 0; 167 adapter->fsf_req_seq_no = 0;
165 /* all ports and units are closed */ 168 /* all ports and units are closed */
166 zfcp_erp_modify_adapter_status(adapter, 169 zfcp_erp_modify_adapter_status(adapter, 24, NULL,
167 ZFCP_STATUS_COMMON_OPEN, ZFCP_CLEAR); 170 ZFCP_STATUS_COMMON_OPEN, ZFCP_CLEAR);
168} 171}
169 172
@@ -179,7 +182,8 @@ static void zfcp_close_fsf(struct zfcp_adapter *adapter)
179static void zfcp_fsf_request_timeout_handler(unsigned long data) 182static void zfcp_fsf_request_timeout_handler(unsigned long data)
180{ 183{
181 struct zfcp_adapter *adapter = (struct zfcp_adapter *) data; 184 struct zfcp_adapter *adapter = (struct zfcp_adapter *) data;
182 zfcp_erp_adapter_reopen(adapter, ZFCP_STATUS_COMMON_ERP_FAILED); 185 zfcp_erp_adapter_reopen(adapter, ZFCP_STATUS_COMMON_ERP_FAILED, 62,
186 NULL);
183} 187}
184 188
185void zfcp_fsf_start_timer(struct zfcp_fsf_req *fsf_req, unsigned long timeout) 189void zfcp_fsf_start_timer(struct zfcp_fsf_req *fsf_req, unsigned long timeout)
@@ -200,12 +204,11 @@ void zfcp_fsf_start_timer(struct zfcp_fsf_req *fsf_req, unsigned long timeout)
200 * returns: 0 - initiated action successfully 204 * returns: 0 - initiated action successfully
201 * <0 - failed to initiate action 205 * <0 - failed to initiate action
202 */ 206 */
203static int 207static int zfcp_erp_adapter_reopen_internal(struct zfcp_adapter *adapter,
204zfcp_erp_adapter_reopen_internal(struct zfcp_adapter *adapter, int clear_mask) 208 int clear_mask, u8 id, void *ref)
205{ 209{
206 int retval; 210 int retval;
207 211
208 debug_text_event(adapter->erp_dbf, 5, "a_ro");
209 ZFCP_LOG_DEBUG("reopen adapter %s\n", 212 ZFCP_LOG_DEBUG("reopen adapter %s\n",
210 zfcp_get_busid_by_adapter(adapter)); 213 zfcp_get_busid_by_adapter(adapter));
211 214
@@ -214,14 +217,13 @@ zfcp_erp_adapter_reopen_internal(struct zfcp_adapter *adapter, int clear_mask)
214 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED, &adapter->status)) { 217 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED, &adapter->status)) {
215 ZFCP_LOG_DEBUG("skipped reopen of failed adapter %s\n", 218 ZFCP_LOG_DEBUG("skipped reopen of failed adapter %s\n",
216 zfcp_get_busid_by_adapter(adapter)); 219 zfcp_get_busid_by_adapter(adapter));
217 debug_text_event(adapter->erp_dbf, 5, "a_ro_f");
218 /* ensure propagation of failed status to new devices */ 220 /* ensure propagation of failed status to new devices */
219 zfcp_erp_adapter_failed(adapter); 221 zfcp_erp_adapter_failed(adapter, 13, NULL);
220 retval = -EIO; 222 retval = -EIO;
221 goto out; 223 goto out;
222 } 224 }
223 retval = zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_ADAPTER, 225 retval = zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_ADAPTER,
224 adapter, NULL, NULL); 226 adapter, NULL, NULL, id, ref);
225 227
226 out: 228 out:
227 return retval; 229 return retval;
@@ -236,56 +238,56 @@ zfcp_erp_adapter_reopen_internal(struct zfcp_adapter *adapter, int clear_mask)
236 * returns: 0 - initiated action successfully 238 * returns: 0 - initiated action successfully
237 * <0 - failed to initiate action 239 * <0 - failed to initiate action
238 */ 240 */
239int 241int zfcp_erp_adapter_reopen(struct zfcp_adapter *adapter, int clear_mask,
240zfcp_erp_adapter_reopen(struct zfcp_adapter *adapter, int clear_mask) 242 u8 id, void *ref)
241{ 243{
242 int retval; 244 int retval;
243 unsigned long flags; 245 unsigned long flags;
244 246
245 read_lock_irqsave(&zfcp_data.config_lock, flags); 247 read_lock_irqsave(&zfcp_data.config_lock, flags);
246 write_lock(&adapter->erp_lock); 248 write_lock(&adapter->erp_lock);
247 retval = zfcp_erp_adapter_reopen_internal(adapter, clear_mask); 249 retval = zfcp_erp_adapter_reopen_internal(adapter, clear_mask, id, ref);
248 write_unlock(&adapter->erp_lock); 250 write_unlock(&adapter->erp_lock);
249 read_unlock_irqrestore(&zfcp_data.config_lock, flags); 251 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
250 252
251 return retval; 253 return retval;
252} 254}
253 255
254int 256int zfcp_erp_adapter_shutdown(struct zfcp_adapter *adapter, int clear_mask,
255zfcp_erp_adapter_shutdown(struct zfcp_adapter *adapter, int clear_mask) 257 u8 id, void *ref)
256{ 258{
257 int retval; 259 int retval;
258 260
259 retval = zfcp_erp_adapter_reopen(adapter, 261 retval = zfcp_erp_adapter_reopen(adapter,
260 ZFCP_STATUS_COMMON_RUNNING | 262 ZFCP_STATUS_COMMON_RUNNING |
261 ZFCP_STATUS_COMMON_ERP_FAILED | 263 ZFCP_STATUS_COMMON_ERP_FAILED |
262 clear_mask); 264 clear_mask, id, ref);
263 265
264 return retval; 266 return retval;
265} 267}
266 268
267int 269int zfcp_erp_port_shutdown(struct zfcp_port *port, int clear_mask, u8 id,
268zfcp_erp_port_shutdown(struct zfcp_port *port, int clear_mask) 270 void *ref)
269{ 271{
270 int retval; 272 int retval;
271 273
272 retval = zfcp_erp_port_reopen(port, 274 retval = zfcp_erp_port_reopen(port,
273 ZFCP_STATUS_COMMON_RUNNING | 275 ZFCP_STATUS_COMMON_RUNNING |
274 ZFCP_STATUS_COMMON_ERP_FAILED | 276 ZFCP_STATUS_COMMON_ERP_FAILED |
275 clear_mask); 277 clear_mask, id, ref);
276 278
277 return retval; 279 return retval;
278} 280}
279 281
280int 282int zfcp_erp_unit_shutdown(struct zfcp_unit *unit, int clear_mask, u8 id,
281zfcp_erp_unit_shutdown(struct zfcp_unit *unit, int clear_mask) 283 void *ref)
282{ 284{
283 int retval; 285 int retval;
284 286
285 retval = zfcp_erp_unit_reopen(unit, 287 retval = zfcp_erp_unit_reopen(unit,
286 ZFCP_STATUS_COMMON_RUNNING | 288 ZFCP_STATUS_COMMON_RUNNING |
287 ZFCP_STATUS_COMMON_ERP_FAILED | 289 ZFCP_STATUS_COMMON_ERP_FAILED |
288 clear_mask); 290 clear_mask, id, ref);
289 291
290 return retval; 292 return retval;
291} 293}
@@ -399,8 +401,7 @@ zfcp_erp_adisc_handler(unsigned long data)
399 "force physical port reopen " 401 "force physical port reopen "
400 "(adapter %s, port d_id=0x%06x)\n", 402 "(adapter %s, port d_id=0x%06x)\n",
401 zfcp_get_busid_by_adapter(adapter), d_id); 403 zfcp_get_busid_by_adapter(adapter), d_id);
402 debug_text_event(adapter->erp_dbf, 3, "forcreop"); 404 if (zfcp_erp_port_forced_reopen(port, 0, 63, NULL))
403 if (zfcp_erp_port_forced_reopen(port, 0))
404 ZFCP_LOG_NORMAL("failed reopen of port " 405 ZFCP_LOG_NORMAL("failed reopen of port "
405 "(adapter %s, wwpn=0x%016Lx)\n", 406 "(adapter %s, wwpn=0x%016Lx)\n",
406 zfcp_get_busid_by_port(port), 407 zfcp_get_busid_by_port(port),
@@ -427,7 +428,7 @@ zfcp_erp_adisc_handler(unsigned long data)
427 "adisc_resp_wwpn=0x%016Lx)\n", 428 "adisc_resp_wwpn=0x%016Lx)\n",
428 zfcp_get_busid_by_port(port), 429 zfcp_get_busid_by_port(port),
429 port->wwpn, (wwn_t) adisc->wwpn); 430 port->wwpn, (wwn_t) adisc->wwpn);
430 if (zfcp_erp_port_reopen(port, 0)) 431 if (zfcp_erp_port_reopen(port, 0, 64, NULL))
431 ZFCP_LOG_NORMAL("failed reopen of port " 432 ZFCP_LOG_NORMAL("failed reopen of port "
432 "(adapter %s, wwpn=0x%016Lx)\n", 433 "(adapter %s, wwpn=0x%016Lx)\n",
433 zfcp_get_busid_by_port(port), 434 zfcp_get_busid_by_port(port),
@@ -461,7 +462,7 @@ zfcp_test_link(struct zfcp_port *port)
461 ZFCP_LOG_NORMAL("reopen needed for port 0x%016Lx " 462 ZFCP_LOG_NORMAL("reopen needed for port 0x%016Lx "
462 "on adapter %s\n ", port->wwpn, 463 "on adapter %s\n ", port->wwpn,
463 zfcp_get_busid_by_port(port)); 464 zfcp_get_busid_by_port(port));
464 retval = zfcp_erp_port_forced_reopen(port, 0); 465 retval = zfcp_erp_port_forced_reopen(port, 0, 65, NULL);
465 if (retval != 0) { 466 if (retval != 0) {
466 ZFCP_LOG_NORMAL("reopen of remote port 0x%016Lx " 467 ZFCP_LOG_NORMAL("reopen of remote port 0x%016Lx "
467 "on adapter %s failed\n", port->wwpn, 468 "on adapter %s failed\n", port->wwpn,
@@ -484,14 +485,11 @@ zfcp_test_link(struct zfcp_port *port)
484 * returns: 0 - initiated action successfully 485 * returns: 0 - initiated action successfully
485 * <0 - failed to initiate action 486 * <0 - failed to initiate action
486 */ 487 */
487static int 488static int zfcp_erp_port_forced_reopen_internal(struct zfcp_port *port,
488zfcp_erp_port_forced_reopen_internal(struct zfcp_port *port, int clear_mask) 489 int clear_mask, u8 id,
490 void *ref)
489{ 491{
490 int retval; 492 int retval;
491 struct zfcp_adapter *adapter = port->adapter;
492
493 debug_text_event(adapter->erp_dbf, 5, "pf_ro");
494 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
495 493
496 ZFCP_LOG_DEBUG("forced reopen of port 0x%016Lx on adapter %s\n", 494 ZFCP_LOG_DEBUG("forced reopen of port 0x%016Lx on adapter %s\n",
497 port->wwpn, zfcp_get_busid_by_port(port)); 495 port->wwpn, zfcp_get_busid_by_port(port));
@@ -502,14 +500,12 @@ zfcp_erp_port_forced_reopen_internal(struct zfcp_port *port, int clear_mask)
502 ZFCP_LOG_DEBUG("skipped forced reopen of failed port 0x%016Lx " 500 ZFCP_LOG_DEBUG("skipped forced reopen of failed port 0x%016Lx "
503 "on adapter %s\n", port->wwpn, 501 "on adapter %s\n", port->wwpn,
504 zfcp_get_busid_by_port(port)); 502 zfcp_get_busid_by_port(port));
505 debug_text_event(adapter->erp_dbf, 5, "pf_ro_f");
506 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
507 retval = -EIO; 503 retval = -EIO;
508 goto out; 504 goto out;
509 } 505 }
510 506
511 retval = zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_PORT_FORCED, 507 retval = zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_PORT_FORCED,
512 port->adapter, port, NULL); 508 port->adapter, port, NULL, id, ref);
513 509
514 out: 510 out:
515 return retval; 511 return retval;
@@ -524,8 +520,8 @@ zfcp_erp_port_forced_reopen_internal(struct zfcp_port *port, int clear_mask)
524 * returns: 0 - initiated action successfully 520 * returns: 0 - initiated action successfully
525 * <0 - failed to initiate action 521 * <0 - failed to initiate action
526 */ 522 */
527int 523int zfcp_erp_port_forced_reopen(struct zfcp_port *port, int clear_mask, u8 id,
528zfcp_erp_port_forced_reopen(struct zfcp_port *port, int clear_mask) 524 void *ref)
529{ 525{
530 int retval; 526 int retval;
531 unsigned long flags; 527 unsigned long flags;
@@ -534,7 +530,8 @@ zfcp_erp_port_forced_reopen(struct zfcp_port *port, int clear_mask)
534 adapter = port->adapter; 530 adapter = port->adapter;
535 read_lock_irqsave(&zfcp_data.config_lock, flags); 531 read_lock_irqsave(&zfcp_data.config_lock, flags);
536 write_lock(&adapter->erp_lock); 532 write_lock(&adapter->erp_lock);
537 retval = zfcp_erp_port_forced_reopen_internal(port, clear_mask); 533 retval = zfcp_erp_port_forced_reopen_internal(port, clear_mask, id,
534 ref);
538 write_unlock(&adapter->erp_lock); 535 write_unlock(&adapter->erp_lock);
539 read_unlock_irqrestore(&zfcp_data.config_lock, flags); 536 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
540 537
@@ -551,14 +548,10 @@ zfcp_erp_port_forced_reopen(struct zfcp_port *port, int clear_mask)
551 * returns: 0 - initiated action successfully 548 * returns: 0 - initiated action successfully
552 * <0 - failed to initiate action 549 * <0 - failed to initiate action
553 */ 550 */
554static int 551static int zfcp_erp_port_reopen_internal(struct zfcp_port *port, int clear_mask,
555zfcp_erp_port_reopen_internal(struct zfcp_port *port, int clear_mask) 552 u8 id, void *ref)
556{ 553{
557 int retval; 554 int retval;
558 struct zfcp_adapter *adapter = port->adapter;
559
560 debug_text_event(adapter->erp_dbf, 5, "p_ro");
561 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
562 555
563 ZFCP_LOG_DEBUG("reopen of port 0x%016Lx on adapter %s\n", 556 ZFCP_LOG_DEBUG("reopen of port 0x%016Lx on adapter %s\n",
564 port->wwpn, zfcp_get_busid_by_port(port)); 557 port->wwpn, zfcp_get_busid_by_port(port));
@@ -569,16 +562,14 @@ zfcp_erp_port_reopen_internal(struct zfcp_port *port, int clear_mask)
569 ZFCP_LOG_DEBUG("skipped reopen of failed port 0x%016Lx " 562 ZFCP_LOG_DEBUG("skipped reopen of failed port 0x%016Lx "
570 "on adapter %s\n", port->wwpn, 563 "on adapter %s\n", port->wwpn,
571 zfcp_get_busid_by_port(port)); 564 zfcp_get_busid_by_port(port));
572 debug_text_event(adapter->erp_dbf, 5, "p_ro_f");
573 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
574 /* ensure propagation of failed status to new devices */ 565 /* ensure propagation of failed status to new devices */
575 zfcp_erp_port_failed(port); 566 zfcp_erp_port_failed(port, 14, NULL);
576 retval = -EIO; 567 retval = -EIO;
577 goto out; 568 goto out;
578 } 569 }
579 570
580 retval = zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_PORT, 571 retval = zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_PORT,
581 port->adapter, port, NULL); 572 port->adapter, port, NULL, id, ref);
582 573
583 out: 574 out:
584 return retval; 575 return retval;
@@ -594,8 +585,8 @@ zfcp_erp_port_reopen_internal(struct zfcp_port *port, int clear_mask)
594 * correct locking. An error recovery task is initiated to do the reopen. 585 * correct locking. An error recovery task is initiated to do the reopen.
595 * To wait for the completion of the reopen zfcp_erp_wait should be used. 586 * To wait for the completion of the reopen zfcp_erp_wait should be used.
596 */ 587 */
597int 588int zfcp_erp_port_reopen(struct zfcp_port *port, int clear_mask, u8 id,
598zfcp_erp_port_reopen(struct zfcp_port *port, int clear_mask) 589 void *ref)
599{ 590{
600 int retval; 591 int retval;
601 unsigned long flags; 592 unsigned long flags;
@@ -603,7 +594,7 @@ zfcp_erp_port_reopen(struct zfcp_port *port, int clear_mask)
603 594
604 read_lock_irqsave(&zfcp_data.config_lock, flags); 595 read_lock_irqsave(&zfcp_data.config_lock, flags);
605 write_lock(&adapter->erp_lock); 596 write_lock(&adapter->erp_lock);
606 retval = zfcp_erp_port_reopen_internal(port, clear_mask); 597 retval = zfcp_erp_port_reopen_internal(port, clear_mask, id, ref);
607 write_unlock(&adapter->erp_lock); 598 write_unlock(&adapter->erp_lock);
608 read_unlock_irqrestore(&zfcp_data.config_lock, flags); 599 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
609 600
@@ -620,14 +611,12 @@ zfcp_erp_port_reopen(struct zfcp_port *port, int clear_mask)
620 * returns: 0 - initiated action successfully 611 * returns: 0 - initiated action successfully
621 * <0 - failed to initiate action 612 * <0 - failed to initiate action
622 */ 613 */
623static int 614static int zfcp_erp_unit_reopen_internal(struct zfcp_unit *unit, int clear_mask,
624zfcp_erp_unit_reopen_internal(struct zfcp_unit *unit, int clear_mask) 615 u8 id, void *ref)
625{ 616{
626 int retval; 617 int retval;
627 struct zfcp_adapter *adapter = unit->port->adapter; 618 struct zfcp_adapter *adapter = unit->port->adapter;
628 619
629 debug_text_event(adapter->erp_dbf, 5, "u_ro");
630 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun, sizeof (fcp_lun_t));
631 ZFCP_LOG_DEBUG("reopen of unit 0x%016Lx on port 0x%016Lx " 620 ZFCP_LOG_DEBUG("reopen of unit 0x%016Lx on port 0x%016Lx "
632 "on adapter %s\n", unit->fcp_lun, 621 "on adapter %s\n", unit->fcp_lun,
633 unit->port->wwpn, zfcp_get_busid_by_unit(unit)); 622 unit->port->wwpn, zfcp_get_busid_by_unit(unit));
@@ -639,15 +628,12 @@ zfcp_erp_unit_reopen_internal(struct zfcp_unit *unit, int clear_mask)
639 "on port 0x%016Lx on adapter %s\n", 628 "on port 0x%016Lx on adapter %s\n",
640 unit->fcp_lun, unit->port->wwpn, 629 unit->fcp_lun, unit->port->wwpn,
641 zfcp_get_busid_by_unit(unit)); 630 zfcp_get_busid_by_unit(unit));
642 debug_text_event(adapter->erp_dbf, 5, "u_ro_f");
643 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun,
644 sizeof (fcp_lun_t));
645 retval = -EIO; 631 retval = -EIO;
646 goto out; 632 goto out;
647 } 633 }
648 634
649 retval = zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_UNIT, 635 retval = zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_UNIT,
650 unit->port->adapter, unit->port, unit); 636 adapter, unit->port, unit, id, ref);
651 out: 637 out:
652 return retval; 638 return retval;
653} 639}
@@ -662,8 +648,8 @@ zfcp_erp_unit_reopen_internal(struct zfcp_unit *unit, int clear_mask)
662 * locking. An error recovery task is initiated to do the reopen. 648 * locking. An error recovery task is initiated to do the reopen.
663 * To wait for the completion of the reopen zfcp_erp_wait should be used. 649 * To wait for the completion of the reopen zfcp_erp_wait should be used.
664 */ 650 */
665int 651int zfcp_erp_unit_reopen(struct zfcp_unit *unit, int clear_mask, u8 id,
666zfcp_erp_unit_reopen(struct zfcp_unit *unit, int clear_mask) 652 void *ref)
667{ 653{
668 int retval; 654 int retval;
669 unsigned long flags; 655 unsigned long flags;
@@ -675,7 +661,7 @@ zfcp_erp_unit_reopen(struct zfcp_unit *unit, int clear_mask)
675 661
676 read_lock_irqsave(&zfcp_data.config_lock, flags); 662 read_lock_irqsave(&zfcp_data.config_lock, flags);
677 write_lock(&adapter->erp_lock); 663 write_lock(&adapter->erp_lock);
678 retval = zfcp_erp_unit_reopen_internal(unit, clear_mask); 664 retval = zfcp_erp_unit_reopen_internal(unit, clear_mask, id, ref);
679 write_unlock(&adapter->erp_lock); 665 write_unlock(&adapter->erp_lock);
680 read_unlock_irqrestore(&zfcp_data.config_lock, flags); 666 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
681 667
@@ -687,19 +673,43 @@ zfcp_erp_unit_reopen(struct zfcp_unit *unit, int clear_mask)
687 */ 673 */
688static void zfcp_erp_adapter_block(struct zfcp_adapter *adapter, int clear_mask) 674static void zfcp_erp_adapter_block(struct zfcp_adapter *adapter, int clear_mask)
689{ 675{
690 debug_text_event(adapter->erp_dbf, 6, "a_bl"); 676 zfcp_erp_modify_adapter_status(adapter, 15, NULL,
691 zfcp_erp_modify_adapter_status(adapter,
692 ZFCP_STATUS_COMMON_UNBLOCKED | 677 ZFCP_STATUS_COMMON_UNBLOCKED |
693 clear_mask, ZFCP_CLEAR); 678 clear_mask, ZFCP_CLEAR);
694} 679}
695 680
681/* FIXME: isn't really atomic */
682/*
683 * returns the mask which has not been set so far, i.e.
684 * 0 if no bit has been changed, !0 if some bit has been changed
685 */
686static int atomic_test_and_set_mask(unsigned long mask, atomic_t *v)
687{
688 int changed_bits = (atomic_read(v) /*XOR*/^ mask) & mask;
689 atomic_set_mask(mask, v);
690 return changed_bits;
691}
692
693/* FIXME: isn't really atomic */
694/*
695 * returns the mask which has not been cleared so far, i.e.
696 * 0 if no bit has been changed, !0 if some bit has been changed
697 */
698static int atomic_test_and_clear_mask(unsigned long mask, atomic_t *v)
699{
700 int changed_bits = atomic_read(v) & mask;
701 atomic_clear_mask(mask, v);
702 return changed_bits;
703}
704
696/** 705/**
697 * zfcp_erp_adapter_unblock - mark adapter as unblocked, allow scsi requests 706 * zfcp_erp_adapter_unblock - mark adapter as unblocked, allow scsi requests
698 */ 707 */
699static void zfcp_erp_adapter_unblock(struct zfcp_adapter *adapter) 708static void zfcp_erp_adapter_unblock(struct zfcp_adapter *adapter)
700{ 709{
701 debug_text_event(adapter->erp_dbf, 6, "a_ubl"); 710 if (atomic_test_and_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED,
702 atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &adapter->status); 711 &adapter->status))
712 zfcp_rec_dbf_event_adapter(16, NULL, adapter);
703} 713}
704 714
705/* 715/*
@@ -714,11 +724,7 @@ static void zfcp_erp_adapter_unblock(struct zfcp_adapter *adapter)
714static void 724static void
715zfcp_erp_port_block(struct zfcp_port *port, int clear_mask) 725zfcp_erp_port_block(struct zfcp_port *port, int clear_mask)
716{ 726{
717 struct zfcp_adapter *adapter = port->adapter; 727 zfcp_erp_modify_port_status(port, 17, NULL,
718
719 debug_text_event(adapter->erp_dbf, 6, "p_bl");
720 debug_event(adapter->erp_dbf, 6, &port->wwpn, sizeof (wwn_t));
721 zfcp_erp_modify_port_status(port,
722 ZFCP_STATUS_COMMON_UNBLOCKED | clear_mask, 728 ZFCP_STATUS_COMMON_UNBLOCKED | clear_mask,
723 ZFCP_CLEAR); 729 ZFCP_CLEAR);
724} 730}
@@ -733,11 +739,9 @@ zfcp_erp_port_block(struct zfcp_port *port, int clear_mask)
733static void 739static void
734zfcp_erp_port_unblock(struct zfcp_port *port) 740zfcp_erp_port_unblock(struct zfcp_port *port)
735{ 741{
736 struct zfcp_adapter *adapter = port->adapter; 742 if (atomic_test_and_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED,
737 743 &port->status))
738 debug_text_event(adapter->erp_dbf, 6, "p_ubl"); 744 zfcp_rec_dbf_event_port(18, NULL, port);
739 debug_event(adapter->erp_dbf, 6, &port->wwpn, sizeof (wwn_t));
740 atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &port->status);
741} 745}
742 746
743/* 747/*
@@ -752,11 +756,7 @@ zfcp_erp_port_unblock(struct zfcp_port *port)
752static void 756static void
753zfcp_erp_unit_block(struct zfcp_unit *unit, int clear_mask) 757zfcp_erp_unit_block(struct zfcp_unit *unit, int clear_mask)
754{ 758{
755 struct zfcp_adapter *adapter = unit->port->adapter; 759 zfcp_erp_modify_unit_status(unit, 19, NULL,
756
757 debug_text_event(adapter->erp_dbf, 6, "u_bl");
758 debug_event(adapter->erp_dbf, 6, &unit->fcp_lun, sizeof (fcp_lun_t));
759 zfcp_erp_modify_unit_status(unit,
760 ZFCP_STATUS_COMMON_UNBLOCKED | clear_mask, 760 ZFCP_STATUS_COMMON_UNBLOCKED | clear_mask,
761 ZFCP_CLEAR); 761 ZFCP_CLEAR);
762} 762}
@@ -771,11 +771,9 @@ zfcp_erp_unit_block(struct zfcp_unit *unit, int clear_mask)
771static void 771static void
772zfcp_erp_unit_unblock(struct zfcp_unit *unit) 772zfcp_erp_unit_unblock(struct zfcp_unit *unit)
773{ 773{
774 struct zfcp_adapter *adapter = unit->port->adapter; 774 if (atomic_test_and_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED,
775 775 &unit->status))
776 debug_text_event(adapter->erp_dbf, 6, "u_ubl"); 776 zfcp_rec_dbf_event_unit(20, NULL, unit);
777 debug_event(adapter->erp_dbf, 6, &unit->fcp_lun, sizeof (fcp_lun_t));
778 atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &unit->status);
779} 777}
780 778
781static void 779static void
@@ -783,11 +781,9 @@ zfcp_erp_action_ready(struct zfcp_erp_action *erp_action)
783{ 781{
784 struct zfcp_adapter *adapter = erp_action->adapter; 782 struct zfcp_adapter *adapter = erp_action->adapter;
785 783
786 debug_text_event(adapter->erp_dbf, 4, "a_ar");
787 debug_event(adapter->erp_dbf, 4, &erp_action->action, sizeof (int));
788
789 zfcp_erp_action_to_ready(erp_action); 784 zfcp_erp_action_to_ready(erp_action);
790 up(&adapter->erp_ready_sem); 785 up(&adapter->erp_ready_sem);
786 zfcp_rec_dbf_event_thread(2, adapter, 0);
791} 787}
792 788
793/* 789/*
@@ -849,18 +845,15 @@ zfcp_erp_strategy_check_fsfreq(struct zfcp_erp_action *erp_action)
849 if (zfcp_reqlist_find_safe(adapter, erp_action->fsf_req) && 845 if (zfcp_reqlist_find_safe(adapter, erp_action->fsf_req) &&
850 erp_action->fsf_req->erp_action == erp_action) { 846 erp_action->fsf_req->erp_action == erp_action) {
851 /* fsf_req still exists */ 847 /* fsf_req still exists */
852 debug_text_event(adapter->erp_dbf, 3, "a_ca_req");
853 debug_event(adapter->erp_dbf, 3, &erp_action->fsf_req,
854 sizeof (unsigned long));
855 /* dismiss fsf_req of timed out/dismissed erp_action */ 848 /* dismiss fsf_req of timed out/dismissed erp_action */
856 if (erp_action->status & (ZFCP_STATUS_ERP_DISMISSED | 849 if (erp_action->status & (ZFCP_STATUS_ERP_DISMISSED |
857 ZFCP_STATUS_ERP_TIMEDOUT)) { 850 ZFCP_STATUS_ERP_TIMEDOUT)) {
858 debug_text_event(adapter->erp_dbf, 3,
859 "a_ca_disreq");
860 erp_action->fsf_req->status |= 851 erp_action->fsf_req->status |=
861 ZFCP_STATUS_FSFREQ_DISMISSED; 852 ZFCP_STATUS_FSFREQ_DISMISSED;
853 zfcp_rec_dbf_event_action(142, erp_action);
862 } 854 }
863 if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT) { 855 if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT) {
856 zfcp_rec_dbf_event_action(143, erp_action);
864 ZFCP_LOG_NORMAL("error: erp step timed out " 857 ZFCP_LOG_NORMAL("error: erp step timed out "
865 "(action=%d, fsf_req=%p)\n ", 858 "(action=%d, fsf_req=%p)\n ",
866 erp_action->action, 859 erp_action->action,
@@ -879,7 +872,6 @@ zfcp_erp_strategy_check_fsfreq(struct zfcp_erp_action *erp_action)
879 erp_action->fsf_req = NULL; 872 erp_action->fsf_req = NULL;
880 } 873 }
881 } else { 874 } else {
882 debug_text_event(adapter->erp_dbf, 3, "a_ca_gonereq");
883 /* 875 /*
884 * even if this fsf_req has gone, forget about 876 * even if this fsf_req has gone, forget about
885 * association between erp_action and fsf_req 877 * association between erp_action and fsf_req
@@ -887,8 +879,7 @@ zfcp_erp_strategy_check_fsfreq(struct zfcp_erp_action *erp_action)
887 erp_action->fsf_req = NULL; 879 erp_action->fsf_req = NULL;
888 } 880 }
889 spin_unlock(&adapter->req_list_lock); 881 spin_unlock(&adapter->req_list_lock);
890 } else 882 }
891 debug_text_event(adapter->erp_dbf, 3, "a_ca_noreq");
892} 883}
893 884
894/** 885/**
@@ -900,19 +891,11 @@ zfcp_erp_strategy_check_fsfreq(struct zfcp_erp_action *erp_action)
900static void zfcp_erp_async_handler_nolock(struct zfcp_erp_action *erp_action, 891static void zfcp_erp_async_handler_nolock(struct zfcp_erp_action *erp_action,
901 unsigned long set_mask) 892 unsigned long set_mask)
902{ 893{
903 struct zfcp_adapter *adapter = erp_action->adapter;
904
905 if (zfcp_erp_action_exists(erp_action) == ZFCP_ERP_ACTION_RUNNING) { 894 if (zfcp_erp_action_exists(erp_action) == ZFCP_ERP_ACTION_RUNNING) {
906 debug_text_event(adapter->erp_dbf, 2, "a_asyh_ex");
907 debug_event(adapter->erp_dbf, 2, &erp_action->action,
908 sizeof (int));
909 erp_action->status |= set_mask; 895 erp_action->status |= set_mask;
910 zfcp_erp_action_ready(erp_action); 896 zfcp_erp_action_ready(erp_action);
911 } else { 897 } else {
912 /* action is ready or gone - nothing to do */ 898 /* action is ready or gone - nothing to do */
913 debug_text_event(adapter->erp_dbf, 3, "a_asyh_gone");
914 debug_event(adapter->erp_dbf, 3, &erp_action->action,
915 sizeof (int));
916 } 899 }
917} 900}
918 901
@@ -939,10 +922,6 @@ static void
939zfcp_erp_memwait_handler(unsigned long data) 922zfcp_erp_memwait_handler(unsigned long data)
940{ 923{
941 struct zfcp_erp_action *erp_action = (struct zfcp_erp_action *) data; 924 struct zfcp_erp_action *erp_action = (struct zfcp_erp_action *) data;
942 struct zfcp_adapter *adapter = erp_action->adapter;
943
944 debug_text_event(adapter->erp_dbf, 2, "a_mwh");
945 debug_event(adapter->erp_dbf, 2, &erp_action->action, sizeof (int));
946 925
947 zfcp_erp_async_handler(erp_action, 0); 926 zfcp_erp_async_handler(erp_action, 0);
948} 927}
@@ -955,10 +934,6 @@ zfcp_erp_memwait_handler(unsigned long data)
955static void zfcp_erp_timeout_handler(unsigned long data) 934static void zfcp_erp_timeout_handler(unsigned long data)
956{ 935{
957 struct zfcp_erp_action *erp_action = (struct zfcp_erp_action *) data; 936 struct zfcp_erp_action *erp_action = (struct zfcp_erp_action *) data;
958 struct zfcp_adapter *adapter = erp_action->adapter;
959
960 debug_text_event(adapter->erp_dbf, 2, "a_th");
961 debug_event(adapter->erp_dbf, 2, &erp_action->action, sizeof (int));
962 937
963 zfcp_erp_async_handler(erp_action, ZFCP_STATUS_ERP_TIMEDOUT); 938 zfcp_erp_async_handler(erp_action, ZFCP_STATUS_ERP_TIMEDOUT);
964} 939}
@@ -973,11 +948,6 @@ static void zfcp_erp_timeout_handler(unsigned long data)
973 */ 948 */
974static void zfcp_erp_action_dismiss(struct zfcp_erp_action *erp_action) 949static void zfcp_erp_action_dismiss(struct zfcp_erp_action *erp_action)
975{ 950{
976 struct zfcp_adapter *adapter = erp_action->adapter;
977
978 debug_text_event(adapter->erp_dbf, 2, "a_adis");
979 debug_event(adapter->erp_dbf, 2, &erp_action->action, sizeof (int));
980
981 erp_action->status |= ZFCP_STATUS_ERP_DISMISSED; 951 erp_action->status |= ZFCP_STATUS_ERP_DISMISSED;
982 if (zfcp_erp_action_exists(erp_action) == ZFCP_ERP_ACTION_RUNNING) 952 if (zfcp_erp_action_exists(erp_action) == ZFCP_ERP_ACTION_RUNNING)
983 zfcp_erp_action_ready(erp_action); 953 zfcp_erp_action_ready(erp_action);
@@ -995,12 +965,10 @@ zfcp_erp_thread_setup(struct zfcp_adapter *adapter)
995 ZFCP_LOG_NORMAL("error: creation of erp thread failed for " 965 ZFCP_LOG_NORMAL("error: creation of erp thread failed for "
996 "adapter %s\n", 966 "adapter %s\n",
997 zfcp_get_busid_by_adapter(adapter)); 967 zfcp_get_busid_by_adapter(adapter));
998 debug_text_event(adapter->erp_dbf, 5, "a_thset_fail");
999 } else { 968 } else {
1000 wait_event(adapter->erp_thread_wqh, 969 wait_event(adapter->erp_thread_wqh,
1001 atomic_test_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP, 970 atomic_test_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP,
1002 &adapter->status)); 971 &adapter->status));
1003 debug_text_event(adapter->erp_dbf, 5, "a_thset_ok");
1004 } 972 }
1005 973
1006 return (retval < 0); 974 return (retval < 0);
@@ -1027,6 +995,7 @@ zfcp_erp_thread_kill(struct zfcp_adapter *adapter)
1027 995
1028 atomic_set_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL, &adapter->status); 996 atomic_set_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL, &adapter->status);
1029 up(&adapter->erp_ready_sem); 997 up(&adapter->erp_ready_sem);
998 zfcp_rec_dbf_event_thread(2, adapter, 1);
1030 999
1031 wait_event(adapter->erp_thread_wqh, 1000 wait_event(adapter->erp_thread_wqh,
1032 !atomic_test_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP, 1001 !atomic_test_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP,
@@ -1035,8 +1004,6 @@ zfcp_erp_thread_kill(struct zfcp_adapter *adapter)
1035 atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL, 1004 atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL,
1036 &adapter->status); 1005 &adapter->status);
1037 1006
1038 debug_text_event(adapter->erp_dbf, 5, "a_thki_ok");
1039
1040 return retval; 1007 return retval;
1041} 1008}
1042 1009
@@ -1059,7 +1026,6 @@ zfcp_erp_thread(void *data)
1059 /* Block all signals */ 1026 /* Block all signals */
1060 siginitsetinv(&current->blocked, 0); 1027 siginitsetinv(&current->blocked, 0);
1061 atomic_set_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP, &adapter->status); 1028 atomic_set_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP, &adapter->status);
1062 debug_text_event(adapter->erp_dbf, 5, "a_th_run");
1063 wake_up(&adapter->erp_thread_wqh); 1029 wake_up(&adapter->erp_thread_wqh);
1064 1030
1065 while (!atomic_test_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL, 1031 while (!atomic_test_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL,
@@ -1084,12 +1050,12 @@ zfcp_erp_thread(void *data)
1084 * no action in 'ready' queue to be processed and 1050 * no action in 'ready' queue to be processed and
1085 * thread is not to be killed 1051 * thread is not to be killed
1086 */ 1052 */
1053 zfcp_rec_dbf_event_thread(4, adapter, 1);
1087 down_interruptible(&adapter->erp_ready_sem); 1054 down_interruptible(&adapter->erp_ready_sem);
1088 debug_text_event(adapter->erp_dbf, 5, "a_th_woken"); 1055 zfcp_rec_dbf_event_thread(5, adapter, 1);
1089 } 1056 }
1090 1057
1091 atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP, &adapter->status); 1058 atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP, &adapter->status);
1092 debug_text_event(adapter->erp_dbf, 5, "a_th_stop");
1093 wake_up(&adapter->erp_thread_wqh); 1059 wake_up(&adapter->erp_thread_wqh);
1094 1060
1095 return 0; 1061 return 0;
@@ -1125,7 +1091,6 @@ zfcp_erp_strategy(struct zfcp_erp_action *erp_action)
1125 /* dequeue dismissed action and leave, if required */ 1091 /* dequeue dismissed action and leave, if required */
1126 retval = zfcp_erp_strategy_check_action(erp_action, retval); 1092 retval = zfcp_erp_strategy_check_action(erp_action, retval);
1127 if (retval == ZFCP_ERP_DISMISSED) { 1093 if (retval == ZFCP_ERP_DISMISSED) {
1128 debug_text_event(adapter->erp_dbf, 4, "a_st_dis1");
1129 goto unlock; 1094 goto unlock;
1130 } 1095 }
1131 1096
@@ -1176,20 +1141,17 @@ zfcp_erp_strategy(struct zfcp_erp_action *erp_action)
1176 element was timed out. 1141 element was timed out.
1177 */ 1142 */
1178 if (adapter->erp_total_count == adapter->erp_low_mem_count) { 1143 if (adapter->erp_total_count == adapter->erp_low_mem_count) {
1179 debug_text_event(adapter->erp_dbf, 3, "a_st_lowmem");
1180 ZFCP_LOG_NORMAL("error: no mempool elements available, " 1144 ZFCP_LOG_NORMAL("error: no mempool elements available, "
1181 "restarting I/O on adapter %s " 1145 "restarting I/O on adapter %s "
1182 "to free mempool\n", 1146 "to free mempool\n",
1183 zfcp_get_busid_by_adapter(adapter)); 1147 zfcp_get_busid_by_adapter(adapter));
1184 zfcp_erp_adapter_reopen_internal(adapter, 0); 1148 zfcp_erp_adapter_reopen_internal(adapter, 0, 66, NULL);
1185 } else { 1149 } else {
1186 debug_text_event(adapter->erp_dbf, 2, "a_st_memw");
1187 retval = zfcp_erp_strategy_memwait(erp_action); 1150 retval = zfcp_erp_strategy_memwait(erp_action);
1188 } 1151 }
1189 goto unlock; 1152 goto unlock;
1190 case ZFCP_ERP_CONTINUES: 1153 case ZFCP_ERP_CONTINUES:
1191 /* leave since this action runs asynchronously */ 1154 /* leave since this action runs asynchronously */
1192 debug_text_event(adapter->erp_dbf, 6, "a_st_cont");
1193 if (erp_action->status & ZFCP_STATUS_ERP_LOWMEM) { 1155 if (erp_action->status & ZFCP_STATUS_ERP_LOWMEM) {
1194 --adapter->erp_low_mem_count; 1156 --adapter->erp_low_mem_count;
1195 erp_action->status &= ~ZFCP_STATUS_ERP_LOWMEM; 1157 erp_action->status &= ~ZFCP_STATUS_ERP_LOWMEM;
@@ -1218,7 +1180,6 @@ zfcp_erp_strategy(struct zfcp_erp_action *erp_action)
1218 * action is repeated in order to process state change 1180 * action is repeated in order to process state change
1219 */ 1181 */
1220 if (retval == ZFCP_ERP_EXIT) { 1182 if (retval == ZFCP_ERP_EXIT) {
1221 debug_text_event(adapter->erp_dbf, 2, "a_st_exit");
1222 goto unlock; 1183 goto unlock;
1223 } 1184 }
1224 1185
@@ -1244,8 +1205,6 @@ zfcp_erp_strategy(struct zfcp_erp_action *erp_action)
1244 if (retval != ZFCP_ERP_DISMISSED) 1205 if (retval != ZFCP_ERP_DISMISSED)
1245 zfcp_erp_strategy_check_queues(adapter); 1206 zfcp_erp_strategy_check_queues(adapter);
1246 1207
1247 debug_text_event(adapter->erp_dbf, 6, "a_st_done");
1248
1249 return retval; 1208 return retval;
1250} 1209}
1251 1210
@@ -1260,17 +1219,12 @@ zfcp_erp_strategy(struct zfcp_erp_action *erp_action)
1260static int 1219static int
1261zfcp_erp_strategy_check_action(struct zfcp_erp_action *erp_action, int retval) 1220zfcp_erp_strategy_check_action(struct zfcp_erp_action *erp_action, int retval)
1262{ 1221{
1263 struct zfcp_adapter *adapter = erp_action->adapter;
1264
1265 zfcp_erp_strategy_check_fsfreq(erp_action); 1222 zfcp_erp_strategy_check_fsfreq(erp_action);
1266 1223
1267 debug_event(adapter->erp_dbf, 5, &erp_action->action, sizeof (int));
1268 if (erp_action->status & ZFCP_STATUS_ERP_DISMISSED) { 1224 if (erp_action->status & ZFCP_STATUS_ERP_DISMISSED) {
1269 debug_text_event(adapter->erp_dbf, 3, "a_stcd_dis");
1270 zfcp_erp_action_dequeue(erp_action); 1225 zfcp_erp_action_dequeue(erp_action);
1271 retval = ZFCP_ERP_DISMISSED; 1226 retval = ZFCP_ERP_DISMISSED;
1272 } else 1227 }
1273 debug_text_event(adapter->erp_dbf, 5, "a_stcd_nodis");
1274 1228
1275 return retval; 1229 return retval;
1276} 1230}
@@ -1279,7 +1233,6 @@ static int
1279zfcp_erp_strategy_do_action(struct zfcp_erp_action *erp_action) 1233zfcp_erp_strategy_do_action(struct zfcp_erp_action *erp_action)
1280{ 1234{
1281 int retval = ZFCP_ERP_FAILED; 1235 int retval = ZFCP_ERP_FAILED;
1282 struct zfcp_adapter *adapter = erp_action->adapter;
1283 1236
1284 /* 1237 /*
1285 * try to execute/continue action as far as possible, 1238 * try to execute/continue action as far as possible,
@@ -1309,9 +1262,6 @@ zfcp_erp_strategy_do_action(struct zfcp_erp_action *erp_action)
1309 break; 1262 break;
1310 1263
1311 default: 1264 default:
1312 debug_text_exception(adapter->erp_dbf, 1, "a_stda_bug");
1313 debug_event(adapter->erp_dbf, 1, &erp_action->action,
1314 sizeof (int));
1315 ZFCP_LOG_NORMAL("bug: unknown erp action requested on " 1265 ZFCP_LOG_NORMAL("bug: unknown erp action requested on "
1316 "adapter %s (action=%d)\n", 1266 "adapter %s (action=%d)\n",
1317 zfcp_get_busid_by_adapter(erp_action->adapter), 1267 zfcp_get_busid_by_adapter(erp_action->adapter),
@@ -1333,10 +1283,7 @@ static int
1333zfcp_erp_strategy_memwait(struct zfcp_erp_action *erp_action) 1283zfcp_erp_strategy_memwait(struct zfcp_erp_action *erp_action)
1334{ 1284{
1335 int retval = ZFCP_ERP_CONTINUES; 1285 int retval = ZFCP_ERP_CONTINUES;
1336 struct zfcp_adapter *adapter = erp_action->adapter;
1337 1286
1338 debug_text_event(adapter->erp_dbf, 6, "a_mwinit");
1339 debug_event(adapter->erp_dbf, 6, &erp_action->action, sizeof (int));
1340 init_timer(&erp_action->timer); 1287 init_timer(&erp_action->timer);
1341 erp_action->timer.function = zfcp_erp_memwait_handler; 1288 erp_action->timer.function = zfcp_erp_memwait_handler;
1342 erp_action->timer.data = (unsigned long) erp_action; 1289 erp_action->timer.data = (unsigned long) erp_action;
@@ -1353,13 +1300,12 @@ zfcp_erp_strategy_memwait(struct zfcp_erp_action *erp_action)
1353 * 1300 *
1354 */ 1301 */
1355void 1302void
1356zfcp_erp_adapter_failed(struct zfcp_adapter *adapter) 1303zfcp_erp_adapter_failed(struct zfcp_adapter *adapter, u8 id, void *ref)
1357{ 1304{
1358 zfcp_erp_modify_adapter_status(adapter, 1305 zfcp_erp_modify_adapter_status(adapter, id, ref,
1359 ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET); 1306 ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET);
1360 ZFCP_LOG_NORMAL("adapter erp failed on adapter %s\n", 1307 ZFCP_LOG_NORMAL("adapter erp failed on adapter %s\n",
1361 zfcp_get_busid_by_adapter(adapter)); 1308 zfcp_get_busid_by_adapter(adapter));
1362 debug_text_event(adapter->erp_dbf, 2, "a_afail");
1363} 1309}
1364 1310
1365/* 1311/*
@@ -1369,9 +1315,9 @@ zfcp_erp_adapter_failed(struct zfcp_adapter *adapter)
1369 * 1315 *
1370 */ 1316 */
1371void 1317void
1372zfcp_erp_port_failed(struct zfcp_port *port) 1318zfcp_erp_port_failed(struct zfcp_port *port, u8 id, void *ref)
1373{ 1319{
1374 zfcp_erp_modify_port_status(port, 1320 zfcp_erp_modify_port_status(port, id, ref,
1375 ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET); 1321 ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET);
1376 1322
1377 if (atomic_test_mask(ZFCP_STATUS_PORT_WKA, &port->status)) 1323 if (atomic_test_mask(ZFCP_STATUS_PORT_WKA, &port->status))
@@ -1381,9 +1327,6 @@ zfcp_erp_port_failed(struct zfcp_port *port)
1381 else 1327 else
1382 ZFCP_LOG_NORMAL("port erp failed (adapter %s, wwpn=0x%016Lx)\n", 1328 ZFCP_LOG_NORMAL("port erp failed (adapter %s, wwpn=0x%016Lx)\n",
1383 zfcp_get_busid_by_port(port), port->wwpn); 1329 zfcp_get_busid_by_port(port), port->wwpn);
1384
1385 debug_text_event(port->adapter->erp_dbf, 2, "p_pfail");
1386 debug_event(port->adapter->erp_dbf, 2, &port->wwpn, sizeof (wwn_t));
1387} 1330}
1388 1331
1389/* 1332/*
@@ -1393,17 +1336,14 @@ zfcp_erp_port_failed(struct zfcp_port *port)
1393 * 1336 *
1394 */ 1337 */
1395void 1338void
1396zfcp_erp_unit_failed(struct zfcp_unit *unit) 1339zfcp_erp_unit_failed(struct zfcp_unit *unit, u8 id, void *ref)
1397{ 1340{
1398 zfcp_erp_modify_unit_status(unit, 1341 zfcp_erp_modify_unit_status(unit, id, ref,
1399 ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET); 1342 ZFCP_STATUS_COMMON_ERP_FAILED, ZFCP_SET);
1400 1343
1401 ZFCP_LOG_NORMAL("unit erp failed on unit 0x%016Lx on port 0x%016Lx " 1344 ZFCP_LOG_NORMAL("unit erp failed on unit 0x%016Lx on port 0x%016Lx "
1402 " on adapter %s\n", unit->fcp_lun, 1345 " on adapter %s\n", unit->fcp_lun,
1403 unit->port->wwpn, zfcp_get_busid_by_unit(unit)); 1346 unit->port->wwpn, zfcp_get_busid_by_unit(unit));
1404 debug_text_event(unit->port->adapter->erp_dbf, 2, "u_ufail");
1405 debug_event(unit->port->adapter->erp_dbf, 2,
1406 &unit->fcp_lun, sizeof (fcp_lun_t));
1407} 1347}
1408 1348
1409/* 1349/*
@@ -1427,10 +1367,6 @@ zfcp_erp_strategy_check_target(struct zfcp_erp_action *erp_action, int result)
1427 struct zfcp_port *port = erp_action->port; 1367 struct zfcp_port *port = erp_action->port;
1428 struct zfcp_unit *unit = erp_action->unit; 1368 struct zfcp_unit *unit = erp_action->unit;
1429 1369
1430 debug_text_event(adapter->erp_dbf, 5, "a_stct_norm");
1431 debug_event(adapter->erp_dbf, 5, &erp_action->action, sizeof (int));
1432 debug_event(adapter->erp_dbf, 5, &result, sizeof (int));
1433
1434 switch (erp_action->action) { 1370 switch (erp_action->action) {
1435 1371
1436 case ZFCP_ERP_ACTION_REOPEN_UNIT: 1372 case ZFCP_ERP_ACTION_REOPEN_UNIT:
@@ -1457,15 +1393,14 @@ zfcp_erp_strategy_statechange(int action,
1457 struct zfcp_port *port, 1393 struct zfcp_port *port,
1458 struct zfcp_unit *unit, int retval) 1394 struct zfcp_unit *unit, int retval)
1459{ 1395{
1460 debug_text_event(adapter->erp_dbf, 3, "a_stsc");
1461 debug_event(adapter->erp_dbf, 3, &action, sizeof (int));
1462
1463 switch (action) { 1396 switch (action) {
1464 1397
1465 case ZFCP_ERP_ACTION_REOPEN_ADAPTER: 1398 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
1466 if (zfcp_erp_strategy_statechange_detected(&adapter->status, 1399 if (zfcp_erp_strategy_statechange_detected(&adapter->status,
1467 status)) { 1400 status)) {
1468 zfcp_erp_adapter_reopen_internal(adapter, ZFCP_STATUS_COMMON_ERP_FAILED); 1401 zfcp_erp_adapter_reopen_internal(adapter,
1402 ZFCP_STATUS_COMMON_ERP_FAILED,
1403 67, NULL);
1469 retval = ZFCP_ERP_EXIT; 1404 retval = ZFCP_ERP_EXIT;
1470 } 1405 }
1471 break; 1406 break;
@@ -1474,7 +1409,9 @@ zfcp_erp_strategy_statechange(int action,
1474 case ZFCP_ERP_ACTION_REOPEN_PORT: 1409 case ZFCP_ERP_ACTION_REOPEN_PORT:
1475 if (zfcp_erp_strategy_statechange_detected(&port->status, 1410 if (zfcp_erp_strategy_statechange_detected(&port->status,
1476 status)) { 1411 status)) {
1477 zfcp_erp_port_reopen_internal(port, ZFCP_STATUS_COMMON_ERP_FAILED); 1412 zfcp_erp_port_reopen_internal(port,
1413 ZFCP_STATUS_COMMON_ERP_FAILED,
1414 68, NULL);
1478 retval = ZFCP_ERP_EXIT; 1415 retval = ZFCP_ERP_EXIT;
1479 } 1416 }
1480 break; 1417 break;
@@ -1482,7 +1419,9 @@ zfcp_erp_strategy_statechange(int action,
1482 case ZFCP_ERP_ACTION_REOPEN_UNIT: 1419 case ZFCP_ERP_ACTION_REOPEN_UNIT:
1483 if (zfcp_erp_strategy_statechange_detected(&unit->status, 1420 if (zfcp_erp_strategy_statechange_detected(&unit->status,
1484 status)) { 1421 status)) {
1485 zfcp_erp_unit_reopen_internal(unit, ZFCP_STATUS_COMMON_ERP_FAILED); 1422 zfcp_erp_unit_reopen_internal(unit,
1423 ZFCP_STATUS_COMMON_ERP_FAILED,
1424 69, NULL);
1486 retval = ZFCP_ERP_EXIT; 1425 retval = ZFCP_ERP_EXIT;
1487 } 1426 }
1488 break; 1427 break;
@@ -1506,10 +1445,6 @@ zfcp_erp_strategy_statechange_detected(atomic_t * target_status, u32 erp_status)
1506static int 1445static int
1507zfcp_erp_strategy_check_unit(struct zfcp_unit *unit, int result) 1446zfcp_erp_strategy_check_unit(struct zfcp_unit *unit, int result)
1508{ 1447{
1509 debug_text_event(unit->port->adapter->erp_dbf, 5, "u_stct");
1510 debug_event(unit->port->adapter->erp_dbf, 5, &unit->fcp_lun,
1511 sizeof (fcp_lun_t));
1512
1513 switch (result) { 1448 switch (result) {
1514 case ZFCP_ERP_SUCCEEDED : 1449 case ZFCP_ERP_SUCCEEDED :
1515 atomic_set(&unit->erp_counter, 0); 1450 atomic_set(&unit->erp_counter, 0);
@@ -1518,7 +1453,7 @@ zfcp_erp_strategy_check_unit(struct zfcp_unit *unit, int result)
1518 case ZFCP_ERP_FAILED : 1453 case ZFCP_ERP_FAILED :
1519 atomic_inc(&unit->erp_counter); 1454 atomic_inc(&unit->erp_counter);
1520 if (atomic_read(&unit->erp_counter) > ZFCP_MAX_ERPS) 1455 if (atomic_read(&unit->erp_counter) > ZFCP_MAX_ERPS)
1521 zfcp_erp_unit_failed(unit); 1456 zfcp_erp_unit_failed(unit, 21, NULL);
1522 break; 1457 break;
1523 case ZFCP_ERP_EXIT : 1458 case ZFCP_ERP_EXIT :
1524 /* nothing */ 1459 /* nothing */
@@ -1536,9 +1471,6 @@ zfcp_erp_strategy_check_unit(struct zfcp_unit *unit, int result)
1536static int 1471static int
1537zfcp_erp_strategy_check_port(struct zfcp_port *port, int result) 1472zfcp_erp_strategy_check_port(struct zfcp_port *port, int result)
1538{ 1473{
1539 debug_text_event(port->adapter->erp_dbf, 5, "p_stct");
1540 debug_event(port->adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
1541
1542 switch (result) { 1474 switch (result) {
1543 case ZFCP_ERP_SUCCEEDED : 1475 case ZFCP_ERP_SUCCEEDED :
1544 atomic_set(&port->erp_counter, 0); 1476 atomic_set(&port->erp_counter, 0);
@@ -1547,7 +1479,7 @@ zfcp_erp_strategy_check_port(struct zfcp_port *port, int result)
1547 case ZFCP_ERP_FAILED : 1479 case ZFCP_ERP_FAILED :
1548 atomic_inc(&port->erp_counter); 1480 atomic_inc(&port->erp_counter);
1549 if (atomic_read(&port->erp_counter) > ZFCP_MAX_ERPS) 1481 if (atomic_read(&port->erp_counter) > ZFCP_MAX_ERPS)
1550 zfcp_erp_port_failed(port); 1482 zfcp_erp_port_failed(port, 22, NULL);
1551 break; 1483 break;
1552 case ZFCP_ERP_EXIT : 1484 case ZFCP_ERP_EXIT :
1553 /* nothing */ 1485 /* nothing */
@@ -1565,8 +1497,6 @@ zfcp_erp_strategy_check_port(struct zfcp_port *port, int result)
1565static int 1497static int
1566zfcp_erp_strategy_check_adapter(struct zfcp_adapter *adapter, int result) 1498zfcp_erp_strategy_check_adapter(struct zfcp_adapter *adapter, int result)
1567{ 1499{
1568 debug_text_event(adapter->erp_dbf, 5, "a_stct");
1569
1570 switch (result) { 1500 switch (result) {
1571 case ZFCP_ERP_SUCCEEDED : 1501 case ZFCP_ERP_SUCCEEDED :
1572 atomic_set(&adapter->erp_counter, 0); 1502 atomic_set(&adapter->erp_counter, 0);
@@ -1575,7 +1505,7 @@ zfcp_erp_strategy_check_adapter(struct zfcp_adapter *adapter, int result)
1575 case ZFCP_ERP_FAILED : 1505 case ZFCP_ERP_FAILED :
1576 atomic_inc(&adapter->erp_counter); 1506 atomic_inc(&adapter->erp_counter);
1577 if (atomic_read(&adapter->erp_counter) > ZFCP_MAX_ERPS) 1507 if (atomic_read(&adapter->erp_counter) > ZFCP_MAX_ERPS)
1578 zfcp_erp_adapter_failed(adapter); 1508 zfcp_erp_adapter_failed(adapter, 23, NULL);
1579 break; 1509 break;
1580 case ZFCP_ERP_EXIT : 1510 case ZFCP_ERP_EXIT :
1581 /* nothing */ 1511 /* nothing */
@@ -1658,37 +1588,34 @@ zfcp_erp_strategy_followup_actions(int action,
1658 struct zfcp_port *port, 1588 struct zfcp_port *port,
1659 struct zfcp_unit *unit, int status) 1589 struct zfcp_unit *unit, int status)
1660{ 1590{
1661 debug_text_event(adapter->erp_dbf, 5, "a_stfol");
1662 debug_event(adapter->erp_dbf, 5, &action, sizeof (int));
1663
1664 /* initiate follow-up actions depending on success of finished action */ 1591 /* initiate follow-up actions depending on success of finished action */
1665 switch (action) { 1592 switch (action) {
1666 1593
1667 case ZFCP_ERP_ACTION_REOPEN_ADAPTER: 1594 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
1668 if (status == ZFCP_ERP_SUCCEEDED) 1595 if (status == ZFCP_ERP_SUCCEEDED)
1669 zfcp_erp_port_reopen_all_internal(adapter, 0); 1596 zfcp_erp_port_reopen_all_internal(adapter, 0, 70, NULL);
1670 else 1597 else
1671 zfcp_erp_adapter_reopen_internal(adapter, 0); 1598 zfcp_erp_adapter_reopen_internal(adapter, 0, 71, NULL);
1672 break; 1599 break;
1673 1600
1674 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: 1601 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
1675 if (status == ZFCP_ERP_SUCCEEDED) 1602 if (status == ZFCP_ERP_SUCCEEDED)
1676 zfcp_erp_port_reopen_internal(port, 0); 1603 zfcp_erp_port_reopen_internal(port, 0, 72, NULL);
1677 else 1604 else
1678 zfcp_erp_adapter_reopen_internal(adapter, 0); 1605 zfcp_erp_adapter_reopen_internal(adapter, 0, 73, NULL);
1679 break; 1606 break;
1680 1607
1681 case ZFCP_ERP_ACTION_REOPEN_PORT: 1608 case ZFCP_ERP_ACTION_REOPEN_PORT:
1682 if (status == ZFCP_ERP_SUCCEEDED) 1609 if (status == ZFCP_ERP_SUCCEEDED)
1683 zfcp_erp_unit_reopen_all_internal(port, 0); 1610 zfcp_erp_unit_reopen_all_internal(port, 0, 74, NULL);
1684 else 1611 else
1685 zfcp_erp_port_forced_reopen_internal(port, 0); 1612 zfcp_erp_port_forced_reopen_internal(port, 0, 75, NULL);
1686 break; 1613 break;
1687 1614
1688 case ZFCP_ERP_ACTION_REOPEN_UNIT: 1615 case ZFCP_ERP_ACTION_REOPEN_UNIT:
1689 /* Nothing to do if status == ZFCP_ERP_SUCCEEDED */ 1616 /* Nothing to do if status == ZFCP_ERP_SUCCEEDED */
1690 if (status != ZFCP_ERP_SUCCEEDED) 1617 if (status != ZFCP_ERP_SUCCEEDED)
1691 zfcp_erp_port_reopen_internal(unit->port, 0); 1618 zfcp_erp_port_reopen_internal(unit->port, 0, 76, NULL);
1692 break; 1619 break;
1693 } 1620 }
1694 1621
@@ -1704,12 +1631,10 @@ zfcp_erp_strategy_check_queues(struct zfcp_adapter *adapter)
1704 read_lock(&adapter->erp_lock); 1631 read_lock(&adapter->erp_lock);
1705 if (list_empty(&adapter->erp_ready_head) && 1632 if (list_empty(&adapter->erp_ready_head) &&
1706 list_empty(&adapter->erp_running_head)) { 1633 list_empty(&adapter->erp_running_head)) {
1707 debug_text_event(adapter->erp_dbf, 4, "a_cq_wake");
1708 atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_PENDING, 1634 atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_PENDING,
1709 &adapter->status); 1635 &adapter->status);
1710 wake_up(&adapter->erp_done_wqh); 1636 wake_up(&adapter->erp_done_wqh);
1711 } else 1637 }
1712 debug_text_event(adapter->erp_dbf, 5, "a_cq_notempty");
1713 read_unlock(&adapter->erp_lock); 1638 read_unlock(&adapter->erp_lock);
1714 read_unlock_irqrestore(&zfcp_data.config_lock, flags); 1639 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
1715 1640
@@ -1733,29 +1658,27 @@ zfcp_erp_wait(struct zfcp_adapter *adapter)
1733 return retval; 1658 return retval;
1734} 1659}
1735 1660
1736void 1661void zfcp_erp_modify_adapter_status(struct zfcp_adapter *adapter, u8 id,
1737zfcp_erp_modify_adapter_status(struct zfcp_adapter *adapter, 1662 void *ref, u32 mask, int set_or_clear)
1738 u32 mask, int set_or_clear)
1739{ 1663{
1740 struct zfcp_port *port; 1664 struct zfcp_port *port;
1741 u32 common_mask = mask & ZFCP_COMMON_FLAGS; 1665 u32 changed, common_mask = mask & ZFCP_COMMON_FLAGS;
1742 1666
1743 if (set_or_clear == ZFCP_SET) { 1667 if (set_or_clear == ZFCP_SET) {
1744 atomic_set_mask(mask, &adapter->status); 1668 changed = atomic_test_and_set_mask(mask, &adapter->status);
1745 debug_text_event(adapter->erp_dbf, 3, "a_mod_as_s");
1746 } else { 1669 } else {
1747 atomic_clear_mask(mask, &adapter->status); 1670 changed = atomic_test_and_clear_mask(mask, &adapter->status);
1748 if (mask & ZFCP_STATUS_COMMON_ERP_FAILED) 1671 if (mask & ZFCP_STATUS_COMMON_ERP_FAILED)
1749 atomic_set(&adapter->erp_counter, 0); 1672 atomic_set(&adapter->erp_counter, 0);
1750 debug_text_event(adapter->erp_dbf, 3, "a_mod_as_c");
1751 } 1673 }
1752 debug_event(adapter->erp_dbf, 3, &mask, sizeof (u32)); 1674 if (changed)
1675 zfcp_rec_dbf_event_adapter(id, ref, adapter);
1753 1676
1754 /* Deal with all underlying devices, only pass common_mask */ 1677 /* Deal with all underlying devices, only pass common_mask */
1755 if (common_mask) 1678 if (common_mask)
1756 list_for_each_entry(port, &adapter->port_list_head, list) 1679 list_for_each_entry(port, &adapter->port_list_head, list)
1757 zfcp_erp_modify_port_status(port, common_mask, 1680 zfcp_erp_modify_port_status(port, id, ref, common_mask,
1758 set_or_clear); 1681 set_or_clear);
1759} 1682}
1760 1683
1761/* 1684/*
@@ -1764,29 +1687,27 @@ zfcp_erp_modify_adapter_status(struct zfcp_adapter *adapter,
1764 * purpose: sets the port and all underlying devices to ERP_FAILED 1687 * purpose: sets the port and all underlying devices to ERP_FAILED
1765 * 1688 *
1766 */ 1689 */
1767void 1690void zfcp_erp_modify_port_status(struct zfcp_port *port, u8 id, void *ref,
1768zfcp_erp_modify_port_status(struct zfcp_port *port, u32 mask, int set_or_clear) 1691 u32 mask, int set_or_clear)
1769{ 1692{
1770 struct zfcp_unit *unit; 1693 struct zfcp_unit *unit;
1771 u32 common_mask = mask & ZFCP_COMMON_FLAGS; 1694 u32 changed, common_mask = mask & ZFCP_COMMON_FLAGS;
1772 1695
1773 if (set_or_clear == ZFCP_SET) { 1696 if (set_or_clear == ZFCP_SET) {
1774 atomic_set_mask(mask, &port->status); 1697 changed = atomic_test_and_set_mask(mask, &port->status);
1775 debug_text_event(port->adapter->erp_dbf, 3, "p_mod_ps_s");
1776 } else { 1698 } else {
1777 atomic_clear_mask(mask, &port->status); 1699 changed = atomic_test_and_clear_mask(mask, &port->status);
1778 if (mask & ZFCP_STATUS_COMMON_ERP_FAILED) 1700 if (mask & ZFCP_STATUS_COMMON_ERP_FAILED)
1779 atomic_set(&port->erp_counter, 0); 1701 atomic_set(&port->erp_counter, 0);
1780 debug_text_event(port->adapter->erp_dbf, 3, "p_mod_ps_c");
1781 } 1702 }
1782 debug_event(port->adapter->erp_dbf, 3, &port->wwpn, sizeof (wwn_t)); 1703 if (changed)
1783 debug_event(port->adapter->erp_dbf, 3, &mask, sizeof (u32)); 1704 zfcp_rec_dbf_event_port(id, ref, port);
1784 1705
1785 /* Modify status of all underlying devices, only pass common mask */ 1706 /* Modify status of all underlying devices, only pass common mask */
1786 if (common_mask) 1707 if (common_mask)
1787 list_for_each_entry(unit, &port->unit_list_head, list) 1708 list_for_each_entry(unit, &port->unit_list_head, list)
1788 zfcp_erp_modify_unit_status(unit, common_mask, 1709 zfcp_erp_modify_unit_status(unit, id, ref, common_mask,
1789 set_or_clear); 1710 set_or_clear);
1790} 1711}
1791 1712
1792/* 1713/*
@@ -1795,22 +1716,21 @@ zfcp_erp_modify_port_status(struct zfcp_port *port, u32 mask, int set_or_clear)
1795 * purpose: sets the unit to ERP_FAILED 1716 * purpose: sets the unit to ERP_FAILED
1796 * 1717 *
1797 */ 1718 */
1798void 1719void zfcp_erp_modify_unit_status(struct zfcp_unit *unit, u8 id, void *ref,
1799zfcp_erp_modify_unit_status(struct zfcp_unit *unit, u32 mask, int set_or_clear) 1720 u32 mask, int set_or_clear)
1800{ 1721{
1722 u32 changed;
1723
1801 if (set_or_clear == ZFCP_SET) { 1724 if (set_or_clear == ZFCP_SET) {
1802 atomic_set_mask(mask, &unit->status); 1725 changed = atomic_test_and_set_mask(mask, &unit->status);
1803 debug_text_event(unit->port->adapter->erp_dbf, 3, "u_mod_us_s");
1804 } else { 1726 } else {
1805 atomic_clear_mask(mask, &unit->status); 1727 changed = atomic_test_and_clear_mask(mask, &unit->status);
1806 if (mask & ZFCP_STATUS_COMMON_ERP_FAILED) { 1728 if (mask & ZFCP_STATUS_COMMON_ERP_FAILED) {
1807 atomic_set(&unit->erp_counter, 0); 1729 atomic_set(&unit->erp_counter, 0);
1808 } 1730 }
1809 debug_text_event(unit->port->adapter->erp_dbf, 3, "u_mod_us_c");
1810 } 1731 }
1811 debug_event(unit->port->adapter->erp_dbf, 3, &unit->fcp_lun, 1732 if (changed)
1812 sizeof (fcp_lun_t)); 1733 zfcp_rec_dbf_event_unit(id, ref, unit);
1813 debug_event(unit->port->adapter->erp_dbf, 3, &mask, sizeof (u32));
1814} 1734}
1815 1735
1816/* 1736/*
@@ -1822,30 +1742,32 @@ zfcp_erp_modify_unit_status(struct zfcp_unit *unit, u32 mask, int set_or_clear)
1822 * returns: 0 - initiated action successfully 1742 * returns: 0 - initiated action successfully
1823 * <0 - failed to initiate action 1743 * <0 - failed to initiate action
1824 */ 1744 */
1825int 1745int zfcp_erp_port_reopen_all(struct zfcp_adapter *adapter, int clear_mask,
1826zfcp_erp_port_reopen_all(struct zfcp_adapter *adapter, int clear_mask) 1746 u8 id, void *ref)
1827{ 1747{
1828 int retval; 1748 int retval;
1829 unsigned long flags; 1749 unsigned long flags;
1830 1750
1831 read_lock_irqsave(&zfcp_data.config_lock, flags); 1751 read_lock_irqsave(&zfcp_data.config_lock, flags);
1832 write_lock(&adapter->erp_lock); 1752 write_lock(&adapter->erp_lock);
1833 retval = zfcp_erp_port_reopen_all_internal(adapter, clear_mask); 1753 retval = zfcp_erp_port_reopen_all_internal(adapter, clear_mask, id,
1754 ref);
1834 write_unlock(&adapter->erp_lock); 1755 write_unlock(&adapter->erp_lock);
1835 read_unlock_irqrestore(&zfcp_data.config_lock, flags); 1756 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
1836 1757
1837 return retval; 1758 return retval;
1838} 1759}
1839 1760
1840static int 1761static int zfcp_erp_port_reopen_all_internal(struct zfcp_adapter *adapter,
1841zfcp_erp_port_reopen_all_internal(struct zfcp_adapter *adapter, int clear_mask) 1762 int clear_mask, u8 id, void *ref)
1842{ 1763{
1843 int retval = 0; 1764 int retval = 0;
1844 struct zfcp_port *port; 1765 struct zfcp_port *port;
1845 1766
1846 list_for_each_entry(port, &adapter->port_list_head, list) 1767 list_for_each_entry(port, &adapter->port_list_head, list)
1847 if (!atomic_test_mask(ZFCP_STATUS_PORT_WKA, &port->status)) 1768 if (!atomic_test_mask(ZFCP_STATUS_PORT_WKA, &port->status))
1848 zfcp_erp_port_reopen_internal(port, clear_mask); 1769 zfcp_erp_port_reopen_internal(port, clear_mask, id,
1770 ref);
1849 1771
1850 return retval; 1772 return retval;
1851} 1773}
@@ -1857,14 +1779,14 @@ zfcp_erp_port_reopen_all_internal(struct zfcp_adapter *adapter, int clear_mask)
1857 * 1779 *
1858 * returns: FIXME 1780 * returns: FIXME
1859 */ 1781 */
1860static int 1782static int zfcp_erp_unit_reopen_all_internal(struct zfcp_port *port,
1861zfcp_erp_unit_reopen_all_internal(struct zfcp_port *port, int clear_mask) 1783 int clear_mask, u8 id, void *ref)
1862{ 1784{
1863 int retval = 0; 1785 int retval = 0;
1864 struct zfcp_unit *unit; 1786 struct zfcp_unit *unit;
1865 1787
1866 list_for_each_entry(unit, &port->unit_list_head, list) 1788 list_for_each_entry(unit, &port->unit_list_head, list)
1867 zfcp_erp_unit_reopen_internal(unit, clear_mask); 1789 zfcp_erp_unit_reopen_internal(unit, clear_mask, id, ref);
1868 1790
1869 return retval; 1791 return retval;
1870} 1792}
@@ -1892,10 +1814,6 @@ zfcp_erp_adapter_strategy(struct zfcp_erp_action *erp_action)
1892 else 1814 else
1893 retval = zfcp_erp_adapter_strategy_open(erp_action); 1815 retval = zfcp_erp_adapter_strategy_open(erp_action);
1894 1816
1895 debug_text_event(adapter->erp_dbf, 3, "a_ast/ret");
1896 debug_event(adapter->erp_dbf, 3, &erp_action->action, sizeof (int));
1897 debug_event(adapter->erp_dbf, 3, &retval, sizeof (int));
1898
1899 if (retval == ZFCP_ERP_FAILED) { 1817 if (retval == ZFCP_ERP_FAILED) {
1900 ZFCP_LOG_INFO("Waiting to allow the adapter %s " 1818 ZFCP_LOG_INFO("Waiting to allow the adapter %s "
1901 "to recover itself\n", 1819 "to recover itself\n",
@@ -2021,7 +1939,6 @@ zfcp_erp_adapter_strategy_open_qdio(struct zfcp_erp_action *erp_action)
2021 zfcp_get_busid_by_adapter(adapter)); 1939 zfcp_get_busid_by_adapter(adapter));
2022 goto failed_qdio_establish; 1940 goto failed_qdio_establish;
2023 } 1941 }
2024 debug_text_event(adapter->erp_dbf, 3, "qdio_est");
2025 1942
2026 if (qdio_activate(adapter->ccw_device, 0) != 0) { 1943 if (qdio_activate(adapter->ccw_device, 0) != 0) {
2027 ZFCP_LOG_INFO("error: activation of QDIO queues failed " 1944 ZFCP_LOG_INFO("error: activation of QDIO queues failed "
@@ -2029,7 +1946,6 @@ zfcp_erp_adapter_strategy_open_qdio(struct zfcp_erp_action *erp_action)
2029 zfcp_get_busid_by_adapter(adapter)); 1946 zfcp_get_busid_by_adapter(adapter));
2030 goto failed_qdio_activate; 1947 goto failed_qdio_activate;
2031 } 1948 }
2032 debug_text_event(adapter->erp_dbf, 3, "qdio_act");
2033 1949
2034 /* 1950 /*
2035 * put buffers into response queue, 1951 * put buffers into response queue,
@@ -2077,11 +1993,9 @@ zfcp_erp_adapter_strategy_open_qdio(struct zfcp_erp_action *erp_action)
2077 /* NOP */ 1993 /* NOP */
2078 1994
2079 failed_qdio_activate: 1995 failed_qdio_activate:
2080 debug_text_event(adapter->erp_dbf, 3, "qdio_down1a");
2081 while (qdio_shutdown(adapter->ccw_device, 1996 while (qdio_shutdown(adapter->ccw_device,
2082 QDIO_FLAG_CLEANUP_USING_CLEAR) == -EINPROGRESS) 1997 QDIO_FLAG_CLEANUP_USING_CLEAR) == -EINPROGRESS)
2083 ssleep(1); 1998 ssleep(1);
2084 debug_text_event(adapter->erp_dbf, 3, "qdio_down1b");
2085 1999
2086 failed_qdio_establish: 2000 failed_qdio_establish:
2087 failed_sanity: 2001 failed_sanity:
@@ -2127,14 +2041,12 @@ zfcp_erp_adapter_strategy_open_fsf_xconfig(struct zfcp_erp_action *erp_action)
2127 write_unlock_irq(&adapter->erp_lock); 2041 write_unlock_irq(&adapter->erp_lock);
2128 if (zfcp_fsf_exchange_config_data(erp_action)) { 2042 if (zfcp_fsf_exchange_config_data(erp_action)) {
2129 retval = ZFCP_ERP_FAILED; 2043 retval = ZFCP_ERP_FAILED;
2130 debug_text_event(adapter->erp_dbf, 5, "a_fstx_xf");
2131 ZFCP_LOG_INFO("error: initiation of exchange of " 2044 ZFCP_LOG_INFO("error: initiation of exchange of "
2132 "configuration data failed for " 2045 "configuration data failed for "
2133 "adapter %s\n", 2046 "adapter %s\n",
2134 zfcp_get_busid_by_adapter(adapter)); 2047 zfcp_get_busid_by_adapter(adapter));
2135 break; 2048 break;
2136 } 2049 }
2137 debug_text_event(adapter->erp_dbf, 6, "a_fstx_xok");
2138 ZFCP_LOG_DEBUG("Xchange underway\n"); 2050 ZFCP_LOG_DEBUG("Xchange underway\n");
2139 2051
2140 /* 2052 /*
@@ -2150,7 +2062,9 @@ zfcp_erp_adapter_strategy_open_fsf_xconfig(struct zfcp_erp_action *erp_action)
2150 * _must_ be the one belonging to the 'exchange config 2062 * _must_ be the one belonging to the 'exchange config
2151 * data' request. 2063 * data' request.
2152 */ 2064 */
2065 zfcp_rec_dbf_event_thread(6, adapter, 1);
2153 down(&adapter->erp_ready_sem); 2066 down(&adapter->erp_ready_sem);
2067 zfcp_rec_dbf_event_thread(7, adapter, 1);
2154 if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT) { 2068 if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT) {
2155 ZFCP_LOG_INFO("error: exchange of configuration data " 2069 ZFCP_LOG_INFO("error: exchange of configuration data "
2156 "for adapter %s timed out\n", 2070 "for adapter %s timed out\n",
@@ -2198,16 +2112,15 @@ zfcp_erp_adapter_strategy_open_fsf_xport(struct zfcp_erp_action *erp_action)
2198 2112
2199 ret = zfcp_fsf_exchange_port_data(erp_action); 2113 ret = zfcp_fsf_exchange_port_data(erp_action);
2200 if (ret == -EOPNOTSUPP) { 2114 if (ret == -EOPNOTSUPP) {
2201 debug_text_event(adapter->erp_dbf, 3, "a_xport_notsupp");
2202 return ZFCP_ERP_SUCCEEDED; 2115 return ZFCP_ERP_SUCCEEDED;
2203 } else if (ret) { 2116 } else if (ret) {
2204 debug_text_event(adapter->erp_dbf, 3, "a_xport_failed");
2205 return ZFCP_ERP_FAILED; 2117 return ZFCP_ERP_FAILED;
2206 } 2118 }
2207 debug_text_event(adapter->erp_dbf, 6, "a_xport_ok");
2208 2119
2209 ret = ZFCP_ERP_SUCCEEDED; 2120 ret = ZFCP_ERP_SUCCEEDED;
2121 zfcp_rec_dbf_event_thread(8, adapter, 1);
2210 down(&adapter->erp_ready_sem); 2122 down(&adapter->erp_ready_sem);
2123 zfcp_rec_dbf_event_thread(9, adapter, 1);
2211 if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT) { 2124 if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT) {
2212 ZFCP_LOG_INFO("error: exchange port data timed out (adapter " 2125 ZFCP_LOG_INFO("error: exchange port data timed out (adapter "
2213 "%s)\n", zfcp_get_busid_by_adapter(adapter)); 2126 "%s)\n", zfcp_get_busid_by_adapter(adapter));
@@ -2261,7 +2174,6 @@ zfcp_erp_port_forced_strategy(struct zfcp_erp_action *erp_action)
2261{ 2174{
2262 int retval = ZFCP_ERP_FAILED; 2175 int retval = ZFCP_ERP_FAILED;
2263 struct zfcp_port *port = erp_action->port; 2176 struct zfcp_port *port = erp_action->port;
2264 struct zfcp_adapter *adapter = erp_action->adapter;
2265 2177
2266 switch (erp_action->step) { 2178 switch (erp_action->step) {
2267 2179
@@ -2298,11 +2210,6 @@ zfcp_erp_port_forced_strategy(struct zfcp_erp_action *erp_action)
2298 break; 2210 break;
2299 } 2211 }
2300 2212
2301 debug_text_event(adapter->erp_dbf, 3, "p_pfst/ret");
2302 debug_event(adapter->erp_dbf, 3, &port->wwpn, sizeof (wwn_t));
2303 debug_event(adapter->erp_dbf, 3, &erp_action->action, sizeof (int));
2304 debug_event(adapter->erp_dbf, 3, &retval, sizeof (int));
2305
2306 return retval; 2213 return retval;
2307} 2214}
2308 2215
@@ -2320,7 +2227,6 @@ zfcp_erp_port_strategy(struct zfcp_erp_action *erp_action)
2320{ 2227{
2321 int retval = ZFCP_ERP_FAILED; 2228 int retval = ZFCP_ERP_FAILED;
2322 struct zfcp_port *port = erp_action->port; 2229 struct zfcp_port *port = erp_action->port;
2323 struct zfcp_adapter *adapter = erp_action->adapter;
2324 2230
2325 switch (erp_action->step) { 2231 switch (erp_action->step) {
2326 2232
@@ -2353,11 +2259,6 @@ zfcp_erp_port_strategy(struct zfcp_erp_action *erp_action)
2353 retval = zfcp_erp_port_strategy_open(erp_action); 2259 retval = zfcp_erp_port_strategy_open(erp_action);
2354 2260
2355 out: 2261 out:
2356 debug_text_event(adapter->erp_dbf, 3, "p_pst/ret");
2357 debug_event(adapter->erp_dbf, 3, &port->wwpn, sizeof (wwn_t));
2358 debug_event(adapter->erp_dbf, 3, &erp_action->action, sizeof (int));
2359 debug_event(adapter->erp_dbf, 3, &retval, sizeof (int));
2360
2361 return retval; 2262 return retval;
2362} 2263}
2363 2264
@@ -2395,7 +2296,7 @@ zfcp_erp_port_strategy_open_common(struct zfcp_erp_action *erp_action)
2395 port->wwpn, 2296 port->wwpn,
2396 zfcp_get_busid_by_adapter(adapter), 2297 zfcp_get_busid_by_adapter(adapter),
2397 adapter->peer_wwpn); 2298 adapter->peer_wwpn);
2398 zfcp_erp_port_failed(port); 2299 zfcp_erp_port_failed(port, 25, NULL);
2399 retval = ZFCP_ERP_FAILED; 2300 retval = ZFCP_ERP_FAILED;
2400 break; 2301 break;
2401 } 2302 }
@@ -2421,8 +2322,8 @@ zfcp_erp_port_strategy_open_common(struct zfcp_erp_action *erp_action)
2421 /* nameserver port may live again */ 2322 /* nameserver port may live again */
2422 atomic_set_mask(ZFCP_STATUS_COMMON_RUNNING, 2323 atomic_set_mask(ZFCP_STATUS_COMMON_RUNNING,
2423 &adapter->nameserver_port->status); 2324 &adapter->nameserver_port->status);
2424 if (zfcp_erp_port_reopen(adapter->nameserver_port, 0) 2325 if (zfcp_erp_port_reopen(adapter->nameserver_port, 0,
2425 >= 0) { 2326 77, erp_action) >= 0) {
2426 erp_action->step = 2327 erp_action->step =
2427 ZFCP_ERP_STEP_NAMESERVER_OPEN; 2328 ZFCP_ERP_STEP_NAMESERVER_OPEN;
2428 retval = ZFCP_ERP_CONTINUES; 2329 retval = ZFCP_ERP_CONTINUES;
@@ -2453,7 +2354,7 @@ zfcp_erp_port_strategy_open_common(struct zfcp_erp_action *erp_action)
2453 "for port 0x%016Lx " 2354 "for port 0x%016Lx "
2454 "(misconfigured WWPN?)\n", 2355 "(misconfigured WWPN?)\n",
2455 port->wwpn); 2356 port->wwpn);
2456 zfcp_erp_port_failed(port); 2357 zfcp_erp_port_failed(port, 26, NULL);
2457 retval = ZFCP_ERP_EXIT; 2358 retval = ZFCP_ERP_EXIT;
2458 } else { 2359 } else {
2459 ZFCP_LOG_DEBUG("nameserver look-up failed for " 2360 ZFCP_LOG_DEBUG("nameserver look-up failed for "
@@ -2549,17 +2450,12 @@ zfcp_erp_port_strategy_open_nameserver_wakeup(struct zfcp_erp_action
2549 read_lock_irqsave(&adapter->erp_lock, flags); 2450 read_lock_irqsave(&adapter->erp_lock, flags);
2550 list_for_each_entry_safe(erp_action, tmp, &adapter->erp_running_head, 2451 list_for_each_entry_safe(erp_action, tmp, &adapter->erp_running_head,
2551 list) { 2452 list) {
2552 debug_text_event(adapter->erp_dbf, 4, "p_pstnsw_n");
2553 debug_event(adapter->erp_dbf, 4, &erp_action->port->wwpn,
2554 sizeof (wwn_t));
2555 if (erp_action->step == ZFCP_ERP_STEP_NAMESERVER_OPEN) { 2453 if (erp_action->step == ZFCP_ERP_STEP_NAMESERVER_OPEN) {
2556 debug_text_event(adapter->erp_dbf, 3, "p_pstnsw_w");
2557 debug_event(adapter->erp_dbf, 3,
2558 &erp_action->port->wwpn, sizeof (wwn_t));
2559 if (atomic_test_mask( 2454 if (atomic_test_mask(
2560 ZFCP_STATUS_COMMON_ERP_FAILED, 2455 ZFCP_STATUS_COMMON_ERP_FAILED,
2561 &adapter->nameserver_port->status)) 2456 &adapter->nameserver_port->status))
2562 zfcp_erp_port_failed(erp_action->port); 2457 zfcp_erp_port_failed(erp_action->port, 27,
2458 NULL);
2563 zfcp_erp_action_ready(erp_action); 2459 zfcp_erp_action_ready(erp_action);
2564 } 2460 }
2565 } 2461 }
@@ -2580,26 +2476,18 @@ static int
2580zfcp_erp_port_forced_strategy_close(struct zfcp_erp_action *erp_action) 2476zfcp_erp_port_forced_strategy_close(struct zfcp_erp_action *erp_action)
2581{ 2477{
2582 int retval; 2478 int retval;
2583 struct zfcp_adapter *adapter = erp_action->adapter;
2584 struct zfcp_port *port = erp_action->port;
2585 2479
2586 retval = zfcp_fsf_close_physical_port(erp_action); 2480 retval = zfcp_fsf_close_physical_port(erp_action);
2587 if (retval == -ENOMEM) { 2481 if (retval == -ENOMEM) {
2588 debug_text_event(adapter->erp_dbf, 5, "o_pfstc_nomem");
2589 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2590 retval = ZFCP_ERP_NOMEM; 2482 retval = ZFCP_ERP_NOMEM;
2591 goto out; 2483 goto out;
2592 } 2484 }
2593 erp_action->step = ZFCP_ERP_STEP_PHYS_PORT_CLOSING; 2485 erp_action->step = ZFCP_ERP_STEP_PHYS_PORT_CLOSING;
2594 if (retval != 0) { 2486 if (retval != 0) {
2595 debug_text_event(adapter->erp_dbf, 5, "o_pfstc_cpf");
2596 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2597 /* could not send 'open', fail */ 2487 /* could not send 'open', fail */
2598 retval = ZFCP_ERP_FAILED; 2488 retval = ZFCP_ERP_FAILED;
2599 goto out; 2489 goto out;
2600 } 2490 }
2601 debug_text_event(adapter->erp_dbf, 6, "o_pfstc_cpok");
2602 debug_event(adapter->erp_dbf, 6, &port->wwpn, sizeof (wwn_t));
2603 retval = ZFCP_ERP_CONTINUES; 2491 retval = ZFCP_ERP_CONTINUES;
2604 out: 2492 out:
2605 return retval; 2493 return retval;
@@ -2609,10 +2497,6 @@ static int
2609zfcp_erp_port_strategy_clearstati(struct zfcp_port *port) 2497zfcp_erp_port_strategy_clearstati(struct zfcp_port *port)
2610{ 2498{
2611 int retval = 0; 2499 int retval = 0;
2612 struct zfcp_adapter *adapter = port->adapter;
2613
2614 debug_text_event(adapter->erp_dbf, 5, "p_pstclst");
2615 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2616 2500
2617 atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING | 2501 atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING |
2618 ZFCP_STATUS_COMMON_CLOSING | 2502 ZFCP_STATUS_COMMON_CLOSING |
@@ -2636,26 +2520,18 @@ static int
2636zfcp_erp_port_strategy_close(struct zfcp_erp_action *erp_action) 2520zfcp_erp_port_strategy_close(struct zfcp_erp_action *erp_action)
2637{ 2521{
2638 int retval; 2522 int retval;
2639 struct zfcp_adapter *adapter = erp_action->adapter;
2640 struct zfcp_port *port = erp_action->port;
2641 2523
2642 retval = zfcp_fsf_close_port(erp_action); 2524 retval = zfcp_fsf_close_port(erp_action);
2643 if (retval == -ENOMEM) { 2525 if (retval == -ENOMEM) {
2644 debug_text_event(adapter->erp_dbf, 5, "p_pstc_nomem");
2645 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2646 retval = ZFCP_ERP_NOMEM; 2526 retval = ZFCP_ERP_NOMEM;
2647 goto out; 2527 goto out;
2648 } 2528 }
2649 erp_action->step = ZFCP_ERP_STEP_PORT_CLOSING; 2529 erp_action->step = ZFCP_ERP_STEP_PORT_CLOSING;
2650 if (retval != 0) { 2530 if (retval != 0) {
2651 debug_text_event(adapter->erp_dbf, 5, "p_pstc_cpf");
2652 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2653 /* could not send 'close', fail */ 2531 /* could not send 'close', fail */
2654 retval = ZFCP_ERP_FAILED; 2532 retval = ZFCP_ERP_FAILED;
2655 goto out; 2533 goto out;
2656 } 2534 }
2657 debug_text_event(adapter->erp_dbf, 6, "p_pstc_cpok");
2658 debug_event(adapter->erp_dbf, 6, &port->wwpn, sizeof (wwn_t));
2659 retval = ZFCP_ERP_CONTINUES; 2535 retval = ZFCP_ERP_CONTINUES;
2660 out: 2536 out:
2661 return retval; 2537 return retval;
@@ -2673,26 +2549,18 @@ static int
2673zfcp_erp_port_strategy_open_port(struct zfcp_erp_action *erp_action) 2549zfcp_erp_port_strategy_open_port(struct zfcp_erp_action *erp_action)
2674{ 2550{
2675 int retval; 2551 int retval;
2676 struct zfcp_adapter *adapter = erp_action->adapter;
2677 struct zfcp_port *port = erp_action->port;
2678 2552
2679 retval = zfcp_fsf_open_port(erp_action); 2553 retval = zfcp_fsf_open_port(erp_action);
2680 if (retval == -ENOMEM) { 2554 if (retval == -ENOMEM) {
2681 debug_text_event(adapter->erp_dbf, 5, "p_psto_nomem");
2682 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2683 retval = ZFCP_ERP_NOMEM; 2555 retval = ZFCP_ERP_NOMEM;
2684 goto out; 2556 goto out;
2685 } 2557 }
2686 erp_action->step = ZFCP_ERP_STEP_PORT_OPENING; 2558 erp_action->step = ZFCP_ERP_STEP_PORT_OPENING;
2687 if (retval != 0) { 2559 if (retval != 0) {
2688 debug_text_event(adapter->erp_dbf, 5, "p_psto_opf");
2689 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2690 /* could not send 'open', fail */ 2560 /* could not send 'open', fail */
2691 retval = ZFCP_ERP_FAILED; 2561 retval = ZFCP_ERP_FAILED;
2692 goto out; 2562 goto out;
2693 } 2563 }
2694 debug_text_event(adapter->erp_dbf, 6, "p_psto_opok");
2695 debug_event(adapter->erp_dbf, 6, &port->wwpn, sizeof (wwn_t));
2696 retval = ZFCP_ERP_CONTINUES; 2564 retval = ZFCP_ERP_CONTINUES;
2697 out: 2565 out:
2698 return retval; 2566 return retval;
@@ -2710,26 +2578,18 @@ static int
2710zfcp_erp_port_strategy_open_common_lookup(struct zfcp_erp_action *erp_action) 2578zfcp_erp_port_strategy_open_common_lookup(struct zfcp_erp_action *erp_action)
2711{ 2579{
2712 int retval; 2580 int retval;
2713 struct zfcp_adapter *adapter = erp_action->adapter;
2714 struct zfcp_port *port = erp_action->port;
2715 2581
2716 retval = zfcp_ns_gid_pn_request(erp_action); 2582 retval = zfcp_ns_gid_pn_request(erp_action);
2717 if (retval == -ENOMEM) { 2583 if (retval == -ENOMEM) {
2718 debug_text_event(adapter->erp_dbf, 5, "p_pstn_nomem");
2719 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2720 retval = ZFCP_ERP_NOMEM; 2584 retval = ZFCP_ERP_NOMEM;
2721 goto out; 2585 goto out;
2722 } 2586 }
2723 erp_action->step = ZFCP_ERP_STEP_NAMESERVER_LOOKUP; 2587 erp_action->step = ZFCP_ERP_STEP_NAMESERVER_LOOKUP;
2724 if (retval != 0) { 2588 if (retval != 0) {
2725 debug_text_event(adapter->erp_dbf, 5, "p_pstn_ref");
2726 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
2727 /* could not send nameserver request, fail */ 2589 /* could not send nameserver request, fail */
2728 retval = ZFCP_ERP_FAILED; 2590 retval = ZFCP_ERP_FAILED;
2729 goto out; 2591 goto out;
2730 } 2592 }
2731 debug_text_event(adapter->erp_dbf, 6, "p_pstn_reok");
2732 debug_event(adapter->erp_dbf, 6, &port->wwpn, sizeof (wwn_t));
2733 retval = ZFCP_ERP_CONTINUES; 2593 retval = ZFCP_ERP_CONTINUES;
2734 out: 2594 out:
2735 return retval; 2595 return retval;
@@ -2750,7 +2610,6 @@ zfcp_erp_unit_strategy(struct zfcp_erp_action *erp_action)
2750{ 2610{
2751 int retval = ZFCP_ERP_FAILED; 2611 int retval = ZFCP_ERP_FAILED;
2752 struct zfcp_unit *unit = erp_action->unit; 2612 struct zfcp_unit *unit = erp_action->unit;
2753 struct zfcp_adapter *adapter = erp_action->adapter;
2754 2613
2755 switch (erp_action->step) { 2614 switch (erp_action->step) {
2756 2615
@@ -2797,10 +2656,6 @@ zfcp_erp_unit_strategy(struct zfcp_erp_action *erp_action)
2797 break; 2656 break;
2798 } 2657 }
2799 2658
2800 debug_text_event(adapter->erp_dbf, 3, "u_ust/ret");
2801 debug_event(adapter->erp_dbf, 3, &unit->fcp_lun, sizeof (fcp_lun_t));
2802 debug_event(adapter->erp_dbf, 3, &erp_action->action, sizeof (int));
2803 debug_event(adapter->erp_dbf, 3, &retval, sizeof (int));
2804 return retval; 2659 return retval;
2805} 2660}
2806 2661
@@ -2808,10 +2663,6 @@ static int
2808zfcp_erp_unit_strategy_clearstati(struct zfcp_unit *unit) 2663zfcp_erp_unit_strategy_clearstati(struct zfcp_unit *unit)
2809{ 2664{
2810 int retval = 0; 2665 int retval = 0;
2811 struct zfcp_adapter *adapter = unit->port->adapter;
2812
2813 debug_text_event(adapter->erp_dbf, 5, "u_ustclst");
2814 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun, sizeof (fcp_lun_t));
2815 2666
2816 atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING | 2667 atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING |
2817 ZFCP_STATUS_COMMON_CLOSING | 2668 ZFCP_STATUS_COMMON_CLOSING |
@@ -2835,28 +2686,18 @@ static int
2835zfcp_erp_unit_strategy_close(struct zfcp_erp_action *erp_action) 2686zfcp_erp_unit_strategy_close(struct zfcp_erp_action *erp_action)
2836{ 2687{
2837 int retval; 2688 int retval;
2838 struct zfcp_adapter *adapter = erp_action->adapter;
2839 struct zfcp_unit *unit = erp_action->unit;
2840 2689
2841 retval = zfcp_fsf_close_unit(erp_action); 2690 retval = zfcp_fsf_close_unit(erp_action);
2842 if (retval == -ENOMEM) { 2691 if (retval == -ENOMEM) {
2843 debug_text_event(adapter->erp_dbf, 5, "u_ustc_nomem");
2844 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun,
2845 sizeof (fcp_lun_t));
2846 retval = ZFCP_ERP_NOMEM; 2692 retval = ZFCP_ERP_NOMEM;
2847 goto out; 2693 goto out;
2848 } 2694 }
2849 erp_action->step = ZFCP_ERP_STEP_UNIT_CLOSING; 2695 erp_action->step = ZFCP_ERP_STEP_UNIT_CLOSING;
2850 if (retval != 0) { 2696 if (retval != 0) {
2851 debug_text_event(adapter->erp_dbf, 5, "u_ustc_cuf");
2852 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun,
2853 sizeof (fcp_lun_t));
2854 /* could not send 'close', fail */ 2697 /* could not send 'close', fail */
2855 retval = ZFCP_ERP_FAILED; 2698 retval = ZFCP_ERP_FAILED;
2856 goto out; 2699 goto out;
2857 } 2700 }
2858 debug_text_event(adapter->erp_dbf, 6, "u_ustc_cuok");
2859 debug_event(adapter->erp_dbf, 6, &unit->fcp_lun, sizeof (fcp_lun_t));
2860 retval = ZFCP_ERP_CONTINUES; 2701 retval = ZFCP_ERP_CONTINUES;
2861 2702
2862 out: 2703 out:
@@ -2875,28 +2716,18 @@ static int
2875zfcp_erp_unit_strategy_open(struct zfcp_erp_action *erp_action) 2716zfcp_erp_unit_strategy_open(struct zfcp_erp_action *erp_action)
2876{ 2717{
2877 int retval; 2718 int retval;
2878 struct zfcp_adapter *adapter = erp_action->adapter;
2879 struct zfcp_unit *unit = erp_action->unit;
2880 2719
2881 retval = zfcp_fsf_open_unit(erp_action); 2720 retval = zfcp_fsf_open_unit(erp_action);
2882 if (retval == -ENOMEM) { 2721 if (retval == -ENOMEM) {
2883 debug_text_event(adapter->erp_dbf, 5, "u_usto_nomem");
2884 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun,
2885 sizeof (fcp_lun_t));
2886 retval = ZFCP_ERP_NOMEM; 2722 retval = ZFCP_ERP_NOMEM;
2887 goto out; 2723 goto out;
2888 } 2724 }
2889 erp_action->step = ZFCP_ERP_STEP_UNIT_OPENING; 2725 erp_action->step = ZFCP_ERP_STEP_UNIT_OPENING;
2890 if (retval != 0) { 2726 if (retval != 0) {
2891 debug_text_event(adapter->erp_dbf, 5, "u_usto_ouf");
2892 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun,
2893 sizeof (fcp_lun_t));
2894 /* could not send 'open', fail */ 2727 /* could not send 'open', fail */
2895 retval = ZFCP_ERP_FAILED; 2728 retval = ZFCP_ERP_FAILED;
2896 goto out; 2729 goto out;
2897 } 2730 }
2898 debug_text_event(adapter->erp_dbf, 6, "u_usto_ouok");
2899 debug_event(adapter->erp_dbf, 6, &unit->fcp_lun, sizeof (fcp_lun_t));
2900 retval = ZFCP_ERP_CONTINUES; 2731 retval = ZFCP_ERP_CONTINUES;
2901 out: 2732 out:
2902 return retval; 2733 return retval;
@@ -2918,14 +2749,12 @@ void zfcp_erp_start_timer(struct zfcp_fsf_req *fsf_req)
2918 * 2749 *
2919 * returns: 2750 * returns:
2920 */ 2751 */
2921static int 2752static int zfcp_erp_action_enqueue(int want, struct zfcp_adapter *adapter,
2922zfcp_erp_action_enqueue(int action, 2753 struct zfcp_port *port,
2923 struct zfcp_adapter *adapter, 2754 struct zfcp_unit *unit, u8 id, void *ref)
2924 struct zfcp_port *port, struct zfcp_unit *unit)
2925{ 2755{
2926 int retval = 1; 2756 int retval = 1, need = want;
2927 struct zfcp_erp_action *erp_action = NULL; 2757 struct zfcp_erp_action *erp_action = NULL;
2928 int stronger_action = 0;
2929 u32 status = 0; 2758 u32 status = 0;
2930 2759
2931 /* 2760 /*
@@ -2944,17 +2773,11 @@ zfcp_erp_action_enqueue(int action,
2944 &adapter->status)) 2773 &adapter->status))
2945 return -EIO; 2774 return -EIO;
2946 2775
2947 debug_event(adapter->erp_dbf, 4, &action, sizeof (int));
2948 /* check whether we really need this */ 2776 /* check whether we really need this */
2949 switch (action) { 2777 switch (want) {
2950 case ZFCP_ERP_ACTION_REOPEN_UNIT: 2778 case ZFCP_ERP_ACTION_REOPEN_UNIT:
2951 if (atomic_test_mask 2779 if (atomic_test_mask
2952 (ZFCP_STATUS_COMMON_ERP_INUSE, &unit->status)) { 2780 (ZFCP_STATUS_COMMON_ERP_INUSE, &unit->status)) {
2953 debug_text_event(adapter->erp_dbf, 4, "u_actenq_drp");
2954 debug_event(adapter->erp_dbf, 4, &port->wwpn,
2955 sizeof (wwn_t));
2956 debug_event(adapter->erp_dbf, 4, &unit->fcp_lun,
2957 sizeof (fcp_lun_t));
2958 goto out; 2781 goto out;
2959 } 2782 }
2960 if (!atomic_test_mask 2783 if (!atomic_test_mask
@@ -2964,18 +2787,13 @@ zfcp_erp_action_enqueue(int action,
2964 goto out; 2787 goto out;
2965 } 2788 }
2966 if (!atomic_test_mask 2789 if (!atomic_test_mask
2967 (ZFCP_STATUS_COMMON_UNBLOCKED, &port->status)) { 2790 (ZFCP_STATUS_COMMON_UNBLOCKED, &port->status))
2968 stronger_action = ZFCP_ERP_ACTION_REOPEN_PORT; 2791 need = ZFCP_ERP_ACTION_REOPEN_PORT;
2969 unit = NULL;
2970 }
2971 /* fall through !!! */ 2792 /* fall through !!! */
2972 2793
2973 case ZFCP_ERP_ACTION_REOPEN_PORT: 2794 case ZFCP_ERP_ACTION_REOPEN_PORT:
2974 if (atomic_test_mask 2795 if (atomic_test_mask
2975 (ZFCP_STATUS_COMMON_ERP_INUSE, &port->status)) { 2796 (ZFCP_STATUS_COMMON_ERP_INUSE, &port->status)) {
2976 debug_text_event(adapter->erp_dbf, 4, "p_actenq_drp");
2977 debug_event(adapter->erp_dbf, 4, &port->wwpn,
2978 sizeof (wwn_t));
2979 goto out; 2797 goto out;
2980 } 2798 }
2981 /* fall through !!! */ 2799 /* fall through !!! */
@@ -2987,15 +2805,9 @@ zfcp_erp_action_enqueue(int action,
2987 ZFCP_ERP_ACTION_REOPEN_PORT_FORCED) { 2805 ZFCP_ERP_ACTION_REOPEN_PORT_FORCED) {
2988 ZFCP_LOG_INFO("dropped erp action %i (port " 2806 ZFCP_LOG_INFO("dropped erp action %i (port "
2989 "0x%016Lx, action in use: %i)\n", 2807 "0x%016Lx, action in use: %i)\n",
2990 action, port->wwpn, 2808 want, port->wwpn,
2991 port->erp_action.action); 2809 port->erp_action.action);
2992 debug_text_event(adapter->erp_dbf, 4, 2810 }
2993 "pf_actenq_drp");
2994 } else
2995 debug_text_event(adapter->erp_dbf, 4,
2996 "pf_actenq_drpcp");
2997 debug_event(adapter->erp_dbf, 4, &port->wwpn,
2998 sizeof (wwn_t));
2999 goto out; 2811 goto out;
3000 } 2812 }
3001 if (!atomic_test_mask 2813 if (!atomic_test_mask
@@ -3005,46 +2817,36 @@ zfcp_erp_action_enqueue(int action,
3005 goto out; 2817 goto out;
3006 } 2818 }
3007 if (!atomic_test_mask 2819 if (!atomic_test_mask
3008 (ZFCP_STATUS_COMMON_UNBLOCKED, &adapter->status)) { 2820 (ZFCP_STATUS_COMMON_UNBLOCKED, &adapter->status))
3009 stronger_action = ZFCP_ERP_ACTION_REOPEN_ADAPTER; 2821 need = ZFCP_ERP_ACTION_REOPEN_ADAPTER;
3010 port = NULL;
3011 }
3012 /* fall through !!! */ 2822 /* fall through !!! */
3013 2823
3014 case ZFCP_ERP_ACTION_REOPEN_ADAPTER: 2824 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
3015 if (atomic_test_mask 2825 if (atomic_test_mask
3016 (ZFCP_STATUS_COMMON_ERP_INUSE, &adapter->status)) { 2826 (ZFCP_STATUS_COMMON_ERP_INUSE, &adapter->status)) {
3017 debug_text_event(adapter->erp_dbf, 4, "a_actenq_drp");
3018 goto out; 2827 goto out;
3019 } 2828 }
3020 break; 2829 break;
3021 2830
3022 default: 2831 default:
3023 debug_text_exception(adapter->erp_dbf, 1, "a_actenq_bug");
3024 debug_event(adapter->erp_dbf, 1, &action, sizeof (int));
3025 ZFCP_LOG_NORMAL("bug: unknown erp action requested " 2832 ZFCP_LOG_NORMAL("bug: unknown erp action requested "
3026 "on adapter %s (action=%d)\n", 2833 "on adapter %s (action=%d)\n",
3027 zfcp_get_busid_by_adapter(adapter), action); 2834 zfcp_get_busid_by_adapter(adapter), want);
3028 goto out; 2835 goto out;
3029 } 2836 }
3030 2837
3031 /* check whether we need something stronger first */ 2838 /* check whether we need something stronger first */
3032 if (stronger_action) { 2839 if (need) {
3033 debug_text_event(adapter->erp_dbf, 4, "a_actenq_str");
3034 debug_event(adapter->erp_dbf, 4, &stronger_action,
3035 sizeof (int));
3036 ZFCP_LOG_DEBUG("stronger erp action %d needed before " 2840 ZFCP_LOG_DEBUG("stronger erp action %d needed before "
3037 "erp action %d on adapter %s\n", 2841 "erp action %d on adapter %s\n",
3038 stronger_action, action, 2842 need, want, zfcp_get_busid_by_adapter(adapter));
3039 zfcp_get_busid_by_adapter(adapter));
3040 action = stronger_action;
3041 } 2843 }
3042 2844
3043 /* mark adapter to have some error recovery pending */ 2845 /* mark adapter to have some error recovery pending */
3044 atomic_set_mask(ZFCP_STATUS_ADAPTER_ERP_PENDING, &adapter->status); 2846 atomic_set_mask(ZFCP_STATUS_ADAPTER_ERP_PENDING, &adapter->status);
3045 2847
3046 /* setup error recovery action */ 2848 /* setup error recovery action */
3047 switch (action) { 2849 switch (need) {
3048 2850
3049 case ZFCP_ERP_ACTION_REOPEN_UNIT: 2851 case ZFCP_ERP_ACTION_REOPEN_UNIT:
3050 zfcp_unit_get(unit); 2852 zfcp_unit_get(unit);
@@ -3077,13 +2879,11 @@ zfcp_erp_action_enqueue(int action,
3077 break; 2879 break;
3078 } 2880 }
3079 2881
3080 debug_text_event(adapter->erp_dbf, 4, "a_actenq");
3081
3082 memset(erp_action, 0, sizeof (struct zfcp_erp_action)); 2882 memset(erp_action, 0, sizeof (struct zfcp_erp_action));
3083 erp_action->adapter = adapter; 2883 erp_action->adapter = adapter;
3084 erp_action->port = port; 2884 erp_action->port = port;
3085 erp_action->unit = unit; 2885 erp_action->unit = unit;
3086 erp_action->action = action; 2886 erp_action->action = need;
3087 erp_action->status = status; 2887 erp_action->status = status;
3088 2888
3089 ++adapter->erp_total_count; 2889 ++adapter->erp_total_count;
@@ -3091,8 +2891,11 @@ zfcp_erp_action_enqueue(int action,
3091 /* finally put it into 'ready' queue and kick erp thread */ 2891 /* finally put it into 'ready' queue and kick erp thread */
3092 list_add_tail(&erp_action->list, &adapter->erp_ready_head); 2892 list_add_tail(&erp_action->list, &adapter->erp_ready_head);
3093 up(&adapter->erp_ready_sem); 2893 up(&adapter->erp_ready_sem);
2894 zfcp_rec_dbf_event_thread(1, adapter, 0);
3094 retval = 0; 2895 retval = 0;
3095 out: 2896 out:
2897 zfcp_rec_dbf_event_trigger(id, ref, want, need, erp_action,
2898 adapter, port, unit);
3096 return retval; 2899 return retval;
3097} 2900}
3098 2901
@@ -3108,9 +2911,9 @@ zfcp_erp_action_dequeue(struct zfcp_erp_action *erp_action)
3108 erp_action->status &= ~ZFCP_STATUS_ERP_LOWMEM; 2911 erp_action->status &= ~ZFCP_STATUS_ERP_LOWMEM;
3109 } 2912 }
3110 2913
3111 debug_text_event(adapter->erp_dbf, 4, "a_actdeq");
3112 debug_event(adapter->erp_dbf, 4, &erp_action->action, sizeof (int));
3113 list_del(&erp_action->list); 2914 list_del(&erp_action->list);
2915 zfcp_rec_dbf_event_action(144, erp_action);
2916
3114 switch (erp_action->action) { 2917 switch (erp_action->action) {
3115 case ZFCP_ERP_ACTION_REOPEN_UNIT: 2918 case ZFCP_ERP_ACTION_REOPEN_UNIT:
3116 atomic_clear_mask(ZFCP_STATUS_COMMON_ERP_INUSE, 2919 atomic_clear_mask(ZFCP_STATUS_COMMON_ERP_INUSE,
@@ -3215,7 +3018,6 @@ static void zfcp_erp_action_dismiss_adapter(struct zfcp_adapter *adapter)
3215{ 3018{
3216 struct zfcp_port *port; 3019 struct zfcp_port *port;
3217 3020
3218 debug_text_event(adapter->erp_dbf, 5, "a_actab");
3219 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &adapter->status)) 3021 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &adapter->status))
3220 zfcp_erp_action_dismiss(&adapter->erp_action); 3022 zfcp_erp_action_dismiss(&adapter->erp_action);
3221 else 3023 else
@@ -3226,10 +3028,7 @@ static void zfcp_erp_action_dismiss_adapter(struct zfcp_adapter *adapter)
3226static void zfcp_erp_action_dismiss_port(struct zfcp_port *port) 3028static void zfcp_erp_action_dismiss_port(struct zfcp_port *port)
3227{ 3029{
3228 struct zfcp_unit *unit; 3030 struct zfcp_unit *unit;
3229 struct zfcp_adapter *adapter = port->adapter;
3230 3031
3231 debug_text_event(adapter->erp_dbf, 5, "p_actab");
3232 debug_event(adapter->erp_dbf, 5, &port->wwpn, sizeof (wwn_t));
3233 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &port->status)) 3032 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &port->status))
3234 zfcp_erp_action_dismiss(&port->erp_action); 3033 zfcp_erp_action_dismiss(&port->erp_action);
3235 else 3034 else
@@ -3239,92 +3038,60 @@ static void zfcp_erp_action_dismiss_port(struct zfcp_port *port)
3239 3038
3240static void zfcp_erp_action_dismiss_unit(struct zfcp_unit *unit) 3039static void zfcp_erp_action_dismiss_unit(struct zfcp_unit *unit)
3241{ 3040{
3242 struct zfcp_adapter *adapter = unit->port->adapter;
3243
3244 debug_text_event(adapter->erp_dbf, 5, "u_actab");
3245 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun, sizeof (fcp_lun_t));
3246 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &unit->status)) 3041 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &unit->status))
3247 zfcp_erp_action_dismiss(&unit->erp_action); 3042 zfcp_erp_action_dismiss(&unit->erp_action);
3248} 3043}
3249 3044
3250static void zfcp_erp_action_to_running(struct zfcp_erp_action *erp_action) 3045static void zfcp_erp_action_to_running(struct zfcp_erp_action *erp_action)
3251{ 3046{
3252 struct zfcp_adapter *adapter = erp_action->adapter;
3253
3254 debug_text_event(adapter->erp_dbf, 6, "a_toru");
3255 debug_event(adapter->erp_dbf, 6, &erp_action->action, sizeof (int));
3256 list_move(&erp_action->list, &erp_action->adapter->erp_running_head); 3047 list_move(&erp_action->list, &erp_action->adapter->erp_running_head);
3048 zfcp_rec_dbf_event_action(145, erp_action);
3257} 3049}
3258 3050
3259static void zfcp_erp_action_to_ready(struct zfcp_erp_action *erp_action) 3051static void zfcp_erp_action_to_ready(struct zfcp_erp_action *erp_action)
3260{ 3052{
3261 struct zfcp_adapter *adapter = erp_action->adapter;
3262
3263 debug_text_event(adapter->erp_dbf, 6, "a_tore");
3264 debug_event(adapter->erp_dbf, 6, &erp_action->action, sizeof (int));
3265 list_move(&erp_action->list, &erp_action->adapter->erp_ready_head); 3053 list_move(&erp_action->list, &erp_action->adapter->erp_ready_head);
3054 zfcp_rec_dbf_event_action(146, erp_action);
3266} 3055}
3267 3056
3268void 3057void zfcp_erp_port_boxed(struct zfcp_port *port, u8 id, void *ref)
3269zfcp_erp_port_boxed(struct zfcp_port *port)
3270{ 3058{
3271 struct zfcp_adapter *adapter = port->adapter;
3272 unsigned long flags; 3059 unsigned long flags;
3273 3060
3274 debug_text_event(adapter->erp_dbf, 3, "p_access_boxed");
3275 debug_event(adapter->erp_dbf, 3, &port->wwpn, sizeof(wwn_t));
3276 read_lock_irqsave(&zfcp_data.config_lock, flags); 3061 read_lock_irqsave(&zfcp_data.config_lock, flags);
3277 zfcp_erp_modify_port_status(port, 3062 zfcp_erp_modify_port_status(port, id, ref,
3278 ZFCP_STATUS_COMMON_ACCESS_BOXED, 3063 ZFCP_STATUS_COMMON_ACCESS_BOXED, ZFCP_SET);
3279 ZFCP_SET);
3280 read_unlock_irqrestore(&zfcp_data.config_lock, flags); 3064 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
3281 zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED); 3065 zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED, id, ref);
3282} 3066}
3283 3067
3284void 3068void zfcp_erp_unit_boxed(struct zfcp_unit *unit, u8 id, void *ref)
3285zfcp_erp_unit_boxed(struct zfcp_unit *unit)
3286{ 3069{
3287 struct zfcp_adapter *adapter = unit->port->adapter; 3070 zfcp_erp_modify_unit_status(unit, id, ref,
3288 3071 ZFCP_STATUS_COMMON_ACCESS_BOXED, ZFCP_SET);
3289 debug_text_event(adapter->erp_dbf, 3, "u_access_boxed"); 3072 zfcp_erp_unit_reopen(unit, ZFCP_STATUS_COMMON_ERP_FAILED, id, ref);
3290 debug_event(adapter->erp_dbf, 3, &unit->fcp_lun, sizeof(fcp_lun_t));
3291 zfcp_erp_modify_unit_status(unit,
3292 ZFCP_STATUS_COMMON_ACCESS_BOXED,
3293 ZFCP_SET);
3294 zfcp_erp_unit_reopen(unit, ZFCP_STATUS_COMMON_ERP_FAILED);
3295} 3073}
3296 3074
3297void 3075void zfcp_erp_port_access_denied(struct zfcp_port *port, u8 id, void *ref)
3298zfcp_erp_port_access_denied(struct zfcp_port *port)
3299{ 3076{
3300 struct zfcp_adapter *adapter = port->adapter;
3301 unsigned long flags; 3077 unsigned long flags;
3302 3078
3303 debug_text_event(adapter->erp_dbf, 3, "p_access_denied");
3304 debug_event(adapter->erp_dbf, 3, &port->wwpn, sizeof(wwn_t));
3305 read_lock_irqsave(&zfcp_data.config_lock, flags); 3079 read_lock_irqsave(&zfcp_data.config_lock, flags);
3306 zfcp_erp_modify_port_status(port, 3080 zfcp_erp_modify_port_status(port, id, ref,
3307 ZFCP_STATUS_COMMON_ERP_FAILED | 3081 ZFCP_STATUS_COMMON_ERP_FAILED |
3308 ZFCP_STATUS_COMMON_ACCESS_DENIED, 3082 ZFCP_STATUS_COMMON_ACCESS_DENIED, ZFCP_SET);
3309 ZFCP_SET);
3310 read_unlock_irqrestore(&zfcp_data.config_lock, flags); 3083 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
3311} 3084}
3312 3085
3313void 3086void zfcp_erp_unit_access_denied(struct zfcp_unit *unit, u8 id, void *ref)
3314zfcp_erp_unit_access_denied(struct zfcp_unit *unit)
3315{ 3087{
3316 struct zfcp_adapter *adapter = unit->port->adapter; 3088 zfcp_erp_modify_unit_status(unit, id, ref,
3317 3089 ZFCP_STATUS_COMMON_ERP_FAILED |
3318 debug_text_event(adapter->erp_dbf, 3, "u_access_denied"); 3090 ZFCP_STATUS_COMMON_ACCESS_DENIED, ZFCP_SET);
3319 debug_event(adapter->erp_dbf, 3, &unit->fcp_lun, sizeof(fcp_lun_t));
3320 zfcp_erp_modify_unit_status(unit,
3321 ZFCP_STATUS_COMMON_ERP_FAILED |
3322 ZFCP_STATUS_COMMON_ACCESS_DENIED,
3323 ZFCP_SET);
3324} 3091}
3325 3092
3326void 3093void zfcp_erp_adapter_access_changed(struct zfcp_adapter *adapter, u8 id,
3327zfcp_erp_adapter_access_changed(struct zfcp_adapter *adapter) 3094 void *ref)
3328{ 3095{
3329 struct zfcp_port *port; 3096 struct zfcp_port *port;
3330 unsigned long flags; 3097 unsigned long flags;
@@ -3332,54 +3099,43 @@ zfcp_erp_adapter_access_changed(struct zfcp_adapter *adapter)
3332 if (adapter->connection_features & FSF_FEATURE_NPIV_MODE) 3099 if (adapter->connection_features & FSF_FEATURE_NPIV_MODE)
3333 return; 3100 return;
3334 3101
3335 debug_text_event(adapter->erp_dbf, 3, "a_access_recover");
3336 debug_event(adapter->erp_dbf, 3, zfcp_get_busid_by_adapter(adapter), 8);
3337
3338 read_lock_irqsave(&zfcp_data.config_lock, flags); 3102 read_lock_irqsave(&zfcp_data.config_lock, flags);
3339 if (adapter->nameserver_port) 3103 if (adapter->nameserver_port)
3340 zfcp_erp_port_access_changed(adapter->nameserver_port); 3104 zfcp_erp_port_access_changed(adapter->nameserver_port, id, ref);
3341 list_for_each_entry(port, &adapter->port_list_head, list) 3105 list_for_each_entry(port, &adapter->port_list_head, list)
3342 if (port != adapter->nameserver_port) 3106 if (port != adapter->nameserver_port)
3343 zfcp_erp_port_access_changed(port); 3107 zfcp_erp_port_access_changed(port, id, ref);
3344 read_unlock_irqrestore(&zfcp_data.config_lock, flags); 3108 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
3345} 3109}
3346 3110
3347void 3111void zfcp_erp_port_access_changed(struct zfcp_port *port, u8 id, void *ref)
3348zfcp_erp_port_access_changed(struct zfcp_port *port)
3349{ 3112{
3350 struct zfcp_adapter *adapter = port->adapter; 3113 struct zfcp_adapter *adapter = port->adapter;
3351 struct zfcp_unit *unit; 3114 struct zfcp_unit *unit;
3352 3115
3353 debug_text_event(adapter->erp_dbf, 3, "p_access_recover");
3354 debug_event(adapter->erp_dbf, 3, &port->wwpn, sizeof(wwn_t));
3355
3356 if (!atomic_test_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED, 3116 if (!atomic_test_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED,
3357 &port->status) && 3117 &port->status) &&
3358 !atomic_test_mask(ZFCP_STATUS_COMMON_ACCESS_BOXED, 3118 !atomic_test_mask(ZFCP_STATUS_COMMON_ACCESS_BOXED,
3359 &port->status)) { 3119 &port->status)) {
3360 if (!atomic_test_mask(ZFCP_STATUS_PORT_WKA, &port->status)) 3120 if (!atomic_test_mask(ZFCP_STATUS_PORT_WKA, &port->status))
3361 list_for_each_entry(unit, &port->unit_list_head, list) 3121 list_for_each_entry(unit, &port->unit_list_head, list)
3362 zfcp_erp_unit_access_changed(unit); 3122 zfcp_erp_unit_access_changed(unit, id, ref);
3363 return; 3123 return;
3364 } 3124 }
3365 3125
3366 ZFCP_LOG_NORMAL("reopen of port 0x%016Lx on adapter %s " 3126 ZFCP_LOG_NORMAL("reopen of port 0x%016Lx on adapter %s "
3367 "(due to ACT update)\n", 3127 "(due to ACT update)\n",
3368 port->wwpn, zfcp_get_busid_by_adapter(adapter)); 3128 port->wwpn, zfcp_get_busid_by_adapter(adapter));
3369 if (zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED) != 0) 3129 if (zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED, id, ref))
3370 ZFCP_LOG_NORMAL("failed reopen of port" 3130 ZFCP_LOG_NORMAL("failed reopen of port"
3371 "(adapter %s, wwpn=0x%016Lx)\n", 3131 "(adapter %s, wwpn=0x%016Lx)\n",
3372 zfcp_get_busid_by_adapter(adapter), port->wwpn); 3132 zfcp_get_busid_by_adapter(adapter), port->wwpn);
3373} 3133}
3374 3134
3375void 3135void zfcp_erp_unit_access_changed(struct zfcp_unit *unit, u8 id, void *ref)
3376zfcp_erp_unit_access_changed(struct zfcp_unit *unit)
3377{ 3136{
3378 struct zfcp_adapter *adapter = unit->port->adapter; 3137 struct zfcp_adapter *adapter = unit->port->adapter;
3379 3138
3380 debug_text_event(adapter->erp_dbf, 3, "u_access_recover");
3381 debug_event(adapter->erp_dbf, 3, &unit->fcp_lun, sizeof(fcp_lun_t));
3382
3383 if (!atomic_test_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED, 3139 if (!atomic_test_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED,
3384 &unit->status) && 3140 &unit->status) &&
3385 !atomic_test_mask(ZFCP_STATUS_COMMON_ACCESS_BOXED, 3141 !atomic_test_mask(ZFCP_STATUS_COMMON_ACCESS_BOXED,
@@ -3390,7 +3146,7 @@ zfcp_erp_unit_access_changed(struct zfcp_unit *unit)
3390 " on adapter %s (due to ACT update)\n", 3146 " on adapter %s (due to ACT update)\n",
3391 unit->fcp_lun, unit->port->wwpn, 3147 unit->fcp_lun, unit->port->wwpn,
3392 zfcp_get_busid_by_adapter(adapter)); 3148 zfcp_get_busid_by_adapter(adapter));
3393 if (zfcp_erp_unit_reopen(unit, ZFCP_STATUS_COMMON_ERP_FAILED) != 0) 3149 if (zfcp_erp_unit_reopen(unit, ZFCP_STATUS_COMMON_ERP_FAILED, id, ref))
3394 ZFCP_LOG_NORMAL("failed reopen of unit (adapter %s, " 3150 ZFCP_LOG_NORMAL("failed reopen of unit (adapter %s, "
3395 "wwpn=0x%016Lx, fcp_lun=0x%016Lx)\n", 3151 "wwpn=0x%016Lx, fcp_lun=0x%016Lx)\n",
3396 zfcp_get_busid_by_adapter(adapter), 3152 zfcp_get_busid_by_adapter(adapter),