fmd_asru.h revision 6e1fa242609208de48dfe1939b8814d4dff455a5
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * CDDL HEADER START
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * The contents of this file are subject to the terms of the
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Common Development and Distribution License (the "License").
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * You may not use this file except in compliance with the License.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * See the License for the specific language governing permissions
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * and limitations under the License.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * When distributing Covered Code, include this CDDL HEADER in each
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * If applicable, add the following below this CDDL HEADER, with the
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * fields enclosed by brackets "[]" replaced with your own identifying
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * information: Portions Copyright [yyyy] [name of copyright owner]
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * CDDL HEADER END
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Use is subject to license terms.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern "C" {
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * The resource is represented by an fmd_asru_t structure and one or more
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * fmd_asru_link_t structures. Each of the latter represents a separate
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj * unrepaired case (problem) involving the resource. There are separate
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj * reference counts for both the fmd_asru_t and fmd_asru_link_t structures,
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj * but only one lock is used (asru_lock) which protects both the parent
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj * fmd_asru_t and its associated fmd_asru_link_t structures. The FMD_ASRU_FAULTY
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj * flags in the fmd_asru_t represents the cumulative value of the associated
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj * FMD_ASRU_FAULTY flags in the fmd_asru_link_t structures (and therefore of
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj * all independant unrepaired problems that are affecting that resource).
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robjtypedef struct fmd_asru {
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj struct fmd_asru *asru_next; /* next asru on hash chain */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi char *asru_name; /* string form of resource fmri (ro) */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi nvlist_t *asru_fmri; /* nvlist form of resource fmri (ro) */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi uint_t asru_uuidlen; /* length of asru_uuid (not incl. \0) */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi pthread_mutex_t asru_lock; /* lock protecting remaining members */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi pthread_cond_t asru_cv; /* condition variable for asru_flags */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi fmd_case_t *asru_case; /* case associated with last change */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi nvlist_t *asru_event; /* event associated with last change */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi fmd_list_t asru_list; /* linked list next/prev pointers */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecinditypedef struct fmd_asru_link {
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi fmd_list_t al_list; /* linked list next/prev pointers */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi struct fmd_asru *al_asru; /* pointer back to parent */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi struct fmd_asru_link *al_asru_next; /* next link on hash chain */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi struct fmd_asru_link *al_case_next; /* next link on hash chain */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi struct fmd_asru_link *al_fru_next; /* next link on hash chain */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi struct fmd_asru_link *al_label_next; /* next link on hash chain */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi struct fmd_asru_link *al_rsrc_next; /* next link on hash chain */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi uint_t al_uuidlen; /* length of al_uuid (not incl. \0) */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi char *al_asru_name; /* string form of asru fmri (ro) */
c40d7343efa60b18ad1ceb316eb337caeea79046cindi char *al_rsrc_name; /* string form of resource fmri (ro) */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi nvlist_t *al_asru_fmri; /* nvlist form of resource fmri (ro) */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi fmd_case_t *al_case; /* case associated with last change */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi nvlist_t *al_event; /* event associated with last change */
dd566498928f08e7c9a79797a40db893c6a4b9fbvn#define FMD_ASRU_FAULTY 0x01 /* asru has been diagnosed as faulty */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#define FMD_ASRU_UNUSABLE 0x02 /* asru can not be used at present */
25c6ff4b77fcddf4097ce78a8277275ca603b46cstephh#define FMD_ASRU_VALID 0x04 /* asru is initialized and valid */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#define FMD_ASRU_INTERNAL 0x08 /* asru is managed by fmd itself */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#define FMD_ASRU_INVISIBLE 0x10 /* asru is not visibly administered */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#define FMD_ASRU_RECREATED 0x20 /* asru recreated by cache replay */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#define FMD_ASRU_PRESENT 0x40 /* asru present at last R$ update */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#define FMD_ASRU_DEGRADED 0x80 /* asru service is degraded */
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj#define FMD_ASRU_PROXY_WITH_ASRU 0x200 /* asru accessible locally on proxy */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#define FMD_ASRU_PROXY_EXTERNAL 0x400 /* proxy over external transport */
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj#define FMD_ASRU_PROXY_RDONLY 0x800 /* proxy over readonly transport */
940d71d237794874e18a0eb72f6564821a823517eschrock * Note the following are defined in order of increasing precedence and
940d71d237794874e18a0eb72f6564821a823517eschrock * this should not be changed
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#define FMD_ASRU_STATE (FMD_ASRU_FAULTY | FMD_ASRU_UNUSABLE)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecinditypedef struct fmd_asru_hash {
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi pthread_rwlock_t ah_lock; /* r/w lock protecting hash contents */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi fmd_asru_t **ah_hash; /* hash bucket array for asrus */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi fmd_asru_link_t **ah_asru_hash; /* hash bucket array for asrus */
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj fmd_asru_link_t **ah_case_hash; /* hash bucket array for frus */
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj fmd_asru_link_t **ah_fru_hash; /* hash bucket array for cases */
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj fmd_asru_link_t **ah_label_hash; /* label hash bucket array */
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj fmd_asru_link_t **ah_rsrc_hash; /* hash bucket array for rsrcs */
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj char *ah_dirpath; /* path of hash's log file directory */
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj uint64_t ah_lifetime; /* max lifetime of log if not present */
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj uint_t ah_al_count; /* count of number of entries in hash */
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robjextern fmd_asru_hash_t *fmd_asru_hash_create(const char *, const char *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi void (*)(fmd_asru_t *, void *), void *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi void (*)(fmd_asru_link_t *, void *), void *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern void fmd_asru_hash_apply_by_asru(fmd_asru_hash_t *, const char *,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi void (*)(fmd_asru_link_t *, void *), void *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern void fmd_asru_hash_apply_by_label(fmd_asru_hash_t *, const char *,
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj void (*)(fmd_asru_link_t *, void *), void *);
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robjextern void fmd_asru_hash_apply_by_fru(fmd_asru_hash_t *, const char *,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi void (*)(fmd_asru_link_t *, void *), void *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern void fmd_asru_hash_apply_by_rsrc(fmd_asru_hash_t *, const char *,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi void (*)(fmd_asru_link_t *, void *), void *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern void fmd_asru_hash_apply_by_case(fmd_asru_hash_t *, fmd_case_t *,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi void (*)(fmd_asru_link_t *, void *), void *);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiextern fmd_asru_t *fmd_asru_hash_lookup_name(fmd_asru_hash_t *, const char *);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiextern fmd_asru_link_t *fmd_asru_hash_create_entry(fmd_asru_hash_t *,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiextern void fmd_asru_hash_release(fmd_asru_hash_t *, fmd_asru_t *);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiextern void fmd_asru_hash_delete_case(fmd_asru_hash_t *, fmd_case_t *);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * flags used in fara_bywhat field in fmd_asru_rep_arg_t
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj * Return values for fmd_asru_repaired. May return "ok" or "not replaced".
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj * If no fault is found we will get default value of "not found".
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj * The following structures are used to pass arguments to the corresponding
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj * function when walking the resource cache by case etc.
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robjtypedef struct {
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj uint8_t fara_reason; /* repaired, acquit, replaced, removed */
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj uint8_t fara_bywhat; /* whether doing a walk by case, asru, etc */
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj char *fara_uuid; /* uuid can be passed in for comparison */
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robjextern void fmd_asru_repaired(fmd_asru_link_t *, void *);
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robjtypedef struct {
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi uint8_t *faus_ba; /* received status for each suspect */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi uint8_t *faus_proxy_asru; /* asru on proxy for each suspect? */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi uint8_t *faus_diag_asru; /* asru on diag for each suspect? */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi boolean_t faus_is_proxy; /* are we on the proxy side? */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern void fmd_asru_update_status(fmd_asru_link_t *alp, void *arg);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecinditypedef struct {
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi uint8_t *fasp_proxy_asru; /* asru on proxy for each suspect? */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi int fasp_proxy_external; /* is this an external transport? */
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj int fasp_proxy_rdonly; /* is this a rdonly transport? */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern void fmd_asru_set_on_proxy(fmd_asru_link_t *alp, void *arg);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern void fmd_asru_update_containees(fmd_asru_link_t *alp, void *arg);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecinditypedef struct {
c40d7343efa60b18ad1ceb316eb337caeea79046cindiextern void fmd_asru_close_status(fmd_asru_link_t *alp, void *arg);
c40d7343efa60b18ad1ceb316eb337caeea79046cindiextern int fmd_asru_setflags(fmd_asru_link_t *, uint_t);
c40d7343efa60b18ad1ceb316eb337caeea79046cindiextern int fmd_asru_clrflags(fmd_asru_link_t *, uint_t, uint8_t);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi#endif /* _FMD_ASRU_H */