Hallo, dies ist ein Test.
PWD: /www/data-lst1/unixsoft/unixsoft/kaempfer/.public_html
Running in File Mode
Relative path: ./../../../../../../usr/include/sys/cgm.h
Real path: /usr/include/sys/cgm.h
Zurück
/* * Copyright (c) 2016, 2021, Oracle and/or its affiliates. */ #ifndef _SYS_CGM_H #define _SYS_CGM_H #include <sys/types.h> #include <sys/mutex.h> #include <sys/param.h> #include <sys/cred.h> #include <sys/uadmin.h> #include <sys/ksynch.h> #include <sys/modhash.h> #include <sys/paths.h> #include <sys/nvpair.h> #include <sys/time.h> #include <sys/errno.h> #include <sys/kmem.h> #include <sys/cmn_err.h> #include <sys/sdt.h> #include <sys/atomic.h> #include <sys/systm.h> #include <sys/t_lock.h> #include <sys/uuid.h> #include <sys/list.h> #include <sys/sa_share.h> #include <nfs/nfs.h> #include <nfs/nfssys.h> #include <sys/rgm.h> #ifdef __cplusplus extern "C" { #endif #define CURRENT_TICK ddi_get_lbolt() /* same size as defined in libshare_cache.c */ #define SHRBUF_SIZE 16 * 1024 /* SMB CA property name used in share property query */ #define CGM_SHOPT_SMBCA "cont_avail" #define CGM_LOGMSG_SIZE 256 #define CGM_LOGBUF_SIZE 1024 /* Consumers of central grace manager */ typedef enum cgm_proto { CGM_NLM_PROTO = 1, /* NLM Protocol service */ CGM_NFSV40_PROTO = 2, /* NFS v4.0 Protocol service */ CGM_NFSV41_PROTO = 4, /* NFS v4.1 Protocol service */ CGM_SMB30_PROTO = 8 /* SMB 3.0 Protocol service */ } cgm_proto_t; /* Action to be performed by consumers */ typedef enum cgm_action { GRACE_START = 1, /* start grace in one instance */ GRACE_START_ALL, /* start grace in all instances */ GRACE_END /* End grace */ } cgm_action_t; typedef enum { CGM_POOL_ADD = 1, CGM_POOL_DEL, CGM_POOL_UPDATE } cgm_pool_op_t; /* * cgm_cbinfo: argument for callback related to grace period start/end. * cgm_cb_zid - zone id * cgm_cb_action - GRACE_START, GRACE_START_ALL, or GRACE_END * cgm_cb_ctx - opaque data provided by consumer during registration * cgm_cb_tid - tofab id */ typedef struct cgm_cbinfo { zoneid_t cgm_cb_zid; cgm_action_t cgm_cb_action; void *cgm_cb_ctx; char *cgm_cb_tid; } cgm_cbinfo_t; /* * cgm_cb_pool: argument for callback related to pool import/export * cgm_cbp_opcode - CGM_POOL_ADD, CGM_POOL_DEL or CGM_POOL_UPDATE * cgm_cbp_zid - zone id * cgm_cbp_ctx - opaque data provided by consumer during registration * cgm_cbp_tid - tofab id * cgm_cbp_pname - pool name */ typedef struct cgm_cb_pool { cgm_pool_op_t cgm_cbp_opcode; zoneid_t cgm_cbp_zid; void *cgm_cbp_ctx; char *cgm_cbp_tid; char *cgm_cbp_pname; } cgm_cb_pool_t; /* * proto_consumer_ops: callback functions provided by consumers * during registration. * proto_cb_graceaction - The callback function for cgm to notify * registered consumer when grace period get started or stopped. * proto_cb_poolnotify - The callback function for cgm to notify * registered consumer when a pool get added or deleted. * NOTICE: all callback function should return as quick as possible. * Otherwise, it will block cgm and other consumers. */ typedef struct proto_consumer_ops { void (*proto_cb_graceaction)(cgm_cbinfo_t *); void (*proto_cb_poolnotify)(cgm_cb_pool_t *); } proto_consumer_ops_t; /* * cgm_proto_consumer: protocol consumer of cgm. * cgmc_zid - zone id * cgmc_proto - protocol id * cgmc_grace_period - grace period length of the protocol in seconds * cgmc_cb_ctx - opaque data provided during registration. Will be used * as argument for callback functions. * cgmc_ops - pointer to callback functions */ typedef struct cgm_proto_consumer { zoneid_t cgmc_zid; cgm_proto_t cgmc_proto; uint64_t cgmc_grace_period; void *cgmc_cb_ctx; proto_consumer_ops_t *cgmc_ops; } cgm_proto_consumer_t; typedef struct cgm_consumer_entry { list_node_t cgmce_node; cgm_proto_consumer_t cgmce_info; } cgm_consumer_entry_t; /* entry in cgm log */ typedef struct cgm_log_entry { int cgmle_level; timestruc_t cgmle_timestamp; char cgmle_msgbuf[CGM_LOGMSG_SIZE]; } cgm_log_entry_t; /* log of cgm. one log per zone */ typedef struct cgm_log { int cgml_cur; int cgml_recur; kmutex_t cgml_lock; cgm_log_entry_t cgml_buf[CGM_LOGBUF_SIZE]; } cgm_log_t; /* * This is a per zone structure which is created when the first consumer calls * cgm_register(). * cgm_zn_zid - zone id. * cgm_zn_num_reg - number of consumers registered with the CGM. * cgm_zn_proto_reg - registered protocol consumers. * cgm_zn_implicit_grace - Implicit grace period. * cgm_zn_maxgrace_period - maximum of grace periods requested by all consumers. * cgm_zn_lock - lock to protect the members in per zone structure. * cgm_zn_cons_list - linked list of consumer entries. Each entry has consumer * identifier and set of callbacks provided by the consumer. * cgm_zn_inst_list - linked list of grace instances. * cgm_zn_log - log for this zone node. */ typedef struct cgm_zone_node { list_node_t cgm_zn_node; zoneid_t cgm_zn_zid; uint32_t cgm_zn_proto_reg; uint64_t cgm_zn_implicit_grace; uint64_t cgm_zn_maxgrace_period; kmutex_t cgm_zn_lock; list_t cgm_zn_cons_list; list_t cgm_zn_inst_list; cgm_log_t cgm_zn_log; } cgm_zone_node_t; /* * CGM_GRACE_INIT - to indicate no consumer registered with CGM. * CGM_IMPLI_GRACE - to indicate the instance is in implicit grace. * implicit grace period has two purposes: * 1. During system boot, multiple consumers start services. Setting * instances to implicit grace period is to avoid such case that * earlier started consumer grant new locks while later started * consumer has not get a chance to request grace period to recover * state. * 2. When a consumer restarts service, locks granted by this consumer * will be cleaned up in memory between service stop and restart. * Putting instances into implicit grace period is able to prevent other * consumer grant conflict locks between service stop and restart. * CGM_SYSTEM_GRACE - to indicate the instance system wide grace. * System wide grace is started by requests from consumers while * doing state recovery and new resources is being added to system - * importing a new pool in cluster context. * CGM_NO_GRACE - to indicate the instance is not in the grace. * * state transistion: * CGM_GRACE_INIT->CGM_IMPLI_GRACE when * first protocol consumer register. * CGM_IMPLI_GRACE->CGM_GRACE_INIT when * timer for implicit grace period fired after * last protocol consumer unregister. * CGM_IMPLI_GRACE->CGM_SYSTEM_GRACE when * timer for implicit grace period fired and any protocol * request grace or new pool is added during implicit grace. * CGM_IMPLI_GRACE->CGM_NO_GRACE when * timer for implicit grace period fired and no grace request * received during implicit grace period * CGM_SYSTEM_GRACE->CGM_IMPLI_GRACE when * system grace period complete earlier than timer, but * implicit grace period that overlap with system grace * period has not yet complete. * CGM_SYSTEM_GRACE->CGM_NO_GRACE when * system grace period complete early or timer fired, and * at least one protocol is registered. * CGM_SYSTEM_GRACE->CGM_GRACE_INIT when * system grace period complete early or timer fired, and * no protocol is registered. * CGM_NO_GRACE->CGM_IMPLI_GRACE when * protocol register (not the first one) * CGM_NO_GRACE->CGM_SYSTEM_GRACE when * any protocol request grace or new pool is added */ typedef enum cgm_state { CGM_GRACE_INIT = 1, CGM_IMPLI_GRACE, CGM_SYSTEM_GRACE, CGM_NO_GRACE } cgm_state_t; /* * Each grace instance(grace instance is per tofab) may contain one or more * pools and this structure is to represent list of pools in a given tofab. */ typedef struct cgm_pool_info { list_node_t p_node; char *p_name; } cgm_pool_info_t; /* * cgm_inst struct represents a grace instance and grace instance is per * tofab. Each grace instance is identified by key called tofab id. * In general solaris case, the key is DEFAULT_RGID. * cgmi_timer_tid - timer for grace period * cgmi_timer_expiry - expiry (in ticks) of timer. * cgmi_implicit_expiry - expiry for implicit grace period while requested * during system grace period. * cgmi_grace_requests - protocol consumers that request grace period. * cgmi_pending_requests - grace request received during implicit grace period * cgmi_state - state of the grace instance. * cgmi_znp - poniter to a per zone structure. * cgmi_tofab_id - key to locate the grace instance. * cgmi_plist_hd - list of pools in a tofab. */ typedef struct cgm_inst { list_node_t cgmi_node; timeout_id_t cgmi_timer_tid; clock_t cgmi_timer_expiry; clock_t cgmi_implicit_expiry; uint32_t cgmi_grace_requests; uint32_t cgmi_pending_requests; cgm_state_t cgmi_state; cgm_zone_node_t *cgmi_znp; char cgmi_tofab_id[UUID_PRINTABLE_STRING_LENGTH]; list_t cgmi_plist_hd; } cgm_inst_t; void cgm_log_printf(int, const char *, ...); void cgm_register(cgm_proto_consumer_t *, void **); void cgm_unregister(void *); void cgm_request_grace(void *, char *); void cgm_grace_complete(void *, char *); bool_t cgm_query_sharename_props(char *, sa_proto_t); bool_t cgm_query_mntpt_props(char *, char *, sa_proto_t); void cgm_pool_add(rgm_cb_obj_t *); void cgm_pool_del(rgm_cb_obj_t *); void cgm_init(); char *cgm_action_to_str(cgm_action_t); char *cgm_proto_to_str(cgm_proto_t); char *cgm_pool_op_to_str(cgm_pool_op_t); #ifdef __cplusplus } #endif #endif /* _SYS_CGM_H */