aboutsummaryrefslogtreecommitdiff
path: root/include/sys/ddt_impl.h
blob: 52b927b7519da1b35c095edeb97a9439f0a78b7d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or https://opensource.org/licenses/CDDL-1.0.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
 * Copyright (c) 2016 by Delphix. All rights reserved.
 * Copyright (c) 2023, Klara Inc.
 */

#ifndef _SYS_DDT_IMPL_H
#define	_SYS_DDT_IMPL_H

#include <sys/ddt.h>

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * Ops vector to access a specific DDT object type.
 */
typedef struct {
	char ddt_op_name[32];
	int (*ddt_op_create)(objset_t *os, uint64_t *object, dmu_tx_t *tx,
	    boolean_t prehash);
	int (*ddt_op_destroy)(objset_t *os, uint64_t object, dmu_tx_t *tx);
	int (*ddt_op_lookup)(objset_t *os, uint64_t object,
	    const ddt_key_t *ddk, ddt_phys_t *phys, size_t psize);
	int (*ddt_op_contains)(objset_t *os, uint64_t object,
	    const ddt_key_t *ddk);
	void (*ddt_op_prefetch)(objset_t *os, uint64_t object,
	    const ddt_key_t *ddk);
	int (*ddt_op_update)(objset_t *os, uint64_t object,
	    const ddt_key_t *ddk, const ddt_phys_t *phys, size_t psize,
	    dmu_tx_t *tx);
	int (*ddt_op_remove)(objset_t *os, uint64_t object,
	    const ddt_key_t *ddk, dmu_tx_t *tx);
	int (*ddt_op_walk)(objset_t *os, uint64_t object, uint64_t *walk,
	    ddt_key_t *ddk, ddt_phys_t *phys, size_t psize);
	int (*ddt_op_count)(objset_t *os, uint64_t object, uint64_t *count);
} ddt_ops_t;

extern const ddt_ops_t ddt_zap_ops;

extern void ddt_stat_update(ddt_t *ddt, ddt_entry_t *dde, uint64_t neg);

/*
 * These are only exposed so that zdb can access them. Try not to use them
 * outside of the DDT implementation proper, and if you do, consider moving
 * them up.
 */

/*
 * Enough room to expand DMU_POOL_DDT format for all possible DDT
 * checksum/class/type combinations.
 */
#define	DDT_NAMELEN	32

extern uint64_t ddt_phys_total_refcnt(const ddt_entry_t *dde);

extern void ddt_key_fill(ddt_key_t *ddk, const blkptr_t *bp);

extern void ddt_stat_add(ddt_stat_t *dst, const ddt_stat_t *src, uint64_t neg);

extern void ddt_object_name(ddt_t *ddt, ddt_type_t type, ddt_class_t clazz,
    char *name);
extern int ddt_object_walk(ddt_t *ddt, ddt_type_t type, ddt_class_t clazz,
    uint64_t *walk, ddt_entry_t *dde);
extern int ddt_object_count(ddt_t *ddt, ddt_type_t type, ddt_class_t clazz,
    uint64_t *count);
extern int ddt_object_info(ddt_t *ddt, ddt_type_t type, ddt_class_t clazz,
    dmu_object_info_t *);

#ifdef	__cplusplus
}
#endif

#endif	/* _SYS_DDT_H */