summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/sys/lvm/md_stripe.h
blob: 1db7fda264c1dcde86cc4757c3e3f96ede6ac87f (plain)
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (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 http://www.opensolaris.org/os/licensing.
 * 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 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _SYS__MD_STRIPE_H
#define	_SYS__MD_STRIPE_H

#pragma ident	"%Z%%M%	%I%	%E% SMI"

#include <sys/lvm/mdvar.h>
#include <sys/lvm/md_mirror_shared.h>
#include <sys/lvm/md_rename.h>

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * ms_comp32_od is for old 32 bit format only
 */
#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
#pragma pack(4)
#endif
typedef struct ms_comp32_od {
	mdkey_t		un_key;
	dev32_t		un_dev;
	daddr32_t	un_start_block;	/* comp start blkno */
	md_m_shared32_od_t un_mirror;
} ms_comp32_od_t;


typedef struct ms_comp {	/* components */
	mdkey_t		un_key;		/* namespace key */
	md_dev64_t	un_dev;		/* device number, 64 bit */
	diskaddr_t	un_start_block;	/* comp start blkno */
	md_m_shared_t	un_mirror;	/* mirror shared data */
} ms_comp_t;
#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
#pragma pack()
#endif

/*
 * ms_unit32_od is for old 32 bit format only
 */
#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
#pragma pack(4)
#endif
typedef struct ms_unit32_od {
	mdc_unit32_od_t	c;
	int		un_hsp_id;	/* hot spare pool db record id */
	uint_t		un_nrows;	/* number of rows */
	uint_t		un_ocomp;	/* offset of  ms_comp array  */
	struct ms_row32_od {
		int	un_icomp;	/* ms_comp array index of first comp */
		uint_t	un_ncomp;	/* # comps in this row */
		int	un_blocks;	/* total blocks in this row */
		int	un_cum_blocks;	/* cum. blks in this and prev. rows */
		int	un_interlace;	/* # blks from each disk in a stripe */
	}un_row[1];
} ms_unit32_od_t;


typedef struct ms_unit {
	mdc_unit_t	c;
	int		un_hsp_id;	/* hot spare pool db record id */
	uint_t		un_nrows;	/* number of rows */
	uint_t		un_ocomp;	/* offset of  ms_comp array  */
	struct ms_row {
		int	un_icomp;	/* ms_comp array index of first comp */
		uint_t	un_ncomp;	/* # comps in this row */
		diskaddr_t un_blocks;	/* total blocks in this row */
		diskaddr_t un_cum_blocks;	/* cum. blks in rows */
		diskaddr_t un_interlace;	/* # blks from each disk */
	}un_row[1];
} ms_unit_t;
#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
#pragma pack()
#endif

#ifdef _KERNEL

typedef struct md_sps {			/* stripe parent save */
	DAEMON_QUEUE
	ms_unit_t	*ps_un;
	mdi_unit_t	*ps_ui;
	buf_t		*ps_bp;
	caddr_t		 ps_addr;
	int		 ps_frags;
	int		 ps_flags;
	ms_comp_t	*ps_errcomp;
	/*
	 * New structure members should be added here; fields added
	 * after ps_mx will not be zeroed during initialization.
	 */
	kmutex_t	 ps_mx;
} md_sps_t;

#define	MD_SPS_ERROR		0x0001
#define	MD_SPS_DONTFREE		0x0002
#define	MD_SPS_DONE		0x0004

#define	SPS_FREE(kc, ps)			\
{						\
	if ((ps)->ps_flags & MD_SPS_DONTFREE)	\
		(ps)->ps_flags |= MD_SPS_DONE;	\
	else					\
		kmem_cache_free((kc), (ps));	\
}

typedef struct md_scs {
	DAEMON_QUEUE
	minor_t		 cs_mdunit;
	md_sps_t	*cs_ps;
	ms_comp_t	*cs_comp;
	/* Add new structure members HERE!! */
	buf_t		 cs_buf;
	/*  DO NOT add struture members here; cs_buf is dynamically sized */
} md_scs_t;

/* Externals from stripe.c */
extern int	stripe_build_incore(void *, int);
extern void	reset_stripe(ms_unit_t *, minor_t, int);
extern intptr_t	stripe_component_count(md_dev64_t, void *);
extern intptr_t	stripe_get_dev(md_dev64_t, void *, int, ms_cd_info_t *);
extern intptr_t stripe_replace_dev(md_dev64_t, void *, int, ms_new_dev_t *,
    mddb_recid_t *, int, void (**)(), void **);
extern void	stripe_replace_done(md_dev64_t, sv_dev_t *);

/* Externals from stripe_ioctl.c */
extern int	md_stripe_ioctl(dev_t dev, int cmd, void *data,
		    int mode, IOLOCK *lockp);

/* rename named service functions (stripe_ioctl.c) */
md_ren_svc_t	stripe_rename_check;

#endif	/* _KERNEL */

#ifdef	__cplusplus
}
#endif

#endif	/* _SYS__MD_STRIPE_H */