Merge commit '7d815089a43a963b49eaddf97e514194ec29805b'
[unleashed.git] / kernel / fs / zfs / sys / aggsum.h
blob59aac07679a8876a645f6e549819dd229b688b28
1 /*
2 * CDDL HEADER START
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.
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.
13 * CDDL HEADER END
16 * Copyright (c) 2017 by Delphix. All rights reserved.
19 #ifndef _SYS_AGGSUM_H
20 #define _SYS_AGGSUM_H
22 #include <sys/zfs_context.h>
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
28 #define CACHE_LINE_SIZE 64
30 typedef struct aggsum_bucket {
31 kmutex_t asc_lock;
32 int64_t asc_delta;
33 uint64_t asc_borrowed;
34 uint64_t asc_pad[4]; /* pad out to cache line (64 bytes) */
35 } aggsum_bucket_t __aligned(CACHE_LINE_SIZE);
38 * Fan out over FANOUT cpus.
40 typedef struct aggsum {
41 kmutex_t as_lock;
42 int64_t as_lower_bound;
43 int64_t as_upper_bound;
44 uint64_t as_numbuckets;
45 aggsum_bucket_t *as_buckets;
46 } aggsum_t;
48 void aggsum_init(aggsum_t *, uint64_t);
49 void aggsum_fini(aggsum_t *);
50 int64_t aggsum_lower_bound(aggsum_t *);
51 int64_t aggsum_upper_bound(aggsum_t *);
52 int aggsum_compare(aggsum_t *, uint64_t);
53 uint64_t aggsum_value(aggsum_t *);
54 void aggsum_add(aggsum_t *, int64_t);
56 #ifdef __cplusplus
58 #endif
60 #endif /* _SYS_AGGSUM_H */