Re: [PATCH 15/23] zfcp: the action field of zfcp_erp_action is actually the type

2018-11-16 Thread Hannes Reinecke

On 11/8/18 3:44 PM, Steffen Maier wrote:

_erp_action.action ==> _erp_action.type

While at it, make use of the already defined enum for this purpose
to get at least some build checking (even though an enum is type equivalent
to an int in C). v2.6.27 commit 287ac01acf22 ("[SCSI] zfcp: Cleanup code
in zfcp_erp.c") introduced the enum which was cpp defines previously.

To prevent compiler warnings with the switch(act->type), we have to
separate the recently added eyecatchers from enum zfcp_erp_act_type.

Since struct zfcp_erp_action type is embedded into other structures
living in zfcp_def.h, we have to move enum zfcp_erp_act_type from
its private definition in zfcp_erp.c to the zfcp-global zfcp_def.h.

Silence one false -Wswitch compiler warning case: LUNs as the leaves in our
object tree do not have any follow-up success recovery.

Signed-off-by: Steffen Maier 
Reviewed-by: Benjamin Block 
---
  drivers/s390/scsi/zfcp_dbf.c |  2 +-
  drivers/s390/scsi/zfcp_def.h | 20 +++-
  drivers/s390/scsi/zfcp_erp.c | 77 +---
  3 files changed, 56 insertions(+), 43 deletions(-)


Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
--
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)


[PATCH 15/23] zfcp: the action field of zfcp_erp_action is actually the type

2018-11-08 Thread Steffen Maier
_erp_action.action ==> _erp_action.type

While at it, make use of the already defined enum for this purpose
to get at least some build checking (even though an enum is type equivalent
to an int in C). v2.6.27 commit 287ac01acf22 ("[SCSI] zfcp: Cleanup code
in zfcp_erp.c") introduced the enum which was cpp defines previously.

To prevent compiler warnings with the switch(act->type), we have to
separate the recently added eyecatchers from enum zfcp_erp_act_type.

Since struct zfcp_erp_action type is embedded into other structures
living in zfcp_def.h, we have to move enum zfcp_erp_act_type from
its private definition in zfcp_erp.c to the zfcp-global zfcp_def.h.

Silence one false -Wswitch compiler warning case: LUNs as the leaves in our
object tree do not have any follow-up success recovery.

Signed-off-by: Steffen Maier 
Reviewed-by: Benjamin Block 
---
 drivers/s390/scsi/zfcp_dbf.c |  2 +-
 drivers/s390/scsi/zfcp_def.h | 20 +++-
 drivers/s390/scsi/zfcp_erp.c | 77 +---
 3 files changed, 56 insertions(+), 43 deletions(-)

diff --git a/drivers/s390/scsi/zfcp_dbf.c b/drivers/s390/scsi/zfcp_dbf.c
index 3503de873963..06696b76c300 100644
--- a/drivers/s390/scsi/zfcp_dbf.c
+++ b/drivers/s390/scsi/zfcp_dbf.c
@@ -357,7 +357,7 @@ void zfcp_dbf_rec_run_lvl(int level, char *tag, struct 
zfcp_erp_action *erp)
rec->u.run.fsf_req_id = erp->fsf_req_id;
rec->u.run.rec_status = erp->status;
rec->u.run.rec_step = erp->step;
-   rec->u.run.rec_action = erp->action;
+   rec->u.run.rec_action = erp->type;
 
if (erp->sdev)
rec->u.run.rec_count =
diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h
index 84a742a67975..4c938eb604b6 100644
--- a/drivers/s390/scsi/zfcp_def.h
+++ b/drivers/s390/scsi/zfcp_def.h
@@ -89,9 +89,27 @@
 
 /* STRUCTURE DEFINITIONS */
 
+/**
+ * enum zfcp_erp_act_type - Type of ERP action object.
+ * @ZFCP_ERP_ACTION_REOPEN_LUN: LUN recovery.
+ * @ZFCP_ERP_ACTION_REOPEN_PORT: Port recovery.
+ * @ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: Forced port recovery.
+ * @ZFCP_ERP_ACTION_REOPEN_ADAPTER: Adapter recovery.
+ *
+ * Values must fit into u8 because of code dependencies:
+ * zfcp_dbf_rec_trig(), _dbf_rec_trigger.want, _dbf_rec_trigger.need;
+ * zfcp_dbf_rec_run_lvl(), zfcp_dbf_rec_run(), 
_dbf_rec_running.rec_action.
+ */
+enum zfcp_erp_act_type {
+   ZFCP_ERP_ACTION_REOPEN_LUN = 1,
+   ZFCP_ERP_ACTION_REOPEN_PORT= 2,
+   ZFCP_ERP_ACTION_REOPEN_PORT_FORCED = 3,
+   ZFCP_ERP_ACTION_REOPEN_ADAPTER = 4,
+};
+
 struct zfcp_erp_action {
struct list_head list;
-   int action;   /* requested action code */
+   enum zfcp_erp_act_type type;  /* requested action code */
struct zfcp_adapter *adapter; /* device which should be recovered */
struct zfcp_port *port;
struct scsi_device *sdev;
diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c
index efb47cd6ab4a..49d04e5af55f 100644
--- a/drivers/s390/scsi/zfcp_erp.c
+++ b/drivers/s390/scsi/zfcp_erp.c
@@ -4,7 +4,7 @@
  *
  * Error Recovery Procedures (ERP).
  *
- * Copyright IBM Corp. 2002, 2016
+ * Copyright IBM Corp. 2002, 2017
  */
 
 #define KMSG_COMPONENT "zfcp"
@@ -33,29 +33,18 @@ enum zfcp_erp_steps {
ZFCP_ERP_STEP_LUN_OPENING   = 0x2000,
 };
 
-/**
- * enum zfcp_erp_act_type - Type of ERP action object.
- * @ZFCP_ERP_ACTION_REOPEN_LUN: LUN recovery.
- * @ZFCP_ERP_ACTION_REOPEN_PORT: Port recovery.
- * @ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: Forced port recovery.
- * @ZFCP_ERP_ACTION_REOPEN_ADAPTER: Adapter recovery.
- * @ZFCP_ERP_ACTION_NONE: Eyecatcher pseudo flag to bitwise or-combine with
- *   either of the first four enum values.
- *   Used to indicate that an ERP action could not be
- *   set up despite a detected need for some recovery.
- * @ZFCP_ERP_ACTION_FAILED: Eyecatcher pseudo flag to bitwise or-combine with
- * either of the first four enum values.
- * Used to indicate that ERP not needed because
- * the object has ZFCP_STATUS_COMMON_ERP_FAILED.
+/*
+ * Eyecatcher pseudo flag to bitwise or-combine with enum zfcp_erp_act_type.
+ * Used to indicate that an ERP action could not be set up despite a detected
+ * need for some recovery.
  */
-enum zfcp_erp_act_type {
-   ZFCP_ERP_ACTION_REOPEN_LUN = 1,
-   ZFCP_ERP_ACTION_REOPEN_PORT= 2,
-   ZFCP_ERP_ACTION_REOPEN_PORT_FORCED = 3,
-   ZFCP_ERP_ACTION_REOPEN_ADAPTER = 4,
-   ZFCP_ERP_ACTION_NONE   = 0xc0,
-   ZFCP_ERP_ACTION_FAILED = 0xe0,
-};
+#define ZFCP_ERP_ACTION_NONE   0xc0
+/*
+ * Eyecatcher pseudo flag to bitwise or-combine with enum zfcp_erp_act_type.
+ * Used to indicate that ERP not needed because the