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