]> git.proxmox.com Git - mirror_zfs.git/blame - include/sys/aggsum.h
Add CODE_OF_CONDUCT.md
[mirror_zfs.git] / include / sys / aggsum.h
CommitLineData
37fb3e43
PD
1/*
2 * CDDL HEADER START
3 *
4 * This file and its contents are supplied under the terms of the
5 * Common Development and Distribution License ("CDDL"), version 1.0.
6 * You may only use this file in accordance with the terms of version
7 * 1.0 of the CDDL.
8 *
9 * A full copy of the text of the CDDL should have accompanied this
10 * source. A copy of the CDDL is also available via the Internet at
11 * http://www.illumos.org/license/CDDL.
12 *
13 * CDDL HEADER END
14 */
15/*
16 * Copyright (c) 2017 by Delphix. All rights reserved.
17 */
18
19#ifndef _SYS_AGGSUM_H
20#define _SYS_AGGSUM_H
21
22#include <sys/zfs_context.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28typedef struct aggsum_bucket aggsum_bucket_t;
29
30struct aggsum_bucket {
31 kmutex_t asc_lock;
32 int64_t asc_delta;
33 uint64_t asc_borrowed;
34} ____cacheline_aligned;
35
36/*
37 * Fan out over FANOUT cpus.
38 */
39typedef struct aggsum {
40 kmutex_t as_lock;
41 int64_t as_lower_bound;
42 int64_t as_upper_bound;
43 uint64_t as_numbuckets;
44 aggsum_bucket_t *as_buckets;
45} aggsum_t;
46
47void aggsum_init(aggsum_t *, uint64_t);
48void aggsum_fini(aggsum_t *);
49int64_t aggsum_lower_bound(aggsum_t *);
50int64_t aggsum_upper_bound(aggsum_t *);
51int aggsum_compare(aggsum_t *, uint64_t);
52uint64_t aggsum_value(aggsum_t *);
53void aggsum_add(aggsum_t *, int64_t);
54
55#ifdef __cplusplus
56}
57#endif
58
59#endif /* _SYS_AGGSUM_H */