2 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
3 * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
5 * This file is part of LVM2.
7 * This copyrighted material is made available to anyone wishing to use,
8 * modify, copy, or redistribute it subject to the terms and conditions
9 * of the GNU Lesser General Public License v.2.1.
11 * You should have received a copy of the GNU Lesser General Public License
12 * along with this program; if not, write to the Free Software Foundation,
13 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 #ifndef _LVM_TEXT_LAYOUT_H
17 #define _LVM_TEXT_LAYOUT_H
20 #include "lvm-types.h"
26 uint64_t offset; /* Offset in bytes to start sector */
27 uint64_t size; /* Bytes */
28 } __attribute__ ((packed));
30 /* Data areas (holding PEs) */
31 struct data_area_list {
33 struct disk_locn disk_locn;
36 /* Fields with the suffix _xl should be xlate'd wherever they appear */
39 int8_t pv_uuid[ID_LEN];
41 /* This size can be overridden if PV belongs to a VG */
42 uint64_t device_size_xl; /* Bytes */
44 /* NULL-terminated list of data areas followed by */
45 /* NULL-terminated list of metadata area headers */
46 struct disk_locn disk_areas_xl[0]; /* Two lists */
47 } __attribute__ ((packed));
50 * Ignore this raw location. This allows us to
51 * ignored metadata areas easily, and thus balance
52 * metadata across VGs with many PVs.
54 #define RAW_LOCN_IGNORED 0x00000001
58 uint64_t offset; /* Offset in bytes to start sector */
59 uint64_t size; /* Bytes */
62 } __attribute__ ((packed));
64 int rlocn_is_ignored(const struct raw_locn *rlocn);
65 void rlocn_set_ignored(struct raw_locn *rlocn, unsigned mda_ignored);
68 /* Structure size limited to one sector */
70 uint32_t checksum_xl; /* Checksum of rest of mda_header */
71 int8_t magic[16]; /* To aid scans for metadata */
73 uint64_t start; /* Absolute start byte of mda_header */
74 uint64_t size; /* Size of metadata area */
76 struct raw_locn raw_locns[0]; /* NULL-terminated list */
77 } __attribute__ ((packed));
79 struct mda_header *raw_read_mda_header(const struct format_type *fmt,
80 struct device_area *dev_area);
85 struct metadata_area_ops *file_ops;
86 struct metadata_area_ops *raw_ops;
90 struct device_area area;
91 uint64_t free_sectors;
92 struct raw_locn rlocn; /* Store inbetween write and commit */
95 /* FIXME Convert this at runtime */
96 #define FMTT_MAGIC "\040\114\126\115\062\040\170\133\065\101\045\162\060\116\052\076"
97 #define FMTT_VERSION 1
98 #define MDA_HEADER_SIZE 512
99 #define LVM2_LABEL "LVM2 001"
100 #define MDA_SIZE_MIN (8 * (unsigned) lvm_getpagesize())
103 const char *vgname_from_mda(const struct format_type *fmt,
104 struct mda_header *mdah,
105 struct device_area *dev_area, struct id *vgid,
106 uint64_t *vgstatus, char **creation_host,
107 uint64_t *mda_free_sectors);