Print this page
NEX-9981 Deadman timer panic from idm_refcnt_wait_ref thread while offlining iSCSI targets
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Rob Gittins <rob.gittins@nexenta.com>
NEX-6018 Return of the walking dead idm_refcnt_wait_ref comstar threads
Reviewed by:  Rick McNeal <rick.mcneal@nexenta.com>
Reviewed by:  Evan Layton <evan.layton@nexenta.com>
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>


   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 2009 Sun Microsystems, Inc.  All rights reserved.

  24  * Use is subject to license terms.
  25  */
  26 
  27 #ifndef _IDM_H
  28 #define _IDM_H
  29 
  30 #ifdef  __cplusplus
  31 extern "C" {
  32 #endif
  33 


  34 typedef enum {
  35         IDM_STATUS_SUCCESS = 0,
  36         IDM_STATUS_FAIL,
  37         IDM_STATUS_NORESOURCES,
  38         IDM_STATUS_REJECT,
  39         IDM_STATUS_IO,
  40         IDM_STATUS_ABORTED,
  41         IDM_STATUS_SUSPENDED,
  42         IDM_STATUS_HEADER_DIGEST,
  43         IDM_STATUS_DATA_DIGEST,
  44         IDM_STATUS_PROTOCOL_ERROR,
  45         IDM_STATUS_LOGIN_FAIL
  46 } idm_status_t;
  47 











  48 
  49 typedef enum {
  50         CN_CONNECT_ACCEPT = 1,  /* Target only */
  51         CN_LOGIN_FAIL,
  52         CN_READY_FOR_LOGIN,     /* Initiator only */
  53         CN_FFP_ENABLED,
  54         CN_FFP_DISABLED,
  55         CN_CONNECT_LOST,
  56         CN_CONNECT_DESTROY,
  57         CN_CONNECT_FAIL,
  58         CN_MAX
  59 } idm_client_notify_t;
  60 
  61 #ifdef IDM_CN_NOTIFY_STRINGS
  62 static const char *idm_cn_strings[CN_MAX + 1] = {
  63         "CN_UNDEFINED",
  64         "CN_CONNECT_ACCEPT",
  65         "CN_LOGIN_FAIL",
  66         "CN_READY_FOR_LOGIN",
  67         "CN_FFP_ENABLED",
  68         "CN_FFP_DISABLED",
  69         "CN_CONNECT_LOST",
  70         "CN_CONNECT_DESTROY",
  71         "CN_CONNECT_FAIL",
  72         "CN_MAX"
  73 };
  74 #endif
  75 
  76 typedef enum {
  77         FD_CONN_FAIL,
  78         FD_CONN_LOGOUT,
  79         FD_SESS_LOGOUT
  80 } idm_ffp_disable_t;
  81 
  82 typedef enum {
  83         AT_INTERNAL_SUSPEND,
  84         AT_INTERNAL_ABORT,
  85         AT_TASK_MGMT_ABORT
  86 } idm_abort_type_t;
  87 










  88 typedef enum {
  89         TASK_IDLE,
  90         TASK_ACTIVE,
  91         TASK_SUSPENDING,
  92         TASK_SUSPENDED,
  93         TASK_ABORTING,
  94         TASK_ABORTED,
  95         TASK_COMPLETE,
  96         TASK_MAX_STATE
  97 } idm_task_state_t;
  98 
  99 #ifdef IDM_TASK_SM_STRINGS
 100 static const char *idm_ts_name[TASK_MAX_STATE+1] = {
 101         "TASK_IDLE",
 102         "TASK_ACTIVE",
 103         "TASK_SUSPENDING",
 104         "TASK_SUSPENDED",
 105         "TASK_ABORTING",
 106         "TASK_ABORTED",
 107         "TASK_COMPLETE",
 108         "TASK_MAX_STATE"
 109 };
 110 #endif
 111 
 112 typedef enum {
 113         KV_HANDLED = 0,
 114         KV_HANDLED_NO_TRANSIT,
 115         KV_UNHANDLED,
 116         KV_TARGET_ONLY,
 117         KV_NO_RESOURCES,
 118         KV_INTERNAL_ERROR,
 119         KV_VALUE_ERROR,
 120         KV_MISSING_FIELDS,
 121         KV_AUTH_FAILED
 122 } kv_status_t;
 123 
 124 /*
 125  * Request structures
 126  */
 127 
 128 /* Defined in idm_impl.h */


 424 
 425 #define IDM_BUFPAT_SET(CHK_BUF)                                 \
 426         if (idm_pattern_checking && (CHK_BUF)->idb_bufalloc) {       \
 427                 idm_bufpat_set(CHK_BUF);                        \
 428         }
 429 
 430 #define IDM_BUFPAT_CHECK(CHK_BUF, CHK_LEN, CHK_TYPE)            \
 431         if (idm_pattern_checking) {                             \
 432                 (void) idm_bufpat_check(CHK_BUF, CHK_LEN, CHK_TYPE);    \
 433         }
 434 
 435 /*
 436  * Task services
 437  */
 438 idm_task_t *
 439 idm_task_alloc(idm_conn_t *ic);
 440 
 441 void
 442 idm_task_start(idm_task_t *idt, uintptr_t handle);
 443 
 444 void
 445 idm_task_abort(idm_conn_t *ic, idm_task_t *idt, idm_abort_type_t abort_type);
 446 
 447 void
 448 idm_task_cleanup(idm_task_t *idt);
 449 
 450 void
 451 idm_task_done(idm_task_t *idt);
 452 
 453 void
 454 idm_task_free(idm_task_t *idt);
 455 
 456 idm_task_t *
 457 idm_task_find(idm_conn_t *ic, uint32_t itt, uint32_t ttt);
 458 
 459 idm_task_t *
 460 idm_task_find_and_complete(idm_conn_t *ic, uint32_t itt, uint32_t ttt);
 461 
 462 void *
 463 idm_task_find_by_handle(idm_conn_t *ic, uintptr_t handle);
 464 


 507 idm_refcnt_destroy(idm_refcnt_t *refcnt);
 508 
 509 void
 510 idm_refcnt_reset(idm_refcnt_t *refcnt);
 511 
 512 void
 513 idm_refcnt_hold(idm_refcnt_t *refcnt);
 514 
 515 void
 516 idm_refcnt_rele(idm_refcnt_t *refcnt);
 517 
 518 void
 519 idm_refcnt_rele_and_destroy(idm_refcnt_t *refcnt, idm_refcnt_cb_t *cb_func);
 520 
 521 void
 522 idm_refcnt_wait_ref(idm_refcnt_t *refcnt);
 523 
 524 void
 525 idm_refcnt_async_wait_ref(idm_refcnt_t *refcnt, idm_refcnt_cb_t *cb_func);
 526 


 527 
 528 #ifdef  __cplusplus
 529 }
 530 #endif
 531 
 532 #endif /* _IDM_H */


   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 2009 Sun Microsystems, Inc.  All rights reserved.
  24  * Copyright 2017 Nexenta Systems, Inc.  All rights reserved.
  25  * Use is subject to license terms.
  26  */
  27 
  28 #ifndef _IDM_H
  29 #define _IDM_H
  30 
  31 #ifdef  __cplusplus
  32 extern "C" {
  33 #endif
  34 
  35 #include <sys/stmf_defines.h>
  36 
  37 typedef enum {
  38         IDM_STATUS_SUCCESS = 0,
  39         IDM_STATUS_FAIL,
  40         IDM_STATUS_NORESOURCES,
  41         IDM_STATUS_REJECT,
  42         IDM_STATUS_IO,
  43         IDM_STATUS_ABORTED,
  44         IDM_STATUS_SUSPENDED,
  45         IDM_STATUS_HEADER_DIGEST,
  46         IDM_STATUS_DATA_DIGEST,
  47         IDM_STATUS_PROTOCOL_ERROR,
  48         IDM_STATUS_LOGIN_FAIL
  49 } idm_status_t;
  50 
  51 #define IDM_CLIENT_NOTIFY_LIST() \
  52         item(CN_UNDEFINED) \
  53         item(CN_CONNECT_ACCEPT)         /* Target only */ \
  54         item(CN_LOGIN_FAIL) \
  55         item(CN_READY_FOR_LOGIN)        /* Initiator only */ \
  56         item(CN_FFP_ENABLED) \
  57         item(CN_FFP_DISABLED) \
  58         item(CN_CONNECT_LOST) \
  59         item(CN_CONNECT_DESTROY) \
  60         item(CN_CONNECT_FAIL) \
  61         item(CN_MAX)
  62 
  63 typedef enum {
  64 #define item(a) a,
  65         IDM_CLIENT_NOTIFY_LIST()
  66 #undef  item






  67 } idm_client_notify_t;
  68 
  69 #ifdef IDM_CN_NOTIFY_STRINGS
  70 static const char *idm_cn_strings[CN_MAX + 1] = {
  71 #define item(a) #a,
  72         IDM_CLIENT_NOTIFY_LIST()
  73 #undef  item







  74 };
  75 #endif
  76 
  77 typedef enum {
  78         FD_CONN_FAIL,
  79         FD_CONN_LOGOUT,
  80         FD_SESS_LOGOUT
  81 } idm_ffp_disable_t;
  82 
  83 typedef enum {
  84         AT_INTERNAL_SUSPEND,
  85         AT_INTERNAL_ABORT,
  86         AT_TASK_MGMT_ABORT
  87 } idm_abort_type_t;
  88 
  89 #define IDM_TASK_STATE_LIST() \
  90         item(TASK_IDLE) \
  91         item(TASK_ACTIVE) \
  92         item(TASK_SUSPENDING) \
  93         item(TASK_SUSPENDED) \
  94         item(TASK_ABORTING) \
  95         item(TASK_ABORTED) \
  96         item(TASK_COMPLETE) \
  97         item(TASK_MAX_STATE)
  98 
  99 typedef enum {
 100 #define item(a) a,
 101         IDM_TASK_STATE_LIST()
 102 #undef  item





 103 } idm_task_state_t;
 104 
 105 #ifdef IDM_TASK_SM_STRINGS
 106 static const char *idm_ts_name[TASK_MAX_STATE+1] = {
 107 #define item(a) #a,
 108         IDM_TASK_STATE_LIST()
 109 #undef  item





 110 };
 111 #endif
 112 
 113 typedef enum {
 114         KV_HANDLED = 0,
 115         KV_HANDLED_NO_TRANSIT,
 116         KV_UNHANDLED,
 117         KV_TARGET_ONLY,
 118         KV_NO_RESOURCES,
 119         KV_INTERNAL_ERROR,
 120         KV_VALUE_ERROR,
 121         KV_MISSING_FIELDS,
 122         KV_AUTH_FAILED
 123 } kv_status_t;
 124 
 125 /*
 126  * Request structures
 127  */
 128 
 129 /* Defined in idm_impl.h */


 425 
 426 #define IDM_BUFPAT_SET(CHK_BUF)                                 \
 427         if (idm_pattern_checking && (CHK_BUF)->idb_bufalloc) {       \
 428                 idm_bufpat_set(CHK_BUF);                        \
 429         }
 430 
 431 #define IDM_BUFPAT_CHECK(CHK_BUF, CHK_LEN, CHK_TYPE)            \
 432         if (idm_pattern_checking) {                             \
 433                 (void) idm_bufpat_check(CHK_BUF, CHK_LEN, CHK_TYPE);    \
 434         }
 435 
 436 /*
 437  * Task services
 438  */
 439 idm_task_t *
 440 idm_task_alloc(idm_conn_t *ic);
 441 
 442 void
 443 idm_task_start(idm_task_t *idt, uintptr_t handle);
 444 
 445 stmf_status_t
 446 idm_task_abort(idm_conn_t *ic, idm_task_t *idt, idm_abort_type_t abort_type);
 447 
 448 void
 449 idm_task_cleanup(idm_task_t *idt);
 450 
 451 void
 452 idm_task_done(idm_task_t *idt);
 453 
 454 void
 455 idm_task_free(idm_task_t *idt);
 456 
 457 idm_task_t *
 458 idm_task_find(idm_conn_t *ic, uint32_t itt, uint32_t ttt);
 459 
 460 idm_task_t *
 461 idm_task_find_and_complete(idm_conn_t *ic, uint32_t itt, uint32_t ttt);
 462 
 463 void *
 464 idm_task_find_by_handle(idm_conn_t *ic, uintptr_t handle);
 465 


 508 idm_refcnt_destroy(idm_refcnt_t *refcnt);
 509 
 510 void
 511 idm_refcnt_reset(idm_refcnt_t *refcnt);
 512 
 513 void
 514 idm_refcnt_hold(idm_refcnt_t *refcnt);
 515 
 516 void
 517 idm_refcnt_rele(idm_refcnt_t *refcnt);
 518 
 519 void
 520 idm_refcnt_rele_and_destroy(idm_refcnt_t *refcnt, idm_refcnt_cb_t *cb_func);
 521 
 522 void
 523 idm_refcnt_wait_ref(idm_refcnt_t *refcnt);
 524 
 525 void
 526 idm_refcnt_async_wait_ref(idm_refcnt_t *refcnt, idm_refcnt_cb_t *cb_func);
 527 
 528 int
 529 idm_refcnt_is_held(idm_refcnt_t *refcnt);
 530 
 531 #ifdef  __cplusplus
 532 }
 533 #endif
 534 
 535 #endif /* _IDM_H */