scsi: zfcp: the action field of zfcp_erp_action is actually the type

&zfcp_erp_action.action ==> &zfcp_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 287ac01acf ("[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 <maier@linux.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
Steffen Maier 2018-11-08 15:44:50 +01:00 committed by Martin K. Petersen
parent 208d096154
commit df91eefd08
3 changed files with 56 additions and 43 deletions

View File

@ -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.fsf_req_id = erp->fsf_req_id;
rec->u.run.rec_status = erp->status; rec->u.run.rec_status = erp->status;
rec->u.run.rec_step = erp->step; rec->u.run.rec_step = erp->step;
rec->u.run.rec_action = erp->action; rec->u.run.rec_action = erp->type;
if (erp->sdev) if (erp->sdev)
rec->u.run.rec_count = rec->u.run.rec_count =

View File

@ -89,9 +89,27 @@
/************************* STRUCTURE DEFINITIONS *****************************/ /************************* 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(), &zfcp_dbf_rec_trigger.want, &zfcp_dbf_rec_trigger.need;
* zfcp_dbf_rec_run_lvl(), zfcp_dbf_rec_run(), &zfcp_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 zfcp_erp_action {
struct list_head list; 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_adapter *adapter; /* device which should be recovered */
struct zfcp_port *port; struct zfcp_port *port;
struct scsi_device *sdev; struct scsi_device *sdev;

View File

@ -4,7 +4,7 @@
* *
* Error Recovery Procedures (ERP). * Error Recovery Procedures (ERP).
* *
* Copyright IBM Corp. 2002, 2016 * Copyright IBM Corp. 2002, 2017
*/ */
#define KMSG_COMPONENT "zfcp" #define KMSG_COMPONENT "zfcp"
@ -33,29 +33,18 @@ enum zfcp_erp_steps {
ZFCP_ERP_STEP_LUN_OPENING = 0x2000, ZFCP_ERP_STEP_LUN_OPENING = 0x2000,
}; };
/** /*
* enum zfcp_erp_act_type - Type of ERP action object. * Eyecatcher pseudo flag to bitwise or-combine with enum zfcp_erp_act_type.
* @ZFCP_ERP_ACTION_REOPEN_LUN: LUN recovery. * Used to indicate that an ERP action could not be set up despite a detected
* @ZFCP_ERP_ACTION_REOPEN_PORT: Port recovery. * need for some 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.
*/ */
enum zfcp_erp_act_type { #define ZFCP_ERP_ACTION_NONE 0xc0
ZFCP_ERP_ACTION_REOPEN_LUN = 1, /*
ZFCP_ERP_ACTION_REOPEN_PORT = 2, * Eyecatcher pseudo flag to bitwise or-combine with enum zfcp_erp_act_type.
ZFCP_ERP_ACTION_REOPEN_PORT_FORCED = 3, * Used to indicate that ERP not needed because the object has
ZFCP_ERP_ACTION_REOPEN_ADAPTER = 4, * ZFCP_STATUS_COMMON_ERP_FAILED.
ZFCP_ERP_ACTION_NONE = 0xc0, */
ZFCP_ERP_ACTION_FAILED = 0xe0, #define ZFCP_ERP_ACTION_FAILED 0xe0
};
enum zfcp_erp_act_result { enum zfcp_erp_act_result {
ZFCP_ERP_SUCCEEDED = 0, ZFCP_ERP_SUCCEEDED = 0,
@ -136,11 +125,11 @@ static void zfcp_erp_action_dismiss_adapter(struct zfcp_adapter *adapter)
} }
} }
static int zfcp_erp_handle_failed(int want, struct zfcp_adapter *adapter, static enum zfcp_erp_act_type zfcp_erp_handle_failed(
struct zfcp_port *port, enum zfcp_erp_act_type want, struct zfcp_adapter *adapter,
struct scsi_device *sdev) struct zfcp_port *port, struct scsi_device *sdev)
{ {
int need = want; enum zfcp_erp_act_type need = want;
struct zfcp_scsi_dev *zsdev; struct zfcp_scsi_dev *zsdev;
switch (want) { switch (want) {
@ -179,11 +168,12 @@ static int zfcp_erp_handle_failed(int want, struct zfcp_adapter *adapter,
return need; return need;
} }
static int zfcp_erp_required_act(int want, struct zfcp_adapter *adapter, static enum zfcp_erp_act_type zfcp_erp_required_act(enum zfcp_erp_act_type want,
struct zfcp_adapter *adapter,
struct zfcp_port *port, struct zfcp_port *port,
struct scsi_device *sdev) struct scsi_device *sdev)
{ {
int need = want; enum zfcp_erp_act_type need = want;
int l_status, p_status, a_status; int l_status, p_status, a_status;
struct zfcp_scsi_dev *zfcp_sdev; struct zfcp_scsi_dev *zfcp_sdev;
@ -230,7 +220,8 @@ static int zfcp_erp_required_act(int want, struct zfcp_adapter *adapter,
return need; return need;
} }
static struct zfcp_erp_action *zfcp_erp_setup_act(int need, u32 act_status, static struct zfcp_erp_action *zfcp_erp_setup_act(enum zfcp_erp_act_type need,
u32 act_status,
struct zfcp_adapter *adapter, struct zfcp_adapter *adapter,
struct zfcp_port *port, struct zfcp_port *port,
struct scsi_device *sdev) struct scsi_device *sdev)
@ -288,18 +279,19 @@ static struct zfcp_erp_action *zfcp_erp_setup_act(int need, u32 act_status,
memset(&erp_action->timer, 0, sizeof(erp_action->timer)); memset(&erp_action->timer, 0, sizeof(erp_action->timer));
erp_action->step = ZFCP_ERP_STEP_UNINITIALIZED; erp_action->step = ZFCP_ERP_STEP_UNINITIALIZED;
erp_action->fsf_req_id = 0; erp_action->fsf_req_id = 0;
erp_action->action = need; erp_action->type = need;
erp_action->status = act_status; erp_action->status = act_status;
return erp_action; return erp_action;
} }
static void zfcp_erp_action_enqueue(int want, struct zfcp_adapter *adapter, static void zfcp_erp_action_enqueue(enum zfcp_erp_act_type want,
struct zfcp_adapter *adapter,
struct zfcp_port *port, struct zfcp_port *port,
struct scsi_device *sdev, struct scsi_device *sdev,
char *dbftag, u32 act_status) char *dbftag, u32 act_status)
{ {
int need; enum zfcp_erp_act_type need;
struct zfcp_erp_action *act; struct zfcp_erp_action *act;
need = zfcp_erp_handle_failed(want, adapter, port, sdev); need = zfcp_erp_handle_failed(want, adapter, port, sdev);
@ -672,7 +664,7 @@ static void _zfcp_erp_lun_reopen_all(struct zfcp_port *port, int clear,
static void zfcp_erp_strategy_followup_failed(struct zfcp_erp_action *act) static void zfcp_erp_strategy_followup_failed(struct zfcp_erp_action *act)
{ {
switch (act->action) { switch (act->type) {
case ZFCP_ERP_ACTION_REOPEN_ADAPTER: case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
_zfcp_erp_adapter_reopen(act->adapter, 0, "ersff_1"); _zfcp_erp_adapter_reopen(act->adapter, 0, "ersff_1");
break; break;
@ -690,7 +682,7 @@ static void zfcp_erp_strategy_followup_failed(struct zfcp_erp_action *act)
static void zfcp_erp_strategy_followup_success(struct zfcp_erp_action *act) static void zfcp_erp_strategy_followup_success(struct zfcp_erp_action *act)
{ {
switch (act->action) { switch (act->type) {
case ZFCP_ERP_ACTION_REOPEN_ADAPTER: case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
_zfcp_erp_port_reopen_all(act->adapter, 0, "ersfs_1"); _zfcp_erp_port_reopen_all(act->adapter, 0, "ersfs_1");
break; break;
@ -700,6 +692,9 @@ static void zfcp_erp_strategy_followup_success(struct zfcp_erp_action *act)
case ZFCP_ERP_ACTION_REOPEN_PORT: case ZFCP_ERP_ACTION_REOPEN_PORT:
_zfcp_erp_lun_reopen_all(act->port, 0, "ersfs_3"); _zfcp_erp_lun_reopen_all(act->port, 0, "ersfs_3");
break; break;
case ZFCP_ERP_ACTION_REOPEN_LUN:
/* NOP */
break;
} }
} }
@ -1163,7 +1158,7 @@ static int zfcp_erp_strategy_check_target(struct zfcp_erp_action *erp_action,
struct zfcp_port *port = erp_action->port; struct zfcp_port *port = erp_action->port;
struct scsi_device *sdev = erp_action->sdev; struct scsi_device *sdev = erp_action->sdev;
switch (erp_action->action) { switch (erp_action->type) {
case ZFCP_ERP_ACTION_REOPEN_LUN: case ZFCP_ERP_ACTION_REOPEN_LUN:
result = zfcp_erp_strategy_check_lun(sdev, result); result = zfcp_erp_strategy_check_lun(sdev, result);
@ -1198,14 +1193,14 @@ static int zfcp_erp_strat_change_det(atomic_t *target_status, u32 erp_status)
static int zfcp_erp_strategy_statechange(struct zfcp_erp_action *act, int ret) static int zfcp_erp_strategy_statechange(struct zfcp_erp_action *act, int ret)
{ {
int action = act->action; enum zfcp_erp_act_type type = act->type;
struct zfcp_adapter *adapter = act->adapter; struct zfcp_adapter *adapter = act->adapter;
struct zfcp_port *port = act->port; struct zfcp_port *port = act->port;
struct scsi_device *sdev = act->sdev; struct scsi_device *sdev = act->sdev;
struct zfcp_scsi_dev *zfcp_sdev; struct zfcp_scsi_dev *zfcp_sdev;
u32 erp_status = act->status; u32 erp_status = act->status;
switch (action) { switch (type) {
case ZFCP_ERP_ACTION_REOPEN_ADAPTER: case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
if (zfcp_erp_strat_change_det(&adapter->status, erp_status)) { if (zfcp_erp_strat_change_det(&adapter->status, erp_status)) {
_zfcp_erp_adapter_reopen(adapter, _zfcp_erp_adapter_reopen(adapter,
@ -1252,7 +1247,7 @@ static void zfcp_erp_action_dequeue(struct zfcp_erp_action *erp_action)
list_del(&erp_action->list); list_del(&erp_action->list);
zfcp_dbf_rec_run("eractd1", erp_action); zfcp_dbf_rec_run("eractd1", erp_action);
switch (erp_action->action) { switch (erp_action->type) {
case ZFCP_ERP_ACTION_REOPEN_LUN: case ZFCP_ERP_ACTION_REOPEN_LUN:
zfcp_sdev = sdev_to_zfcp(erp_action->sdev); zfcp_sdev = sdev_to_zfcp(erp_action->sdev);
atomic_andnot(ZFCP_STATUS_COMMON_ERP_INUSE, atomic_andnot(ZFCP_STATUS_COMMON_ERP_INUSE,
@ -1334,7 +1329,7 @@ static void zfcp_erp_action_cleanup(struct zfcp_erp_action *act, int result)
struct zfcp_port *port = act->port; struct zfcp_port *port = act->port;
struct scsi_device *sdev = act->sdev; struct scsi_device *sdev = act->sdev;
switch (act->action) { switch (act->type) {
case ZFCP_ERP_ACTION_REOPEN_LUN: case ZFCP_ERP_ACTION_REOPEN_LUN:
if (!(act->status & ZFCP_STATUS_ERP_NO_REF)) if (!(act->status & ZFCP_STATUS_ERP_NO_REF))
scsi_device_put(sdev); scsi_device_put(sdev);
@ -1370,7 +1365,7 @@ static void zfcp_erp_action_cleanup(struct zfcp_erp_action *act, int result)
static int zfcp_erp_strategy_do_action(struct zfcp_erp_action *erp_action) static int zfcp_erp_strategy_do_action(struct zfcp_erp_action *erp_action)
{ {
switch (erp_action->action) { switch (erp_action->type) {
case ZFCP_ERP_ACTION_REOPEN_ADAPTER: case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
return zfcp_erp_adapter_strategy(erp_action); return zfcp_erp_adapter_strategy(erp_action);
case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: