master - tests: use exclusive activation
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3a8bb8d3a4ef37...
Commit: 3a8bb8d3a4ef379298e97ca5f087a1c8908841ed
Parent: ab1887fe4719a296c2bd4b4778348f55f1b7a49a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jul 22 23:43:26 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Jul 22 23:44:06 2014 +0200
tests: use exclusive activation
---
test/shell/lvconvert-raid-allocation.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/shell/lvconvert-raid-allocation.sh b/test/shell/lvconvert-raid-allocation.sh
index aef786c..bd2cab5 100644
--- a/test/shell/lvconvert-raid-allocation.sh
+++ b/test/shell/lvconvert-raid-allocation.sh
@@ -18,7 +18,7 @@ vgcreate -s 256k $vg $(cat DEVICES)
# Start with linear on 2 PV and ensure that converting to
# RAID is not allowed to reuse PVs for different images. (Bug 1113180)
-lvcreate -l 4 -n $lv1 $vg "$dev1:0-1" "$dev2:0-1"
+lvcreate -aey -l 4 -n $lv1 $vg "$dev1:0-1" "$dev2:0-1"
not lvconvert --type raid1 -m 1 $vg/$lv1 "$dev1" "$dev2"
not lvconvert --type raid1 -m 1 $vg/$lv1 "$dev1" "$dev3:0-2"
lvconvert --type raid1 -m 1 $vg/$lv1 "$dev3"
9 years, 9 months
master - man: Update the lvscan manpage with a section on --cache.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ab1887fe4719a2...
Commit: ab1887fe4719a296c2bd4b4778348f55f1b7a49a
Parent: 66686a5bc5ec09a48b0e549f5539424cbf2c7de8
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Tue Jul 22 22:47:27 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Tue Jul 22 22:48:41 2014 +0200
man: Update the lvscan manpage with a section on --cache.
---
man/lvscan.8.in | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/man/lvscan.8.in b/man/lvscan.8.in
index fad0fbe..0b6e50b 100644
--- a/man/lvscan.8.in
+++ b/man/lvscan.8.in
@@ -34,6 +34,15 @@ mimage_0, mimage_1, and mlog.
.BR \-b ", " \-\-blockdevice
This option is now ignored. Instead, use \fBlvs\fP(8) or
\fBlvdisplay\fP(8) to obtain the device number.
+.TP
+.IR \fB\-\-cache " " LogicalVolume
+Applicable only when \fBlvmetad\fP(8) is in use (see also \fBlvm.conf\fP(5),
+global/use_lvmetad). This command issues a rescan of physical volume labels and
+metadata areas of all PVs that the logical volume uses. In particular, this can
+be used when a RAID logical volume becomes degraded, to update information
+about physical volume availability. This is only necessary if the logical
+volume is \fBnot\fP being monitored by dmeventd (see \fBlvchange\fP(8), option
+\fB\-\-monitor\fP).
.SH SEE ALSO
.BR lvm (8),
.BR lvcreate (8),
9 years, 9 months
master - WHATS_NEW: lvscan --cache, dmeventd RAID + lvmetad
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=66686a5bc5ec09...
Commit: 66686a5bc5ec09a48b0e549f5539424cbf2c7de8
Parent: 5dc6671bb550f4b480befee03d234373d08e188a
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Tue Jul 22 22:33:42 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Tue Jul 22 22:48:41 2014 +0200
WHATS_NEW: lvscan --cache, dmeventd RAID + lvmetad
---
WHATS_NEW | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 88319bf..3595517 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,7 @@
Version 2.02.108 -
=================================
+ Add lvscan --cache which re-scans constituents of a particular LV.
+ Make dmeventd's RAID plugin re-scan failed PVs when lvmetad is in use.
Improve code sharing for lvconvert and lvcreate and pools (cache & thin).
Improve lvconvert --merge validation.
Improve lvconvert --splitsnapshot validation.
9 years, 9 months
master - dmeventd: Call lvscan --cache in the RAID plugin.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5dc6671bb550f4...
Commit: 5dc6671bb550f4b480befee03d234373d08e188a
Parent: a9ea014e5152b806f57f6099311b64a2c03ca482
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Mon Jul 21 04:33:21 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Tue Jul 22 22:48:21 2014 +0200
dmeventd: Call lvscan --cache in the RAID plugin.
---
daemons/dmeventd/plugins/raid/dmeventd_raid.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/daemons/dmeventd/plugins/raid/dmeventd_raid.c b/daemons/dmeventd/plugins/raid/dmeventd_raid.c
index 3fbae15..4690cfa 100644
--- a/daemons/dmeventd/plugins/raid/dmeventd_raid.c
+++ b/daemons/dmeventd/plugins/raid/dmeventd_raid.c
@@ -33,10 +33,20 @@ static int run_repair(const char *device)
char cmd_str[CMD_SIZE];
if (!dmeventd_lvm2_command(dmeventd_lvm2_pool(), cmd_str, sizeof(cmd_str),
+ "lvscan --cache", device))
+ return -1;
+
+ r = dmeventd_lvm2_run(cmd_str);
+
+ if (!r)
+ syslog(LOG_INFO, "Re-scan of RAID device %s failed.", device);
+
+ if (!dmeventd_lvm2_command(dmeventd_lvm2_pool(), cmd_str, sizeof(cmd_str),
"lvconvert --config devices{ignore_suspended_devices=1} "
"--repair --use-policies", device))
return -1;
+ /* if repair goes OK, report success even if lvscan has failed */
r = dmeventd_lvm2_run(cmd_str);
if (!r)
9 years, 9 months
master - lvscan: Implement a --cache mode.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a9ea014e5152b8...
Commit: a9ea014e5152b806f57f6099311b64a2c03ca482
Parent: 653fd7bee3d9f765fdf81743331f2d9e91ea28bf
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Mon Jul 21 03:55:46 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Tue Jul 22 22:48:21 2014 +0200
lvscan: Implement a --cache mode.
---
tools/commands.h | 3 ++-
tools/lvscan.c | 27 ++++++++++++++++++++++++++-
2 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/tools/commands.h b/tools/commands.h
index 1f9d03c..6e115d9 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -581,6 +581,7 @@ xx(lvscan,
"lvscan " "\n"
"\t[-a|--all]\n"
"\t[-b|--blockdevice] " "\n"
+ "\t[--cache]\n"
"\t[--commandprofile ProfileName]\n"
"\t[-d|--debug] " "\n"
"\t[-h|-?|--help] " "\n"
@@ -591,7 +592,7 @@ xx(lvscan,
"\t[--version]\n",
all_ARG, blockdevice_ARG, ignorelockingfailure_ARG, partial_ARG,
- readonly_ARG)
+ readonly_ARG, cache_ARG)
xx(pvchange,
"Change attributes of physical volume(s)",
diff --git a/tools/lvscan.c b/tools/lvscan.c
index 2641054..df8a12e 100644
--- a/tools/lvscan.c
+++ b/tools/lvscan.c
@@ -15,6 +15,28 @@
#include "tools.h"
+static int _lvscan_single_lvmetad(struct cmd_context *cmd, struct logical_volume *lv)
+{
+ struct pv_list *pvl;
+ struct dm_list pvs;
+
+ if (!lvmetad_used()) {
+ log_verbose("Ignoring lvscan --cache because lvmetad is not in use.");
+ return ECMD_PROCESSED;
+ }
+
+ dm_list_init(&pvs);
+
+ if (!get_pv_list_for_lv(lv->vg->vgmem, lv, &pvs))
+ return ECMD_FAILED;
+
+ dm_list_iterate_items(pvl, &pvs)
+ if (!lvmetad_pvscan_single(cmd, pvl->pv->dev, NULL))
+ return ECMD_FAILED;
+
+ return ECMD_PROCESSED;
+}
+
static int lvscan_single(struct cmd_context *cmd, struct logical_volume *lv,
void *handle __attribute__((unused)))
{
@@ -24,6 +46,9 @@ static int lvscan_single(struct cmd_context *cmd, struct logical_volume *lv,
const char *active_str, *snapshot_str;
+ if (arg_count(cmd, cache_ARG))
+ return _lvscan_single_lvmetad(cmd, lv);
+
if (!arg_count(cmd, all_ARG) && !lv_is_visible(lv))
return ECMD_PROCESSED;
@@ -58,7 +83,7 @@ static int lvscan_single(struct cmd_context *cmd, struct logical_volume *lv,
int lvscan(struct cmd_context *cmd, int argc, char **argv)
{
- if (argc) {
+ if (argc && !arg_count(cmd, cache_ARG)) {
log_error("No additional command line arguments allowed");
return EINVALID_CMD_LINE;
}
9 years, 9 months
master - tests: new lvconvert features
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=653fd7bee3d9f7...
Commit: 653fd7bee3d9f765fdf81743331f2d9e91ea28bf
Parent: ee11bb841612ec4dba173c31bf795a8560ca134e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Jul 11 12:15:46 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Jul 22 22:41:41 2014 +0200
tests: new lvconvert features
---
test/shell/lvconvert-cache.sh | 44 +++++++++++++++++++++++++++++++-
test/shell/lvconvert-thin-external.sh | 2 +-
test/shell/lvconvert-thin.sh | 12 ++++++--
3 files changed, 52 insertions(+), 6 deletions(-)
diff --git a/test/shell/lvconvert-cache.sh b/test/shell/lvconvert-cache.sh
index 79d5fd1..6c2acd9 100644
--- a/test/shell/lvconvert-cache.sh
+++ b/test/shell/lvconvert-cache.sh
@@ -16,10 +16,50 @@ aux have_cache 1 3 0 || skip
aux prepare_vg 5 80
# lvcreate origin, lvcreate cache-pool, and lvconvert to cache
-lvcreate -l 2 -n $lv1 $vg
+lvcreate -L 2 -n $lv1 $vg
+lvcreate -L 8 -n $lv2 $vg
+lvcreate -L 8 -n $lv3 $vg
+
+# undefined cachepool
+invalid lvconvert --type cache --poolmetadata $vg/$lv2 $vg/$lv1
+
+# cannot mix with thins
+invalid lvconvert --type cache --poolmetadata $vg/$lv2 --thinpool $vg/$lv1
+invalid lvconvert --type cache --thin --poolmetadata $vg/$lv2 $vg/$lv1
+
+# undefined cached volume
+invalid lvconvert --type cache --cachepool $vg/$lv1
+invalid lvconvert --cache --cachepool $vg/$lv1
+
+# single vg
+invalid lvconvert --type cache --cachepool $vg/$lv1 --poolmetadata $vg1/$lv2 $vg/$lv3
+invalid lvconvert --type cache --cachepool $vg/$lv1 --poolmetadata $lv2 $vg1/$lv3
+invalid lvconvert --type cache --cachepool $vg1/$lv1 --poolmetadata $vg2/$lv2 $vg/$lv3
+
+invalid lvconvert --cachepool $vg1/$lv1 --poolmetadata $vg2/$lv2
+invalid lvconvert --type cache-pool --poolmetadata $vg2/$lv2 $vg1/$lv1
+
+fail lvconvert --yes --type cache-pool --chunksize 16M --poolmetadata $lv2 $vg/$lv1
+
+lvconvert --yes --type cache-pool --cachepool $vg/$lv1
+
+#fail lvconvert --cachepool $vg/$lv1 --poolmetadata $vg/$lv2
+#lvconvert --yes --type cache-pool --poolmetadata $vg/$lv2 $vg/$lv1
+#lvconvert --yes --poolmetadata $vg/$lv2 --cachepool $vg/$lv1
+
+lvremove -ff $vg
+
+lvcreate -L 2 -n $lv1 $vg
lvcreate --type cache-pool -l 1 -n ${lv1}_cachepool $vg
-lvconvert --type cache --cachepool $vg/${lv1}_cachepool $vg/$lv1
+
+lvconvert --cache --cachepool $vg/${lv1}_cachepool $vg/$lv1
dmsetup table ${vg}-$lv1 | grep cache # ensure it is loaded in kernel
+
+#lvconvert --cachepool $vg/${lv1}_cachepool $vg/$lv1
+#lvconvert --cachepool $vg/${lv1}_cachepool --poolmetadatasize 20 "$dev3"
+
+
+fail lvconvert --type cache --cachepool $vg/${lv1}_cachepool $vg/$lv1
lvremove -ff $vg
# Bug 1095843
diff --git a/test/shell/lvconvert-thin-external.sh b/test/shell/lvconvert-thin-external.sh
index 676851e..1e9887a 100644
--- a/test/shell/lvconvert-thin-external.sh
+++ b/test/shell/lvconvert-thin-external.sh
@@ -109,7 +109,7 @@ lvchange -aey $vg
lvs -a -o+origin_size,seg_size $vg
# Chain external origins
-lvconvert --originname extorg1 --thinpool $vg/pool -T $vg/extorg
+lvconvert --type thin --originname extorg1 --thinpool $vg/pool $vg/extorg
check inactive $vg extorg1
lvconvert --originname extorg2 --thinpool $vg/pool -T $vg/extorg1
diff --git a/test/shell/lvconvert-thin.sh b/test/shell/lvconvert-thin.sh
index 80f55dd..4aee7d2 100644
--- a/test/shell/lvconvert-thin.sh
+++ b/test/shell/lvconvert-thin.sh
@@ -12,8 +12,7 @@
. lib/inittest
-prepare_lvs()
-{
+prepare_lvs() {
lvremove -f $vg
lvcreate -L10M -n $lv1 $vg
lvcreate -L8M -n $lv2 $vg
@@ -38,6 +37,13 @@ aux extend_filter_LVMTEST
pvcreate "$DM_DEV_DIR/$vg1/$lv"
vgcreate $vg -s 64K $(tail -n+4 DEVICES) "$DM_DEV_DIR/$vg1/$lv"
+lvcreate -L1T -n $lv1 $vg
+invalid lvconvert --yes -c 8M --type thin --poolmetadatasize 1G $vg/$lv1
+
+# needs some --cachepool or --thinpool
+invalid lvconvert --yes --poolmetadatasize 1G $vg/$lv1
+lvremove -f $vg
+
# create mirrored LVs for data and metadata volumes
lvcreate -aey -L10M --type mirror -m1 --mirrorlog core -n $lv1 $vg
lvcreate -aey -L10M -n $lv2 $vg
@@ -60,7 +66,7 @@ lvconvert --yes -c 64 --stripes 2 --thinpool $vg/$lv1 --readahead 48
lvremove -f $vg
lvcreate -L1T -n $lv1 $vg
-lvconvert --yes -c 8M --thinpool $vg/$lv1
+lvconvert --yes -c 8M --type thin-pool $vg/$lv1
lvremove -f $vg
# test with bigger sizes
9 years, 9 months
master - tests: use full option name
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ee11bb841612ec...
Commit: ee11bb841612ec4dba173c31bf795a8560ca134e
Parent: b51f1b3df6c07f611ce364b4b662af7a2d1c9544
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jul 22 22:14:31 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Jul 22 22:41:41 2014 +0200
tests: use full option name
Don't overuse shortcut support -
since poolmetadatasize was the only allowed option
it's been equivalent to poolmetadata
---
test/shell/lvresize-thin-metadata.sh | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/test/shell/lvresize-thin-metadata.sh b/test/shell/lvresize-thin-metadata.sh
index a034d07..9e2ae4d 100644
--- a/test/shell/lvresize-thin-metadata.sh
+++ b/test/shell/lvresize-thin-metadata.sh
@@ -26,14 +26,14 @@ for deactivate in true false; do
test $deactivate && lvchange -an $vg
- lvresize --poolmetadata +2M $vg/pool
+ lvresize --poolmetadatasize +2M $vg/pool
# Test it's been resized to 4M
check lv_field $vg/pool_tmeta size "4.00m"
- lvresize --poolmetadata +256M $vg/pool
+ lvresize --poolmetadatasize +256M $vg/pool
check lv_field $vg/pool_tmeta size "260.00m"
- lvresize --poolmetadata +3G $vg/pool
+ lvresize --poolmetadatasize +3G $vg/pool
check lv_field $vg/pool_tmeta size "3.25g"
vgchange -an $vg
9 years, 9 months
master - man: lvconvert poolmetadataspare
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b51f1b3df6c07f...
Commit: b51f1b3df6c07f611ce364b4b662af7a2d1c9544
Parent: d7d81e11574baad841def2fc1efb7a22ea44cd3e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jul 22 17:31:22 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Jul 22 22:41:41 2014 +0200
man: lvconvert poolmetadataspare
Add missing description for --poolmetadataspare option.
---
man/lvconvert.8.in | 11 +++++++++++
man/lvcreate.8.in | 4 ++--
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/man/lvconvert.8.in b/man/lvconvert.8.in
index 032fbff..93fb9a9 100644
--- a/man/lvconvert.8.in
+++ b/man/lvconvert.8.in
@@ -118,6 +118,8 @@ lvconvert \(em convert a logical volume from linear to mirror or snapshot
.RI { ReadAheadSectors | auto | none }]
.RB [ \-\-stripes \ \fIStripes
.RB [ \-I | \-\-stripesize \ \fIStripeSize ]]]
+.RB [ \-\-poolmetadataspare
+.RI { y | n }]
.RB [ \-Z | \-\-zero \ { \fIy | \fIn }]]
.RI [[ ExternalOrigin | ThinPool ] LogicalVolume { Name | Path }]
.RI [ PhysicalVolume [ Path ][ :PE
@@ -141,6 +143,8 @@ lvconvert \(em convert a logical volume from linear to mirror or snapshot
|
.B \-\-poolmetadatasize
.IR CachePoolMetadataSize [ bBsSkKmMgG ]}]
+.RB [ \-\-poolmetadataspare
+.RI { y | n }]
.IR LogicalVolume { Name | Path }
.RI [ PhysicalVolume [ Path ][ :PE [ \-PE ]]...]
.RB [ \-\-commandprofile
@@ -373,6 +377,13 @@ The default value is estimated with this formula
(Pool_LV_size / Pool_LV_chunk_size * 64b).
Default unit is megabytes.
.TP
+.IR \fB\-\-poolmetadataspare " {" y | n }
+Controls creation and maintanence of pool metadata spare logical volume
+that will be used for automated pool recovery.
+Only one such volume is maintained within a volume group
+with the size of the biggest pool metadata volume.
+Default is \fIy\fPes.
+.TP
.IR \fB\-r ", " \fB\-\-readahead " {" ReadAheadSectors | auto | none }
Sets read ahead sector count of thin pool metadata logical volume.
The default value is "\fIauto\fP" which allows the kernel to choose
diff --git a/man/lvcreate.8.in b/man/lvcreate.8.in
index 4ae2b9a..5440ced 100644
--- a/man/lvcreate.8.in
+++ b/man/lvcreate.8.in
@@ -346,9 +346,9 @@ Default unit is megabytes.
.TP
.IR \fB\-\-poolmetadataspare " {" y | n }
Controls creation and maintanence of pool metadata spare logical volume
-that will be used for automated thin pool recovery.
+that will be used for automated pool recovery.
Only one such volume is maintained within a volume group
-with the size of the biggest thin metadata volume.
+with the size of the biggest pool metadata volume.
Default is \fIy\fPes.
.TP
.IR \fB\-r ", " \fB\-\-readahead " {" ReadAheadSectors | auto | none }
9 years, 9 months
master - cleanup: show better messages
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d7d81e11574baa...
Commit: d7d81e11574baad841def2fc1efb7a22ea44cd3e
Parent: 894eda4707dbcf9e160922d95621703c0fa58f94
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jul 22 17:29:53 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Jul 22 22:41:40 2014 +0200
cleanup: show better messages
---
lib/metadata/cache_manip.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index e6b6551..184df79 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -41,8 +41,8 @@ int update_cache_pool_params(struct volume_group *vg, unsigned attr,
}
if (*chunk_size & (DM_CACHE_MIN_DATA_BLOCK_SIZE - 1)) {
- log_error("Chunk size must be a multiple of %u sectors.",
- DM_CACHE_MIN_DATA_BLOCK_SIZE);
+ log_error("Chunk size must be a multiple of %s.",
+ display_size(vg->cmd, DM_CACHE_MIN_DATA_BLOCK_SIZE));
return 0;
}
9 years, 9 months
master - thin and cache: unify pool common code
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=894eda4707dbcf...
Commit: 894eda4707dbcf9e160922d95621703c0fa58f94
Parent: 8c56c5fbacf6a4e9a0130b6f1fdc5683d6f108ec
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jul 22 22:20:18 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Jul 22 22:41:38 2014 +0200
thin and cache: unify pool common code
Fix get_pool_params to only read params.
Add poolmetadataspare option to get_pool_params.
Move all profile code into update_pool_params.
Move recalculate code into pool_manip.c
---
WHATS_NEW | 1 +
lib/config/config.c | 6 +-
lib/metadata/cache_manip.c | 11 ++--
lib/metadata/lv_manip.c | 104 +++-------------------------------
lib/metadata/metadata-exported.h | 24 +++++---
lib/metadata/pool_manip.c | 116 ++++++++++++++++++++++++++++++++++++++
lib/metadata/thin_manip.c | 63 +++++++--------------
tools/lvconvert.c | 84 ++++++++-------------------
tools/lvcreate.c | 57 +++++-------------
tools/toollib.c | 69 +++++++++++++----------
tools/toollib.h | 6 +-
11 files changed, 253 insertions(+), 288 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index c800dd0..88319bf 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.108 -
=================================
+ Improve code sharing for lvconvert and lvcreate and pools (cache & thin).
Improve lvconvert --merge validation.
Improve lvconvert --splitsnapshot validation.
Add report/list_item_separator lvm.conf option.
diff --git a/lib/config/config.c b/lib/config/config.c
index 8148a18..a71cbdc 100644
--- a/lib/config/config.c
+++ b/lib/config/config.c
@@ -1988,9 +1988,9 @@ int get_default_allocation_thin_pool_chunk_size_CFG(struct cmd_context *cmd, str
}
if (!strcasecmp(str, "generic"))
- chunk_size = DEFAULT_THIN_POOL_CHUNK_SIZE;
+ chunk_size = DEFAULT_THIN_POOL_CHUNK_SIZE * 2;
else if (!strcasecmp(str, "performance"))
- chunk_size = DEFAULT_THIN_POOL_CHUNK_SIZE_PERFORMANCE;
+ chunk_size = DEFAULT_THIN_POOL_CHUNK_SIZE_PERFORMANCE * 2;
else {
log_error("Thin pool chunk size calculation policy \"%s\" is unrecognised.", str);
return 0;
@@ -2001,5 +2001,5 @@ int get_default_allocation_thin_pool_chunk_size_CFG(struct cmd_context *cmd, str
int get_default_allocation_cache_pool_chunk_size_CFG(struct cmd_context *cmd, struct profile *profile)
{
- return DEFAULT_CACHE_POOL_CHUNK_SIZE;
+ return DEFAULT_CACHE_POOL_CHUNK_SIZE * 2;
}
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index 8a5e5e3..e6b6551 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -23,14 +23,15 @@
#include "defaults.h"
int update_cache_pool_params(struct volume_group *vg, unsigned attr,
- int passed_args,
- uint32_t data_extents, uint32_t extent_size,
- int *chunk_size_calc_method, uint32_t *chunk_size,
- thin_discards_t *discards,
- uint64_t *pool_metadata_size, int *zero)
+ int passed_args, uint32_t data_extents,
+ uint64_t *pool_metadata_size,
+ int *chunk_size_calc_method, uint32_t *chunk_size)
{
uint64_t min_meta_size;
+ if (!(passed_args & PASS_ARG_CHUNK_SIZE))
+ *chunk_size = DEFAULT_CACHE_POOL_CHUNK_SIZE * 2;
+
if ((*chunk_size < DM_CACHE_MIN_DATA_BLOCK_SIZE) ||
(*chunk_size > DM_CACHE_MAX_DATA_BLOCK_SIZE)) {
log_error("Chunk size must be in the range %s to %s.",
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index c55b31f..0d39166 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6040,97 +6040,6 @@ int lv_activation_skip(struct logical_volume *lv, activation_change_t activate,
return 1;
}
-/* Greatest common divisor */
-static unsigned long _gcd(unsigned long n1, unsigned long n2)
-{
- unsigned long remainder;
-
- do {
- remainder = n1 % n2;
- n1 = n2;
- n2 = remainder;
- } while (n2);
-
- return n1;
-}
-
-/* Least common multiple */
-static unsigned long _lcm(unsigned long n1, unsigned long n2)
-{
- if (!n1 || !n2)
- return 0;
- return (n1 * n2) / _gcd(n1, n2);
-}
-
-static int _recalculate_pool_chunk_size_with_dev_hints(struct lvcreate_params *lp,
- struct logical_volume *pool_lv)
-{
- struct logical_volume *pool_data_lv;
- struct lv_segment *seg;
- struct physical_volume *pv;
- struct cmd_context *cmd = pool_lv->vg->cmd;
- unsigned long previous_hint = 0, hint = 0;
- uint32_t chunk_size = lp->chunk_size;
- uint32_t default_chunk_size;
- uint32_t min_chunk_size, max_chunk_size;
-
- if (lp->passed_args & PASS_ARG_CHUNK_SIZE)
- goto out;
-
- if (seg_is_thin_pool(lp)) {
- if (find_config_tree_int(cmd, allocation_thin_pool_chunk_size_CFG, NULL))
- goto out;
-
- min_chunk_size = DM_THIN_MIN_DATA_BLOCK_SIZE;
- max_chunk_size = DM_THIN_MAX_DATA_BLOCK_SIZE;
- default_chunk_size = get_default_allocation_thin_pool_chunk_size_CFG(cmd, NULL) * 2;
- } else if (seg_is_cache_pool(lp)) {
- if (find_config_tree_int(cmd, allocation_cache_pool_chunk_size_CFG, NULL))
- goto out;
- min_chunk_size = DM_CACHE_MIN_DATA_BLOCK_SIZE;
- max_chunk_size = DM_CACHE_MAX_DATA_BLOCK_SIZE;
- default_chunk_size = get_default_allocation_cache_pool_chunk_size_CFG(cmd, NULL) * 2;
- } else {
- log_error(INTERNAL_ERROR "%s is not a thin pool or cache pool",
- pool_lv->name);
- return 0;
- }
-
- pool_data_lv = seg_lv(first_seg(pool_lv), 0);
-
- dm_list_iterate_items(seg, &pool_data_lv->segments) {
- pv = seg_pv(seg, 0);
- if (lp->thin_chunk_size_calc_policy == THIN_CHUNK_SIZE_CALC_METHOD_PERFORMANCE)
- hint = dev_optimal_io_size(cmd->dev_types, pv_dev(pv));
- else
- hint = dev_minimum_io_size(cmd->dev_types, pv_dev(pv));
-
- if (!hint)
- continue;
- if (previous_hint)
- hint = _lcm(previous_hint, hint);
- previous_hint = hint;
- }
-
- if (!hint) {
- log_debug_alloc("No usable device hint found while recalculating"
- " thin pool chunk size for %s.", pool_lv->name);
- goto out;
- }
-
- if ((hint < min_chunk_size) || (hint > max_chunk_size)) {
- log_debug_alloc("Calculated chunk size value of %ld sectors for"
- " thin pool %s is out of allowed range (%d-%d).",
- hint, pool_lv->name,
- min_chunk_size, max_chunk_size);
- } else
- chunk_size = (hint >= default_chunk_size) ?
- hint : default_chunk_size;
-out:
- first_seg(pool_lv)->chunk_size = chunk_size;
- return 1;
-}
-
static int _should_wipe_lv(struct lvcreate_params *lp, struct logical_volume *lv) {
int r = lp->zero | lp->wipe_signatures;
@@ -6496,16 +6405,21 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
return_NULL;
if (seg_is_cache_pool(lp)) {
- if (!_recalculate_pool_chunk_size_with_dev_hints(lp, lv))
- return_NULL;
+ first_seg(lv)->chunk_size = lp->chunk_size;
first_seg(lv)->feature_flags = lp->feature_flags;
- } else if (seg_is_thin_pool(lp)) {
- if (!_recalculate_pool_chunk_size_with_dev_hints(lp, lv))
+ /* TODO: some calc_policy solution for cache ? */
+ if (!recalculate_pool_chunk_size_with_dev_hints(lv, lp->passed_args,
+ THIN_CHUNK_SIZE_CALC_METHOD_GENERIC))
return_NULL;
+ } else if (seg_is_thin_pool(lp)) {
+ first_seg(lv)->chunk_size = lp->chunk_size;
first_seg(lv)->zero_new_blocks = lp->zero ? 1 : 0;
first_seg(lv)->discards = lp->discards;
/* FIXME: use lowwatermark via lvm.conf global for all thinpools ? */
first_seg(lv)->low_water_mark = 0;
+ if (!recalculate_pool_chunk_size_with_dev_hints(lv, lp->passed_args,
+ lp->thin_chunk_size_calc_policy))
+ return_NULL;
} else if (seg_is_thin_volume(lp)) {
pool_lv = first_seg(lv)->pool_lv;
if (!(first_seg(lv)->device_id =
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 9d7a653..fa96a1a 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -703,17 +703,25 @@ struct logical_volume *find_pool_lv(const struct logical_volume *lv);
int pool_is_active(const struct logical_volume *pool_lv);
int pool_supports_external_origin(const struct lv_segment *pool_seg, const struct logical_volume *external_lv);
int thin_pool_feature_supported(const struct logical_volume *pool_lv, int feature);
+int recalculate_pool_chunk_size_with_dev_hints(struct logical_volume *pool_lv,
+ int passed_args,
+ int chunk_size_calc_policy);
int update_pool_lv(struct logical_volume *lv, int activate);
+int update_pool_params(const struct segment_type *segtype,
+ struct volume_group *vg, unsigned target_attr,
+ int passed_args, uint32_t data_extents,
+ uint64_t *pool_metadata_size,
+ int *chunk_size_calc_policy, uint32_t *chunk_size,
+ thin_discards_t *discards, int *zero);
int update_profilable_pool_params(struct cmd_context *cmd, struct profile *profile,
int passed_args, int *chunk_size_calc_method,
uint32_t *chunk_size, thin_discards_t *discards,
int *zero);
int update_thin_pool_params(struct volume_group *vg, unsigned attr,
- int passed_args,
- uint32_t data_extents, uint32_t extent_size,
+ int passed_args, uint32_t data_extents,
+ uint64_t *pool_metadata_size,
int *chunk_size_calc_method, uint32_t *chunk_size,
- thin_discards_t *discards,
- uint64_t *pool_metadata_size, int *zero);
+ thin_discards_t *discards, int *zero);
int get_pool_discards(const char *str, thin_discards_t *discards);
const char *get_pool_discards_name(thin_discards_t discards);
struct logical_volume *alloc_pool_metadata(struct logical_volume *pool_lv,
@@ -1043,11 +1051,9 @@ int partial_raid_lv_supports_degraded_activation(struct logical_volume *lv);
/* ++ metadata/cache_manip.c */
int update_cache_pool_params(struct volume_group *vg, unsigned attr,
- int passed_args,
- uint32_t data_extents, uint32_t extent_size,
- int *chunk_size_calc_method, uint32_t *chunk_size,
- thin_discards_t *discards,
- uint64_t *pool_metadata_size, int *zero);
+ int passed_args, uint32_t data_extents,
+ uint64_t *pool_metadata_size,
+ int *chunk_size_calc_method, uint32_t *chunk_size);
struct logical_volume *lv_cache_create(struct logical_volume *pool,
struct logical_volume *origin);
int lv_cache_remove(struct logical_volume *cache_lv);
diff --git a/lib/metadata/pool_manip.c b/lib/metadata/pool_manip.c
index e32b109..0ed5d64 100644
--- a/lib/metadata/pool_manip.c
+++ b/lib/metadata/pool_manip.c
@@ -23,7 +23,9 @@
#include "segtype.h"
#include "lv_alloc.h"
#include "defaults.h"
+#include "dev-type.h"
#include "display.h"
+#include "toolcontext.h"
int attach_pool_metadata_lv(struct lv_segment *pool_seg,
struct logical_volume *metadata_lv)
@@ -230,6 +232,120 @@ struct lv_segment *find_pool_seg(const struct lv_segment *seg)
return pool_seg;
}
+/* Greatest common divisor */
+static unsigned long _gcd(unsigned long n1, unsigned long n2)
+{
+ unsigned long remainder;
+
+ do {
+ remainder = n1 % n2;
+ n1 = n2;
+ n2 = remainder;
+ } while (n2);
+
+ return n1;
+}
+
+/* Least common multiple */
+static unsigned long _lcm(unsigned long n1, unsigned long n2)
+{
+ if (!n1 || !n2)
+ return 0;
+ return (n1 * n2) / _gcd(n1, n2);
+}
+
+int recalculate_pool_chunk_size_with_dev_hints(struct logical_volume *pool_lv,
+ int passed_args,
+ int chunk_size_calc_policy)
+{
+ struct logical_volume *pool_data_lv;
+ struct lv_segment *seg;
+ struct physical_volume *pv;
+ struct cmd_context *cmd = pool_lv->vg->cmd;
+ unsigned long previous_hint = 0, hint = 0;
+ uint32_t default_chunk_size;
+ uint32_t min_chunk_size, max_chunk_size;
+
+ if (passed_args & PASS_ARG_CHUNK_SIZE)
+ return 1;
+
+ if (lv_is_thin_pool(pool_lv)) {
+ if (find_config_tree_int(cmd, allocation_thin_pool_chunk_size_CFG, NULL))
+ return 1;
+ min_chunk_size = DM_THIN_MIN_DATA_BLOCK_SIZE;
+ max_chunk_size = DM_THIN_MAX_DATA_BLOCK_SIZE;
+ default_chunk_size = get_default_allocation_thin_pool_chunk_size_CFG(cmd, NULL);
+ } else if (lv_is_cache_pool(pool_lv)) {
+ if (find_config_tree_int(cmd, allocation_cache_pool_chunk_size_CFG, NULL))
+ return 1;
+ min_chunk_size = DM_CACHE_MIN_DATA_BLOCK_SIZE;
+ max_chunk_size = DM_CACHE_MAX_DATA_BLOCK_SIZE;
+ default_chunk_size = get_default_allocation_cache_pool_chunk_size_CFG(cmd, NULL);
+ } else {
+ log_error(INTERNAL_ERROR "%s is not a pool logical volume.", display_lvname(pool_lv));
+ return 0;
+ }
+
+ pool_data_lv = seg_lv(first_seg(pool_lv), 0);
+ dm_list_iterate_items(seg, &pool_data_lv->segments) {
+ pv = seg_pv(seg, 0);
+ if (chunk_size_calc_policy == THIN_CHUNK_SIZE_CALC_METHOD_PERFORMANCE)
+ hint = dev_optimal_io_size(cmd->dev_types, pv_dev(pv));
+ else
+ hint = dev_minimum_io_size(cmd->dev_types, pv_dev(pv));
+ if (!hint)
+ continue;
+ if (previous_hint)
+ hint = _lcm(previous_hint, hint);
+ previous_hint = hint;
+ }
+
+ if (!hint)
+ log_debug_alloc("No usable device hint found while recalculating "
+ "pool chunk size for %s.", display_lvname(pool_lv));
+ else if ((hint < min_chunk_size) || (hint > max_chunk_size))
+ log_debug_alloc("Calculated chunk size %s for pool %s "
+ "is out of allowed range (%s-%s).",
+ display_size(cmd, hint), display_lvname(pool_lv),
+ display_size(cmd, min_chunk_size),
+ display_size(cmd, max_chunk_size));
+ else
+ first_seg(pool_lv)->chunk_size =
+ (hint >= default_chunk_size) ? hint : default_chunk_size;
+
+ return 1;
+}
+
+int update_pool_params(const struct segment_type *segtype,
+ struct volume_group *vg, unsigned target_attr,
+ int passed_args, uint32_t data_extents,
+ uint64_t *pool_metadata_size,
+ int *chunk_size_calc_policy, uint32_t *chunk_size,
+ thin_discards_t *discards, int *zero)
+{
+ if (segtype_is_cache_pool(segtype) || segtype_is_cache(segtype)) {
+ if (!update_cache_pool_params(vg, target_attr, passed_args,
+ data_extents, pool_metadata_size,
+ chunk_size_calc_policy, chunk_size))
+ return_0;
+ } else if (!update_thin_pool_params(vg, target_attr, passed_args,
+ data_extents, pool_metadata_size,
+ chunk_size_calc_policy, chunk_size,
+ discards, zero)) /* thin-pool */
+ return_0;
+
+ if ((uint64_t) *chunk_size > (uint64_t) data_extents * vg->extent_size) {
+ log_error("Chunk size %s is bigger then pool data size.",
+ display_size(vg->cmd, *chunk_size));
+ return 0;
+ }
+
+ log_verbose("Using pool metadata size %s.",
+ display_size(vg->cmd, *pool_metadata_size));
+
+ return 1;
+}
+
int create_pool(struct logical_volume *pool_lv,
const struct segment_type *segtype,
struct alloc_handle *ah, uint32_t stripes, uint32_t stripe_size)
diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c
index 28b6bbf..07246f7 100644
--- a/lib/metadata/thin_manip.c
+++ b/lib/metadata/thin_manip.c
@@ -348,11 +348,16 @@ int update_pool_lv(struct logical_volume *lv, int activate)
return 1;
}
-int update_profilable_pool_params(struct cmd_context *cmd, struct profile *profile,
- int passed_args, int *chunk_size_calc_method,
- uint32_t *chunk_size, thin_discards_t *discards,
- int *zero)
+int update_thin_pool_params(struct volume_group *vg,
+ unsigned attr, int passed_args, uint32_t data_extents,
+ uint64_t *pool_metadata_size,
+ int *chunk_size_calc_method, uint32_t *chunk_size,
+ thin_discards_t *discards, int *zero)
{
+ struct cmd_context *cmd = vg->cmd;
+ struct profile *profile = vg->profile;
+ uint32_t extent_size = vg->extent_size;
+ size_t estimate_chunk_size;
const char *str;
if (!(passed_args & PASS_ARG_CHUNK_SIZE)) {
@@ -369,7 +374,8 @@ int update_profilable_pool_params(struct cmd_context *cmd, struct profile *profi
log_error("Thin pool chunk size calculation policy \"%s\" is unrecognised.", str);
return 0;
}
- *chunk_size = get_default_allocation_thin_pool_chunk_size_CFG(cmd, profile) * 2;
+ if (!(*chunk_size = get_default_allocation_thin_pool_chunk_size_CFG(cmd, profile)))
+ return_0;
}
}
@@ -393,24 +399,6 @@ int update_profilable_pool_params(struct cmd_context *cmd, struct profile *profi
if (!(passed_args & PASS_ARG_ZERO))
*zero = find_config_tree_bool(cmd, allocation_thin_pool_zero_CFG, profile);
- return 1;
-}
-
-int update_thin_pool_params(struct volume_group *vg, unsigned attr,
- int passed_args,
- uint32_t data_extents, uint32_t extent_size,
- int *chunk_size_calc_method, uint32_t *chunk_size,
- thin_discards_t *discards,
- uint64_t *pool_metadata_size, int *zero)
-{
- size_t estimate_chunk_size;
- struct cmd_context *cmd = vg->cmd;
-
- if (!update_profilable_pool_params(cmd, vg->profile, passed_args,
- chunk_size_calc_method, chunk_size,
- discards, zero))
- return_0;
-
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.");
@@ -435,11 +423,10 @@ int update_thin_pool_params(struct volume_group *vg, unsigned attr,
}
log_verbose("Setting chunk size to %s.",
display_size(cmd, *chunk_size));
- } else if (*pool_metadata_size > (2 * DEFAULT_THIN_POOL_MAX_METADATA_SIZE)) {
+ } else if (*pool_metadata_size > (DEFAULT_THIN_POOL_MAX_METADATA_SIZE * 2)) {
/* 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)));
+ (DEFAULT_THIN_POOL_MAX_METADATA_SIZE * 2 * (SECTOR_SIZE / UINT64_C(64)));
log_warn("WARNING: Chunk size is too small for pool, suggested minimum is %s.",
display_size(cmd, UINT64_C(1) << (ffs(estimate_chunk_size) + 1)));
}
@@ -448,19 +435,17 @@ int update_thin_pool_params(struct volume_group *vg, unsigned attr,
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 /
+ estimate_chunk_size = (uint64_t) data_extents * extent_size /
(*pool_metadata_size * (SECTOR_SIZE / UINT64_C(64)));
+ if (estimate_chunk_size < DM_THIN_MIN_DATA_BLOCK_SIZE)
+ estimate_chunk_size = DM_THIN_MIN_DATA_BLOCK_SIZE;
+ else if (estimate_chunk_size > DM_THIN_MAX_DATA_BLOCK_SIZE)
+ estimate_chunk_size = DM_THIN_MAX_DATA_BLOCK_SIZE;
+
/* Check to eventually use bigger chunk size */
if (!(passed_args & PASS_ARG_CHUNK_SIZE)) {
*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 %s.",
- display_size(cmd, *chunk_size));
+ log_verbose("Setting chunk size %s.", display_size(cmd, *chunk_size));
} else if (*chunk_size < estimate_chunk_size) {
/* Suggest bigger chunk size */
log_warn("WARNING: Chunk size is smaller then suggested minimum size %s.",
@@ -468,11 +453,6 @@ int update_thin_pool_params(struct volume_group *vg, unsigned attr,
}
}
- 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)) {
*pool_metadata_size = 2 * DEFAULT_THIN_POOL_MAX_METADATA_SIZE;
if (passed_args & PASS_ARG_POOL_METADATA_SIZE)
@@ -485,9 +465,6 @@ int update_thin_pool_params(struct volume_group *vg, unsigned attr,
display_size(cmd, *pool_metadata_size));
}
- log_verbose("Setting pool metadata size to %s.",
- display_size(cmd, *pool_metadata_size));
-
return 1;
}
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 61b1660..333459d 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -290,38 +290,24 @@ static int _read_pool_params(struct lvconvert_params *lp, struct cmd_context *cm
if (thinpool || cachepool) {
if (arg_from_list_is_set(cmd, "is invalid with pools",
merge_ARG, mirrors_ARG, repair_ARG, snapshot_ARG,
- splitmirrors_ARG, -1))
+ splitmirrors_ARG, splitsnapshot_ARG, -1))
return_0;
- 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.");
- return 0;
- }
- if (arg_count(cmd, poolmetadata_ARG)) {
- log_error("Please specify either metadata logical volume or its size.");
- return 0;
- }
- /* value is read in get_pool_params() */
- }
-
- if ((lp->pool_metadata_lv_name = arg_str_value(cmd, poolmetadata_ARG, NULL))) {
- 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 (!(lp->segtype = get_segtype_from_string(cmd, type_str)))
+ return_0;
- if (arg_count(cmd, readahead_ARG)) {
- log_error("Can't use --readahead with --poolmetadata.");
- return 0;
- }
- }
+ if (!get_pool_params(cmd, lp->segtype, &lp->passed_args,
+ &lp->pool_metadata_size,
+ &lp->poolmetadataspare,
+ &lp->chunk_size, &lp->discards,
+ &lp->zero))
+ return_0;
- if (arg_count(cmd, chunksize_ARG) &&
- (arg_sign_value(cmd, chunksize_ARG, SIGN_NONE) == SIGN_MINUS)) {
- log_error("Negative chunk size is invalid.");
- return 0;
- }
+ if ((lp->pool_metadata_lv_name = arg_str_value(cmd, poolmetadata_ARG, NULL)) &&
+ arg_from_list_is_set(cmd, "is invalid with --poolmetadata",
+ stripesize_ARG, stripes_long_ARG,
+ readahead_ARG, -1))
+ return_0;
if (!lp->pool_data_lv_name) {
if (!*pargc) {
@@ -334,12 +320,11 @@ static int _read_pool_params(struct lvconvert_params *lp, struct cmd_context *cm
if (!lp->thin && !lp->cache)
lp->lv_name_full = lp->pool_data_lv_name;
+
/* Hmm _read_activation_params */
lp->read_ahead = arg_uint_value(cmd, readahead_ARG,
cmd->default_settings.read_ahead);
- if (!(lp->segtype = get_segtype_from_string(cmd, type_str)))
- return_0;
} else if (arg_from_list_is_set(cmd, "is valid only with pools",
poolmetadatasize_ARG, poolmetadataspare_ARG,
-1))
@@ -638,9 +623,6 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
} /* else segtype will default to current type */
}
- /* TODO: default in lvm.conf ? */
- lp->poolmetadataspare = arg_int_value(cmd, poolmetadataspare_ARG,
- DEFAULT_POOL_METADATA_SPARE);
lp->force = arg_count(cmd, force_ARG);
lp->yes = arg_count(cmd, yes_ARG);
@@ -2663,26 +2645,16 @@ revert_new_lv:
static int _lvconvert_update_pool_params(struct logical_volume *pool_lv,
struct lvconvert_params *lp)
{
- if (seg_is_cache_pool(lp))
- return update_cache_pool_params(pool_lv->vg, lp->target_attr,
- lp->passed_args,
- pool_lv->le_count,
- pool_lv->vg->extent_size,
- &lp->thin_chunk_size_calc_policy,
- &lp->chunk_size,
- &lp->discards,
- &lp->pool_metadata_size,
- &lp->zero);
-
- return update_thin_pool_params(pool_lv->vg, lp->target_attr,
- lp->passed_args,
- pool_lv->le_count,
- pool_lv->vg->extent_size,
- &lp->thin_chunk_size_calc_policy,
- &lp->chunk_size,
- &lp->discards,
- &lp->pool_metadata_size,
- &lp->zero);
+ return update_pool_params(lp->segtype,
+ pool_lv->vg,
+ lp->target_attr,
+ lp->passed_args,
+ pool_lv->le_count,
+ &lp->pool_metadata_size,
+ &lp->thin_chunk_size_calc_policy,
+ &lp->chunk_size,
+ &lp->discards,
+ &lp->zero);
}
/*
@@ -3156,12 +3128,6 @@ static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
if (!_lvconvert_snapshot(cmd, lv, lp))
return_ECMD_FAILED;
} else if (segtype_is_pool(lp->segtype) || lp->thin || lp->cache) {
- if (!get_pool_params(cmd, lv_config_profile(lv),
- &lp->passed_args, &lp->thin_chunk_size_calc_policy,
- &lp->chunk_size, &lp->discards,
- &lp->pool_metadata_size, &lp->zero))
- return_ECMD_FAILED;
-
if (!_lvconvert_pool(cmd, lv, lp))
return_ECMD_FAILED;
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index e9a170c..541fd51 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -267,20 +267,11 @@ static int _determine_snapshot_type(struct volume_group *vg,
static int _lvcreate_update_pool_params(struct volume_group *vg,
struct lvcreate_params *lp)
{
- if (seg_is_cache_pool(lp))
- return update_cache_pool_params(vg, lp->target_attr,
- lp->passed_args,
- lp->extents, vg->extent_size,
- &lp->thin_chunk_size_calc_policy,
- &lp->chunk_size, &lp->discards,
- &lp->poolmetadatasize,
- &lp->zero);
-
- return update_thin_pool_params(vg, lp->target_attr, lp->passed_args,
- lp->extents, vg->extent_size,
- &lp->thin_chunk_size_calc_policy,
- &lp->chunk_size, &lp->discards,
- &lp->poolmetadatasize, &lp->zero);
+ return update_pool_params(lp->segtype, vg, lp->target_attr,
+ lp->passed_args, lp->extents,
+ &lp->poolmetadatasize,
+ &lp->thin_chunk_size_calc_policy, &lp->chunk_size,
+ &lp->discards, &lp->zero);
}
/*
@@ -320,9 +311,6 @@ static int _determine_cache_argument(struct volume_group *vg,
} else {
lp->pool = NULL;
lp->create_pool = 1;
- lp->poolmetadataspare = arg_int_value(vg->cmd,
- poolmetadataspare_ARG,
- DEFAULT_POOL_METADATA_SPARE);
}
return 1;
@@ -505,7 +493,7 @@ static int _read_size_params(struct lvcreate_params *lp,
lp->create_pool = 1;
if (!lp->create_pool && arg_count(cmd, poolmetadatasize_ARG)) {
- log_error("--poolmetadatasize may only be specified when allocating the thin pool.");
+ log_error("--poolmetadatasize may only be specified when allocating the pool.");
return 0;
}
@@ -705,14 +693,6 @@ static int _read_cache_pool_params(struct lvcreate_params *lp,
if (!segtype_is_cache_pool(lp->segtype))
return 1;
- 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,
- DEFAULT_CACHE_POOL_CHUNK_SIZE * 2);
-
if ((str_arg = arg_str_value(cmd, cachemode_ARG, NULL)) &&
!get_cache_mode(str_arg, &lp->feature_flags))
return_0;
@@ -884,6 +864,8 @@ static int _lvcreate_params(struct lvcreate_params *lp,
}
else if (arg_count(cmd, thin_ARG) || arg_count(cmd, thinpool_ARG))
segtype_str = "thin";
+ else if (arg_count(cmd, cache_ARG) || arg_count(cmd, cachepool_ARG))
+ segtype_str = "cache";
else
segtype_str = "striped";
@@ -907,12 +889,9 @@ static int _lvcreate_params(struct lvcreate_params *lp,
(!seg_is_thin(lp) && arg_count(cmd, virtualsize_ARG)))
lp->snapshot = 1;
- if (seg_is_cache_pool(lp))
- lp->create_pool = 1;
-
- if (seg_is_thin_pool(lp)) {
+ if (seg_is_pool(lp)) {
if (lp->snapshot) {
- log_error("Snapshots are incompatible with thin_pool segment_type.");
+ log_error("Snapshots are incompatible with pool segment_type.");
return 0;
}
lp->create_pool = 1;
@@ -1035,10 +1014,9 @@ static int _lvcreate_params(struct lvcreate_params *lp,
!_read_size_params(lp, lcp, cmd) ||
!get_stripe_params(cmd, &lp->stripes, &lp->stripe_size) ||
(lp->create_pool &&
- !get_pool_params(cmd, NULL, &lp->passed_args,
- &lp->thin_chunk_size_calc_policy,
- &lp->chunk_size, &lp->discards,
- &lp->poolmetadatasize, &lp->zero)) ||
+ !get_pool_params(cmd, lp->segtype, &lp->passed_args,
+ &lp->poolmetadatasize, &lp->poolmetadataspare,
+ &lp->chunk_size, &lp->discards, &lp->zero)) ||
!_read_mirror_params(lp, cmd) ||
!_read_raid_params(lp, cmd) ||
!_read_cache_pool_params(lp, cmd))
@@ -1061,12 +1039,9 @@ static int _lvcreate_params(struct lvcreate_params *lp,
return 0;
}
- if (lp->create_pool) {
- /* TODO: add lvm.conf default y|n */
- lp->poolmetadataspare = arg_int_value(cmd, poolmetadataspare_ARG,
- DEFAULT_POOL_METADATA_SPARE);
- } else if (arg_count(cmd, poolmetadataspare_ARG)) {
- log_error("--poolmetadataspare is only available with thin pool creation.");
+ if (!lp->create_pool &&
+ arg_count(cmd, poolmetadataspare_ARG)) {
+ log_error("--poolmetadataspare is only available with pool creation.");
return 0;
}
/*
diff --git a/tools/toollib.c b/tools/toollib.c
index 312a76d..d6ef845 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1650,59 +1650,68 @@ int get_activation_monitoring_mode(struct cmd_context *cmd,
return 1;
}
+/*
+ * Read pool options from cmdline
+ */
int get_pool_params(struct cmd_context *cmd,
- struct profile *profile,
+ const struct segment_type *segtype,
int *passed_args,
- int *chunk_size_calc_method,
+ uint64_t *pool_metadata_size,
+ int *pool_metadata_spare,
uint32_t *chunk_size,
thin_discards_t *discards,
- uint64_t *pool_metadata_size,
int *zero)
{
- int cache_pool = 0;
-
- if (!strcmp("cache-pool", arg_str_value(cmd, type_ARG, "")))
- cache_pool = 1;
-
*passed_args = 0;
- if (!cache_pool && arg_count(cmd, zero_ARG)) {
- *passed_args |= PASS_ARG_ZERO;
- *zero = strcmp(arg_str_value(cmd, zero_ARG, "y"), "n");
- log_very_verbose("Setting pool zeroing: %u", *zero);
- }
- if (!cache_pool && arg_count(cmd, discards_ARG)) {
- *passed_args |= PASS_ARG_DISCARDS;
- *discards = (thin_discards_t) arg_uint_value(cmd, discards_ARG, 0);
- log_very_verbose("Setting pool discards: %s",
- get_pool_discards_name(*discards));
+ if (segtype_is_thin_pool(segtype) || segtype_is_thin(segtype)) {
+ if (arg_count(cmd, zero_ARG)) {
+ *passed_args |= PASS_ARG_ZERO;
+ *zero = strcmp(arg_str_value(cmd, zero_ARG, "y"), "n");
+ log_very_verbose("Setting pool zeroing: %u", *zero);
+ }
+
+ if (arg_count(cmd, discards_ARG)) {
+ *passed_args |= PASS_ARG_DISCARDS;
+ *discards = (thin_discards_t) arg_uint_value(cmd, discards_ARG, 0);
+ log_very_verbose("Setting pool discards: %s",
+ get_pool_discards_name(*discards));
+ }
}
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;
+ }
+
*passed_args |= PASS_ARG_CHUNK_SIZE;
- *chunk_size = arg_uint_value(cmd, chunksize_ARG, cache_pool ?
- DM_CACHE_MIN_DATA_BLOCK_SIZE :
- DM_THIN_MIN_DATA_BLOCK_SIZE);
+ *chunk_size = arg_uint_value(cmd, chunksize_ARG, 0);
log_very_verbose("Setting pool chunk size: %s",
display_size(cmd, *chunk_size));
}
- if (cache_pool) {
- //FIXME: add cache_pool support to update_profilable_pool_params
- if (!(*passed_args & PASS_ARG_CHUNK_SIZE))
- *chunk_size = DEFAULT_CACHE_POOL_CHUNK_SIZE * 2;
- } else if (!update_profilable_pool_params(cmd, profile, *passed_args,
- chunk_size_calc_method,
- chunk_size, discards, zero))
- return_0;
-
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.");
+ return 0;
+ }
+
+ if (arg_count(cmd, poolmetadata_ARG)) {
+ log_error("Please specify either metadata logical volume or its size.");
+ return 0;
+ }
+
*passed_args |= PASS_ARG_POOL_METADATA_SIZE;
*pool_metadata_size = arg_uint64_value(cmd, poolmetadatasize_ARG,
UINT64_C(0));
} else if (arg_count(cmd, poolmetadata_ARG))
*passed_args |= PASS_ARG_POOL_METADATA_SIZE; /* fixed size */
+ /* TODO: default in lvm.conf ? */
+ *pool_metadata_spare = arg_int_value(cmd, poolmetadataspare_ARG,
+ DEFAULT_POOL_METADATA_SPARE);
+
return 1;
}
diff --git a/tools/toollib.h b/tools/toollib.h
index 54636ab..b51c637 100644
--- a/tools/toollib.h
+++ b/tools/toollib.h
@@ -125,12 +125,12 @@ int get_activation_monitoring_mode(struct cmd_context *cmd,
int *monitoring_mode);
int get_pool_params(struct cmd_context *cmd,
- struct profile *profile,
+ const struct segment_type *segtype,
int *passed_args,
- int *chunk_size_calc_method,
+ uint64_t *pool_metadata_size,
+ int *pool_metadataspare,
uint32_t *chunk_size,
thin_discards_t *discards,
- uint64_t *pool_metadata_size,
int *zero);
int get_stripe_params(struct cmd_context *cmd, uint32_t *stripes,
9 years, 9 months