4 * Copyright (C) 1997-2004 Sistina Software, Inc. All rights reserved.
5 * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
7 * This file is part of LVM2.
9 * This copyrighted material is made available to anyone wishing to use,
10 * modify, copy, or redistribute it subject to the terms and conditions
11 * of the GNU Lesser General Public License v.2.1.
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program; if not, write to the Free Software Foundation,
15 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 #ifndef DISK_REP_FORMAT_POOL_H
19 #define DISK_REP_FORMAT_POOL_H
24 #define MINOR_OFFSET 65536
27 #define NSPMajorVersion 4
28 #define NSPMinorVersion 1
29 #define NSPUpdateLevel 3
32 #define POOL_NAME_SIZE (256)
33 #define POOL_MAGIC 0x011670
34 #define POOL_MAJOR (121)
35 #define POOL_MAX_DEVICES 128
37 /* When checking for version matching, the first two numbers **
38 ** are important for metadata formats, a.k.a pool labels. **
39 ** All the numbers are important when checking if the user **
40 ** space tools match up with the kernel module............. */
41 #define POOL_VERSION (NSPMajorVersion << 16 | \
42 NSPMinorVersion << 8 | \
45 /* Pool label is at the head of every pool disk partition */
46 #define SIZEOF_POOL_LABEL (8192)
49 #define POOL_PE_SIZE (SIZEOF_POOL_LABEL >> SECTOR_SHIFT)
50 #define POOL_PE_START (SIZEOF_POOL_LABEL >> SECTOR_SHIFT)
53 #define get_pool_vg_uuid(id, pd) do { get_pool_uuid((char *)(id), \
54 (pd)->pl_pool_id, 0, 0); \
56 #define get_pool_pv_uuid(id, pd) do { get_pool_uuid((char *)(id), \
61 #define get_pool_lv_uuid(id, pd) do { get_pool_uuid((char *)&(id)[0], \
62 (pd)->pl_pool_id, 0, 0); \
63 get_pool_uuid((char*)&(id)[1], \
64 (pd)->pl_pool_id, 0, 0); \
73 uint64_t pl_magic
; /* Pool magic number */
74 uint64_t pl_pool_id
; /* Unique pool identifier */
75 char pl_pool_name
[POOL_NAME_SIZE
]; /* Name of pool */
76 uint32_t pl_version
; /* Pool version */
77 uint32_t pl_subpools
; /* Number of subpools in this pool */
78 uint32_t pl_sp_id
; /* Subpool number within pool */
79 uint32_t pl_sp_devs
; /* Number of data partitions in this subpool */
80 uint32_t pl_sp_devid
; /* Partition number within subpool */
81 uint32_t pl_sp_type
; /* Partition type */
82 uint64_t pl_blocks
; /* Number of blocks in this partition */
83 uint32_t pl_striping
; /* Striping size within subpool */
85 * If the number of DMEP devices is zero, then the next field **
86 * ** (pl_sp_dmepid) becomes the subpool ID for redirection. In **
87 * ** other words, if this subpool does not have the capability **
88 * ** to do DMEP, then it must specify which subpool will do it **
93 * While the next 3 field are no longer used, they must stay to keep **
94 * ** backward compatibility...........................................
96 uint32_t pl_sp_dmepdevs
;/* Number of dmep devices in this subpool */
97 uint32_t pl_sp_dmepid
; /* Dmep device number within subpool */
98 uint32_t pl_sp_weight
; /* if dmep dev, pref to using it */
100 uint32_t pl_minor
; /* the pool minor number */
101 uint32_t pl_padding
; /* reminder - think about alignment */
104 * Even though we're zeroing out 8k at the front of the disk before
105 * writing the label, putting this in
107 char pl_reserve
[184]; /* bump the structure size out to 512 bytes */
113 struct physical_volume
*pv
;
118 struct user_subpool
{
119 uint32_t initialized
;
125 struct user_device
*devs
;
129 uint32_t initialized
;
134 struct physical_volume
*pv
;
137 int read_pool_label(struct pool_list
*pl
, struct labeller
*l
,
138 struct device
*dev
, char *buf
, struct label
**label
);
139 void pool_label_out(struct pool_disk
*pl
, void *buf
);
140 void pool_label_in(struct pool_disk
*pl
, void *buf
);
141 void get_pool_uuid(char *uuid
, uint64_t poolid
, uint32_t spid
, uint32_t devid
);
142 int import_pool_vg(struct volume_group
*vg
, struct dm_pool
*mem
, struct dm_list
*pls
);
143 int import_pool_lvs(struct volume_group
*vg
, struct dm_pool
*mem
,
144 struct dm_list
*pls
);
145 int import_pool_pvs(const struct format_type
*fmt
, struct volume_group
*vg
,
146 struct dm_list
*pvs
, struct dm_pool
*mem
, struct dm_list
*pls
);
147 int import_pool_pv(const struct format_type
*fmt
, struct dm_pool
*mem
,
148 struct volume_group
*vg
, struct physical_volume
*pv
,
149 struct pool_list
*pl
);
150 int import_pool_segments(struct dm_list
*lvs
, struct dm_pool
*mem
,
151 struct user_subpool
*usp
, int sp_count
);
152 int read_pool_pds(const struct format_type
*fmt
, const char *vgname
,
153 struct dm_pool
*mem
, struct dm_list
*head
);
154 struct pool_list
*read_pool_disk(const struct format_type
*fmt
,
155 struct device
*dev
, struct dm_pool
*mem
,
156 const char *vg_name
);
158 #endif /* DISK_REP_POOL_FORMAT_H */