Skip to content

Commit

Permalink
Support LVM thin provisioning.
Browse files Browse the repository at this point in the history
This adds the ability to do LVM thin provisioning. If you haven't fully
read 'man 7 lvmthin' then please do as this will answer most of your
questions. LVM thin provisioning is used for doing one form of GlusterFS
snapshots.
  • Loading branch information
purpleidea committed Apr 10, 2014
1 parent b5e8342 commit b0f645e
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 7 deletions.
16 changes: 16 additions & 0 deletions DOCUMENTATION.md
Expand Up @@ -652,6 +652,22 @@ Do you want to use lvm on the lower level device (typically a partition, or the
device itself), or not. Using lvm might be required when using a commercially
supported GlusterFS solution.
####`lvm_thinp`
Set to _true_ to enable LVM thin provisioning. Read 'man 7 lvmthin' to
understand what thin provisioning is all about. This is needed for one form of
GlusterFS snapshots. Obviously this requires that you also enable _LVM_.
####`lvm_virtsize`
The value that will be passed to _--virtualsize_. By default this will pass in
a command that will return the size of your volume group. This is usually a
sane value, and help you to remember not to overcommit.
####`lvm_chunksize`
Value of _--chunksize_ for _lvcreate_ when using thin provisioning.
####`lvm_metadatasize`
Value of _--poolmetadatasize_ for _lvcreate_ when using thin provisioning.
####`fsuuid`
File system UUID. This ensures we can distinctly identify a file system. You
can set this to be used with automatic file system creation, or you can specify
Expand Down
57 changes: 50 additions & 7 deletions manifests/brick.pp
Expand Up @@ -27,6 +27,10 @@
$labeltype = '', # gpt

$lvm = true, # use lvm or not ?
$lvm_thinp = false, # use lvm thin-p or not ?
$lvm_virtsize = '', # defaults to 100% available.
$lvm_chunksize = '', # chunk size for thin-p
$lvm_metadatasize = '', # meta data size for thin-p

$fsuuid = '', # set a uuid for this fs (uuidgen)
$fstype = '', # xfs
Expand Down Expand Up @@ -156,8 +160,12 @@
#
# lvm...
#
if $lvm_thinp and ( ! $lvm ) {
warning('You must enable $lvm if you want to use LVM thin-p.')
}

if $lvm {
# NOTE: this is need for thin-provisioning, and RHS compliance!
# NOTE: this is used for thin-provisioning, and RHS compliance!

# NOTE: as a consequence of this type of automation, we generate
# really ugly vg names like: "vg_annex1.example.com+_gluster_" !
Expand All @@ -166,6 +174,7 @@
$lvm_safename = regsubst("${safename}", ':', '+', 'G') # safe!
$lvm_vgname = "vg_${lvm_safename}"
$lvm_lvname = "lv_${lvm_safename}"
$lvm_tpname = "tp_${lvm_safename}" # thin pool (tp)

$lvm_dataalignment = inline_template('<%= @raid_su.to_i*@raid_sw.to_i %>')

Expand All @@ -176,14 +185,48 @@

$lvm_vgcreate = "/sbin/vgcreate ${lvm_vgname} ${dev1}"

# creates dev /dev/vgname/lvname
# FIXME: should we use --extents or --size and what values ?
$lvm_lvcreate = "/sbin/lvcreate --extents 100%PVS -n ${lvm_lvname} ${lvm_vgname}"
# match --virtualsize with 100% of available vg by default
$lvm_thinp_virtsize = "${lvm_virtsize}" ? { # --virtualsize
'' => "`/sbin/vgs -o size --units b --noheadings ${lvm_vgname}`",
default => "${lvm_virtsize}",
}

$dev2 = "/dev/${lvm_vgname}/${lvm_lvname}"
# TODO: is 64k a good/sane default ?
$lvm_thinp_chunksize = "${lvm_chunksize}" ? {
'' => '',
default => "--chunksize ${lvm_chunksize}",
}

} else {
$dev2 = "${dev1}" # pass through, because not using lvm
# TODO: is 16384 a good/sane default ?
$lvm_thinp_metadatasize = "${lvm_metadatasize}" ? {
'' => '',
default => "--poolmetadatasize ${lvm_metadatasize}",
}

# README: 'man 7 lvmthin' to understand lvm thin provisioning
# MIRROR: http://man7.org/linux/man-pages/man7/lvmthin.7.html
# TODO: is this the optimal setup for thin-p ?
$lvm_thinp_lvcreate_cmdlist = [
'/sbin/lvcreate',
"--thinpool ${lvm_vgname}/${lvm_tpname}", # thinp
'--extents 100%FREE', # let lvm figure out the --size
"--virtualsize ${lvm_thinp_virtsize}",
"${lvm_thinp_chunksize}",
"${lvm_thinp_metadatasize}",
" -n ${lvm_lvname}", # name it
]
$lvm_thinp_lvcreate = join(delete($lvm_thinp_lvcreate_cmdlist, ''), ' ')

# creates dev /dev/vgname/lvname
$lvm_lvcreate = $lvm_thinp ? {
true => "${lvm_thinp_lvcreate}",
default => "/sbin/lvcreate --extents 100%PVS -n ${lvm_lvname} ${lvm_vgname}",
}
}

$dev2 = $lvm ? {
false => "${dev1}", # pass through, because not using lvm
default => "/dev/${lvm_vgname}/${lvm_lvname}", # thin-p too :)
}

#
Expand Down
Binary file modified puppet-gluster-documentation.pdf
Binary file not shown.

0 comments on commit b0f645e

Please sign in to comment.