Path: blob/main/sys/contrib/openzfs/cmd/zed/agents/fmd_serd.h
48529 views
// SPDX-License-Identifier: CDDL-1.01/*2* CDDL HEADER START3*4* The contents of this file are subject to the terms of the5* Common Development and Distribution License, Version 1.0 only6* (the "License"). You may not use this file except in compliance7* with the License.8*9* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE10* or https://opensource.org/licenses/CDDL-1.0.11* See the License for the specific language governing permissions12* and limitations under the License.13*14* When distributing Covered Code, include this CDDL HEADER in each15* file and include the License file at usr/src/OPENSOLARIS.LICENSE.16* If applicable, add the following below this CDDL HEADER, with the17* fields enclosed by brackets "[]" replaced with your own identifying18* information: Portions Copyright [yyyy] [name of copyright owner]19*20* CDDL HEADER END21*/22/*23* Copyright 2004 Sun Microsystems, Inc. All rights reserved.24* Use is subject to license terms.25*26* Copyright (c) 2016, Intel Corporation.27*/2829#ifndef _FMD_SERD_H30#define _FMD_SERD_H3132#ifdef __cplusplus33extern "C" {34#endif3536#include <sys/list.h>37#include <sys/time.h>3839typedef struct fmd_serd_elem {40list_node_t se_list; /* linked list forward/back pointers */41hrtime_t se_hrt; /* upper bound on event hrtime */42} fmd_serd_elem_t;4344typedef struct fmd_serd_eng {45char *sg_name; /* string name for this engine */46struct fmd_serd_eng *sg_next; /* next engine on hash chain */47list_t sg_list; /* list of fmd_serd_elem_t's */48uint_t sg_count; /* count of events in sg_list */49uint_t sg_flags; /* engine flags (see below) */50uint_t sg_n; /* engine N parameter (event count) */51hrtime_t sg_t; /* engine T parameter (nanoseconds) */52} fmd_serd_eng_t;5354#define FMD_SERD_FIRED 0x1 /* error rate has exceeded threshold */55#define FMD_SERD_DIRTY 0x2 /* engine needs to be checkpointed */5657typedef void fmd_serd_eng_f(fmd_serd_eng_t *, void *);5859typedef struct fmd_serd_hash {60fmd_serd_eng_t **sh_hash; /* hash bucket array for buffers */61uint_t sh_hashlen; /* length of hash bucket array */62uint_t sh_count; /* count of engines in hash */63} fmd_serd_hash_t;6465extern void fmd_serd_hash_create(fmd_serd_hash_t *);66extern void fmd_serd_hash_destroy(fmd_serd_hash_t *);67extern void fmd_serd_hash_apply(fmd_serd_hash_t *, fmd_serd_eng_f *, void *);6869extern fmd_serd_eng_t *fmd_serd_eng_insert(fmd_serd_hash_t *,70const char *, uint32_t, hrtime_t);7172extern fmd_serd_eng_t *fmd_serd_eng_lookup(fmd_serd_hash_t *, const char *);73extern void fmd_serd_eng_delete(fmd_serd_hash_t *, const char *);7475extern int fmd_serd_eng_record(fmd_serd_eng_t *, hrtime_t);76extern int fmd_serd_eng_fired(fmd_serd_eng_t *);77extern int fmd_serd_eng_empty(fmd_serd_eng_t *);7879extern void fmd_serd_eng_reset(fmd_serd_eng_t *);80extern void fmd_serd_eng_gc(fmd_serd_eng_t *, void *);8182#ifdef __cplusplus83}84#endif8586#endif /* _FMD_SERD_H */878889