Print this page
NEX-3177 enums and string arrays required to be in sync.
Reviewed by: Rob Gittins <rob.gittins@nexenta.com>
Reviewed by: Steve Peng <steve.peng@nexenta.com>
re #8564, rb4224 "mutex_enter: bad mutex" panic when under heavy load
   1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */

  21 /*
  22  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright 2013, Nexenta Systems, Inc. All rights reserved.
  24  */
  25 #ifndef _PPPT_H
  26 #define _PPPT_H
  27 
  28 #include <sys/pppt_ic_if.h>
  29 
  30 #ifdef  __cplusplus
  31 extern "C" {
  32 #endif
  33 
  34 #define PPPT_GLOBAL_LOCK() mutex_enter(&pppt_global.global_lock)
  35 #define PPPT_GLOBAL_UNLOCK() mutex_exit(&pppt_global.global_lock)
  36 
  37 extern int pppt_logging;
  38 
  39 #define PPPT_LOG if (pppt_logging) cmn_err
  40 
  41 #define TGT_DEREG_RETRY_SECONDS 1
  42 
  43 typedef enum {
  44         PPPT_STATUS_SUCCESS = 0,
  45         PPPT_STATUS_FAIL,
  46         PPPT_STATUS_ABORTED,
  47         PPPT_STATUS_DONE
  48 } pppt_status_t;
  49 
  50 #define PPPT_MODNAME "pppt"
  51 















  52 /* Target states and events, update pppt_ts_name table whenever modified */
  53 typedef enum {
  54         TS_UNDEFINED = 0,
  55         TS_CREATED,
  56         TS_ONLINING,
  57         TS_ONLINE,
  58         TS_STMF_ONLINE,
  59         TS_DELETING_NEED_OFFLINE,
  60         TS_OFFLINING,
  61         TS_OFFLINE,
  62         TS_STMF_OFFLINE,
  63         TS_DELETING_STMF_DEREG,
  64         TS_DELETING_STMF_DEREG_FAIL,
  65         TS_DELETING,
  66         TS_MAX_STATE
  67 } pppt_tgt_state_t;
  68 
  69 #ifdef PPPT_TGT_SM_STRINGS
  70 static const char *pppt_ts_name[TS_MAX_STATE+1] = {
  71         "TS_UNDEFINED",
  72         "TS_CREATED",
  73         "TS_ONLINING",
  74         "TS_ONLINE",
  75         "TS_STMF_ONLINE",
  76         "TS_DELETING_NEED_OFFLINE",
  77         "TS_OFFLINING",
  78         "TS_OFFLINE",
  79         "TS_STMF_OFFLINE",
  80         "TS_DELETING_STMF_DEREG",
  81         "TS_DELETING_STMF_DEREG_FAIL",
  82         "TS_DELETING",
  83         "TS_MAX_STATE"
  84 };
  85 #endif
  86 
















  87 typedef enum {
  88         TE_UNDEFINED = 0,
  89         TE_STMF_ONLINE_REQ,
  90         TE_ONLINE_SUCCESS,
  91         TE_ONLINE_FAIL,
  92         TE_STMF_ONLINE_COMPLETE_ACK,
  93         TE_STMF_OFFLINE_REQ,
  94         TE_OFFLINE_COMPLETE,
  95         TE_STMF_OFFLINE_COMPLETE_ACK,
  96         TE_DELETE,
  97         TE_STMF_DEREG_SUCCESS,
  98         TE_STMF_DEREG_FAIL,
  99         TE_STMF_DEREG_RETRY,
 100         TE_WAIT_REF_COMPLETE, /* XXX */
 101         TE_MAX_EVENT
 102 } pppt_tgt_event_t;
 103 
 104 #ifdef PPPT_TGT_SM_STRINGS
 105 static const char *pppt_te_name[TE_MAX_EVENT+1] = {
 106         "TE_UNDEFINED",
 107         "TE_STMF_ONLINE_REQ",
 108         "TE_ONLINE_SUCCESS",
 109         "TE_ONLINE_FAIL",
 110         "TE_STMF_ONLINE_COMPLETE_ACK",
 111         "TE_STMF_OFFLINE_REQ",
 112         "TE_OFFLINE_COMPLETE",
 113         "TE_STMF_OFFLINE_COMPLETE_ACK",
 114         "TE_DELETE",
 115         "TE_STMF_DEREG_SUCCESS",
 116         "TE_STMF_DEREG_FAIL",
 117         "TE_STMF_DEREG_RETRY",
 118         "TE_WAIT_REF_COMPLETE",
 119         "TE_MAX_EVENT"
 120 };
 121 #endif
 122 
 123 typedef struct pppt_tgt_s {
 124         kmutex_t                target_mutex;
 125         kcondvar_t              target_cv;
 126         avl_node_t              target_global_ln;
 127         scsi_devid_desc_t       *target_devid;
 128         stmf_local_port_t       *target_stmf_lport;
 129         avl_tree_t              target_sess_list;
 130 
 131         /* Target state */
 132         boolean_t               target_sm_busy;
 133         boolean_t               target_deleting;
 134         pppt_tgt_state_t        target_state;
 135         pppt_tgt_state_t        target_last_state;
 136         int                     target_refcount;
 137         list_t                  target_events;
 138 } pppt_tgt_t;
 139 


   1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright 2013, 2015 Nexenta Systems, Inc. All rights reserved.
  25  */
  26 #ifndef _PPPT_H
  27 #define _PPPT_H
  28 
  29 #include <sys/pppt_ic_if.h>
  30 
  31 #ifdef  __cplusplus
  32 extern "C" {
  33 #endif
  34 
  35 #define PPPT_GLOBAL_LOCK() mutex_enter(&pppt_global.global_lock)
  36 #define PPPT_GLOBAL_UNLOCK() mutex_exit(&pppt_global.global_lock)
  37 
  38 extern int pppt_logging;
  39 
  40 #define PPPT_LOG if (pppt_logging) cmn_err
  41 
  42 #define TGT_DEREG_RETRY_SECONDS 1
  43 
  44 typedef enum {
  45         PPPT_STATUS_SUCCESS = 0,
  46         PPPT_STATUS_FAIL,
  47         PPPT_STATUS_ABORTED,
  48         PPPT_STATUS_DONE
  49 } pppt_status_t;
  50 
  51 #define PPPT_MODNAME "pppt"
  52 
  53 #define TGT_STATE_LIST() \
  54         item(TS_UNDEFINED) \
  55         item(TS_CREATED) \
  56         item(TS_ONLINING) \
  57         item(TS_ONLINE) \
  58         item(TS_STMF_ONLINE) \
  59         item(TS_DELETING_NEED_OFFLINE) \
  60         item(TS_OFFLINING) \
  61         item(TS_OFFLINE) \
  62         item(TS_STMF_OFFLINE) \
  63         item(TS_DELETING_STMF_DEREG) \
  64         item(TS_DELETING_STMF_DEREG_FAIL) \
  65         item(TS_DELETING) \
  66         item(TS_MAX_STATE)
  67 
  68 /* Target states and events, update pppt_ts_name table whenever modified */
  69 typedef enum {
  70 #define item(a) a,
  71         TGT_STATE_LIST()
  72 #undef  item










  73 } pppt_tgt_state_t;
  74 
  75 #ifdef PPPT_TGT_SM_STRINGS
  76 static const char *pppt_ts_name[TS_MAX_STATE + 1] = {
  77 #define item(a) #a,
  78         TGT_STATE_LIST()
  79 #undef  item










  80 };
  81 #endif
  82 
  83 #define TGT_EVENT_LIST() \
  84         item(TE_UNDEFINED) \
  85         item(TE_STMF_ONLINE_REQ) \
  86         item(TE_ONLINE_SUCCESS) \
  87         item(TE_ONLINE_FAIL) \
  88         item(TE_STMF_ONLINE_COMPLETE_ACK) \
  89         item(TE_STMF_OFFLINE_REQ) \
  90         item(TE_OFFLINE_COMPLETE) \
  91         item(TE_STMF_OFFLINE_COMPLETE_ACK) \
  92         item(TE_DELETE) \
  93         item(TE_STMF_DEREG_SUCCESS) \
  94         item(TE_STMF_DEREG_FAIL) \
  95         item(TE_STMF_DEREG_RETRY) \
  96         item(TE_WAIT_REF_COMPLETE) /* XXX */ \
  97         item(TE_MAX_EVENT)
  98 
  99 typedef enum {
 100 #define item(a) a,
 101         TGT_EVENT_LIST()
 102 #undef  item











 103 } pppt_tgt_event_t;
 104 
 105 #ifdef PPPT_TGT_SM_STRINGS
 106 static const char *pppt_te_name[TE_MAX_EVENT + 1] = {
 107 #define item(a) #a,
 108         TGT_EVENT_LIST()
 109 #undef  item











 110 };
 111 #endif
 112 
 113 typedef struct pppt_tgt_s {
 114         kmutex_t                target_mutex;
 115         kcondvar_t              target_cv;
 116         avl_node_t              target_global_ln;
 117         scsi_devid_desc_t       *target_devid;
 118         stmf_local_port_t       *target_stmf_lport;
 119         avl_tree_t              target_sess_list;
 120 
 121         /* Target state */
 122         boolean_t               target_sm_busy;
 123         boolean_t               target_deleting;
 124         pppt_tgt_state_t        target_state;
 125         pppt_tgt_state_t        target_last_state;
 126         int                     target_refcount;
 127         list_t                  target_events;
 128 } pppt_tgt_t;
 129