hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/s390/scsi/zfcp_erp.c
....@@ -4,7 +4,7 @@
44 *
55 * Error Recovery Procedures (ERP).
66 *
7
- * Copyright IBM Corp. 2002, 2016
7
+ * Copyright IBM Corp. 2002, 2020
88 */
99
1010 #define KMSG_COMPONENT "zfcp"
....@@ -14,6 +14,7 @@
1414 #include <linux/bug.h>
1515 #include "zfcp_ext.h"
1616 #include "zfcp_reqlist.h"
17
+#include "zfcp_diag.h"
1718
1819 #define ZFCP_MAX_ERPS 3
1920
....@@ -25,38 +26,18 @@
2526 ZFCP_STATUS_ERP_NO_REF = 0x00800000,
2627 };
2728
28
-enum zfcp_erp_steps {
29
- ZFCP_ERP_STEP_UNINITIALIZED = 0x0000,
30
- ZFCP_ERP_STEP_PHYS_PORT_CLOSING = 0x0010,
31
- ZFCP_ERP_STEP_PORT_CLOSING = 0x0100,
32
- ZFCP_ERP_STEP_PORT_OPENING = 0x0800,
33
- ZFCP_ERP_STEP_LUN_CLOSING = 0x1000,
34
- ZFCP_ERP_STEP_LUN_OPENING = 0x2000,
35
-};
36
-
37
-/**
38
- * enum zfcp_erp_act_type - Type of ERP action object.
39
- * @ZFCP_ERP_ACTION_REOPEN_LUN: LUN recovery.
40
- * @ZFCP_ERP_ACTION_REOPEN_PORT: Port recovery.
41
- * @ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: Forced port recovery.
42
- * @ZFCP_ERP_ACTION_REOPEN_ADAPTER: Adapter recovery.
43
- * @ZFCP_ERP_ACTION_NONE: Eyecatcher pseudo flag to bitwise or-combine with
44
- * either of the first four enum values.
45
- * Used to indicate that an ERP action could not be
46
- * set up despite a detected need for some recovery.
47
- * @ZFCP_ERP_ACTION_FAILED: Eyecatcher pseudo flag to bitwise or-combine with
48
- * either of the first four enum values.
49
- * Used to indicate that ERP not needed because
50
- * the object has ZFCP_STATUS_COMMON_ERP_FAILED.
29
+/*
30
+ * Eyecatcher pseudo flag to bitwise or-combine with enum zfcp_erp_act_type.
31
+ * Used to indicate that an ERP action could not be set up despite a detected
32
+ * need for some recovery.
5133 */
52
-enum zfcp_erp_act_type {
53
- ZFCP_ERP_ACTION_REOPEN_LUN = 1,
54
- ZFCP_ERP_ACTION_REOPEN_PORT = 2,
55
- ZFCP_ERP_ACTION_REOPEN_PORT_FORCED = 3,
56
- ZFCP_ERP_ACTION_REOPEN_ADAPTER = 4,
57
- ZFCP_ERP_ACTION_NONE = 0xc0,
58
- ZFCP_ERP_ACTION_FAILED = 0xe0,
59
-};
34
+#define ZFCP_ERP_ACTION_NONE 0xc0
35
+/*
36
+ * Eyecatcher pseudo flag to bitwise or-combine with enum zfcp_erp_act_type.
37
+ * Used to indicate that ERP not needed because the object has
38
+ * ZFCP_STATUS_COMMON_ERP_FAILED.
39
+ */
40
+#define ZFCP_ERP_ACTION_FAILED 0xe0
6041
6142 enum zfcp_erp_act_result {
6243 ZFCP_ERP_SUCCEEDED = 0,
....@@ -87,7 +68,7 @@
8768 {
8869 struct zfcp_adapter *adapter = act->adapter;
8970
90
- list_move(&act->list, &act->adapter->erp_ready_head);
71
+ list_move(&act->list, &adapter->erp_ready_head);
9172 zfcp_dbf_rec_run("erardy1", act);
9273 wake_up(&adapter->erp_ready_wq);
9374 zfcp_dbf_rec_run("erardy2", act);
....@@ -137,11 +118,11 @@
137118 }
138119 }
139120
140
-static int zfcp_erp_handle_failed(int want, struct zfcp_adapter *adapter,
141
- struct zfcp_port *port,
142
- struct scsi_device *sdev)
121
+static enum zfcp_erp_act_type zfcp_erp_handle_failed(
122
+ enum zfcp_erp_act_type want, struct zfcp_adapter *adapter,
123
+ struct zfcp_port *port, struct scsi_device *sdev)
143124 {
144
- int need = want;
125
+ enum zfcp_erp_act_type need = want;
145126 struct zfcp_scsi_dev *zsdev;
146127
147128 switch (want) {
....@@ -177,11 +158,12 @@
177158 return need;
178159 }
179160
180
-static int zfcp_erp_required_act(int want, struct zfcp_adapter *adapter,
161
+static enum zfcp_erp_act_type zfcp_erp_required_act(enum zfcp_erp_act_type want,
162
+ struct zfcp_adapter *adapter,
181163 struct zfcp_port *port,
182164 struct scsi_device *sdev)
183165 {
184
- int need = want;
166
+ enum zfcp_erp_act_type need = want;
185167 int l_status, p_status, a_status;
186168 struct zfcp_scsi_dev *zfcp_sdev;
187169
....@@ -193,29 +175,29 @@
193175 return 0;
194176 p_status = atomic_read(&port->status);
195177 if (!(p_status & ZFCP_STATUS_COMMON_RUNNING) ||
196
- p_status & ZFCP_STATUS_COMMON_ERP_FAILED)
178
+ p_status & ZFCP_STATUS_COMMON_ERP_FAILED)
197179 return 0;
198180 if (!(p_status & ZFCP_STATUS_COMMON_UNBLOCKED))
199181 need = ZFCP_ERP_ACTION_REOPEN_PORT;
200
- /* fall through */
182
+ fallthrough;
201183 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
202184 p_status = atomic_read(&port->status);
203185 if (!(p_status & ZFCP_STATUS_COMMON_OPEN))
204186 need = ZFCP_ERP_ACTION_REOPEN_PORT;
205
- /* fall through */
187
+ fallthrough;
206188 case ZFCP_ERP_ACTION_REOPEN_PORT:
207189 p_status = atomic_read(&port->status);
208190 if (p_status & ZFCP_STATUS_COMMON_ERP_INUSE)
209191 return 0;
210192 a_status = atomic_read(&adapter->status);
211193 if (!(a_status & ZFCP_STATUS_COMMON_RUNNING) ||
212
- a_status & ZFCP_STATUS_COMMON_ERP_FAILED)
194
+ a_status & ZFCP_STATUS_COMMON_ERP_FAILED)
213195 return 0;
214196 if (p_status & ZFCP_STATUS_COMMON_NOESC)
215197 return need;
216198 if (!(a_status & ZFCP_STATUS_COMMON_UNBLOCKED))
217199 need = ZFCP_ERP_ACTION_REOPEN_ADAPTER;
218
- /* fall through */
200
+ fallthrough;
219201 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
220202 a_status = atomic_read(&adapter->status);
221203 if (a_status & ZFCP_STATUS_COMMON_ERP_INUSE)
....@@ -228,7 +210,8 @@
228210 return need;
229211 }
230212
231
-static struct zfcp_erp_action *zfcp_erp_setup_act(int need, u32 act_status,
213
+static struct zfcp_erp_action *zfcp_erp_setup_act(enum zfcp_erp_act_type need,
214
+ u32 act_status,
232215 struct zfcp_adapter *adapter,
233216 struct zfcp_port *port,
234217 struct scsi_device *sdev)
....@@ -282,9 +265,6 @@
282265 ZFCP_STATUS_COMMON_RUNNING))
283266 act_status |= ZFCP_STATUS_ERP_CLOSE_ONLY;
284267 break;
285
-
286
- default:
287
- return NULL;
288268 }
289269
290270 WARN_ON_ONCE(erp_action->adapter != adapter);
....@@ -292,18 +272,19 @@
292272 memset(&erp_action->timer, 0, sizeof(erp_action->timer));
293273 erp_action->step = ZFCP_ERP_STEP_UNINITIALIZED;
294274 erp_action->fsf_req_id = 0;
295
- erp_action->action = need;
275
+ erp_action->type = need;
296276 erp_action->status = act_status;
297277
298278 return erp_action;
299279 }
300280
301
-static void zfcp_erp_action_enqueue(int want, struct zfcp_adapter *adapter,
281
+static void zfcp_erp_action_enqueue(enum zfcp_erp_act_type want,
282
+ struct zfcp_adapter *adapter,
302283 struct zfcp_port *port,
303284 struct scsi_device *sdev,
304
- char *id, u32 act_status)
285
+ char *dbftag, u32 act_status)
305286 {
306
- int need;
287
+ enum zfcp_erp_act_type need;
307288 struct zfcp_erp_action *act;
308289
309290 need = zfcp_erp_handle_failed(want, adapter, port, sdev);
....@@ -331,10 +312,11 @@
331312 list_add_tail(&act->list, &adapter->erp_ready_head);
332313 wake_up(&adapter->erp_ready_wq);
333314 out:
334
- zfcp_dbf_rec_trig(id, adapter, port, sdev, want, need);
315
+ zfcp_dbf_rec_trig(dbftag, adapter, port, sdev, want, need);
335316 }
336317
337
-void zfcp_erp_port_forced_no_port_dbf(char *id, struct zfcp_adapter *adapter,
318
+void zfcp_erp_port_forced_no_port_dbf(char *dbftag,
319
+ struct zfcp_adapter *adapter,
338320 u64 port_name, u32 port_id)
339321 {
340322 unsigned long flags;
....@@ -348,29 +330,30 @@
348330 atomic_set(&tmpport.status, -1); /* unknown */
349331 tmpport.wwpn = port_name;
350332 tmpport.d_id = port_id;
351
- zfcp_dbf_rec_trig(id, adapter, &tmpport, NULL,
333
+ zfcp_dbf_rec_trig(dbftag, adapter, &tmpport, NULL,
352334 ZFCP_ERP_ACTION_REOPEN_PORT_FORCED,
353335 ZFCP_ERP_ACTION_NONE);
354336 write_unlock_irqrestore(&adapter->erp_lock, flags);
355337 }
356338
357339 static void _zfcp_erp_adapter_reopen(struct zfcp_adapter *adapter,
358
- int clear_mask, char *id)
340
+ int clear_mask, char *dbftag)
359341 {
360342 zfcp_erp_adapter_block(adapter, clear_mask);
361343 zfcp_scsi_schedule_rports_block(adapter);
362344
363345 zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_ADAPTER,
364
- adapter, NULL, NULL, id, 0);
346
+ adapter, NULL, NULL, dbftag, 0);
365347 }
366348
367349 /**
368350 * zfcp_erp_adapter_reopen - Reopen adapter.
369351 * @adapter: Adapter to reopen.
370352 * @clear: Status flags to clear.
371
- * @id: Id for debug trace event.
353
+ * @dbftag: Tag for debug trace event.
372354 */
373
-void zfcp_erp_adapter_reopen(struct zfcp_adapter *adapter, int clear, char *id)
355
+void zfcp_erp_adapter_reopen(struct zfcp_adapter *adapter, int clear,
356
+ char *dbftag)
374357 {
375358 unsigned long flags;
376359
....@@ -379,7 +362,7 @@
379362
380363 write_lock_irqsave(&adapter->erp_lock, flags);
381364 zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_ADAPTER, adapter,
382
- NULL, NULL, id, 0);
365
+ NULL, NULL, dbftag, 0);
383366 write_unlock_irqrestore(&adapter->erp_lock, flags);
384367 }
385368
....@@ -387,25 +370,25 @@
387370 * zfcp_erp_adapter_shutdown - Shutdown adapter.
388371 * @adapter: Adapter to shut down.
389372 * @clear: Status flags to clear.
390
- * @id: Id for debug trace event.
373
+ * @dbftag: Tag for debug trace event.
391374 */
392375 void zfcp_erp_adapter_shutdown(struct zfcp_adapter *adapter, int clear,
393
- char *id)
376
+ char *dbftag)
394377 {
395378 int flags = ZFCP_STATUS_COMMON_RUNNING | ZFCP_STATUS_COMMON_ERP_FAILED;
396
- zfcp_erp_adapter_reopen(adapter, clear | flags, id);
379
+ zfcp_erp_adapter_reopen(adapter, clear | flags, dbftag);
397380 }
398381
399382 /**
400383 * zfcp_erp_port_shutdown - Shutdown port
401384 * @port: Port to shut down.
402385 * @clear: Status flags to clear.
403
- * @id: Id for debug trace event.
386
+ * @dbftag: Tag for debug trace event.
404387 */
405
-void zfcp_erp_port_shutdown(struct zfcp_port *port, int clear, char *id)
388
+void zfcp_erp_port_shutdown(struct zfcp_port *port, int clear, char *dbftag)
406389 {
407390 int flags = ZFCP_STATUS_COMMON_RUNNING | ZFCP_STATUS_COMMON_ERP_FAILED;
408
- zfcp_erp_port_reopen(port, clear | flags, id);
391
+ zfcp_erp_port_reopen(port, clear | flags, dbftag);
409392 }
410393
411394 static void zfcp_erp_port_block(struct zfcp_port *port, int clear)
....@@ -415,53 +398,55 @@
415398 }
416399
417400 static void _zfcp_erp_port_forced_reopen(struct zfcp_port *port, int clear,
418
- char *id)
401
+ char *dbftag)
419402 {
420403 zfcp_erp_port_block(port, clear);
421404 zfcp_scsi_schedule_rport_block(port);
422405
423406 zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_PORT_FORCED,
424
- port->adapter, port, NULL, id, 0);
407
+ port->adapter, port, NULL, dbftag, 0);
425408 }
426409
427410 /**
428411 * zfcp_erp_port_forced_reopen - Forced close of port and open again
429412 * @port: Port to force close and to reopen.
430413 * @clear: Status flags to clear.
431
- * @id: Id for debug trace event.
414
+ * @dbftag: Tag for debug trace event.
432415 */
433
-void zfcp_erp_port_forced_reopen(struct zfcp_port *port, int clear, char *id)
416
+void zfcp_erp_port_forced_reopen(struct zfcp_port *port, int clear,
417
+ char *dbftag)
434418 {
435419 unsigned long flags;
436420 struct zfcp_adapter *adapter = port->adapter;
437421
438422 write_lock_irqsave(&adapter->erp_lock, flags);
439
- _zfcp_erp_port_forced_reopen(port, clear, id);
423
+ _zfcp_erp_port_forced_reopen(port, clear, dbftag);
440424 write_unlock_irqrestore(&adapter->erp_lock, flags);
441425 }
442426
443
-static void _zfcp_erp_port_reopen(struct zfcp_port *port, int clear, char *id)
427
+static void _zfcp_erp_port_reopen(struct zfcp_port *port, int clear,
428
+ char *dbftag)
444429 {
445430 zfcp_erp_port_block(port, clear);
446431 zfcp_scsi_schedule_rport_block(port);
447432
448433 zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_PORT,
449
- port->adapter, port, NULL, id, 0);
434
+ port->adapter, port, NULL, dbftag, 0);
450435 }
451436
452437 /**
453438 * zfcp_erp_port_reopen - trigger remote port recovery
454439 * @port: port to recover
455
- * @clear_mask: flags in port status to be cleared
456
- * @id: Id for debug trace event.
440
+ * @clear: flags in port status to be cleared
441
+ * @dbftag: Tag for debug trace event.
457442 */
458
-void zfcp_erp_port_reopen(struct zfcp_port *port, int clear, char *id)
443
+void zfcp_erp_port_reopen(struct zfcp_port *port, int clear, char *dbftag)
459444 {
460445 unsigned long flags;
461446 struct zfcp_adapter *adapter = port->adapter;
462447
463448 write_lock_irqsave(&adapter->erp_lock, flags);
464
- _zfcp_erp_port_reopen(port, clear, id);
449
+ _zfcp_erp_port_reopen(port, clear, dbftag);
465450 write_unlock_irqrestore(&adapter->erp_lock, flags);
466451 }
467452
....@@ -471,8 +456,8 @@
471456 ZFCP_STATUS_COMMON_UNBLOCKED | clear_mask);
472457 }
473458
474
-static void _zfcp_erp_lun_reopen(struct scsi_device *sdev, int clear, char *id,
475
- u32 act_status)
459
+static void _zfcp_erp_lun_reopen(struct scsi_device *sdev, int clear,
460
+ char *dbftag, u32 act_status)
476461 {
477462 struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev);
478463 struct zfcp_adapter *adapter = zfcp_sdev->port->adapter;
....@@ -480,18 +465,18 @@
480465 zfcp_erp_lun_block(sdev, clear);
481466
482467 zfcp_erp_action_enqueue(ZFCP_ERP_ACTION_REOPEN_LUN, adapter,
483
- zfcp_sdev->port, sdev, id, act_status);
468
+ zfcp_sdev->port, sdev, dbftag, act_status);
484469 }
485470
486471 /**
487472 * zfcp_erp_lun_reopen - initiate reopen of a LUN
488473 * @sdev: SCSI device / LUN to be reopened
489
- * @clear_mask: specifies flags in LUN status to be cleared
490
- * @id: Id for debug trace event.
474
+ * @clear: specifies flags in LUN status to be cleared
475
+ * @dbftag: Tag for debug trace event.
491476 *
492477 * Return: 0 on success, < 0 on error
493478 */
494
-void zfcp_erp_lun_reopen(struct scsi_device *sdev, int clear, char *id)
479
+void zfcp_erp_lun_reopen(struct scsi_device *sdev, int clear, char *dbftag)
495480 {
496481 unsigned long flags;
497482 struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev);
....@@ -499,7 +484,7 @@
499484 struct zfcp_adapter *adapter = port->adapter;
500485
501486 write_lock_irqsave(&adapter->erp_lock, flags);
502
- _zfcp_erp_lun_reopen(sdev, clear, id, 0);
487
+ _zfcp_erp_lun_reopen(sdev, clear, dbftag, 0);
503488 write_unlock_irqrestore(&adapter->erp_lock, flags);
504489 }
505490
....@@ -507,25 +492,25 @@
507492 * zfcp_erp_lun_shutdown - Shutdown LUN
508493 * @sdev: SCSI device / LUN to shut down.
509494 * @clear: Status flags to clear.
510
- * @id: Id for debug trace event.
495
+ * @dbftag: Tag for debug trace event.
511496 */
512
-void zfcp_erp_lun_shutdown(struct scsi_device *sdev, int clear, char *id)
497
+void zfcp_erp_lun_shutdown(struct scsi_device *sdev, int clear, char *dbftag)
513498 {
514499 int flags = ZFCP_STATUS_COMMON_RUNNING | ZFCP_STATUS_COMMON_ERP_FAILED;
515
- zfcp_erp_lun_reopen(sdev, clear | flags, id);
500
+ zfcp_erp_lun_reopen(sdev, clear | flags, dbftag);
516501 }
517502
518503 /**
519504 * zfcp_erp_lun_shutdown_wait - Shutdown LUN and wait for erp completion
520505 * @sdev: SCSI device / LUN to shut down.
521
- * @id: Id for debug trace event.
506
+ * @dbftag: Tag for debug trace event.
522507 *
523508 * Do not acquire a reference for the LUN when creating the ERP
524509 * action. It is safe, because this function waits for the ERP to
525510 * complete first. This allows to shutdown the LUN, even when the SCSI
526511 * device is in the state SDEV_DEL when scsi_device_get will fail.
527512 */
528
-void zfcp_erp_lun_shutdown_wait(struct scsi_device *sdev, char *id)
513
+void zfcp_erp_lun_shutdown_wait(struct scsi_device *sdev, char *dbftag)
529514 {
530515 unsigned long flags;
531516 struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev);
....@@ -534,7 +519,7 @@
534519 int clear = ZFCP_STATUS_COMMON_RUNNING | ZFCP_STATUS_COMMON_ERP_FAILED;
535520
536521 write_lock_irqsave(&adapter->erp_lock, flags);
537
- _zfcp_erp_lun_reopen(sdev, clear, id, ZFCP_STATUS_ERP_NO_REF);
522
+ _zfcp_erp_lun_reopen(sdev, clear, dbftag, ZFCP_STATUS_ERP_NO_REF);
538523 write_unlock_irqrestore(&adapter->erp_lock, flags);
539524
540525 zfcp_erp_wait(adapter);
....@@ -626,7 +611,7 @@
626611
627612 /**
628613 * zfcp_erp_timeout_handler - Trigger ERP action from timed out ERP request
629
- * @data: ERP action (from timer data)
614
+ * @t: timer list entry embedded in zfcp FSF request
630615 */
631616 void zfcp_erp_timeout_handler(struct timer_list *t)
632617 {
....@@ -671,31 +656,31 @@
671656 }
672657
673658 static void _zfcp_erp_port_reopen_all(struct zfcp_adapter *adapter,
674
- int clear, char *id)
659
+ int clear, char *dbftag)
675660 {
676661 struct zfcp_port *port;
677662
678663 read_lock(&adapter->port_list_lock);
679664 list_for_each_entry(port, &adapter->port_list, list)
680
- _zfcp_erp_port_reopen(port, clear, id);
665
+ _zfcp_erp_port_reopen(port, clear, dbftag);
681666 read_unlock(&adapter->port_list_lock);
682667 }
683668
684669 static void _zfcp_erp_lun_reopen_all(struct zfcp_port *port, int clear,
685
- char *id)
670
+ char *dbftag)
686671 {
687672 struct scsi_device *sdev;
688673
689674 spin_lock(port->adapter->scsi_host->host_lock);
690675 __shost_for_each_device(sdev, port->adapter->scsi_host)
691676 if (sdev_to_zfcp(sdev)->port == port)
692
- _zfcp_erp_lun_reopen(sdev, clear, id, 0);
677
+ _zfcp_erp_lun_reopen(sdev, clear, dbftag, 0);
693678 spin_unlock(port->adapter->scsi_host->host_lock);
694679 }
695680
696681 static void zfcp_erp_strategy_followup_failed(struct zfcp_erp_action *act)
697682 {
698
- switch (act->action) {
683
+ switch (act->type) {
699684 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
700685 _zfcp_erp_adapter_reopen(act->adapter, 0, "ersff_1");
701686 break;
....@@ -713,7 +698,7 @@
713698
714699 static void zfcp_erp_strategy_followup_success(struct zfcp_erp_action *act)
715700 {
716
- switch (act->action) {
701
+ switch (act->type) {
717702 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
718703 _zfcp_erp_port_reopen_all(act->adapter, 0, "ersfs_1");
719704 break;
....@@ -722,6 +707,9 @@
722707 break;
723708 case ZFCP_ERP_ACTION_REOPEN_PORT:
724709 _zfcp_erp_lun_reopen_all(act->port, 0, "ersfs_3");
710
+ break;
711
+ case ZFCP_ERP_ACTION_REOPEN_LUN:
712
+ /* NOP */
725713 break;
726714 }
727715 }
....@@ -750,7 +738,8 @@
750738 zfcp_erp_port_reopen(port, 0, "ereptp1");
751739 }
752740
753
-static int zfcp_erp_adapter_strat_fsf_xconf(struct zfcp_erp_action *erp_action)
741
+static enum zfcp_erp_act_result zfcp_erp_adapter_strat_fsf_xconf(
742
+ struct zfcp_erp_action *erp_action)
754743 {
755744 int retries;
756745 int sleep = 1;
....@@ -789,13 +778,18 @@
789778 if (!(atomic_read(&adapter->status) & ZFCP_STATUS_ADAPTER_XCONFIG_OK))
790779 return ZFCP_ERP_FAILED;
791780
792
- if (fc_host_port_type(adapter->scsi_host) == FC_PORTTYPE_PTP)
793
- zfcp_erp_enqueue_ptp_port(adapter);
794
-
795781 return ZFCP_ERP_SUCCEEDED;
796782 }
797783
798
-static int zfcp_erp_adapter_strategy_open_fsf_xport(struct zfcp_erp_action *act)
784
+static void
785
+zfcp_erp_adapter_strategy_open_ptp_port(struct zfcp_adapter *const adapter)
786
+{
787
+ if (fc_host_port_type(adapter->scsi_host) == FC_PORTTYPE_PTP)
788
+ zfcp_erp_enqueue_ptp_port(adapter);
789
+}
790
+
791
+static enum zfcp_erp_act_result zfcp_erp_adapter_strategy_open_fsf_xport(
792
+ struct zfcp_erp_action *act)
799793 {
800794 int ret;
801795 struct zfcp_adapter *adapter = act->adapter;
....@@ -820,13 +814,73 @@
820814 return ZFCP_ERP_SUCCEEDED;
821815 }
822816
823
-static int zfcp_erp_adapter_strategy_open_fsf(struct zfcp_erp_action *act)
817
+static enum zfcp_erp_act_result
818
+zfcp_erp_adapter_strategy_alloc_shost(struct zfcp_adapter *const adapter)
819
+{
820
+ struct zfcp_diag_adapter_config_data *const config_data =
821
+ &adapter->diagnostics->config_data;
822
+ struct zfcp_diag_adapter_port_data *const port_data =
823
+ &adapter->diagnostics->port_data;
824
+ unsigned long flags;
825
+ int rc;
826
+
827
+ rc = zfcp_scsi_adapter_register(adapter);
828
+ if (rc == -EEXIST)
829
+ return ZFCP_ERP_SUCCEEDED;
830
+ else if (rc)
831
+ return ZFCP_ERP_FAILED;
832
+
833
+ /*
834
+ * We allocated the shost for the first time. Before it was NULL,
835
+ * and so we deferred all updates in the xconf- and xport-data
836
+ * handlers. We need to make up for that now, and make all the updates
837
+ * that would have been done before.
838
+ *
839
+ * We can be sure that xconf- and xport-data succeeded, because
840
+ * otherwise this function is not called. But they might have been
841
+ * incomplete.
842
+ */
843
+
844
+ spin_lock_irqsave(&config_data->header.access_lock, flags);
845
+ zfcp_scsi_shost_update_config_data(adapter, &config_data->data,
846
+ !!config_data->header.incomplete);
847
+ spin_unlock_irqrestore(&config_data->header.access_lock, flags);
848
+
849
+ if (adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT) {
850
+ spin_lock_irqsave(&port_data->header.access_lock, flags);
851
+ zfcp_scsi_shost_update_port_data(adapter, &port_data->data);
852
+ spin_unlock_irqrestore(&port_data->header.access_lock, flags);
853
+ }
854
+
855
+ /*
856
+ * There is a remote possibility that the 'Exchange Port Data' request
857
+ * reports a different connectivity status than 'Exchange Config Data'.
858
+ * But any change to the connectivity status of the local optic that
859
+ * happens after the initial xconf request is expected to be reported
860
+ * to us, as soon as we post Status Read Buffers to the FCP channel
861
+ * firmware after this function. So any resulting inconsistency will
862
+ * only be momentary.
863
+ */
864
+ if (config_data->header.incomplete)
865
+ zfcp_fsf_fc_host_link_down(adapter);
866
+
867
+ return ZFCP_ERP_SUCCEEDED;
868
+}
869
+
870
+static enum zfcp_erp_act_result zfcp_erp_adapter_strategy_open_fsf(
871
+ struct zfcp_erp_action *act)
824872 {
825873 if (zfcp_erp_adapter_strat_fsf_xconf(act) == ZFCP_ERP_FAILED)
826874 return ZFCP_ERP_FAILED;
827875
828876 if (zfcp_erp_adapter_strategy_open_fsf_xport(act) == ZFCP_ERP_FAILED)
829877 return ZFCP_ERP_FAILED;
878
+
879
+ if (zfcp_erp_adapter_strategy_alloc_shost(act->adapter) ==
880
+ ZFCP_ERP_FAILED)
881
+ return ZFCP_ERP_FAILED;
882
+
883
+ zfcp_erp_adapter_strategy_open_ptp_port(act->adapter);
830884
831885 if (mempool_resize(act->adapter->pool.sr_data,
832886 act->adapter->stat_read_buf_num))
....@@ -859,7 +913,8 @@
859913 ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, &adapter->status);
860914 }
861915
862
-static int zfcp_erp_adapter_strategy_open(struct zfcp_erp_action *act)
916
+static enum zfcp_erp_act_result zfcp_erp_adapter_strategy_open(
917
+ struct zfcp_erp_action *act)
863918 {
864919 struct zfcp_adapter *adapter = act->adapter;
865920
....@@ -880,7 +935,8 @@
880935 return ZFCP_ERP_SUCCEEDED;
881936 }
882937
883
-static int zfcp_erp_adapter_strategy(struct zfcp_erp_action *act)
938
+static enum zfcp_erp_act_result zfcp_erp_adapter_strategy(
939
+ struct zfcp_erp_action *act)
884940 {
885941 struct zfcp_adapter *adapter = act->adapter;
886942
....@@ -898,7 +954,8 @@
898954 return ZFCP_ERP_SUCCEEDED;
899955 }
900956
901
-static int zfcp_erp_port_forced_strategy_close(struct zfcp_erp_action *act)
957
+static enum zfcp_erp_act_result zfcp_erp_port_forced_strategy_close(
958
+ struct zfcp_erp_action *act)
902959 {
903960 int retval;
904961
....@@ -912,7 +969,8 @@
912969 return ZFCP_ERP_CONTINUES;
913970 }
914971
915
-static int zfcp_erp_port_forced_strategy(struct zfcp_erp_action *erp_action)
972
+static enum zfcp_erp_act_result zfcp_erp_port_forced_strategy(
973
+ struct zfcp_erp_action *erp_action)
916974 {
917975 struct zfcp_port *port = erp_action->port;
918976 int status = atomic_read(&port->status);
....@@ -928,11 +986,19 @@
928986 case ZFCP_ERP_STEP_PHYS_PORT_CLOSING:
929987 if (!(status & ZFCP_STATUS_PORT_PHYS_OPEN))
930988 return ZFCP_ERP_SUCCEEDED;
989
+ break;
990
+ case ZFCP_ERP_STEP_PORT_CLOSING:
991
+ case ZFCP_ERP_STEP_PORT_OPENING:
992
+ case ZFCP_ERP_STEP_LUN_CLOSING:
993
+ case ZFCP_ERP_STEP_LUN_OPENING:
994
+ /* NOP */
995
+ break;
931996 }
932997 return ZFCP_ERP_FAILED;
933998 }
934999
935
-static int zfcp_erp_port_strategy_close(struct zfcp_erp_action *erp_action)
1000
+static enum zfcp_erp_act_result zfcp_erp_port_strategy_close(
1001
+ struct zfcp_erp_action *erp_action)
9361002 {
9371003 int retval;
9381004
....@@ -945,7 +1011,8 @@
9451011 return ZFCP_ERP_CONTINUES;
9461012 }
9471013
948
-static int zfcp_erp_port_strategy_open_port(struct zfcp_erp_action *erp_action)
1014
+static enum zfcp_erp_act_result zfcp_erp_port_strategy_open_port(
1015
+ struct zfcp_erp_action *erp_action)
9491016 {
9501017 int retval;
9511018
....@@ -971,7 +1038,8 @@
9711038 return zfcp_erp_port_strategy_open_port(act);
9721039 }
9731040
974
-static int zfcp_erp_port_strategy_open_common(struct zfcp_erp_action *act)
1041
+static enum zfcp_erp_act_result zfcp_erp_port_strategy_open_common(
1042
+ struct zfcp_erp_action *act)
9751043 {
9761044 struct zfcp_adapter *adapter = act->adapter;
9771045 struct zfcp_port *port = act->port;
....@@ -1002,12 +1070,18 @@
10021070 port->d_id = 0;
10031071 return ZFCP_ERP_FAILED;
10041072 }
1005
- /* fall through otherwise */
1073
+ /* no early return otherwise, continue after switch case */
1074
+ break;
1075
+ case ZFCP_ERP_STEP_LUN_CLOSING:
1076
+ case ZFCP_ERP_STEP_LUN_OPENING:
1077
+ /* NOP */
1078
+ break;
10061079 }
10071080 return ZFCP_ERP_FAILED;
10081081 }
10091082
1010
-static int zfcp_erp_port_strategy(struct zfcp_erp_action *erp_action)
1083
+static enum zfcp_erp_act_result zfcp_erp_port_strategy(
1084
+ struct zfcp_erp_action *erp_action)
10111085 {
10121086 struct zfcp_port *port = erp_action->port;
10131087 int p_status = atomic_read(&port->status);
....@@ -1026,6 +1100,12 @@
10261100 if (p_status & ZFCP_STATUS_COMMON_OPEN)
10271101 return ZFCP_ERP_FAILED;
10281102 break;
1103
+ case ZFCP_ERP_STEP_PHYS_PORT_CLOSING:
1104
+ case ZFCP_ERP_STEP_PORT_OPENING:
1105
+ case ZFCP_ERP_STEP_LUN_CLOSING:
1106
+ case ZFCP_ERP_STEP_LUN_OPENING:
1107
+ /* NOP */
1108
+ break;
10291109 }
10301110
10311111 close_init_done:
....@@ -1043,7 +1123,8 @@
10431123 &zfcp_sdev->status);
10441124 }
10451125
1046
-static int zfcp_erp_lun_strategy_close(struct zfcp_erp_action *erp_action)
1126
+static enum zfcp_erp_act_result zfcp_erp_lun_strategy_close(
1127
+ struct zfcp_erp_action *erp_action)
10471128 {
10481129 int retval = zfcp_fsf_close_lun(erp_action);
10491130 if (retval == -ENOMEM)
....@@ -1054,7 +1135,8 @@
10541135 return ZFCP_ERP_CONTINUES;
10551136 }
10561137
1057
-static int zfcp_erp_lun_strategy_open(struct zfcp_erp_action *erp_action)
1138
+static enum zfcp_erp_act_result zfcp_erp_lun_strategy_open(
1139
+ struct zfcp_erp_action *erp_action)
10581140 {
10591141 int retval = zfcp_fsf_open_lun(erp_action);
10601142 if (retval == -ENOMEM)
....@@ -1065,7 +1147,8 @@
10651147 return ZFCP_ERP_CONTINUES;
10661148 }
10671149
1068
-static int zfcp_erp_lun_strategy(struct zfcp_erp_action *erp_action)
1150
+static enum zfcp_erp_act_result zfcp_erp_lun_strategy(
1151
+ struct zfcp_erp_action *erp_action)
10691152 {
10701153 struct scsi_device *sdev = erp_action->sdev;
10711154 struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev);
....@@ -1075,7 +1158,8 @@
10751158 zfcp_erp_lun_strategy_clearstati(sdev);
10761159 if (atomic_read(&zfcp_sdev->status) & ZFCP_STATUS_COMMON_OPEN)
10771160 return zfcp_erp_lun_strategy_close(erp_action);
1078
- /* already closed, fall through */
1161
+ /* already closed */
1162
+ fallthrough;
10791163 case ZFCP_ERP_STEP_LUN_CLOSING:
10801164 if (atomic_read(&zfcp_sdev->status) & ZFCP_STATUS_COMMON_OPEN)
10811165 return ZFCP_ERP_FAILED;
....@@ -1086,11 +1170,18 @@
10861170 case ZFCP_ERP_STEP_LUN_OPENING:
10871171 if (atomic_read(&zfcp_sdev->status) & ZFCP_STATUS_COMMON_OPEN)
10881172 return ZFCP_ERP_SUCCEEDED;
1173
+ break;
1174
+ case ZFCP_ERP_STEP_PHYS_PORT_CLOSING:
1175
+ case ZFCP_ERP_STEP_PORT_CLOSING:
1176
+ case ZFCP_ERP_STEP_PORT_OPENING:
1177
+ /* NOP */
1178
+ break;
10891179 }
10901180 return ZFCP_ERP_FAILED;
10911181 }
10921182
1093
-static int zfcp_erp_strategy_check_lun(struct scsi_device *sdev, int result)
1183
+static enum zfcp_erp_act_result zfcp_erp_strategy_check_lun(
1184
+ struct scsi_device *sdev, enum zfcp_erp_act_result result)
10941185 {
10951186 struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev);
10961187
....@@ -1111,6 +1202,12 @@
11111202 ZFCP_STATUS_COMMON_ERP_FAILED);
11121203 }
11131204 break;
1205
+ case ZFCP_ERP_CONTINUES:
1206
+ case ZFCP_ERP_EXIT:
1207
+ case ZFCP_ERP_DISMISSED:
1208
+ case ZFCP_ERP_NOMEM:
1209
+ /* NOP */
1210
+ break;
11141211 }
11151212
11161213 if (atomic_read(&zfcp_sdev->status) & ZFCP_STATUS_COMMON_ERP_FAILED) {
....@@ -1120,7 +1217,8 @@
11201217 return result;
11211218 }
11221219
1123
-static int zfcp_erp_strategy_check_port(struct zfcp_port *port, int result)
1220
+static enum zfcp_erp_act_result zfcp_erp_strategy_check_port(
1221
+ struct zfcp_port *port, enum zfcp_erp_act_result result)
11241222 {
11251223 switch (result) {
11261224 case ZFCP_ERP_SUCCEEDED :
....@@ -1142,6 +1240,12 @@
11421240 ZFCP_STATUS_COMMON_ERP_FAILED);
11431241 }
11441242 break;
1243
+ case ZFCP_ERP_CONTINUES:
1244
+ case ZFCP_ERP_EXIT:
1245
+ case ZFCP_ERP_DISMISSED:
1246
+ case ZFCP_ERP_NOMEM:
1247
+ /* NOP */
1248
+ break;
11451249 }
11461250
11471251 if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_FAILED) {
....@@ -1151,8 +1255,8 @@
11511255 return result;
11521256 }
11531257
1154
-static int zfcp_erp_strategy_check_adapter(struct zfcp_adapter *adapter,
1155
- int result)
1258
+static enum zfcp_erp_act_result zfcp_erp_strategy_check_adapter(
1259
+ struct zfcp_adapter *adapter, enum zfcp_erp_act_result result)
11561260 {
11571261 switch (result) {
11581262 case ZFCP_ERP_SUCCEEDED :
....@@ -1170,6 +1274,12 @@
11701274 ZFCP_STATUS_COMMON_ERP_FAILED);
11711275 }
11721276 break;
1277
+ case ZFCP_ERP_CONTINUES:
1278
+ case ZFCP_ERP_EXIT:
1279
+ case ZFCP_ERP_DISMISSED:
1280
+ case ZFCP_ERP_NOMEM:
1281
+ /* NOP */
1282
+ break;
11731283 }
11741284
11751285 if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_ERP_FAILED) {
....@@ -1179,14 +1289,14 @@
11791289 return result;
11801290 }
11811291
1182
-static int zfcp_erp_strategy_check_target(struct zfcp_erp_action *erp_action,
1183
- int result)
1292
+static enum zfcp_erp_act_result zfcp_erp_strategy_check_target(
1293
+ struct zfcp_erp_action *erp_action, enum zfcp_erp_act_result result)
11841294 {
11851295 struct zfcp_adapter *adapter = erp_action->adapter;
11861296 struct zfcp_port *port = erp_action->port;
11871297 struct scsi_device *sdev = erp_action->sdev;
11881298
1189
- switch (erp_action->action) {
1299
+ switch (erp_action->type) {
11901300
11911301 case ZFCP_ERP_ACTION_REOPEN_LUN:
11921302 result = zfcp_erp_strategy_check_lun(sdev, result);
....@@ -1219,16 +1329,17 @@
12191329 return 0;
12201330 }
12211331
1222
-static int zfcp_erp_strategy_statechange(struct zfcp_erp_action *act, int ret)
1332
+static enum zfcp_erp_act_result zfcp_erp_strategy_statechange(
1333
+ struct zfcp_erp_action *act, enum zfcp_erp_act_result result)
12231334 {
1224
- int action = act->action;
1335
+ enum zfcp_erp_act_type type = act->type;
12251336 struct zfcp_adapter *adapter = act->adapter;
12261337 struct zfcp_port *port = act->port;
12271338 struct scsi_device *sdev = act->sdev;
12281339 struct zfcp_scsi_dev *zfcp_sdev;
12291340 u32 erp_status = act->status;
12301341
1231
- switch (action) {
1342
+ switch (type) {
12321343 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
12331344 if (zfcp_erp_strat_change_det(&adapter->status, erp_status)) {
12341345 _zfcp_erp_adapter_reopen(adapter,
....@@ -1258,7 +1369,7 @@
12581369 }
12591370 break;
12601371 }
1261
- return ret;
1372
+ return result;
12621373 }
12631374
12641375 static void zfcp_erp_action_dequeue(struct zfcp_erp_action *erp_action)
....@@ -1275,7 +1386,7 @@
12751386 list_del(&erp_action->list);
12761387 zfcp_dbf_rec_run("eractd1", erp_action);
12771388
1278
- switch (erp_action->action) {
1389
+ switch (erp_action->type) {
12791390 case ZFCP_ERP_ACTION_REOPEN_LUN:
12801391 zfcp_sdev = sdev_to_zfcp(erp_action->sdev);
12811392 atomic_andnot(ZFCP_STATUS_COMMON_ERP_INUSE,
....@@ -1354,13 +1465,14 @@
13541465 write_unlock_irqrestore(&adapter->erp_lock, flags);
13551466 }
13561467
1357
-static void zfcp_erp_action_cleanup(struct zfcp_erp_action *act, int result)
1468
+static void zfcp_erp_action_cleanup(struct zfcp_erp_action *act,
1469
+ enum zfcp_erp_act_result result)
13581470 {
13591471 struct zfcp_adapter *adapter = act->adapter;
13601472 struct zfcp_port *port = act->port;
13611473 struct scsi_device *sdev = act->sdev;
13621474
1363
- switch (act->action) {
1475
+ switch (act->type) {
13641476 case ZFCP_ERP_ACTION_REOPEN_LUN:
13651477 if (!(act->status & ZFCP_STATUS_ERP_NO_REF))
13661478 scsi_device_put(sdev);
....@@ -1376,7 +1488,7 @@
13761488 if (act->step != ZFCP_ERP_STEP_UNINITIALIZED)
13771489 if (result == ZFCP_ERP_SUCCEEDED)
13781490 zfcp_erp_try_rport_unblock(port);
1379
- /* fall through */
1491
+ fallthrough;
13801492 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
13811493 put_device(&port->dev);
13821494 break;
....@@ -1394,9 +1506,10 @@
13941506 }
13951507 }
13961508
1397
-static int zfcp_erp_strategy_do_action(struct zfcp_erp_action *erp_action)
1509
+static enum zfcp_erp_act_result zfcp_erp_strategy_do_action(
1510
+ struct zfcp_erp_action *erp_action)
13981511 {
1399
- switch (erp_action->action) {
1512
+ switch (erp_action->type) {
14001513 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
14011514 return zfcp_erp_adapter_strategy(erp_action);
14021515 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
....@@ -1409,9 +1522,10 @@
14091522 return ZFCP_ERP_FAILED;
14101523 }
14111524
1412
-static int zfcp_erp_strategy(struct zfcp_erp_action *erp_action)
1525
+static enum zfcp_erp_act_result zfcp_erp_strategy(
1526
+ struct zfcp_erp_action *erp_action)
14131527 {
1414
- int retval;
1528
+ enum zfcp_erp_act_result result;
14151529 unsigned long flags;
14161530 struct zfcp_adapter *adapter = erp_action->adapter;
14171531
....@@ -1422,12 +1536,12 @@
14221536
14231537 if (erp_action->status & ZFCP_STATUS_ERP_DISMISSED) {
14241538 zfcp_erp_action_dequeue(erp_action);
1425
- retval = ZFCP_ERP_DISMISSED;
1539
+ result = ZFCP_ERP_DISMISSED;
14261540 goto unlock;
14271541 }
14281542
14291543 if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT) {
1430
- retval = ZFCP_ERP_FAILED;
1544
+ result = ZFCP_ERP_FAILED;
14311545 goto check_target;
14321546 }
14331547
....@@ -1435,13 +1549,13 @@
14351549
14361550 /* no lock to allow for blocking operations */
14371551 write_unlock_irqrestore(&adapter->erp_lock, flags);
1438
- retval = zfcp_erp_strategy_do_action(erp_action);
1552
+ result = zfcp_erp_strategy_do_action(erp_action);
14391553 write_lock_irqsave(&adapter->erp_lock, flags);
14401554
14411555 if (erp_action->status & ZFCP_STATUS_ERP_DISMISSED)
1442
- retval = ZFCP_ERP_CONTINUES;
1556
+ result = ZFCP_ERP_CONTINUES;
14431557
1444
- switch (retval) {
1558
+ switch (result) {
14451559 case ZFCP_ERP_NOMEM:
14461560 if (!(erp_action->status & ZFCP_STATUS_ERP_LOWMEM)) {
14471561 ++adapter->erp_low_mem_count;
....@@ -1451,7 +1565,7 @@
14511565 _zfcp_erp_adapter_reopen(adapter, 0, "erstgy1");
14521566 else {
14531567 zfcp_erp_strategy_memwait(erp_action);
1454
- retval = ZFCP_ERP_CONTINUES;
1568
+ result = ZFCP_ERP_CONTINUES;
14551569 }
14561570 goto unlock;
14571571
....@@ -1461,33 +1575,38 @@
14611575 erp_action->status &= ~ZFCP_STATUS_ERP_LOWMEM;
14621576 }
14631577 goto unlock;
1578
+ case ZFCP_ERP_SUCCEEDED:
1579
+ case ZFCP_ERP_FAILED:
1580
+ case ZFCP_ERP_EXIT:
1581
+ case ZFCP_ERP_DISMISSED:
1582
+ /* NOP */
1583
+ break;
14641584 }
14651585
14661586 check_target:
1467
- retval = zfcp_erp_strategy_check_target(erp_action, retval);
1587
+ result = zfcp_erp_strategy_check_target(erp_action, result);
14681588 zfcp_erp_action_dequeue(erp_action);
1469
- retval = zfcp_erp_strategy_statechange(erp_action, retval);
1470
- if (retval == ZFCP_ERP_EXIT)
1589
+ result = zfcp_erp_strategy_statechange(erp_action, result);
1590
+ if (result == ZFCP_ERP_EXIT)
14711591 goto unlock;
1472
- if (retval == ZFCP_ERP_SUCCEEDED)
1592
+ if (result == ZFCP_ERP_SUCCEEDED)
14731593 zfcp_erp_strategy_followup_success(erp_action);
1474
- if (retval == ZFCP_ERP_FAILED)
1594
+ if (result == ZFCP_ERP_FAILED)
14751595 zfcp_erp_strategy_followup_failed(erp_action);
14761596
14771597 unlock:
14781598 write_unlock_irqrestore(&adapter->erp_lock, flags);
14791599
1480
- if (retval != ZFCP_ERP_CONTINUES)
1481
- zfcp_erp_action_cleanup(erp_action, retval);
1600
+ if (result != ZFCP_ERP_CONTINUES)
1601
+ zfcp_erp_action_cleanup(erp_action, result);
14821602
14831603 kref_put(&adapter->ref, zfcp_adapter_release);
1484
- return retval;
1604
+ return result;
14851605 }
14861606
14871607 static int zfcp_erp_thread(void *data)
14881608 {
14891609 struct zfcp_adapter *adapter = (struct zfcp_adapter *) data;
1490
- struct list_head *next;
14911610 struct zfcp_erp_action *act;
14921611 unsigned long flags;
14931612
....@@ -1500,12 +1619,11 @@
15001619 break;
15011620
15021621 write_lock_irqsave(&adapter->erp_lock, flags);
1503
- next = adapter->erp_ready_head.next;
1622
+ act = list_first_entry_or_null(&adapter->erp_ready_head,
1623
+ struct zfcp_erp_action, list);
15041624 write_unlock_irqrestore(&adapter->erp_lock, flags);
15051625
1506
- if (next != &adapter->erp_ready_head) {
1507
- act = list_entry(next, struct zfcp_erp_action, list);
1508
-
1626
+ if (act) {
15091627 /* there is more to come after dismission, no notify */
15101628 if (zfcp_erp_strategy(act) != ZFCP_ERP_DISMISSED)
15111629 zfcp_erp_wakeup(adapter);
....@@ -1519,7 +1637,7 @@
15191637 * zfcp_erp_thread_setup - Start ERP thread for adapter
15201638 * @adapter: Adapter to start the ERP thread for
15211639 *
1522
- * Returns 0 on success or error code from kernel_thread()
1640
+ * Return: 0 on success, or error code from kthread_run().
15231641 */
15241642 int zfcp_erp_thread_setup(struct zfcp_adapter *adapter)
15251643 {
....@@ -1589,6 +1707,13 @@
15891707 atomic_or(common_mask, &port->status);
15901708 read_unlock_irqrestore(&adapter->port_list_lock, flags);
15911709
1710
+ /*
1711
+ * if `scsi_host` is missing, xconfig/xport data has never completed
1712
+ * yet, so we can't access it, but there are also no SDEVs yet
1713
+ */
1714
+ if (adapter->scsi_host == NULL)
1715
+ return;
1716
+
15921717 spin_lock_irqsave(adapter->scsi_host->host_lock, flags);
15931718 __shost_for_each_device(sdev, adapter->scsi_host)
15941719 atomic_or(common_mask, &sdev_to_zfcp(sdev)->status);
....@@ -1625,6 +1750,13 @@
16251750 atomic_set(&port->erp_counter, 0);
16261751 }
16271752 read_unlock_irqrestore(&adapter->port_list_lock, flags);
1753
+
1754
+ /*
1755
+ * if `scsi_host` is missing, xconfig/xport data has never completed
1756
+ * yet, so we can't access it, but there are also no SDEVs yet
1757
+ */
1758
+ if (adapter->scsi_host == NULL)
1759
+ return;
16281760
16291761 spin_lock_irqsave(adapter->scsi_host->host_lock, flags);
16301762 __shost_for_each_device(sdev, adapter->scsi_host) {
....@@ -1724,11 +1856,11 @@
17241856 /**
17251857 * zfcp_erp_adapter_reset_sync() - Really reopen adapter and wait.
17261858 * @adapter: Pointer to zfcp_adapter to reopen.
1727
- * @id: Trace tag string of length %ZFCP_DBF_TAG_LEN.
1859
+ * @dbftag: Trace tag string of length %ZFCP_DBF_TAG_LEN.
17281860 */
1729
-void zfcp_erp_adapter_reset_sync(struct zfcp_adapter *adapter, char *id)
1861
+void zfcp_erp_adapter_reset_sync(struct zfcp_adapter *adapter, char *dbftag)
17301862 {
17311863 zfcp_erp_set_adapter_status(adapter, ZFCP_STATUS_COMMON_RUNNING);
1732
- zfcp_erp_adapter_reopen(adapter, ZFCP_STATUS_COMMON_ERP_FAILED, id);
1864
+ zfcp_erp_adapter_reopen(adapter, ZFCP_STATUS_COMMON_ERP_FAILED, dbftag);
17331865 zfcp_erp_wait(adapter);
17341866 }