Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/sys/contrib/openzfs/include/zfs_crrd.h
48255 views
1
// SPDX-License-Identifier: CDDL-1.0
2
/*
3
* CDDL HEADER START
4
*
5
* The contents of this file are subject to the terms of the
6
* Common Development and Distribution License (the "License").
7
* You may not use this file except in compliance with the License.
8
*
9
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10
* or https://opensource.org/licenses/CDDL-1.0.
11
* See the License for the specific language governing permissions
12
* and limitations under the License.
13
*
14
* When distributing Covered Code, include this CDDL HEADER in each
15
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16
* If applicable, add the following below this CDDL HEADER, with the
17
* fields enclosed by brackets "[]" replaced with your own identifying
18
* information: Portions Copyright [yyyy] [name of copyright owner]
19
*
20
* CDDL HEADER END
21
*/
22
/*
23
* Copyright (c) 2024 Klara Inc.
24
*
25
* This software was developed by
26
* Mariusz Zaborski <[email protected]>
27
* Fred Weigel <[email protected]>
28
* under sponsorship from Wasabi Technology, Inc. and Klara Inc.
29
*/
30
31
#ifndef _CRRD_H_
32
#define _CRRD_H_
33
34
#define RRD_MAX_ENTRIES 256
35
36
#define RRD_ENTRY_SIZE sizeof (uint64_t)
37
#define RRD_STRUCT_ELEM (sizeof (rrd_t) / RRD_ENTRY_SIZE)
38
39
typedef enum {
40
DBRRD_FLOOR,
41
DBRRD_CEILING
42
} dbrrd_rounding_t;
43
44
typedef struct {
45
uint64_t rrdd_time;
46
uint64_t rrdd_txg;
47
} rrd_data_t;
48
49
typedef struct {
50
uint64_t rrd_head; /* head (beginning) */
51
uint64_t rrd_tail; /* tail (end) */
52
uint64_t rrd_length;
53
54
rrd_data_t rrd_entries[RRD_MAX_ENTRIES];
55
} rrd_t;
56
57
typedef struct {
58
rrd_t dbr_minutes;
59
rrd_t dbr_days;
60
rrd_t dbr_months;
61
} dbrrd_t;
62
63
size_t rrd_len(rrd_t *rrd);
64
65
const rrd_data_t *rrd_entry(rrd_t *r, size_t i);
66
rrd_data_t *rrd_tail_entry(rrd_t *rrd);
67
uint64_t rrd_tail(rrd_t *rrd);
68
uint64_t rrd_get(rrd_t *rrd, size_t i);
69
70
void rrd_add(rrd_t *rrd, hrtime_t time, uint64_t txg);
71
72
void dbrrd_add(dbrrd_t *db, hrtime_t time, uint64_t txg);
73
uint64_t dbrrd_query(dbrrd_t *r, hrtime_t tv, dbrrd_rounding_t rouding);
74
75
#endif
76
77