]> git.proxmox.com Git - mirror_zfs.git/blob - include/sys/ddt_impl.h
ddt: split internal DDT API into separate header
[mirror_zfs.git] / include / sys / ddt_impl.h
1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * 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.LICENSE
9 * or https://opensource.org/licenses/CDDL-1.0.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2016 by Delphix. All rights reserved.
24 * Copyright (c) 2023, Klara Inc.
25 */
26
27 #ifndef _SYS_DDT_IMPL_H
28 #define _SYS_DDT_IMPL_H
29
30 #include <sys/ddt.h>
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 /*
37 * Ops vector to access a specific DDT object type.
38 */
39 typedef struct ddt_ops {
40 char ddt_op_name[32];
41 int (*ddt_op_create)(objset_t *os, uint64_t *object, dmu_tx_t *tx,
42 boolean_t prehash);
43 int (*ddt_op_destroy)(objset_t *os, uint64_t object, dmu_tx_t *tx);
44 int (*ddt_op_lookup)(objset_t *os, uint64_t object, ddt_entry_t *dde);
45 void (*ddt_op_prefetch)(objset_t *os, uint64_t object,
46 ddt_entry_t *dde);
47 int (*ddt_op_update)(objset_t *os, uint64_t object, ddt_entry_t *dde,
48 dmu_tx_t *tx);
49 int (*ddt_op_remove)(objset_t *os, uint64_t object, ddt_entry_t *dde,
50 dmu_tx_t *tx);
51 int (*ddt_op_walk)(objset_t *os, uint64_t object, ddt_entry_t *dde,
52 uint64_t *walk);
53 int (*ddt_op_count)(objset_t *os, uint64_t object, uint64_t *count);
54 } ddt_ops_t;
55
56 extern const ddt_ops_t ddt_zap_ops;
57
58 extern void ddt_stat_update(ddt_t *ddt, ddt_entry_t *dde, uint64_t neg);
59
60 /*
61 * These are only exposed so that zdb can access them. Try not to use them
62 * outside of the DDT implementation proper, and if you do, consider moving
63 * them up.
64 */
65 #define DDT_NAMELEN 107
66
67 extern uint64_t ddt_phys_total_refcnt(const ddt_entry_t *dde);
68
69 extern void ddt_key_fill(ddt_key_t *ddk, const blkptr_t *bp);
70
71 extern void ddt_stat_add(ddt_stat_t *dst, const ddt_stat_t *src, uint64_t neg);
72
73 extern void ddt_object_name(ddt_t *ddt, enum ddt_type type,
74 enum ddt_class clazz, char *name);
75 extern int ddt_object_walk(ddt_t *ddt, enum ddt_type type,
76 enum ddt_class clazz, uint64_t *walk, ddt_entry_t *dde);
77 extern int ddt_object_count(ddt_t *ddt, enum ddt_type type,
78 enum ddt_class clazz, uint64_t *count);
79 extern int ddt_object_info(ddt_t *ddt, enum ddt_type type,
80 enum ddt_class clazz, dmu_object_info_t *);
81
82 #ifdef __cplusplus
83 }
84 #endif
85
86 #endif /* _SYS_DDT_H */