xref: /titanic_41/usr/src/uts/common/sys/lvm/md_stripe.h (revision 6185db853e024a486ff8837e6784dd290d866112)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS__MD_STRIPE_H
28 #define	_SYS__MD_STRIPE_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/lvm/mdvar.h>
33 #include <sys/lvm/md_mirror_shared.h>
34 #include <sys/lvm/md_rename.h>
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 /*
41  * ms_comp32_od is for old 32 bit format only
42  */
43 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
44 #pragma pack(4)
45 #endif
46 typedef struct ms_comp32_od {
47 	mdkey_t		un_key;
48 	dev32_t		un_dev;
49 	daddr32_t	un_start_block;	/* comp start blkno */
50 	md_m_shared32_od_t un_mirror;
51 } ms_comp32_od_t;
52 
53 
54 typedef struct ms_comp {	/* components */
55 	mdkey_t		un_key;		/* namespace key */
56 	md_dev64_t	un_dev;		/* device number, 64 bit */
57 	diskaddr_t	un_start_block;	/* comp start blkno */
58 	md_m_shared_t	un_mirror;	/* mirror shared data */
59 } ms_comp_t;
60 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
61 #pragma pack()
62 #endif
63 
64 /*
65  * ms_unit32_od is for old 32 bit format only
66  */
67 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
68 #pragma pack(4)
69 #endif
70 typedef struct ms_unit32_od {
71 	mdc_unit32_od_t	c;
72 	int		un_hsp_id;	/* hot spare pool db record id */
73 	uint_t		un_nrows;	/* number of rows */
74 	uint_t		un_ocomp;	/* offset of  ms_comp array  */
75 	struct ms_row32_od {
76 		int	un_icomp;	/* ms_comp array index of first comp */
77 		uint_t	un_ncomp;	/* # comps in this row */
78 		int	un_blocks;	/* total blocks in this row */
79 		int	un_cum_blocks;	/* cum. blks in this and prev. rows */
80 		int	un_interlace;	/* # blks from each disk in a stripe */
81 	}un_row[1];
82 } ms_unit32_od_t;
83 
84 
85 typedef struct ms_unit {
86 	mdc_unit_t	c;
87 	int		un_hsp_id;	/* hot spare pool db record id */
88 	uint_t		un_nrows;	/* number of rows */
89 	uint_t		un_ocomp;	/* offset of  ms_comp array  */
90 	struct ms_row {
91 		int	un_icomp;	/* ms_comp array index of first comp */
92 		uint_t	un_ncomp;	/* # comps in this row */
93 		diskaddr_t un_blocks;	/* total blocks in this row */
94 		diskaddr_t un_cum_blocks;	/* cum. blks in rows */
95 		diskaddr_t un_interlace;	/* # blks from each disk */
96 	}un_row[1];
97 } ms_unit_t;
98 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
99 #pragma pack()
100 #endif
101 
102 #ifdef _KERNEL
103 
104 typedef struct md_sps {			/* stripe parent save */
105 	DAEMON_QUEUE
106 	ms_unit_t	*ps_un;
107 	mdi_unit_t	*ps_ui;
108 	buf_t		*ps_bp;
109 	caddr_t		 ps_addr;
110 	int		 ps_frags;
111 	int		 ps_flags;
112 	ms_comp_t	*ps_errcomp;
113 	/*
114 	 * New structure members should be added here; fields added
115 	 * after ps_mx will not be zeroed during initialization.
116 	 */
117 	kmutex_t	 ps_mx;
118 } md_sps_t;
119 
120 #define	MD_SPS_ERROR		0x0001
121 #define	MD_SPS_DONTFREE		0x0002
122 #define	MD_SPS_DONE		0x0004
123 
124 #define	SPS_FREE(kc, ps)			\
125 {						\
126 	if ((ps)->ps_flags & MD_SPS_DONTFREE)	\
127 		(ps)->ps_flags |= MD_SPS_DONE;	\
128 	else					\
129 		kmem_cache_free((kc), (ps));	\
130 }
131 
132 typedef struct md_scs {
133 	DAEMON_QUEUE
134 	minor_t		 cs_mdunit;
135 	md_sps_t	*cs_ps;
136 	ms_comp_t	*cs_comp;
137 	/* Add new structure members HERE!! */
138 	buf_t		 cs_buf;
139 	/*  DO NOT add struture members here; cs_buf is dynamically sized */
140 } md_scs_t;
141 
142 /* Externals from stripe.c */
143 extern int	stripe_build_incore(void *, int);
144 extern void	reset_stripe(ms_unit_t *, minor_t, int);
145 extern intptr_t	stripe_component_count(md_dev64_t, void *);
146 extern intptr_t	stripe_get_dev(md_dev64_t, void *, int, ms_cd_info_t *);
147 extern intptr_t stripe_replace_dev(md_dev64_t, void *, int, ms_new_dev_t *,
148     mddb_recid_t *, int, void (**)(), void **);
149 extern void	stripe_replace_done(md_dev64_t, sv_dev_t *);
150 
151 /* Externals from stripe_ioctl.c */
152 extern int	md_stripe_ioctl(dev_t dev, int cmd, void *data,
153 		    int mode, IOLOCK *lockp);
154 
155 /* rename named service functions (stripe_ioctl.c) */
156 md_ren_svc_t	stripe_rename_check;
157 
158 #endif	/* _KERNEL */
159 
160 #ifdef	__cplusplus
161 }
162 #endif
163 
164 #endif	/* _SYS__MD_STRIPE_H */
165