4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
30 #include <sys/lvm/mdvar.h>
36 #define META_SP_DEBUG ("META_SP_DEBUG")
38 /* on-disk structures */
39 #define MD_SP_MAGIC (0x20000127)
40 /* number of sectors to reserve at the beginning of the volume */
41 #define MD_SP_START (0)
42 /* current watermark version number */
43 #define MD_SP_VERSION (1)
44 /* size of a watermark in sectors */
45 #define MD_SP_WMSIZE (1)
46 /* free watermark name */
47 #define MD_SP_FREEWMNAME "free"
49 #define MD_SP_LOCALSETNAME ""
50 /* maximum length of a soft partition metadevice name. eg. dXXXX\0 */
51 #define MD_SP_MAX_DEVNAME_PLUS_1 (6)
54 * The size of this structure is forced to be 512 bytes (ie a sector) by
55 * using a union. Note the MD_MAX_SETNAME_PLUS_1 is set in meta_basic.h
58 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
61 typedef union mp_watermark
{
63 uint32_t wm_magic
; /* magic number */
64 uint32_t wm_version
; /* version number */
65 uint32_t wm_checksum
; /* structure checksum */
66 uint32_t wm_seq
; /* sequence number */
67 uint32_t wm_type
; /* extent type */
68 uint64_t wm_length
; /* length of extent */
69 char wm_mdname
[MD_MAX_SETNAME_PLUS_1
+
70 MD_SP_MAX_DEVNAME_PLUS_1
]; /* SP name */
71 char wm_setname
[MD_MAX_SETNAME_PLUS_1
]; /* setname */
73 uchar_t wm_pad
[MD_SP_WMSIZE
* DEV_BSIZE
];
75 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
79 #define wm_magic wm.wm_magic
80 #define wm_version wm.wm_version
81 #define wm_checksum wm.wm_checksum
82 #define wm_seq wm.wm_seq
83 #define wm_type wm.wm_type
84 #define wm_length wm.wm_length
85 #define wm_mdname wm.wm_mdname
86 #define wm_setname wm.wm_setname
89 typedef enum sp_ext_type
{
90 EXTTYP_ALLOC
= 0x1, /* this extent is in use by a soft partition */
91 EXTTYP_FREE
= 0x2, /* extent is not in use */
92 EXTTYP_END
= 0x3, /* last descriptor on the volume */
93 EXTTYP_RESERVED
= 0x4 /* extent will not be used or updated */
97 #define MD_IOC_SPSTATUS (MDIOC_MISC|0)
98 #define MD_IOC_SPUPDATEWM (MDIOC_MISC|1)
99 #define MD_IOC_SPREADWM (MDIOC_MISC|2)
100 #define MD_MN_IOC_SPUPDATEWM (MDIOC_MISC|3)
105 * parent and child save areas provide the mechanism for tracking
106 * I/O operations in the metadevice stack.
109 /* soft partitioning parent save area */
110 typedef struct md_spps
{ /* soft partition parent save */
112 mp_unit_t
*ps_un
; /* sp unit structure */
113 mdi_unit_t
*ps_ui
; /* incore unit struct */
114 buf_t
*ps_bp
; /* parent buffer */
119 * New structure members should be added here; fields added
120 * after ps_mx will not be zeroed during initialization.
125 /* parent save flags. */
126 #define MD_SPPS_ERROR 0x0001
127 #define MD_SPPS_DONTFREE 0x0002
128 #define MD_SPPS_DONE 0x0004
130 /* soft partitioning child save area */
131 typedef struct md_spcs
{
133 minor_t cs_mdunit
; /* child minor number */
134 md_spps_t
*cs_ps
; /* parent save pointer */
135 /* Add new structure members HERE!! */
136 buf_t cs_buf
; /* child buffer */
137 /* DO NOT add struture members here; cs_buf is dynamically sized */
140 #define SPPS_FREE(kc, ps) \
142 if ((ps)->ps_flags & MD_SPPS_DONTFREE) \
143 (ps)->ps_flags |= MD_SPPS_DONE; \
145 kmem_cache_free((kc), (ps)); \
148 /* externals from sp.c */
149 extern int sp_build_incore(void *, int);
150 extern void reset_sp(mp_unit_t
*, minor_t
, int);
151 extern int sp_directed_read(minor_t
, vol_directed_rd_t
*, int);
153 /* externals from sp_ioctl.c */
154 extern int md_sp_ioctl(dev_t dev
, int cmd
, void *data
,
155 int mode
, IOLOCK
*lockp
);
163 #endif /* _SYS__MD_SP_H */