xref: /freebsd/sys/contrib/openzfs/include/sys/vdev_indirect_births.h (revision 22649d4dba730d46244fd2dff4fd174903c8379f)
1 // SPDX-License-Identifier: CDDL-1.0
2 /*
3  * This file and its contents are supplied under the terms of the
4  * Common Development and Distribution License ("CDDL"), version 1.0.
5  * You may only use this file in accordance with the terms of version
6  * 1.0 of the CDDL.
7  *
8  * A full copy of the text of the CDDL should have accompanied this
9  * source.  A copy of the CDDL is also available via the Internet at
10  * https://opensource.org/license/CDDL-1.0.
11  */
12 
13 /*
14  * Copyright (c) 2015 by Delphix. All rights reserved.
15  */
16 
17 #ifndef	_SYS_VDEV_INDIRECT_BIRTHS_H
18 #define	_SYS_VDEV_INDIRECT_BIRTHS_H
19 
20 #include <sys/dmu.h>
21 #include <sys/spa.h>
22 
23 #ifdef	__cplusplus
24 extern "C" {
25 #endif
26 
27 typedef struct vdev_indirect_birth_entry_phys {
28 	uint64_t vibe_offset;
29 	uint64_t vibe_phys_birth_txg;
30 } vdev_indirect_birth_entry_phys_t;
31 
32 typedef struct vdev_indirect_birth_phys {
33 	uint64_t	vib_count; /* count of v_i_b_entry_phys_t's */
34 } vdev_indirect_birth_phys_t;
35 
36 typedef struct vdev_indirect_births {
37 	uint64_t	vib_object;
38 
39 	/*
40 	 * Each entry indicates that everything up to but not including
41 	 * vibe_offset was copied in vibe_phys_birth_txg. Entries are sorted
42 	 * by increasing phys_birth, and also by increasing offset. See
43 	 * vdev_indirect_births_physbirth for usage.
44 	 */
45 	vdev_indirect_birth_entry_phys_t *vib_entries;
46 
47 	objset_t	*vib_objset;
48 
49 	dmu_buf_t	*vib_dbuf;
50 	vdev_indirect_birth_phys_t	*vib_phys;
51 } vdev_indirect_births_t;
52 
53 extern vdev_indirect_births_t *vdev_indirect_births_open(objset_t *os,
54     uint64_t object);
55 extern void vdev_indirect_births_close(vdev_indirect_births_t *vib);
56 extern boolean_t vdev_indirect_births_is_open(vdev_indirect_births_t *vib);
57 extern uint64_t vdev_indirect_births_alloc(objset_t *os, dmu_tx_t *tx);
58 extern void vdev_indirect_births_free(objset_t *os, uint64_t object,
59     dmu_tx_t *tx);
60 
61 extern uint64_t vdev_indirect_births_count(vdev_indirect_births_t *vib);
62 extern uint64_t vdev_indirect_births_object(vdev_indirect_births_t *vib);
63 
64 extern void vdev_indirect_births_add_entry(vdev_indirect_births_t *vib,
65     uint64_t offset, uint64_t txg, dmu_tx_t *tx);
66 
67 extern uint64_t vdev_indirect_births_physbirth(vdev_indirect_births_t *vib,
68     uint64_t offset, uint64_t asize);
69 
70 extern uint64_t vdev_indirect_births_last_entry_txg(
71     vdev_indirect_births_t *vib);
72 
73 #ifdef	__cplusplus
74 }
75 #endif
76 
77 #endif	/* _SYS_VDEV_INDIRECT_BIRTHS_H */
78