Path: blob/main/sys/contrib/openzfs/include/zfs_crrd.h
48255 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 (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.LICENSE9* or https://opensource.org/licenses/CDDL-1.0.10* See the License for the specific language governing permissions11* and limitations under the License.12*13* When distributing Covered Code, include this CDDL HEADER in each14* file and include the License file at usr/src/OPENSOLARIS.LICENSE.15* If applicable, add the following below this CDDL HEADER, with the16* fields enclosed by brackets "[]" replaced with your own identifying17* information: Portions Copyright [yyyy] [name of copyright owner]18*19* CDDL HEADER END20*/21/*22* Copyright (c) 2024 Klara Inc.23*24* This software was developed by25* Mariusz Zaborski <[email protected]>26* Fred Weigel <[email protected]>27* under sponsorship from Wasabi Technology, Inc. and Klara Inc.28*/2930#ifndef _CRRD_H_31#define _CRRD_H_3233#define RRD_MAX_ENTRIES 2563435#define RRD_ENTRY_SIZE sizeof (uint64_t)36#define RRD_STRUCT_ELEM (sizeof (rrd_t) / RRD_ENTRY_SIZE)3738typedef enum {39DBRRD_FLOOR,40DBRRD_CEILING41} dbrrd_rounding_t;4243typedef struct {44uint64_t rrdd_time;45uint64_t rrdd_txg;46} rrd_data_t;4748typedef struct {49uint64_t rrd_head; /* head (beginning) */50uint64_t rrd_tail; /* tail (end) */51uint64_t rrd_length;5253rrd_data_t rrd_entries[RRD_MAX_ENTRIES];54} rrd_t;5556typedef struct {57rrd_t dbr_minutes;58rrd_t dbr_days;59rrd_t dbr_months;60} dbrrd_t;6162size_t rrd_len(rrd_t *rrd);6364const rrd_data_t *rrd_entry(rrd_t *r, size_t i);65rrd_data_t *rrd_tail_entry(rrd_t *rrd);66uint64_t rrd_tail(rrd_t *rrd);67uint64_t rrd_get(rrd_t *rrd, size_t i);6869void rrd_add(rrd_t *rrd, hrtime_t time, uint64_t txg);7071void dbrrd_add(dbrrd_t *db, hrtime_t time, uint64_t txg);72uint64_t dbrrd_query(dbrrd_t *r, hrtime_t tv, dbrrd_rounding_t rouding);7374#endif757677