Add a geom class to map Linux LVM logical volumes.

The logical disks will appear as /dev/lvm/<vol group>-<logical vol>, for
instance /dev/lvm/vg0-home. GLVM currently supports linear stripes with
segments on multiple physical disks. The metadata is read only, logical
volumes can not be allocated or resized.

Reviewed by:	Ivan Voras
This commit is contained in:
Andrew Thompson 2008-02-11 03:05:11 +00:00
parent 4f52b754df
commit 77b65eef19
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=176166
3 changed files with 1378 additions and 0 deletions

88
share/man/man4/geom_lvm.4 Normal file
View File

@ -0,0 +1,88 @@
.\"
.\" Copyright (c) 2008 Andrew Thompson
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD$
.\"
.Dd February 11, 2008
.Os
.Dt GEOM_LVM 4
.Sh NAME
.Nm geom_lvm
.Nd "GEOM based Linux LVM logical volume mapping"
.Sh SYNOPSIS
To compile this driver into the kernel,
place the following line in your
kernel configuration file:
.Bd -ragged -offset indent
.Cd "options GEOM_LVM"
.Ed
.Pp
Alternatively, to load the driver as a
module at boot time, place the following line in
.Xr loader.conf 5 :
.Bd -literal -offset indent
geom_lvm_load="YES"
.Ed
.Sh DESCRIPTION
The
.Nm
framework provides support for mapping Linux LVM volumes to GEOM providers.
.Nm
currently supports linear stripes with segments on one or more physical disks.
The parser is able to read LVM2 Text Format metadata, the logical volumes will
be assembled and made available under
.Pa /dev/lvm/ .
The metadata is read only, logical volumes can not be allocated or resized.
To view which
.Nm
devices are available:
.Bd -literal -offset indent
# geom lvm list
Geom name: vg1
Providers:
1. Name: lvm/vg1-home
Mediasize: 4294967296 (4.0G)
Sectorsize: 512
Mode: r0w0e0
2. Name: lvm/vg1-logs
Mediasize: 4294967296 (4.0G)
Sectorsize: 512
Mode: r0w0e0
Consumers:
1. Name: ad0s1
Mediasize: 80023716864 (75G)
Sectorsize: 512
Mode: r0w0e0
.Ed
.Pp
.Sh SEE ALSO
.Xr GEOM 4 ,
.Xr geom 8 ,
.Sh AUTHORS
.An -nosplit
The
.Nm
driver was written by
.An "Andrew Thompson" Aq thompsa@FreeBSD.org .

1177
sys/geom/lvm/g_lvm.c Normal file

File diff suppressed because it is too large Load Diff

113
sys/geom/lvm/g_lvm.h Normal file
View File

@ -0,0 +1,113 @@
/*-
* Copyright (c) 2008 Andrew Thompson <thompsa@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#define G_LVM_DEBUG(lvl, ...) do { \
if (g_lvm_debug >= (lvl)) { \
printf("GEOM_LVM"); \
if (g_lvm_debug > 0) \
printf("[%u]", lvl); \
printf(": "); \
printf(__VA_ARGS__); \
printf("\n"); \
} \
} while (0)
#define G_LVM_CLASS_NAME "LVM"
#define G_LVM_NAMELEN 128
#define G_LVM_UUIDLEN 40
#define G_LVM_MAGIC "\040\114\126\115\062\040\170\133" \
"\065\101\045\162\060\116\052\076"
struct g_lvm_label {
uint64_t ll_sector;
uint32_t ll_crc;
uint32_t ll_offset;
char ll_uuid[G_LVM_UUIDLEN];
uint64_t ll_size;
uint64_t ll_pestart;
uint64_t ll_md_offset;
uint64_t ll_md_size;
};
struct g_lvm_metadata {
uint32_t md_csum;
uint32_t md_version;
uint64_t md_start;
uint64_t md_size;
uint64_t md_reloffset;
uint64_t md_relsize;
struct g_lvm_vg *md_vg;
};
struct g_lvm_lv {
LIST_ENTRY(g_lvm_lv) lv_next;
struct g_lvm_vg *lv_vg;
char lv_name[G_LVM_NAMELEN];
char lv_uuid[G_LVM_UUIDLEN];
int lv_sgcount;
int lv_sgactive;
struct g_provider *lv_gprov;
int lv_extentcount;
LIST_HEAD(, g_lvm_segment) lv_segs;
int lv_numsegs;
struct g_lvm_segment *lv_firstsg;
};
struct g_lvm_pv {
LIST_ENTRY(g_lvm_pv) pv_next;
struct g_lvm_vg *pv_vg;
char pv_name[G_LVM_NAMELEN];
char pv_uuid[G_LVM_UUIDLEN];
size_t pv_size;
off_t pv_start;
int pv_count;
struct g_provider *pv_gprov;
struct g_consumer *pv_gcons;
};
struct g_lvm_segment {
LIST_ENTRY(g_lvm_segment) sg_next;
int sg_start;
int sg_end;
int sg_count;
char sg_pvname[G_LVM_NAMELEN];
struct g_lvm_pv *sg_pv;
int sg_pvstart;
off_t sg_pvoffset;
};
struct g_lvm_vg {
LIST_ENTRY(g_lvm_vg) vg_next;
char vg_name[G_LVM_NAMELEN];
char vg_uuid[G_LVM_UUIDLEN];
size_t vg_extentsize;
int vg_sectorsize;
struct g_geom *vg_geom;
LIST_HEAD(, g_lvm_pv) vg_pvs;
LIST_HEAD(, g_lvm_lv) vg_lvs;
};