xref: /freebsd/sys/geom/linux_lvm/g_linux_lvm.h (revision 350b7c3570aa6c87c537e54f706f1866f93a4142)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2008 Andrew Thompson <thompsa@FreeBSD.org>
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  *
28  * $FreeBSD$
29  */
30 
31 #define	G_LLVM_DEBUG(lvl, ...) \
32     _GEOM_DEBUG("GEOM_LINUX_LVM", g_llvm_debug, (lvl), NULL, __VA_ARGS__)
33 
34 #define	G_LLVM_CLASS_NAME	"LINUX_LVM"
35 #define	G_LLVM_NAMELEN		128
36 #define	G_LLVM_UUIDLEN		40
37 #define	G_LLVM_MAGIC		"\040\114\126\115\062\040\170\133" \
38 				"\065\101\045\162\060\116\052\076"
39 
40 struct g_llvm_label {
41 	uint64_t	ll_sector;
42 	uint32_t	ll_crc;
43 	uint32_t	ll_offset;
44 	char		ll_uuid[G_LLVM_UUIDLEN];
45 	uint64_t	ll_size;
46 	uint64_t	ll_pestart;
47 	uint64_t	ll_md_offset;
48 	uint64_t	ll_md_size;
49 };
50 
51 struct g_llvm_metadata {
52 	uint32_t		md_csum;
53 	uint32_t		md_version;
54 	uint64_t		md_start;
55 	uint64_t		md_size;
56 	uint64_t		md_reloffset;
57 	uint64_t		md_relsize;
58 	struct g_llvm_vg	*md_vg;
59 };
60 
61 struct g_llvm_lv {
62 	LIST_ENTRY(g_llvm_lv)	lv_next;
63 	struct g_llvm_vg	*lv_vg;
64 	char			lv_name[G_LLVM_NAMELEN];
65 	char			lv_uuid[G_LLVM_UUIDLEN];
66 	int			lv_sgcount;
67 	int			lv_sgactive;
68 	struct g_provider	*lv_gprov;
69 	int			lv_extentcount;
70 	LIST_HEAD(, g_llvm_segment) lv_segs;
71 	int			lv_numsegs;
72 	struct g_llvm_segment	*lv_firstsg;
73 };
74 
75 struct g_llvm_pv {
76 	LIST_ENTRY(g_llvm_pv)	pv_next;
77 	struct g_llvm_vg	*pv_vg;
78 	char			pv_name[G_LLVM_NAMELEN];
79 	char			pv_uuid[G_LLVM_UUIDLEN];
80 	size_t			pv_size;
81 	off_t			pv_start;
82 	int			pv_count;
83 	struct g_provider	*pv_gprov;
84 	struct g_consumer	*pv_gcons;
85 };
86 
87 struct g_llvm_segment {
88 	LIST_ENTRY(g_llvm_segment)	sg_next;
89 	int			sg_start;
90 	int			sg_end;
91 	int			sg_count;
92 	char			sg_pvname[G_LLVM_NAMELEN];
93 	struct g_llvm_pv	*sg_pv;
94 	int			sg_pvstart;
95 	off_t			sg_pvoffset;
96 };
97 
98 struct g_llvm_vg {
99 	LIST_ENTRY(g_llvm_vg)	vg_next;
100 	char			vg_name[G_LLVM_NAMELEN];
101 	char			vg_uuid[G_LLVM_UUIDLEN];
102 	size_t			vg_extentsize;
103 	int			vg_sectorsize;
104 	struct g_geom		*vg_geom;
105 	LIST_HEAD(, g_llvm_pv)	vg_pvs;
106 	LIST_HEAD(, g_llvm_lv)	vg_lvs;
107 };
108