master - mm: skip mlocking [vectors]
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d5697b29ee0091...
Commit: d5697b29ee009104a4ed91f79543e22cc8c8d2c4
Parent: 5ef6ca00b99e0a2ed83a00c4ddcb577dd3b52a7b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Nov 20 09:58:53 2012 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Nov 20 10:02:51 2012 +0100
mm: skip mlocking [vectors]
Somehow forgotten:
https://www.redhat.com/archives/linux-lvm/2012-June/msg00019.html
Need for arm architecture support.
---
WHATS_NEW | 1 +
lib/mm/memlock.c | 1 +
2 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 84afb82..e96703c 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Skip mlocking [vectors] on arm architecture.
Support allocation of pool metadata with lvconvert command.
Move common functionality for thin lvcreate and lvconvert to toollib.
Mirrored log is now fixed before its mirror when double-fault occurs.
diff --git a/lib/mm/memlock.c b/lib/mm/memlock.c
index 2240a1d..6d0996a 100644
--- a/lib/mm/memlock.c
+++ b/lib/mm/memlock.c
@@ -84,6 +84,7 @@ static int _default_priority;
static const char * const _ignore_maps[] = {
"[vdso]",
"[vsyscall]",
+ "[vectors]",
};
/* default blacklist for maps */
11 years
master - docs: host tags has a default volume_list
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5ef6ca00b99e0a...
Commit: 5ef6ca00b99e0a2ed83a00c4ddcb577dd3b52a7b
Parent: 999952c5b9a21451d1b76c53a7dca615cd815113
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Mon Nov 19 22:29:23 2012 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Mon Nov 19 22:29:23 2012 +0000
docs: host tags has a default volume_list
Document that lvm.conf activation/volume_list defaults to @* when
there's a host tag.
---
doc/example.conf.in | 11 +++++++++--
man/lvm.conf.5.in | 2 ++
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/doc/example.conf.in b/doc/example.conf.in
index f7344bb..7f94223 100644
--- a/doc/example.conf.in
+++ b/doc/example.conf.in
@@ -569,15 +569,21 @@ activation {
# If volume_list is defined, each LV is only activated if there is a
# match against the list.
+ #
# "vgname" and "vgname/lvname" are matched exactly.
# "@tag" matches any tag set in the LV or VG.
# "@*" matches if any tag defined on the host is also set in the LV or VG
#
+ # If any host tags exist but volume_list is not defined, a default
+ # single-entry list containing "@*" is assumed.
+ #
# volume_list = [ "vg1", "vg2/lvol1", "@tag1", "@*" ]
# If auto_activation_volume_list is defined, each LV that is to be
- # activated is checked against the list while using the autoactivation
- # option (--activate ay/-a ay), and if it matches, it is activated.
+ # activated with the autoactivation option (--activate ay/-a ay)
+ # is first checked against the list. If it does not match, the LV
+ # is not activated. This list is checked as well as volume_list.
+ #
# "vgname" and "vgname/lvname" are matched exactly.
# "@tag" matches any tag set in the LV or VG.
# "@*" matches if any tag defined on the host is also set in the LV or VG
@@ -588,6 +594,7 @@ activation {
# is checked against the list, and if it matches, it as activated
# in read-only mode. (This overrides '--permission rw' stored in the
# metadata.)
+ #
# "vgname" and "vgname/lvname" are matched exactly.
# "@tag" matches any tag set in the LV or VG.
# "@*" matches if any tag defined on the host is also set in the LV or VG
diff --git a/man/lvm.conf.5.in b/man/lvm.conf.5.in
index 718cf4d..5592f34 100644
--- a/man/lvm.conf.5.in
+++ b/man/lvm.conf.5.in
@@ -447,6 +447,8 @@ metadata for a match.
\fBtags\fP above).
Logical volume and volume groups can also be included in the list
by name e.g. vg00, vg00/lvol1.
+If this setting is not present but at least one host tag is defined
+then a default single-entry list containing @* is assumed.
.IP
\fBauto_activation_volume_list\fP \(em This acts as a filter through
which all requests to autoactivate a logical volume on this machine
11 years
master - thin: update recent patchset
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=999952c5b9a214...
Commit: 999952c5b9a21451d1b76c53a7dca615cd815113
Parent: c907ee0351b226eb9e89929afcfc008985f32f97
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Nov 19 16:23:18 2012 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 19 16:28:00 2012 +0100
thin: update recent patchset
Parse pool params only for creation of thin pools.
---
tools/lvcreate.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 470084c..801ff64 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -785,8 +785,9 @@ static int _lvcreate_params(struct lvcreate_params *lp,
if (!_lvcreate_name_params(lp, cmd, &argc, &argv) ||
!_read_size_params(lp, lcp, cmd) ||
!get_stripe_params(cmd, &lp->stripes, &lp->stripe_size) ||
- !get_pool_params(cmd, &lp->chunk_size, &lp->discards,
- &lp->poolmetadatasize, &lp->zero) ||
+ (lp->create_thin_pool &&
+ !get_pool_params(cmd, &lp->chunk_size, &lp->discards,
+ &lp->poolmetadatasize, &lp->zero)) ||
!_read_mirror_params(lp, cmd) ||
!_read_raid_params(lp, cmd))
return_0;
11 years
master - Document use_lvmetad and global_filter in lvm.conf.5.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c907ee0351b226...
Commit: c907ee0351b226eb9e89929afcfc008985f32f97
Parent: a7893ae8580d344f3f55ddb08892991edf17408f
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Mon Nov 19 16:19:58 2012 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Mon Nov 19 16:20:54 2012 +0100
Document use_lvmetad and global_filter in lvm.conf.5.
---
man/lvm.conf.5.in | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/man/lvm.conf.5.in b/man/lvm.conf.5.in
index 79044fc..718cf4d 100644
--- a/man/lvm.conf.5.in
+++ b/man/lvm.conf.5.in
@@ -104,6 +104,12 @@ otherwise it is accepted. As an example, to ignore /dev/cdrom you could use:
.br
\fBdevices { filter=["r|cdrom|"] }\fP
.IP
+\fBglobal_filter\fP \(em Since "filter" is often overriden from command line, it
+is not suitable for system-wide device filtering (udev rules, lvmetad). To hide
+devices from LVM-specific udev processing and/or from lvmetad, you need to set
+global_filter. The syntax is the same as for normal "filter" above. Devices that
+fail the global_filter are not even opened by LVM.
+.IP
\fBcache_dir\fP \(em Persistent filter cache file directory.
Defaults to "#DEFAULT_CACHE_DIR#".
.IP
@@ -354,6 +360,18 @@ if \fBlocking_type\fP is set to 1. The default is \fB/var/lock/lvm\fP.
library to load if \fBlocking_type\fP is set to 2.
The default is \fBliblvm2clusterlock.so\fP. If you need to write
such a library, look at the lib/locking source code directory.
+.IP
+\fBuse_lvmetad\fP \(em Whether to use (trust) a running instance of lvmetad. If
+this is set to 0, all commands fall back to the usual scanning mechanisms. When
+set to 1 \fBand\fP when lvmetad is running (it is not auto-started), the volume
+group metadata and PV state flags are obtained from the lvmetad instance and no
+scanning is done by the individual commands. In a setup with lvmetad, lvmetad
+udev rules \fBmust\fP be set up for LVM to work correctly. Without proper udev
+rules, all changes in block device configuration will be \fBignored\fP until a
+manual 'pvscan --cache' is performed.
+.br
+If lvmetad has been running while use_lvmetad was 0, it \fBMUST\fP be stopped before
+changing use_lvmetad to 1 and started again afterwards.
.TP
\fBtags\fP \(em Host tag settings
.IP
11 years
master - test: testing lvconvert
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a7893ae8580d34...
Commit: a7893ae8580d344f3f55ddb08892991edf17408f
Parent: bf1cf1459f414eb1b397c21a0cdbd5acda7540f6
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Nov 19 12:31:11 2012 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 19 14:38:17 2012 +0100
test: testing lvconvert
---
test/shell/lvconvert-thin.sh | 75 ++++++++++++++++++++++++++++++++++-------
1 files changed, 62 insertions(+), 13 deletions(-)
diff --git a/test/shell/lvconvert-thin.sh b/test/shell/lvconvert-thin.sh
index 97ccc09..f21453f 100644
--- a/test/shell/lvconvert-thin.sh
+++ b/test/shell/lvconvert-thin.sh
@@ -12,32 +12,81 @@
. lib/test
+prepare_lvs()
+{
+ lvremove -f $vg
+ lvcreate -L10M -n $lv1 $vg
+ lvcreate -L8M -n $lv2 $vg
+}
+
#
# Main
#
aux have_thin 1 0 0 || skip
-aux prepare_pvs 4 64
+aux prepare_pvs 4 6400000
vgcreate $vg -s 64K $(cat DEVICES)
# create mirrored LVs for data and metadata volumes
-lvcreate -aey -l8 -m1 --mirrorlog core -n $lv1 $vg
-lvcreate -aey -l4 -m1 --mirrorlog core -n $lv2 $vg
+lvcreate -aey -L10M -m1 --mirrorlog core -n $lv1 $vg
+lvcreate -aey -L8M -m1 --mirrorlog core -n $lv2 $vg
+lvchange -an $vg/$lv1
+
+
+# conversion fails for internal volumes
+not lvconvert --thinpool $vg/${lv1}_mimage_0
+not lvconvert --thinpool $vg/$lv1 --poolmetadata $vg/${lv2}_mimage_0
+# can't use --readahead with --poolmetadata
+not lvconvert --thinpool $vg/$lv1 --poolmetadata $vg/$lv2 --readahead 512
+
+lvconvert --thinpool $vg/$lv1 --poolmetadata $vg/$lv2
+
+prepare_lvs
+lvconvert -c 64 --stripes 2 --thinpool $vg/$lv1 --readahead 48
+
+lvremove -f $vg
+lvcreate -L1T -n $lv1 $vg
+lvconvert -c 8M --thinpool $vg/$lv1
+
+lvremove -f $vg
+# test with bigger sizes
+lvcreate -L1T -n $lv1 $vg
+lvcreate -L8M -n $lv2 $vg
+lvcreate -L1M -n $lv3 $vg
-lvconvert -c 64K --thinpool $vg/$lv1 --poolmetadata $vg/$lv2
+# chunk size is bigger then size of thin pool data
+not lvconvert -c 1G --thinpool $vg/$lv3
+# stripes can't be used with poolmetadata
+not lvconvert --stripes 2 --thinpool $vg/$lv1 --poolmetadata $vg/$lv2
+# too small metadata (<2M)
+not lvconvert -c 64 --thinpool $vg/$lv1 --poolmetadata $vg/$lv3
+# too small chunk size fails
+not lvconvert -c 4 --thinpool $vg/$lv1 --poolmetadata $vg/$lv2
+# too big chunk size fails
+not lvconvert -c 2G --thinpool $vg/$lv1 --poolmetadata $vg/$lv2
+# negative chunk size fails
+not lvconvert -c -256 --thinpool $vg/$lv1 --poolmetadata $vg/$lv2
+# non power of 2 fails
+not lvconvert -c 88 --thinpool $vg/$lv1 --poolmetadata $vg/$lv2
-lvcreate -V10M -T $vg/$lv1 --name $lv3
+# Warning about smaller then suggested
+lvconvert -c 256 --thinpool $vg/$lv1 --poolmetadata $vg/$lv2 |& tee err
+grep "WARNING: Chunk size is smaller" err
-# check lvrename work properly
-lvrename $vg/$lv1 $vg/pool
-check lv_field $vg/pool name "pool"
+lvremove -f $vg
+lvcreate -L1T -n $lv1 $vg
+lvcreate -L32G -n $lv2 $vg
+# Warning about bigger then needed
+lvconvert --thinpool $vg/$lv1 --poolmetadata $vg/$lv2 |& tee err
+grep "WARNING: Maximum size" err
-lvrename $vg/$lv3 $vg/$lv4
-check lv_field $vg/$lv4 name "$lv4"
+lvremove -f $vg
+lvcreate -L24T -n $lv1 $vg
+# Warning about bigger then needed (24T data and 16G -> 128K chunk)
+lvconvert -c 64 --thinpool $vg/$lv1 |& tee err
+grep "WARNING: Chunk size is too small" err
-# not yet supported conversions
-not lvconvert -m 1 $vg/pool
-not lvconvert -m 1 $vg/$lv3
+#lvs -a -o+chunk_size,stripe_size,seg_pe_ranges
vgremove -ff $vg
11 years
master - thin: man page updates
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=bf1cf1459f414e...
Commit: bf1cf1459f414eb1b397c21a0cdbd5acda7540f6
Parent: 1794f777f48be29184ef8030b6e11b3a8e61757b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Oct 30 17:11:59 2012 +0000
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 19 14:38:17 2012 +0100
thin: man page updates
Cover latest extensions of lvconvert functionality.
Update also lvcreate page.
---
man/lvconvert.8.in | 103 ++++++++++++++++++++++++++++++++++++++++++++--------
man/lvcreate.8.in | 18 +++++-----
2 files changed, 96 insertions(+), 25 deletions(-)
diff --git a/man/lvconvert.8.in b/man/lvconvert.8.in
index 2659719..48345a9 100644
--- a/man/lvconvert.8.in
+++ b/man/lvconvert.8.in
@@ -40,7 +40,7 @@ lvconvert \- convert a logical volume from linear to mirror or snapshot
.B lvconvert
.BR \-s | \-\-snapshot
.RB [ \-c | \-\-chunksize
-.IR ChunkSize ]
+.IR ChunkSize [ bBsSkK ]]
.RB [ \-h | \-? | \-\-help ]
.RB [ \-\-noudevsync ]
.RB [ \-v | \-\-verbose ]
@@ -59,17 +59,6 @@ lvconvert \- convert a logical volume from linear to mirror or snapshot
.RB [ \-\-version ]
.IR LogicalVolume [ Path ]...
.sp
-.B lvconvert \-\-thinpool
-.IR ThinPoolLogicalVolume { Name | Path }
-.RB [ \-c | \-\-chunksize
-.IR ChunkSize ]
-.RB [ \-h | \-? | \-\-help ]
-.RB [ \-v | \-\-verbose ]
-.RB [ \-\-version ]
-.RB [ \-Z | \-\-zero
-.RI { y | n }]
-.IR ThinMetadataLogicalVolume { Name | Path }
-.sp
.B lvconvert \-\-repair
.RB [ \-h | \-? | \-\-help ]
.RB [ \-v | \-\-verbose ]
@@ -83,6 +72,31 @@ lvconvert \- convert a logical volume from linear to mirror or snapshot
.RB [ \-\-version ]
.IR LogicalVolume [ Path ]
.RI [ PhysicalVolume [ Path ]...]
+.sp
+.B lvconvert \-\-thinpool
+.IR ThinPoolLogicalVolume { Name | Path }
+.RB [ \-c | \-\-chunksize
+.IR ChunkSize [ bBsSkKmMgG ]]
+.RB [ \-\-discards
+.RI { ignore | nopassdown | passdown }]
+.RB [[ \-\-poolmetadata
+.IR ThinPoolMetadataLogicalVolume { Name | Path }]
+|
+.RB [ \-\-poolmetadatasize
+.IR ThinPoolMetadataSize [ bBsSkKmMgG ]]
+.RB [ \-r | \-\-readahead
+.RI { ReadAheadSectors | auto | none }]
+.RB [ \-\-stripes
+.I Stripes
+.RB [ \-I | \-\-stripesize
+.IR StripeSize ]]]
+.RB [ \-Z | \-\-zero
+.RI { y | n }]
+.RB [ \-h | \-? | \-\-help ]
+.RB [ \-v | \-\-verbose ]
+.RB [ \-\-version ]
+.RI [ PhysicalVolume [ Path ][ :PE [ -PE ]]...]
+.sp
.SH DESCRIPTION
lvconvert is used to change the segment type (i.e. linear, mirror, etc) or
@@ -102,8 +116,9 @@ the freed extents come first from the specified PhysicalVolumes.
See \fBlvm\fP(8) for common options.
.br
Exactly one of
-.BR \-\-splitmirrors ", " \-\-mirrors ", " \-\-repair ", " \-\-snapshot
-or \fB\-\-merge\fP arguments is required.
+.BR \-\-merge ", " \-\-mirrors ", " \-\-repair ", " \-\-replace
+.RB ", " \-\-snapshot ", " \-\-splitmirrors " or " \-\-thinpool
+arguments is required.
.TP
.BR \-m ", " \-\-mirrors " " \fIMirrors
Specifies the degree of the mirror you wish to create.
@@ -170,12 +185,28 @@ implementation and not with the original device-mapper mirror implementation.
Create a snapshot from existing logical volume using another
existing logical volume as its origin.
.TP
-.BR \-c ", " \-\-chunksize " " \fIChunkSize
-Power of 2 chunk size for the snapshot logical volume between 4KiB and 512KiB.
+.BR \-c ", " \-\-chunksize " " \fIChunkSize [ \fIbBsSkKmMgG ]
+Gives the size of chunk for snapshot and thin pool logical volumes.
+For snapshots the value must be power of 2 between 4KiB and 512KiB
+and the default value is 4.
+For thin pools the value must be between 64KiB and
+1GiB and the default value starts with 64 and scales
+up to fit the pool metadata size within 128MB,
+if the pool metadata size is not specified.
+Older dm thin pool target version (<1.4) requires the value to be power of 2.
+The newer version requires to be the multiple of 64KiB, however discard is
+not supported for non power of 2 values.
+Default unit is in kilobytes.
+.TP
+.BR \-\-discards " {" \fIignore | \fInopassdown | \fIpassdown }
+Sets discards behavior for thin pool.
+Default is \fIpassdown\fP.
.TP
.BR \-Z ", " \-\-zero " {" \fIy | \fIn }
Controls zeroing of the first KB of data in the snapshot.
If the volume is read-only the snapshot will not be zeroed.
+For thin pool volumes it controls zeroing of provisioned blocks.
+Note: Provisioning of large zeroed chunks impacts performance.
.TP
.B \-\-merge
Merges a snapshot into its origin volume or merges a raid1 image that has
@@ -195,6 +226,28 @@ merge finishes, the merged snapshot is removed. Multiple snapshots may
be specified on the commandline or a @tag may be used to specify
multiple snapshots be merged to their respective origin.
.TP
+.BR \-\-poolmetadata " " \fIThinPoolMetadataLogicalVolume { \fIName | \fIPath }
+Specifies thin pool metadata logical volume.
+The size should be in between 2MiB and 16GiB.
+Thin pool is specified with the option
+\fB\-\-thinpool\fP.
+.TP
+.BR \-\-poolmetadatasize " " \fIThinPoolMetadataSize [ \fIbBsSkKmMgG ]
+Sets the size of thin pool's metadata logical volume,
+if the pool metadata volume is undefined.
+Thin pool is specified with the option
+\fB\-\-thinpool\fP.
+Supported value is in the range between 2MiB and 16GiB.
+The default value is estimated with this formula
+(Pool_LV_size / Pool_LV_chunk_size * 64b).
+Default unit is megabytes.
+.TP
+.IR \fB\-r ", " \fB\-\-readahead " {" ReadAheadSectors | auto | none }
+Sets read ahead sector count of thin pool metadata logical volume.
+The default value is "auto" which allows the kernel to choose
+a suitable value automatically.
+"None" is equivalent to specifying zero.
+.TP
.B \-\-repair
Repair a mirror after suffering a disk failure. The mirror will be brought back
into a consistent state. By default, the original number of mirrors will be
@@ -210,6 +263,24 @@ Remove the specified device (\fIPhysicalVolume\fP) and replace it with one
that is available in the volume group or from the specific list provided.
This option is only available to RAID segment types
(e.g. "raid1", "raid5", etc).
+.TP
+.BR \-\-stripes " " \fIStripes
+Gives the number of stripes.
+This is equal to the number of physical volumes to scatter
+the logical volume.
+.TP
+.BR \-I ", " \-\-stripesize " " \fIStripeSize
+Gives the number of kilobytes for the granularity of the stripes.
+.br
+StripeSize must be 2^n (n = 2 to 9) for metadata in LVM1 format.
+For metadata in LVM2 format, the stripe size may be a larger
+power of 2 but must not exceed the physical extent size.
+.TP
+.IR \fB\-\-thinpool " " ThinPoolLogicalVolume { Name | Path }
+Changes logical volume into a thin pool volume. The volume
+will store the pool's data.
+Thin pool metadata logical volume can be specified with the option
+\fB\-\-poolmetadata\fP or allocated with \fB\-\-poolmetadatasize\fP.
.SH Examples
Converts the linear logical volume "vg00/lvol1" to a two-way mirror
diff --git a/man/lvcreate.8.in b/man/lvcreate.8.in
index f374950..705ebae 100644
--- a/man/lvcreate.8.in
+++ b/man/lvcreate.8.in
@@ -53,11 +53,11 @@ lvcreate \- create a logical volume in an existing volume group
.RB [ \-t | \-\-test ]
.RB [ \-T | \-\-thin
.RB [ \-c | \-\-chunksize
-.IR ChunkSize ]
+.IR ChunkSize [ bBsSkKmMgG ]]
.RB [ \-\-discards
.RI { ignore | nopassdown | passdown }]
.RB [ \-\-poolmetadatasize
-.IR MetadataSize [ bBsSkKmMgG ]]]
+.IR ThinPoolMetadataSize [ bBsSkKmMgG ]]]
.RB [ \-\-thinpool
.IR ThinPoolLogicalVolume { Name | Path }]
.RB [ \-\-type
@@ -76,7 +76,7 @@ lvcreate \- create a logical volume in an existing volume group
.BR \-L | \-\-size
.IR LogicalVolumeSize [ bBsSkKmMgGtTpPeE ]]
.RB [ \-c | \-\-chunksize
-.IR ChunkSize ]
+.IR ChunkSize [ bBsSkK ]]
.RB [ \-\-noudevsync ]
.RB [ \-\-ignoremonitoring ]
.RB [ \-\-monitor " {" \fIy | \fIn }]
@@ -125,14 +125,14 @@ always assumed and it can't be overridden. If clustered locking is enabled,
\fB\-a\fIey\fR will activate exclusively on one node and \fB\-a\fIly\fR will
activate only on the local node.
.TP
-.BR \-c ", " \-\-chunksize " " \fIChunkSize
+.BR \-c ", " \-\-chunksize " " \fIChunkSize [ \fIbBsSkKmMgG ]
Gives the size of chunk for snapshot and thin pool logical volumes.
For snapshots the value must be power of 2 between 4KiB and 512KiB
and the default value is 4.
For thin pools the value must be between 64KiB and
-1048576KiB and the default value starts with 64 and scales
+1GiB and the default value starts with 64 and scales
up to fit the pool metadata size within 128MB,
-if the poolmetadata size is not specified.
+if the pool metadata size is not specified.
Older dm thin pool target version (<1.4) requires the value to be power of 2.
The newer version requires to be the multiple of 64KiB, however discard is
not supported for non power of 2 values.
@@ -144,7 +144,7 @@ logical volumes. Default is no contiguous allocation based
on a next free principle.
.TP
.BR \-\-discards " {" \fIignore | \fInopassdown | \fIpassdown }
-Set discards behavior.
+Set discards behavior for thin pool.
Default is \fIpassdown\fP.
.TP
.BR \-i ", " \-\-stripes " " \fIStripes
@@ -236,7 +236,7 @@ Set access permissions to read only or read and write.
.br
Default is read and write.
.TP
-.IR \fB\-\-poolmetadatasize " " MetadataSize [ bBsSkKmMgG ]
+.IR \fB\-\-poolmetadatasize " " ThinPoolMetadataSize [ bBsSkKmMgG ]
Set the size of thin pool's metadata logical volume.
Supported value is in range between 2MiB and 16GiB.
Default value is (Pool_LV_size / Pool_LV_chunk_size * 64b).
@@ -372,7 +372,7 @@ copies.
.B lvcreate \-\-type raid10 \-L 5G \-i 2 \-m 1 \-n my_lv vg00
Creates 100MiB pool logical volume for thin provisioning
-build with 2 stripes 64KiB and chunk size 128KiB together with
+build with 2 stripes 64KiB and chunk size 256KiB together with
1TiB thin provisioned logical volume "vg00/thin_lv":
.sp
.B lvcreate \-i 2 \-I 64 \-c 256 \-L100M \-T vg00/pool \-V 1T \-\-name thin_lv
11 years
master - thin: lvcreate use common functions
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1794f777f48be2...
Commit: 1794f777f48be29184ef8030b6e11b3a8e61757b
Parent: b21d3e3592e380cb79e5e45f2aa8164ae0747e15
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Nov 19 12:47:34 2012 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 19 14:38:17 2012 +0100
thin: lvcreate use common functions
Use common functions from toollib and eliminate code from here.
---
tools/lvcreate.c | 100 +++++++++++-------------------------------------------
1 files changed, 20 insertions(+), 80 deletions(-)
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index dad0ba7..470084c 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -234,7 +234,6 @@ static int _update_extents_params(struct volume_group *vg,
{
uint32_t pv_extent_count;
struct logical_volume *origin = NULL;
- int changed = 0;
uint32_t size_rest;
uint32_t stripesize_extents;
@@ -308,38 +307,11 @@ static int _update_extents_params(struct volume_group *vg,
}
if (lp->create_thin_pool) {
- if (!arg_count(vg->cmd, poolmetadatasize_ARG)) {
- /* Defaults to nr_pool_blocks * 64b */
- lp->poolmetadatasize = (uint64_t) lp->extents * vg->extent_size /
- (uint64_t) (lp->chunk_size * (SECTOR_SIZE / UINT64_C(64)));
-
- /* Check if we could eventually use bigger chunk size */
- if (!arg_count(vg->cmd, chunksize_ARG)) {
- while ((lp->poolmetadatasize >
- (DEFAULT_THIN_POOL_OPTIMAL_SIZE / SECTOR_SIZE)) &&
- (lp->chunk_size < DM_THIN_MAX_DATA_BLOCK_SIZE)) {
- lp->chunk_size <<= 1;
- lp->poolmetadatasize >>= 1;
- changed++;
- }
- if (changed)
- log_verbose("Changed chunksize to %u sectors.",
- lp->chunk_size);
- }
- }
-
- if (lp->poolmetadatasize > (2 * DEFAULT_THIN_POOL_MAX_METADATA_SIZE)) {
- if (arg_count(vg->cmd, poolmetadatasize_ARG))
- log_warn("WARNING: Maximum supported pool metadata size is 16GB.");
- lp->poolmetadatasize = 2 * DEFAULT_THIN_POOL_MAX_METADATA_SIZE;
- } else if (lp->poolmetadatasize < (2 * DEFAULT_THIN_POOL_MIN_METADATA_SIZE)) {
- if (arg_count(vg->cmd, poolmetadatasize_ARG))
- log_warn("WARNING: Minimum supported pool metadata size is 2M.");
- lp->poolmetadatasize = 2 * DEFAULT_THIN_POOL_MIN_METADATA_SIZE;
- }
-
- log_verbose("Setting pool metadata size to %" PRIu64 " sectors.",
- lp->poolmetadatasize);
+ if (!update_pool_params(vg->cmd, lp->target_attr,
+ lp->extents, vg->extent_size,
+ &lp->chunk_size, &lp->discards,
+ &lp->poolmetadatasize))
+ return_0;
if (!(lp->poolmetadataextents =
extents_from_size(vg->cmd, lp->poolmetadatasize, vg->extent_size)))
@@ -386,16 +358,9 @@ static int _read_size_params(struct lvcreate_params *lp,
if (lp->thin && (arg_count(cmd, size_ARG) || arg_count(cmd, extents_ARG)))
lp->create_thin_pool = 1;
- if (arg_count(cmd, poolmetadatasize_ARG)) {
- if (!seg_is_thin(lp)) {
- log_error("--poolmetadatasize may only be specified when allocating the thin pool.");
- return 0;
- }
- if (arg_sign_value(cmd, poolmetadatasize_ARG, SIGN_NONE) == SIGN_MINUS) {
- log_error("Negative poolmetadatasize is invalid.");
- return 0;
- }
- lp->poolmetadatasize = arg_uint64_value(cmd, poolmetadatasize_ARG, UINT64_C(0));
+ if (arg_count(cmd, poolmetadatasize_ARG) && !seg_is_thin(lp)) {
+ log_error("--poolmetadatasize may only be specified when allocating the thin pool.");
+ return 0;
}
/* Size returned in kilobyte units; held in sectors */
@@ -820,13 +785,13 @@ static int _lvcreate_params(struct lvcreate_params *lp,
if (!_lvcreate_name_params(lp, cmd, &argc, &argv) ||
!_read_size_params(lp, lcp, cmd) ||
!get_stripe_params(cmd, &lp->stripes, &lp->stripe_size) ||
+ !get_pool_params(cmd, &lp->chunk_size, &lp->discards,
+ &lp->poolmetadatasize, &lp->zero) ||
!_read_mirror_params(lp, cmd) ||
!_read_raid_params(lp, cmd))
return_0;
- if (lp->create_thin_pool)
- lp->discards = (thin_discards_t) arg_uint_value(cmd, discards_ARG, THIN_DISCARDS_PASSDOWN);
- else if (arg_count(cmd, discards_ARG)) {
+ if (!lp->create_thin_pool && arg_count(cmd, discards_ARG)) {
log_error("--discards is only available for thin pool creation.");
return 0;
}
@@ -836,48 +801,23 @@ static int _lvcreate_params(struct lvcreate_params *lp,
else if (lp->thin && !lp->create_thin_pool) {
if (arg_count(cmd, chunksize_ARG))
log_warn("WARNING: Ignoring --chunksize when using an existing pool.");
- } else if (lp->snapshot || lp->create_thin_pool) {
+ } else if (lp->snapshot) {
if (arg_sign_value(cmd, chunksize_ARG, SIGN_NONE) == SIGN_MINUS) {
log_error("Negative chunk size is invalid");
return 0;
}
- if (lp->snapshot) {
- lp->chunk_size = arg_uint_value(cmd, chunksize_ARG, 8);
- if (lp->chunk_size < 8 || lp->chunk_size > 1024 ||
- (lp->chunk_size & (lp->chunk_size - 1))) {
- log_error("Chunk size must be a power of 2 in the "
- "range 4K to 512K");
- return 0;
- }
- } else {
- lp->chunk_size = arg_uint_value(cmd, chunksize_ARG,
- DM_THIN_MIN_DATA_BLOCK_SIZE);
- if ((lp->chunk_size < DM_THIN_MIN_DATA_BLOCK_SIZE) ||
- (lp->chunk_size > DM_THIN_MAX_DATA_BLOCK_SIZE)) {
- log_error("Chunk size must be in the range %uK to %uK",
- (DM_THIN_MIN_DATA_BLOCK_SIZE / 2),
- (DM_THIN_MAX_DATA_BLOCK_SIZE / 2));
- return 0;
- }
- if (!(attr & THIN_FEATURE_BLOCK_SIZE) &&
- (lp->chunk_size & (lp->chunk_size - 1))) {
- log_error("Chunk size must be a power of 2 for this thin target version.");
- return 0;
- } else if (lp->chunk_size & (DM_THIN_MIN_DATA_BLOCK_SIZE - 1)) {
- log_error("Chunk size must be multiple of %uK.",
- DM_THIN_MIN_DATA_BLOCK_SIZE / 2);
- return 0;
- } else if ((lp->discards != THIN_DISCARDS_IGNORE) &&
- (lp->chunk_size & (lp->chunk_size - 1))) {
- log_warn("WARNING: Using discards ignore for chunk size non power of 2.");
- lp->discards = THIN_DISCARDS_IGNORE;
- }
+ lp->chunk_size = arg_uint_value(cmd, chunksize_ARG, 8);
+ if (lp->chunk_size < 8 || lp->chunk_size > 1024 ||
+ (lp->chunk_size & (lp->chunk_size - 1))) {
+ log_error("Chunk size must be a power of 2 in the "
+ "range 4K to 512K");
+ return 0;
}
- log_verbose("Setting chunksize to %u sectors.", lp->chunk_size);
+ log_verbose("Setting chunksize to %s.", display_size(cmd, lp->chunk_size));
if (!lp->thin && lp->snapshot && !(lp->segtype = get_segtype_from_string(cmd, "snapshot")))
return_0;
- } else if (arg_count(cmd, chunksize_ARG)) {
+ } else if (arg_count(cmd, chunksize_ARG) && !lp->create_thin_pool) {
log_error("-c is only available with snapshots and thin pools");
return 0;
}
11 years
master - thin: lvconvert update
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b21d3e3592e380...
Commit: b21d3e3592e380cb79e5e45f2aa8164ae0747e15
Parent: b78609686399ee01a53d8a2e8685cd05389d8cc9
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Nov 19 13:37:57 2012 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 19 14:38:17 2012 +0100
thin: lvconvert update
Use common function from toollib and support allocation
of metadata LV with give thin pool data LV.
---
WHATS_NEW | 1 +
tools/commands.h | 7 ++-
tools/lvconvert.c | 162 +++++++++++++++++++++++++++++------------------------
3 files changed, 94 insertions(+), 76 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 59a69da..84afb82 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Support allocation of pool metadata with lvconvert command.
Move common functionality for thin lvcreate and lvconvert to toollib.
Mirrored log is now fixed before its mirror when double-fault occurs.
Add python-lvm unit test case
diff --git a/tools/commands.h b/tools/commands.h
index 6415d34..8d5d190 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -147,13 +147,16 @@ xx(lvconvert,
"--thinpool ThinPoolLogicalVolume[Path]\n"
"\t[--chunksize size]\n"
"\t[--discards {ignore|nopassdown|passdown}]\n"
- "\t[[--poolmetadatasize size] | --poolmetadata ThinMetadataLogicalVolume[Path]]\n"
+ "\t[--poolmetadata ThinMetadataLogicalVolume[Path] |\n"
+ "\t [--poolmetadatasize size]\n"
+ "\t [-r|--readahead ReadAheadSectors|auto|none]\n"
+ "\t [--stripes Stripes [-I|--stripesize StripeSize]]]\n"
"\t[-Z|--zero {y|n}]\n"
"\t[-d|--debug] [-h|-?|--help] [-v|--verbose]\n",
alloc_ARG, background_ARG, chunksize_ARG, corelog_ARG, interval_ARG,
merge_ARG, mirrorlog_ARG, mirrors_ARG, name_ARG, noudevsync_ARG,
- regionsize_ARG, repair_ARG, replace_ARG, snapshot_ARG, splitmirrors_ARG,
+ readahead_ARG, regionsize_ARG, repair_ARG, replace_ARG, snapshot_ARG, splitmirrors_ARG,
trackchanges_ARG, type_ARG, stripes_long_ARG, stripesize_ARG, test_ARG,
chunksize_ARG, discards_ARG, poolmetadata_ARG, poolmetadatasize_ARG, thinpool_ARG,
use_policies_ARG, yes_ARG, force_ARG, zero_ARG)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 7d03a5f..7a01cce 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -39,6 +39,7 @@ struct lvconvert_params {
uint32_t keep_mimages;
uint32_t stripes;
uint32_t stripe_size;
+ uint32_t read_ahead;
const struct segment_type *segtype;
unsigned target_attr;
@@ -336,53 +337,21 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
return 0;
}
+ if (!get_pool_params(cmd,
+ &lp->chunk_size,
+ &lp->discards,
+ &lp->poolmetadata_size,
+ &lp->zero))
+ return_0;
+
if (arg_count(cmd, poolmetadata_ARG)) {
- lp->pool_metadata_lv_name = arg_str_value(cmd, poolmetadata_ARG, "");
- } else if (arg_count(cmd, poolmetadatasize_ARG)) {
- if (arg_sign_value(cmd, poolmetadatasize_ARG, SIGN_NONE) == SIGN_MINUS) {
- log_error("Negative pool metadata size is invalid.");
+ if (arg_count(cmd, poolmetadatasize_ARG)) {
+ log_error("--poolmetadatasize is invalid with --poolmetadata.");
return 0;
}
- lp->poolmetadata_size = arg_uint64_value(cmd, poolmetadatasize_ARG, UINT64_C(0));
-
- if (lp->poolmetadata_size > (2 * DEFAULT_THIN_POOL_MAX_METADATA_SIZE)) {
- if (arg_count(cmd, poolmetadatasize_ARG))
- log_warn("WARNING: Maximum supported pool metadata size is 16GB.");
- lp->poolmetadata_size = 2 * DEFAULT_THIN_POOL_MAX_METADATA_SIZE;
- } else if (lp->poolmetadata_size < (2 * DEFAULT_THIN_POOL_MIN_METADATA_SIZE)) {
- if (arg_count(cmd, poolmetadatasize_ARG))
- log_warn("WARNING: Minimum supported pool metadata size is 2M.");
- lp->poolmetadata_size = 2 * DEFAULT_THIN_POOL_MIN_METADATA_SIZE;
- }
-
- log_verbose("Setting pool metadata size to %" PRIu64 " sectors.",
- lp->poolmetadata_size);
+ lp->pool_metadata_lv_name = arg_str_value(cmd, poolmetadata_ARG, "");
}
- if (arg_count(cmd, chunksize_ARG)) {
- if (arg_sign_value(cmd, chunksize_ARG, SIGN_NONE) == SIGN_MINUS) {
- log_error("Negative chunk size is invalid.");
- return 0;
- }
- lp->chunk_size = arg_uint_value(cmd, chunksize_ARG,
- DM_THIN_MIN_DATA_BLOCK_SIZE);
-
- if ((lp->chunk_size < DM_THIN_MIN_DATA_BLOCK_SIZE) ||
- (lp->chunk_size > DM_THIN_MAX_DATA_BLOCK_SIZE)) {
- log_error("Chunk size must be in the range %uK to %uK.",
- (DM_THIN_MIN_DATA_BLOCK_SIZE / 2),
- (DM_THIN_MAX_DATA_BLOCK_SIZE / 2));
- return 0;
- }
- } else
- lp->chunk_size = DM_THIN_MIN_DATA_BLOCK_SIZE;
-
- log_verbose("Setting pool metadata chunk size to %u sectors.",
- lp->chunk_size);
-
- if (arg_count(cmd, zero_ARG))
- lp->zero = strcmp(arg_str_value(cmd, zero_ARG, "y"), "n");
-
/* If --thinpool contains VG name, extract it. */
if ((tmp_str = strchr(lp->pool_data_lv_name, (int) '/'))) {
if (!(lp->vg_name = extract_vgname(cmd, lp->pool_data_lv_name)))
@@ -1827,6 +1796,12 @@ static int _lvconvert_thinpool(struct cmd_context *cmd,
struct logical_volume *data_lv;
struct logical_volume *metadata_lv;
+ if (!lv_is_visible(pool_lv)) {
+ log_error("Can't convert internal LV %s/%s.",
+ pool_lv->vg->name, pool_lv->name);
+ return 0;
+ }
+
if (lv_is_thin_type(pool_lv)) {
log_error("Can't use thin logical volume %s/%s for thin pool data.",
pool_lv->vg->name, pool_lv->name);
@@ -1840,14 +1815,41 @@ static int _lvconvert_thinpool(struct cmd_context *cmd,
return 0;
}
+ len = strlen(pool_lv->name) + 16;
+ if (!(name = dm_pool_alloc(pool_lv->vg->vgmem, len))) {
+ log_error("Can't allocate new name.");
+ return 0;
+ }
+
+ if (dm_snprintf(name, len, "%s_tmeta", pool_lv->name) < 0)
+ return_0;
+
if (lp->pool_metadata_lv_name) {
+ if (arg_count(cmd, stripesize_ARG) || arg_count(cmd, stripes_long_ARG)) {
+ log_error("Can't use --stripes and --stripesize with --poolmetadata.");
+ return 0;
+ }
+ if (arg_count(cmd, readahead_ARG)) {
+ log_error("Can't use --readahead with --poolmetadata.");
+ return 0;
+ }
metadata_lv = find_lv(pool_lv->vg, lp->pool_metadata_lv_name);
if (!metadata_lv) {
- log_error("Unknown metadata LV %s", lp->pool_metadata_lv_name);
+ log_error("Unknown metadata LV %s.", lp->pool_metadata_lv_name);
+ return 0;
+ }
+ if (!lv_is_visible(metadata_lv)) {
+ log_error("Can't convert internal LV %s/%s.",
+ metadata_lv->vg->name, metadata_lv->name);
+ return 0;
+ }
+ if (metadata_lv->status & LOCKED) {
+ log_error("Can't convert locked LV %s/%s.",
+ metadata_lv->vg->name, metadata_lv->name);
return 0;
}
if (metadata_lv == pool_lv) {
- log_error("Can't use same LV for thin data and metadata LV %s",
+ log_error("Can't use same LV for thin pool data and metadata LV %s.",
lp->pool_metadata_lv_name);
return 0;
}
@@ -1857,37 +1859,51 @@ static int _lvconvert_thinpool(struct cmd_context *cmd,
metadata_lv->vg->name, metadata_lv->name);
return 0;
}
- } else if (arg_count(cmd, poolmetadatasize_ARG)) {
- /* FIXME: allocate metadata LV! */
- metadata_lv = NULL;
- log_error("Uncreated metadata.");
- return 0;
- } else {
- log_error("Uknown metadata.");
- return 0;
- }
-
- len = strlen(pool_lv->name) + 16;
- if (!(name = dm_pool_alloc(pool_lv->vg->vgmem, len))) {
- log_error("Cannot allocate new name.");
- return 0;
- }
-
- if (!lv_is_active(metadata_lv)) {
- if (!deactivate_lv(cmd, metadata_lv)) {
- log_error("Can't deactivate logical volume %s/%s.",
- metadata_lv->vg->name, metadata_lv->name);
+ if (!lv_is_active(metadata_lv) &&
+ !activate_lv_local(cmd, metadata_lv)) {
+ log_error("Aborting. Failed to activate thin metadata lv.");
+ return 0;
+ }
+ if (!set_lv(cmd, metadata_lv, UINT64_C(0), 0)) {
+ log_error("Aborting. Failed to wipe thin metadata lv.");
return 0;
}
- if (!activate_lv_local(cmd, metadata_lv)) {
- log_error("Aborting. Failed to activate thin metadata lv.");
+
+ lp->poolmetadata_size =
+ (uint64_t) metadata_lv->le_count * metadata_lv->vg->extent_size;
+ if (lp->poolmetadata_size > (2 * DEFAULT_THIN_POOL_MAX_METADATA_SIZE)) {
+ log_warn("WARNING: Maximum size used by metadata is %s, rest is unused.",
+ display_size(cmd, 2 * DEFAULT_THIN_POOL_MAX_METADATA_SIZE));
+ lp->poolmetadata_size = 2 * DEFAULT_THIN_POOL_MAX_METADATA_SIZE;
+ } else if (lp->poolmetadata_size < (2 * DEFAULT_THIN_POOL_MIN_METADATA_SIZE)) {
+ log_error("Logical volume %s/%s is too small (<%s) for metadata.",
+ metadata_lv->vg->name, metadata_lv->name,
+ display_size(cmd, 2 * DEFAULT_THIN_POOL_MIN_METADATA_SIZE));
return 0;
}
- }
+ if (!update_pool_params(cmd, lp->target_attr,
+ pool_lv->le_count, pool_lv->vg->extent_size,
+ &lp->chunk_size, &lp->discards,
+ &lp->poolmetadata_size))
+ return_0;
+ } else {
+ if (!update_pool_params(cmd, lp->target_attr,
+ pool_lv->le_count, pool_lv->vg->extent_size,
+ &lp->chunk_size, &lp->discards,
+ &lp->poolmetadata_size))
+ return_0;
- if (!set_lv(cmd, metadata_lv, UINT64_C(0), 0)) {
- log_error("Aborting. Failed to wipe thin metadata lv.");
- return 0;
+ if (!get_stripe_params(cmd, &lp->stripes, &lp->stripe_size))
+ return_0;
+ /* Hmm _read_activation_params */
+ lp->read_ahead = arg_uint_value(cmd, readahead_ARG,
+ cmd->default_settings.read_ahead);
+
+ if (!(metadata_lv = alloc_pool_metadata(pool_lv, lp->alloc, name,
+ lp->pvh, lp->read_ahead,
+ lp->stripes, lp->stripe_size,
+ lp->poolmetadata_size)))
+ return_0;
}
if (!deactivate_lv(cmd, metadata_lv)) {
@@ -1896,12 +1912,10 @@ static int _lvconvert_thinpool(struct cmd_context *cmd,
return 0;
}
- if (dm_snprintf(name, len, "%s_tmeta", pool_lv->name) < 0)
- return_0;
-
/* Rename deactivated metadata LV to have _tmeta suffix */
/* Implicit checks if metadata_lv is visible */
- if (!lv_rename_update(cmd, metadata_lv, name, 0))
+ if (strcmp(metadata_lv->name, name) &&
+ !lv_rename_update(cmd, metadata_lv, name, 0))
return_0;
/*
11 years
master - thin: add alloc_pool_metadata
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b78609686399ee...
Commit: b78609686399ee01a53d8a2e8685cd05389d8cc9
Parent: f4137640f60af5377615a1b9e50238b593cf272b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Nov 19 13:37:36 2012 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 19 14:38:17 2012 +0100
thin: add alloc_pool_metadata
Since our api call is not yet powerfull enough,
use this wrapper to preset options.
---
tools/toollib.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
tools/toollib.h | 5 +++++
2 files changed, 49 insertions(+), 0 deletions(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index c3c6381..ba1ba94 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1650,6 +1650,50 @@ int update_pool_params(struct cmd_context *cmd, unsigned attr,
return 1;
}
+struct logical_volume *alloc_pool_metadata(struct logical_volume *pool_lv,
+ alloc_policy_t alloc,
+ const char *name,
+ struct dm_list *pvh,
+ uint32_t read_ahead,
+ uint32_t stripes,
+ uint32_t stripe_size,
+ uint64_t size)
+{
+ struct logical_volume *metadata_lv;
+ struct lvcreate_params lvc;
+
+ /* FIXME: Make lvm2api usable */
+ memset(&lvc, 0, sizeof(lvc));
+
+ if (!(lvc.extents = extents_from_size(pool_lv->vg->cmd, size,
+ pool_lv->vg->extent_size)))
+ return_0;
+
+ if (!(lvc.segtype = get_segtype_from_string(pool_lv->vg->cmd, "striped")))
+ return_0;
+
+ dm_list_init(&lvc.tags);
+
+ /* FIXME: allocate properly space for metadata_lv */
+ lvc.activate = CHANGE_ALY;
+ lvc.alloc = alloc;
+ lvc.lv_name = name;
+ lvc.major = -1;
+ lvc.minor = -1;
+ lvc.permission = LVM_READ | LVM_WRITE;
+ lvc.pvh = pvh;
+ lvc.read_ahead = read_ahead;
+ lvc.stripe_size = stripe_size;
+ lvc.stripes = stripes;
+ lvc.vg_name = pool_lv->vg->name;
+ lvc.zero = 1;
+
+ if (!(metadata_lv = lv_create_single(pool_lv->vg, &lvc)))
+ return_0;
+
+ return metadata_lv;
+}
+
/*
* Generic stripe parameter checks.
*/
diff --git a/tools/toollib.h b/tools/toollib.h
index 09071b3..80c01fd 100644
--- a/tools/toollib.h
+++ b/tools/toollib.h
@@ -120,6 +120,11 @@ int update_pool_params(struct cmd_context *cmd, unsigned attr,
uint32_t data_extents, uint32_t extent_size,
uint32_t *chunk_size, thin_discards_t *discards,
uint64_t *pool_metadata_size);
+struct logical_volume *alloc_pool_metadata(struct logical_volume *pool_lv,
+ alloc_policy_t alloc, const char *name,
+ struct dm_list *pvh, uint32_t read_ahead,
+ uint32_t stripes, uint32_t stripe_size,
+ uint64_t size);
int get_stripe_params(struct cmd_context *cmd, uint32_t *stripes,
uint32_t *stripe_size);
11 years
master - thin: add common pool functions
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f4137640f60af5...
Commit: f4137640f60af5377615a1b9e50238b593cf272b
Parent: 2e96ea4a899a0d0a5adb5e3d8fa09e04fd7a4173
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Nov 15 14:48:32 2012 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 19 14:38:17 2012 +0100
thin: add common pool functions
Move common functions for lvcreate and lvconvert.
get_pool_params() - read thin pool args.
update_pool_params() - updates/validates some thin args.
It is getting complicated and even few more things will be
implemented, so to avoid reimplementing things differently
in lvcreate and lvconvert code has been splitted
into 2 common functions that allow some future extension.
---
WHATS_NEW | 1 +
tools/toollib.c | 129 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
tools/toollib.h | 9 ++++
3 files changed, 139 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 8117165..59a69da 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Move common functionality for thin lvcreate and lvconvert to toollib.
Mirrored log is now fixed before its mirror when double-fault occurs.
Add python-lvm unit test case
Exit pvscan --cache immediately if cluster locking used or lvmetad not used.
diff --git a/tools/toollib.c b/tools/toollib.c
index 62f59d8..c3c6381 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -15,6 +15,7 @@
#include "tools.h"
#include <sys/stat.h>
+#include <strings.h>
const char *command_name(struct cmd_context *cmd)
{
@@ -1521,6 +1522,134 @@ int get_activation_monitoring_mode(struct cmd_context *cmd,
return 1;
}
+int get_pool_params(struct cmd_context *cmd,
+ uint32_t *chunk_size,
+ thin_discards_t *discards,
+ uint64_t *pool_metadata_size,
+ int *zero)
+{
+ if (arg_count(cmd, zero_ARG))
+ *zero = strcmp(arg_str_value(cmd, zero_ARG, "y"), "n");
+ else
+ *zero = 1; /* TODO: Make default configurable */
+
+ *discards = (thin_discards_t) arg_uint_value(cmd, discards_ARG,
+ THIN_DISCARDS_PASSDOWN);
+
+ if (arg_sign_value(cmd, chunksize_ARG, SIGN_NONE) == SIGN_MINUS) {
+ log_error("Negative chunk size is invalid.");
+ return 0;
+ }
+ *chunk_size = arg_uint_value(cmd, chunksize_ARG,
+ DM_THIN_MIN_DATA_BLOCK_SIZE);
+
+ if ((*chunk_size < DM_THIN_MIN_DATA_BLOCK_SIZE) ||
+ (*chunk_size > DM_THIN_MAX_DATA_BLOCK_SIZE)) {
+ log_error("Chunk size must be in the range %s to %s.",
+ display_size(cmd, DM_THIN_MIN_DATA_BLOCK_SIZE),
+ display_size(cmd, DM_THIN_MAX_DATA_BLOCK_SIZE));
+ return 0;
+ }
+
+ if (arg_sign_value(cmd, poolmetadatasize_ARG, SIGN_NONE) == SIGN_MINUS) {
+ log_error("Negative pool metadata size is invalid.");
+ return 0;
+ }
+ *pool_metadata_size = arg_uint64_value(cmd, poolmetadatasize_ARG, UINT64_C(0));
+
+ return 1;
+}
+
+int update_pool_params(struct cmd_context *cmd, unsigned attr,
+ uint32_t data_extents, uint32_t extent_size,
+ uint32_t *chunk_size, thin_discards_t *discards,
+ uint64_t *pool_metadata_size)
+{
+ size_t estimate_chunk_size;
+
+ if (!(attr & THIN_FEATURE_BLOCK_SIZE) &&
+ (*chunk_size & (*chunk_size - 1))) {
+ log_error("Chunk size must be a power of 2 for this thin target version.");
+ return 0;
+ } else if (*chunk_size & (DM_THIN_MIN_DATA_BLOCK_SIZE - 1)) {
+ log_error("Chunk size must be multiple of %s.",
+ display_size(cmd, DM_THIN_MIN_DATA_BLOCK_SIZE));
+ return 0;
+ } else if ((*discards != THIN_DISCARDS_IGNORE) &&
+ (*chunk_size & (*chunk_size - 1))) {
+ log_warn("WARNING: Using discards ignore for chunk size non power of 2.");
+ *discards = THIN_DISCARDS_IGNORE;
+ }
+
+ if (!*pool_metadata_size) {
+ /* Defaults to nr_pool_blocks * 64b converted to size in sectors */
+ *pool_metadata_size = (uint64_t) data_extents * extent_size /
+ (*chunk_size * (SECTOR_SIZE / UINT64_C(64)));
+ /* Check if we could eventually use bigger chunk size */
+ if (!arg_count(cmd, chunksize_ARG)) {
+ while ((*pool_metadata_size >
+ (DEFAULT_THIN_POOL_OPTIMAL_SIZE / SECTOR_SIZE)) &&
+ (*chunk_size < DM_THIN_MAX_DATA_BLOCK_SIZE)) {
+ *chunk_size <<= 1;
+ *pool_metadata_size >>= 1;
+ }
+ log_verbose("Setting chunk size to %s.",
+ display_size(cmd, *chunk_size));
+ } else if (*pool_metadata_size > (2 * DEFAULT_THIN_POOL_MAX_METADATA_SIZE)) {
+ /* Suggest bigger chunk size */
+ estimate_chunk_size = (uint64_t) data_extents * extent_size /
+ (2 * DEFAULT_THIN_POOL_MAX_METADATA_SIZE *
+ (SECTOR_SIZE / UINT64_C(64)));
+ log_warn("WARNING: Chunk size is too small for pool, suggested minimum is %s.",
+ display_size(cmd, 1 << (ffs(estimate_chunk_size) + 1)));
+ }
+
+ /* Round up to extent size */
+ if (*pool_metadata_size % extent_size)
+ *pool_metadata_size += extent_size - *pool_metadata_size % extent_size;
+ } else {
+ estimate_chunk_size = (uint64_t) data_extents * extent_size /
+ (*pool_metadata_size * (SECTOR_SIZE / UINT64_C(64)));
+ /* Check to eventually use bigger chunk size */
+ if (!arg_count(cmd, chunksize_ARG)) {
+ *chunk_size = estimate_chunk_size;
+
+ if (*chunk_size < DM_THIN_MIN_DATA_BLOCK_SIZE)
+ *chunk_size = DM_THIN_MIN_DATA_BLOCK_SIZE;
+ else if (*chunk_size > DM_THIN_MAX_DATA_BLOCK_SIZE)
+ *chunk_size = DM_THIN_MAX_DATA_BLOCK_SIZE;
+
+ log_verbose("Setting chunk size %uKiB.", *chunk_size / 2);
+ } else if (*chunk_size < estimate_chunk_size) {
+ /* Suggest bigger chunk size */
+ log_warn("WARNING: Chunk size is smaller then suggested minimum size %s.",
+ display_size(cmd, estimate_chunk_size));
+ }
+ }
+
+ if ((uint64_t) *chunk_size > (uint64_t) data_extents * extent_size) {
+ log_error("Chunk size is bigger then pool data size.");
+ return 0;
+ }
+
+ if (*pool_metadata_size > (2 * DEFAULT_THIN_POOL_MAX_METADATA_SIZE)) {
+ if (arg_count(cmd, poolmetadatasize_ARG))
+ log_warn("WARNING: Maximum supported pool metadata size is %s.",
+ display_size(cmd, 2 * DEFAULT_THIN_POOL_MAX_METADATA_SIZE));
+ *pool_metadata_size = 2 * DEFAULT_THIN_POOL_MAX_METADATA_SIZE;
+ } else if (*pool_metadata_size < (2 * DEFAULT_THIN_POOL_MIN_METADATA_SIZE)) {
+ if (arg_count(cmd, poolmetadatasize_ARG))
+ log_warn("WARNING: Minimum supported pool metadata size is %s.",
+ display_size(cmd, 2 * DEFAULT_THIN_POOL_MIN_METADATA_SIZE));
+ *pool_metadata_size = 2 * DEFAULT_THIN_POOL_MIN_METADATA_SIZE;
+ }
+
+ log_verbose("Setting pool metadata size to %s.",
+ display_size(cmd, *pool_metadata_size));
+
+ return 1;
+}
+
/*
* Generic stripe parameter checks.
*/
diff --git a/tools/toollib.h b/tools/toollib.h
index b3b0a7c..09071b3 100644
--- a/tools/toollib.h
+++ b/tools/toollib.h
@@ -111,6 +111,15 @@ int pvcreate_params_validate(struct cmd_context *cmd,
int get_activation_monitoring_mode(struct cmd_context *cmd,
int *monitoring_mode);
+int get_pool_params(struct cmd_context *cmd,
+ uint32_t *chunk_size,
+ thin_discards_t *discards,
+ uint64_t *pool_metadata_size,
+ int *zero);
+int update_pool_params(struct cmd_context *cmd, unsigned attr,
+ uint32_t data_extents, uint32_t extent_size,
+ uint32_t *chunk_size, thin_discards_t *discards,
+ uint64_t *pool_metadata_size);
int get_stripe_params(struct cmd_context *cmd, uint32_t *stripes,
uint32_t *stripe_size);
11 years