import lvm2-2.03.11-5.el8

This commit is contained in:
CentOS Sources 2021-05-18 02:39:24 -04:00 committed by Andrew Lukoshko
parent 45bd5eb560
commit 03fc3e8e9e
45 changed files with 2524 additions and 17024 deletions

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/LVM2.2.03.09.tgz
SOURCES/LVM2.2.03.11.tgz

View File

@ -1 +1 @@
15a90d5039a2a1e9f67611a2a6c2faa72e8996aa SOURCES/LVM2.2.03.09.tgz
9484fd277914a85f330b4067aa222ee13f061189 SOURCES/LVM2.2.03.11.tgz

File diff suppressed because it is too large Load Diff

View File

@ -1,210 +0,0 @@
From f540a18fd7f5f65599a6c85c0bd3ba84e54f1cc8 Mon Sep 17 00:00:00 2001
From: Marian Csontos <mcsontos@redhat.com>
Date: Thu, 28 May 2020 18:02:16 +0200
Subject: [PATCH] Merge master up to commit be61bd6ff5c6
---
VERSION | 2 +-
VERSION_DM | 2 +-
test/shell/cache-single-usage.sh | 13 +++++++++++++
test/shell/integrity-dmeventd.sh | 8 ++++++++
test/shell/integrity-large.sh | 8 ++++++++
test/shell/integrity-misc.sh | 8 ++++++++
test/shell/integrity.sh | 8 ++++++++
test/shell/thin-foreign-repair.sh | 14 ++++++++++----
tools/lvconvert.c | 15 +++++++++++++++
9 files changed, 72 insertions(+), 6 deletions(-)
diff --git a/VERSION b/VERSION
index 00618e0..9ad7a70 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.03.09(2)-RHEL8 (2020-04-21)
+2.03.09(2)-RHEL8 (2020-05-28)
diff --git a/VERSION_DM b/VERSION_DM
index b9ec43e..bcd97de 100644
--- a/VERSION_DM
+++ b/VERSION_DM
@@ -1 +1 @@
-1.02.171-RHEL8 (2020-04-21)
+1.02.171-RHEL8 (2020-05-28)
diff --git a/test/shell/cache-single-usage.sh b/test/shell/cache-single-usage.sh
index a885bf7..8936aa3 100644
--- a/test/shell/cache-single-usage.sh
+++ b/test/shell/cache-single-usage.sh
@@ -127,4 +127,17 @@ umount "$mount_dir"
lvchange -an $vg/$lv1
lvchange -an $vg/$lv2
+# misc tests
+
+lvremove $vg
+
+lvcreate -n $lv1 -l 2 -an $vg "$dev1"
+lvcreate -n $lv2 -l 2 -an $vg "$dev1"
+lvcreate -n $lv3 -l 2 -an $vg "$dev2"
+
+lvconvert -y --type writecache --cachevol $lv3 $vg/$lv1
+not lvconvert -y --type writecache --cachevol ${lv3}_cvol $vg/$lv2
+not lvconvert -y --type cache --cachevol ${lv3}_cvol $vg/$lv2
+not lvconvert -y --type cache --cachepool ${lv3}_cvol $vg/$lv2
+
vgremove -ff $vg
diff --git a/test/shell/integrity-dmeventd.sh b/test/shell/integrity-dmeventd.sh
index ed2436a..296f556 100644
--- a/test/shell/integrity-dmeventd.sh
+++ b/test/shell/integrity-dmeventd.sh
@@ -109,6 +109,14 @@ _wait_recalc() {
sleep 1
done
+ # TODO: There is some strange bug, first leg of RAID with integrity
+ # enabled never gets in sync. I saw this in BB, but not when executing
+ # the commands manually
+ if test -z "$sync"; then
+ echo "TEST WARNING: Resync of dm-integrity device '$checklv' failed"
+ dmsetup status "$DM_DEV_DIR/mapper/${checklv/\//-}"
+ exit
+ fi
echo "timeout waiting for recalc"
return 1
}
diff --git a/test/shell/integrity-large.sh b/test/shell/integrity-large.sh
index 7a333c1..5aba80e 100644
--- a/test/shell/integrity-large.sh
+++ b/test/shell/integrity-large.sh
@@ -95,6 +95,14 @@ _wait_recalc() {
sleep 1
done
+ # TODO: There is some strange bug, first leg of RAID with integrity
+ # enabled never gets in sync. I saw this in BB, but not when executing
+ # the commands manually
+ if test -z "$sync"; then
+ echo "TEST WARNING: Resync of dm-integrity device '$checklv' failed"
+ dmsetup status "$DM_DEV_DIR/mapper/${checklv/\//-}"
+ exit
+ fi
echo "timeout waiting for recalc"
return 1
}
diff --git a/test/shell/integrity-misc.sh b/test/shell/integrity-misc.sh
index a176f18..0d05689 100644
--- a/test/shell/integrity-misc.sh
+++ b/test/shell/integrity-misc.sh
@@ -109,6 +109,14 @@ _wait_recalc() {
sleep 1
done
+ # TODO: There is some strange bug, first leg of RAID with integrity
+ # enabled never gets in sync. I saw this in BB, but not when executing
+ # the commands manually
+ if test -z "$sync"; then
+ echo "TEST WARNING: Resync of dm-integrity device '$checklv' failed"
+ dmsetup status "$DM_DEV_DIR/mapper/${checklv/\//-}"
+ exit
+ fi
echo "timeout waiting for recalc"
return 1
}
diff --git a/test/shell/integrity.sh b/test/shell/integrity.sh
index 6baccf0..77e9430 100644
--- a/test/shell/integrity.sh
+++ b/test/shell/integrity.sh
@@ -204,6 +204,14 @@ _wait_recalc() {
sleep 1
done
+ # TODO: There is some strange bug, first leg of RAID with integrity
+ # enabled never gets in sync. I saw this in BB, but not when executing
+ # the commands manually
+ if test -z "$sync"; then
+ echo "TEST WARNING: Resync of dm-integrity device '$checklv' failed"
+ dmsetup status "$DM_DEV_DIR/mapper/${checklv/\//-}"
+ exit
+ fi
echo "timeout waiting for recalc"
return 1
}
diff --git a/test/shell/thin-foreign-repair.sh b/test/shell/thin-foreign-repair.sh
index 8b4018e..55e9f62 100644
--- a/test/shell/thin-foreign-repair.sh
+++ b/test/shell/thin-foreign-repair.sh
@@ -17,9 +17,15 @@ SKIP_WITH_LVMPOLLD=1
. lib/inittest
+clean_thin_()
+{
+ aux udev_wait
+ dmsetup remove "$THIN" || { sleep .5 ; dmsetup remove "$THIN" ; }
+}
+
cleanup_mounted_and_teardown()
{
- dmsetup remove $THIN || true
+ clean_thin_ || true
vgremove -ff $vg
aux teardown
}
@@ -56,9 +62,7 @@ dmsetup create "$THIN" --table "0 40960 thin $DM_DEV_DIR/mapper/$POOL 0"
mkfs.ext4 "$DM_DEV_DIR/mapper/$THIN"
-aux udev_wait
-
-dmsetup remove "$THIN" || { sleep .5 ; dmsetup remove "$THIN" }
+clean_thin_
lvchange -an $vg/pool
@@ -72,3 +76,5 @@ lvchange -ay $vg/pool
dmsetup create "$THIN" --table "0 40960 thin $DM_DEV_DIR/mapper/$POOL 0"
fsck -n "$DM_DEV_DIR/mapper/$THIN"
+
+# exit calls cleanup_mounted_and_teardown
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index cf93538..8652252 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -4264,6 +4264,11 @@ static int _lvconvert_cachevol_attach_single(struct cmd_context *cmd,
goto out;
}
+ if (lv_is_cache_vol(cachevol_lv)) {
+ log_error("LV %s is already used as a cachevol.", display_lvname(cachevol_lv));
+ goto out;
+ }
+
/* Ensure the LV is not active elsewhere. */
if (!lockd_lv(cmd, lv, "ex", 0))
goto_out;
@@ -4347,6 +4352,11 @@ static int _lvconvert_cachepool_attach_single(struct cmd_context *cmd,
goto out;
}
+ if (lv_is_cache_vol(cachepool_lv)) {
+ log_error("LV %s is already used as a cachevol.", display_lvname(cachepool_lv));
+ goto out;
+ }
+
if (cachepool_lv == lv) {
log_error("Use a different LV for cache pool LV and cache LV %s.",
display_lvname(cachepool_lv));
@@ -5629,6 +5639,11 @@ static int _lvconvert_writecache_attach_single(struct cmd_context *cmd,
goto bad;
}
+ if (lv_is_cache_vol(lv_fast)) {
+ log_error("LV %s is already used as a cachevol.", display_lvname(lv_fast));
+ goto bad;
+ }
+
/*
* To permit this we need to check the block size of the fs using lv
* (recently in libblkid) so that we can use a matching writecache
--
1.8.3.1

File diff suppressed because it is too large Load Diff

View File

@ -1,422 +0,0 @@
From 99b646d87469b5ca0e93fad6b77f51a00fbbd2b7 Mon Sep 17 00:00:00 2001
From: Marian Csontos <mcsontos@redhat.com>
Date: Wed, 12 Aug 2020 18:47:15 +0200
Subject: [PATCH] Revert "debug: missing stacktrace"
This reverts commit d0faad0db38fe733cae42d7df136d7ed4f7bcba6.
Revert "raid: no wiping when zeroing raid metadata device"
This reverts commit 9b9bf8786fb423a4430cc676301edadf2310098d.
Revert "lvconvert: more support for yes conversion"
This reverts commit b7f3667ce20b731bbda9b1d61df49abbcd1bd20e.
Revert "wipe_lv: always zero at least 4K"
This reverts commit fe78cd4082cb9af10580180d61898fcef93dc624.
Revert "tests: check pool metadata are zeroed"
This reverts commit 3f32f9811e01c8953d201c7c9b563561ad856130.
Revert "tests: failure of zeroing fails command"
This reverts commit 094d6f80ddb6d8a1c64977dfaae4073827063fe3.
Revert "make: make generate"
This reverts commit 88b92d4225b90db82047f3bac55d8059918e9c1b.
Conflicts:
man/lvconvert.8_pregen
Revert "pool: zero metadata"
This reverts commit bc39d5bec6fea787a8d8d16fa484084b7d2a7c29.
Conflicts:
WHATS_NEW
Revert "wipe_lv: make error a fatal event"
This reverts commit edbc5a62b26806e5c4de59b5292609e955303576.
Conflicts:
WHATS_NEW
build: make generate
---
WHATS_NEW | 2 -
conf/example.conf.in | 6 +--
lib/config/config_settings.h | 5 +--
lib/config/defaults.h | 1 -
lib/metadata/lv_manip.c | 78 ++++++++++++---------------------
lib/metadata/metadata-exported.h | 2 -
lib/metadata/pool_manip.c | 6 +--
test/lib/aux.sh | 1 -
test/shell/lvcreate-signature-wiping.sh | 7 ---
test/shell/lvcreate-thin.sh | 21 ---------
tools/lvconvert.c | 12 ++---
11 files changed, 36 insertions(+), 105 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index ac99e97..6a098b5 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -6,8 +6,6 @@ Version 2.03.10 -
warning.
Fix conversion to raid from striped lagging type.
Fix conversion to 'mirrored' mirror log with larger regionsize.
- Zero pool metadata on allocation (disable with allocation/zero_metadata=0).
- Failure in zeroing or wiping will fail command (bypass with -Zn, -Wn).
Fix running out of free buffers for async writing for larger writes.
Add integrity with raid capability.
Fix support for lvconvert --repair used by foreign apps (i.e. Docker).
diff --git a/conf/example.conf.in b/conf/example.conf.in
index d5807e6..88858fc 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -489,7 +489,7 @@ allocation {
# This configuration option does not have a default value defined.
# Configuration option allocation/thin_pool_metadata_require_separate_pvs.
- # Thin pool metadata and data will always use different PVs.
+ # Thin pool metdata and data will always use different PVs.
thin_pool_metadata_require_separate_pvs = 0
# Configuration option allocation/thin_pool_zero.
@@ -527,10 +527,6 @@ allocation {
# This configuration option has an automatic default value.
# thin_pool_chunk_size_policy = "generic"
- # Configuration option allocation/zero_metadata.
- # Zero whole metadata area before use with thin or cache pool.
- zero_metadata = 1
-
# Configuration option allocation/thin_pool_chunk_size.
# The minimal chunk size in KiB for thin pool volumes.
# Larger chunk sizes may improve performance for plain thin volumes,
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index b38ca11..dce9705 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -626,7 +626,7 @@ cfg(allocation_cache_pool_max_chunks_CFG, "cache_pool_max_chunks", allocation_CF
"Using cache pool with more chunks may degrade cache performance.\n")
cfg(allocation_thin_pool_metadata_require_separate_pvs_CFG, "thin_pool_metadata_require_separate_pvs", allocation_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_THIN_POOL_METADATA_REQUIRE_SEPARATE_PVS, vsn(2, 2, 89), NULL, 0, NULL,
- "Thin pool metadata and data will always use different PVs.\n")
+ "Thin pool metdata and data will always use different PVs.\n")
cfg(allocation_thin_pool_zero_CFG, "thin_pool_zero", allocation_CFG_SECTION, CFG_PROFILABLE | CFG_PROFILABLE_METADATA | CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_THIN_POOL_ZERO, vsn(2, 2, 99), NULL, 0, NULL,
"Thin pool data chunks are zeroed before they are first used.\n"
@@ -657,9 +657,6 @@ cfg(allocation_thin_pool_chunk_size_policy_CFG, "thin_pool_chunk_size_policy", a
" 512KiB.\n"
"#\n")
-cfg(allocation_zero_metadata_CFG, "zero_metadata", allocation_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_ZERO_METADATA, vsn(2, 3, 10), NULL, 0, NULL,
- "Zero whole metadata area before use with thin or cache pool.\n")
-
cfg_runtime(allocation_thin_pool_chunk_size_CFG, "thin_pool_chunk_size", allocation_CFG_SECTION, CFG_PROFILABLE | CFG_PROFILABLE_METADATA | CFG_DEFAULT_UNDEFINED, CFG_TYPE_INT, vsn(2, 2, 99), 0, NULL,
"The minimal chunk size in KiB for thin pool volumes.\n"
"Larger chunk sizes may improve performance for plain thin volumes,\n"
diff --git a/lib/config/defaults.h b/lib/config/defaults.h
index 708a575..be4f5ff 100644
--- a/lib/config/defaults.h
+++ b/lib/config/defaults.h
@@ -129,7 +129,6 @@
#define DEFAULT_THIN_POOL_DISCARDS "passdown"
#define DEFAULT_THIN_POOL_ZERO 1
#define DEFAULT_POOL_METADATA_SPARE 1 /* thin + cache */
-#define DEFAULT_ZERO_METADATA 1 /* thin + cache */
#ifdef CACHE_CHECK_NEEDS_CHECK
# define DEFAULT_CACHE_CHECK_OPTION1 "-q"
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index f0ba3f0..1642b90 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -7576,22 +7576,20 @@ int wipe_lv(struct logical_volume *lv, struct wipe_params wp)
struct device *dev;
char name[PATH_MAX];
uint64_t zero_sectors;
- int zero_metadata = wp.is_metadata ?
- find_config_tree_bool(lv->vg->cmd, allocation_zero_metadata_CFG, NULL) : 0;
- if (!wp.do_zero && !wp.do_wipe_signatures && !wp.is_metadata)
+ if (!wp.do_zero && !wp.do_wipe_signatures)
/* nothing to do */
return 1;
if (!lv_is_active(lv)) {
- log_error("Volume %s is not active locally (volume_list activation filter?).",
- display_lvname(lv));
+ log_error("Volume \"%s/%s\" is not active locally (volume_list activation filter?).",
+ lv->vg->name, lv->name);
return 0;
}
/* Wait until devices are available */
if (!sync_local_dev_names(lv->vg->cmd)) {
- log_error("Failed to sync local devices before wiping volume %s.",
+ log_error("Failed to sync local devices before wiping LV %s.",
display_lvname(lv));
return 0;
}
@@ -7615,59 +7613,40 @@ int wipe_lv(struct logical_volume *lv, struct wipe_params wp)
}
if (!label_scan_open_rw(dev)) {
- log_error("Failed to open %s for wiping and zeroing.", display_lvname(lv));
- return 0;
+ log_error("Failed to open %s/%s for wiping and zeroing.", lv->vg->name, lv->name);
+ goto out;
}
if (wp.do_wipe_signatures) {
- log_verbose("Wiping known signatures on logical volume %s.",
- display_lvname(lv));
+ log_verbose("Wiping known signatures on logical volume \"%s/%s\"",
+ lv->vg->name, lv->name);
if (!wipe_known_signatures(lv->vg->cmd, dev, name, 0,
TYPE_DM_SNAPSHOT_COW,
- wp.yes, wp.force, NULL)) {
- log_error("Filed to wipe signatures of logical volume %s.",
- display_lvname(lv));
- return 0;
- }
+ wp.yes, wp.force, NULL))
+ stack;
}
- if (wp.do_zero || wp.is_metadata) {
- zero_metadata = !wp.is_metadata ? 0 :
- find_config_tree_bool(lv->vg->cmd, allocation_zero_metadata_CFG, NULL);
- if (zero_metadata) {
- log_debug("Metadata logical volume %s will be fully zeroed.",
- display_lvname(lv));
- zero_sectors = lv->size;
- } else {
- if (wp.is_metadata) /* Verbosely notify metadata will not be fully zeroed */
- log_verbose("Metadata logical volume %s not fully zeroed and may contain stale data.",
- display_lvname(lv));
- zero_sectors = UINT64_C(4096) >> SECTOR_SHIFT;
- if (wp.zero_sectors > zero_sectors)
- zero_sectors = wp.zero_sectors;
+ if (wp.do_zero) {
+ zero_sectors = wp.zero_sectors ? : UINT64_C(4096) >> SECTOR_SHIFT;
- if (zero_sectors > lv->size)
- zero_sectors = lv->size;
- }
+ if (zero_sectors > lv->size)
+ zero_sectors = lv->size;
- log_verbose("Initializing %s of logical volume %s with value %d.",
+ log_verbose("Initializing %s of logical volume \"%s/%s\" with value %d.",
display_size(lv->vg->cmd, zero_sectors),
- display_lvname(lv), wp.zero_value);
-
- if ((!wp.is_metadata &&
- wp.zero_value && !dev_set_bytes(dev, UINT64_C(0),
- (size_t) zero_sectors << SECTOR_SHIFT,
- (uint8_t)wp.zero_value)) ||
- !dev_write_zeros(dev, UINT64_C(0), (size_t) zero_sectors << SECTOR_SHIFT)) {
- log_error("Failed to initialize %s of logical volume %s with value %d.",
- display_size(lv->vg->cmd, zero_sectors),
- display_lvname(lv), wp.zero_value);
- return 0;
+ lv->vg->name, lv->name, wp.zero_value);
+
+ if (!wp.zero_value) {
+ if (!dev_write_zeros(dev, UINT64_C(0), (size_t) zero_sectors << SECTOR_SHIFT))
+ stack;
+ } else {
+ if (!dev_set_bytes(dev, UINT64_C(0), (size_t) zero_sectors << SECTOR_SHIFT, (uint8_t)wp.zero_value))
+ stack;
}
}
label_scan_invalidate(dev);
-
+out:
lv->status &= ~LV_NOSCAN;
return 1;
@@ -7731,10 +7710,12 @@ int activate_and_wipe_lvlist(struct dm_list *lv_list, int commit)
}
dm_list_iterate_items(lvl, lv_list) {
+ log_verbose("Wiping metadata area %s.", display_lvname(lvl->lv));
/* Wipe any know signatures */
- if (!wipe_lv(lvl->lv, (struct wipe_params) { .do_zero = 1 /* TODO: is_metadata = 1 */ })) {
+ if (!wipe_lv(lvl->lv, (struct wipe_params) { .do_wipe_signatures = 1, .do_zero = 1, .zero_sectors = 1 })) {
+ log_error("Failed to wipe %s.", display_lvname(lvl->lv));
r = 0;
- goto_out;
+ goto out;
}
}
out:
@@ -8479,8 +8460,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
.do_zero = lp->zero,
.do_wipe_signatures = lp->wipe_signatures,
.yes = lp->yes,
- .force = lp->force,
- .is_metadata = lp->is_metadata,
+ .force = lp->force
})) {
log_error("Aborting. Failed to wipe %s.", lp->snapshot
? "snapshot exception store" : "start of new LV");
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 06ea757..0cc5f37 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -803,7 +803,6 @@ struct wipe_params {
int do_wipe_signatures; /* should we wipe known signatures found on LV? */
int yes; /* answer yes automatically to all questions */
force_t force; /* force mode */
- int is_metadata; /* wipe volume is metadata LV */
};
/* Zero out LV and/or wipe signatures */
@@ -956,7 +955,6 @@ struct lvcreate_params {
unsigned suppress_zero_warn : 1;
unsigned needs_lockd_init : 1;
unsigned ignore_type : 1;
- unsigned is_metadata : 1; /* created LV will be used as metadata LV (and can be zeroed) */
const char *vg_name; /* only-used when VG is not yet opened (in /tools) */
const char *lv_name; /* all */
diff --git a/lib/metadata/pool_manip.c b/lib/metadata/pool_manip.c
index 23b5b63..bed51f1 100644
--- a/lib/metadata/pool_manip.c
+++ b/lib/metadata/pool_manip.c
@@ -545,8 +545,8 @@ int create_pool(struct logical_volume *pool_lv,
display_lvname(pool_lv));
goto bad;
}
- /* Clear pool metadata device. */
- if (!(r = wipe_lv(pool_lv, (struct wipe_params) { .is_metadata = 1 }))) {
+ /* Clear 4KB of pool metadata device. */
+ if (!(r = wipe_lv(pool_lv, (struct wipe_params) { .do_zero = 1 }))) {
log_error("Aborting. Failed to wipe pool metadata %s.",
display_lvname(pool_lv));
}
@@ -627,7 +627,6 @@ struct logical_volume *alloc_pool_metadata(struct logical_volume *pool_lv,
.tags = DM_LIST_HEAD_INIT(lvc.tags),
.temporary = 1,
.zero = 1,
- .is_metadata = 1,
};
if (!(lvc.segtype = get_segtype_from_string(pool_lv->vg->cmd, SEG_TYPE_NAME_STRIPED)))
@@ -664,7 +663,6 @@ static struct logical_volume *_alloc_pool_metadata_spare(struct volume_group *vg
.tags = DM_LIST_HEAD_INIT(lp.tags),
.temporary = 1,
.zero = 1,
- .is_metadata = 1,
};
if (!(lp.segtype = get_segtype_from_string(vg->cmd, SEG_TYPE_NAME_STRIPED)))
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 17e7935..e40da95 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -1234,7 +1234,6 @@ activation/verify_udev_operations = $LVM_VERIFY_UDEV
activation/raid_region_size = 512
allocation/wipe_signatures_when_zeroing_new_lvs = 0
allocation/vdo_slab_size_mb = 128
-allocation/zero_metadata = 0
backup/archive = 0
backup/backup = 0
devices/cache_dir = "$TESTDIR/etc"
diff --git a/test/shell/lvcreate-signature-wiping.sh b/test/shell/lvcreate-signature-wiping.sh
index 18d7a2f..73fea54 100644
--- a/test/shell/lvcreate-signature-wiping.sh
+++ b/test/shell/lvcreate-signature-wiping.sh
@@ -42,13 +42,6 @@ init_lv_
test_blkid_ || skip
lvremove -f $vg/$lv1
-# Zeroing stops the command when there is a failure (write error in this case)
-aux error_dev "$dev1" "$(get first_extent_sector "$dev1"):2"
-not lvcreate -l1 -n $lv1 $vg 2>&1 | tee out
-grep "Failed to initialize" out
-aux enable_dev "$dev1"
-
-
aux lvmconf "allocation/wipe_signatures_when_zeroing_new_lvs = 0"
lvcreate -y -Zn -l1 -n $lv1 $vg 2>&1 | tee out
diff --git a/test/shell/lvcreate-thin.sh b/test/shell/lvcreate-thin.sh
index c073eaf..9ca7f11 100644
--- a/test/shell/lvcreate-thin.sh
+++ b/test/shell/lvcreate-thin.sh
@@ -248,25 +248,4 @@ not lvcreate -s $vg/lv1 -L4M -V2G --name $vg/lv4
not lvcreate -T mirpool -L4M --alloc anywhere -m1 $vg
not lvcreate --thinpool mirpool -L4M --alloc anywhere -m1 $vg
-
-# Check pool metadata volume is zeroed, when zero_metadata is enabled.
-# 1st. ensure 8megs of both PVs will have some non-0 data
-lvcreate -L8m -n $lv1 $vg "$dev1"
-lvextend -L+8m $vg/$lv1 "$dev2"
-dd if=/dev/urandom of="$DM_DEV_DIR/$vg/$lv1" bs=1M count=16 oflag=direct conv=fdatasync
-lvremove -ff $vg/$lv1
-
-lvcreate -l1 --poolmetadatasize 4m --conf 'allocation/zero_metadata=1' -vvvv -T $vg/pool
-lvchange -an $vg
-# component activation to check device was zeroed
-lvchange -y -ay $vg/pool_tmeta
-dd if="$DM_DEV_DIR/$vg/pool_tmeta" of=file bs=1M count=3 skip=1 iflag=direct conv=fdatasync
-
-md5sum -b file | tee out
-# md5sum of 3M of zeros
-grep d1dd210d6b1312cb342b56d02bd5e651 out
-lvchange -an $vg
-lvremove -ff $vg
-
-
vgremove -ff $vg
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 524ed5a..6324ed7 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -3286,11 +3286,7 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
}
metadata_lv->status &= ~LV_ACTIVATION_SKIP;
- if (!wipe_lv(metadata_lv, (struct wipe_params) {
- .do_wipe_signatures = 1,
- .is_metadata = 1,
- .yes = arg_count(cmd, yes_ARG),
- .force = arg_count(cmd, force_ARG) } )) {
+ if (!wipe_lv(metadata_lv, (struct wipe_params) { .do_zero = 1 })) {
log_error("Aborting. Failed to wipe metadata lv.");
goto bad;
}
@@ -5527,8 +5523,7 @@ static int _writecache_zero(struct cmd_context *cmd, struct logical_volume *lv)
struct wipe_params wp = {
.do_wipe_signatures = 1, /* optional, to print warning if clobbering something */
.do_zero = 1, /* required for dm-writecache to work */
- .yes = arg_count(cmd, yes_ARG),
- .force = arg_count(cmd, force_ARG)
+ .zero_sectors = 1
};
int ret;
@@ -5545,8 +5540,7 @@ static int _writecache_zero(struct cmd_context *cmd, struct logical_volume *lv)
return 0;
}
- if (!(ret = wipe_lv(lv, wp)))
- stack;
+ ret = wipe_lv(lv, wp);
if (!deactivate_lv(cmd, lv)) {
log_error("Failed to deactivate LV %s for zeroing.", display_lvname(lv));
--
1.8.3.1

View File

@ -1,31 +0,0 @@
From 48105f492f7f8c157ba714217ae55c6fb50e76c0 Mon Sep 17 00:00:00 2001
From: Maxim Plotnikov <wgh@torlan.ru>
Date: Wed, 22 Apr 2020 00:16:29 +0300
Subject: [PATCH] Fix scripts/lvmlocks.service.in using nonexistent --lock-opt
autowait
The --lock-opt autowait was dropped back in 9ab6bdce01,
and attempting to specify it has quite an opposite effect:
no waiting is done, which makes the unit almost useless.
(cherry picked from commit a509776588a5c0c0bfc2394e4d1ed717531b0257)
---
scripts/lvmlocks.service.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/lvmlocks.service.in b/scripts/lvmlocks.service.in
index f6a951f..a3d0bd4 100644
--- a/scripts/lvmlocks.service.in
+++ b/scripts/lvmlocks.service.in
@@ -8,7 +8,7 @@ Type=oneshot
RemainAfterExit=yes
# start lockspaces and wait for them to finish starting
-ExecStart=@SBINDIR@/lvm vgchange --lock-start --lock-opt autowait
+ExecStart=@SBINDIR@/lvm vgchange --lock-start --lock-opt auto
# stop lockspaces and wait for them to finish stopping
ExecStop=@SBINDIR@/lvmlockctl --stop-lockspaces --wait 1
--
1.8.3.1

View File

@ -1,24 +0,0 @@
From a08afc8d0d18b2547176e731852b816df76c63eb Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Wed, 15 Apr 2020 11:04:12 -0500
Subject: [PATCH 3/3] WHATS_NEW: integrity with raid
(cherry picked from commit 211eaa284c4df992916e0a523d0ff932aa790a98)
---
WHATS_NEW | 1 +
1 file changed, 1 insertion(+)
diff --git a/WHATS_NEW b/WHATS_NEW
index 89583f7..c0267b7 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.10 -
=================================
+ Add integrity with raid capability.
Fix support for lvconvert --repair used by foreign apps (i.e. Docker).
Version 2.03.09 - 26th March 2020
--
1.8.3.1

View File

@ -1,15 +0,0 @@
WHATS_NEW | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/WHATS_NEW b/WHATS_NEW
index db914c0..89583f7 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,3 +1,7 @@
+Version 2.03.10 -
+=================================
+ Fix support for lvconvert --repair used by foreign apps (i.e. Docker).
+
Version 2.03.09 - 26th March 2020
=================================
Fix formating of vdopool (vdo_slab_size_mb was smaller by 2 bits).

View File

@ -1,179 +0,0 @@
WHATS_NEW_DM | 4 ++++
man/blkdeactivate.8_main | 11 +++++++++++
scripts/blkdeactivate.sh.in | 48 ++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 62 insertions(+), 1 deletion(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 12bdcea..3ec9c3c 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,3 +1,7 @@
+Version 1.02.173 -
+==================================
+ Add support for VDO in blkdeactivate script.
+
Version 1.02.171 - 26th March 2020
==================================
Fix dm_list interators with gcc 10 optimization (-ftree-pta).
diff --git a/man/blkdeactivate.8_main b/man/blkdeactivate.8_main
index f3c19a8..06af52e 100644
--- a/man/blkdeactivate.8_main
+++ b/man/blkdeactivate.8_main
@@ -9,6 +9,7 @@ blkdeactivate \(em utility to deactivate block devices
.RB [ -l \ \fIlvm_options\fP ]
.RB [ -m \ \fImpath_options\fP ]
.RB [ -r \ \fImdraid_options\fP ]
+.RB [ -o \ \fIvdo_options\fP ]
.RB [ -u ]
.RB [ -v ]
.RI [ device ]
@@ -70,6 +71,15 @@ Comma-separated list of MD RAID specific options:
Wait MD device's resync, recovery or reshape action to complete
before deactivation.
.RE
+
+.TP
+.BR -o ", " --vdooptions \ \fIvdo_options\fP
+Comma-separated list of VDO specific options:
+.RS
+.IP \fIconfigfile=file\fP
+Use specified VDO configuration file.
+.RE
+
.TP
.BR -u ", " --umount
Unmount a mounted device before trying to deactivate it.
@@ -120,4 +130,5 @@ of a device-mapper device fails, retry it and force removal.
.BR lvm (8),
.BR mdadm (8),
.BR multipathd (8),
+.BR vdo (8),
.BR umount (8)
diff --git a/scripts/blkdeactivate.sh.in b/scripts/blkdeactivate.sh.in
index a4b8a8f..57b3e58 100644
--- a/scripts/blkdeactivate.sh.in
+++ b/scripts/blkdeactivate.sh.in
@@ -1,6 +1,6 @@
#!/bin/bash
#
-# Copyright (C) 2012-2017 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2012-2020 Red Hat, Inc. All rights reserved.
#
# This file is part of LVM2.
#
@@ -38,6 +38,7 @@ MDADM="/sbin/mdadm"
MOUNTPOINT="/bin/mountpoint"
MPATHD="/sbin/multipathd"
UMOUNT="/bin/umount"
+VDO="/bin/vdo"
sbindir="@SBINDIR@"
DMSETUP="$sbindir/dmsetup"
@@ -54,6 +55,7 @@ DMSETUP_OPTS=""
LVM_OPTS=""
MDADM_OPTS=""
MPATHD_OPTS=""
+VDO_OPTS=""
LSBLK="/bin/lsblk -r --noheadings -o TYPE,KNAME,NAME,MOUNTPOINT"
LSBLK_VARS="local devtype local kname local name local mnt"
@@ -124,6 +126,7 @@ usage() {
echo " -l | --lvmoptions LVM_OPTIONS Comma separated LVM specific options"
echo " -m | --mpathoptions MPATH_OPTIONS Comma separated DM-multipath specific options"
echo " -r | --mdraidoptions MDRAID_OPTIONS Comma separated MD RAID specific options"
+ echo " -o | --vdooptions VDO_OPTIONS Comma separated VDO specific options"
echo " -u | --umount Unmount the device if mounted"
echo " -v | --verbose Verbose mode (also implies -e)"
echo
@@ -138,6 +141,8 @@ usage() {
echo " wait wait for resync, recovery or reshape to complete first"
echo " MPATH_OPTIONS:"
echo " disablequeueing disable queueing on all DM-multipath devices first"
+ echo " VDO_OPTIONS:"
+ echo " configfile=file use specified VDO configuration file"
exit
}
@@ -319,6 +324,23 @@ deactivate_md () {
fi
}
+deactivate_vdo() {
+ local xname
+ xname=$(printf "%s" "$name")
+ test -b "$DEV_DIR/mapper/$xname" || return 0
+ test -z "${SKIP_DEVICE_LIST["$kname"]}" || return 1
+
+ deactivate_holders "$DEV_DIR/mapper/$xname" || return 1
+
+ echo -n " [VDO]: deactivating VDO volume $xname... "
+ if eval "$VDO" stop $VDO_OPTS --name="$xname" "$OUT" "$ERR"; then
+ echo "done"
+ else
+ echo "skipping"
+ add_device_to_skip_list
+ fi
+}
+
deactivate () {
######################################################################
# DEACTIVATION HOOKS FOR NEW DEVICE TYPES GO HERE! #
@@ -335,6 +357,8 @@ deactivate () {
######################################################################
if test "$devtype" = "lvm"; then
deactivate_lvm
+ elif test "$devtype" = "vdo"; then
+ deactivate_vdo
elif test "${kname:0:3}" = "dm-"; then
deactivate_dm
elif test "${kname:0:2}" = "md"; then
@@ -479,6 +503,20 @@ get_mpathopts() {
IFS=$ORIG_IFS
}
+get_vdoopts() {
+ ORIG_IFS=$IFS; IFS=','
+
+ for opt in $1; do
+ case "$opt" in
+ "") ;;
+ configfile=*) tmp=${opt#*=}; VDO_OPTS+="--confFile=${tmp%%,*} " ;;
+ *) echo "$opt: unknown VDO option"
+ esac
+ done
+
+ IFS=$ORIG_IFS
+}
+
set_env() {
if test "$ERRORS" -eq "1"; then
unset ERR
@@ -493,6 +531,7 @@ set_env() {
LVM_OPTS+="-vvvv"
MDADM_OPTS+="-vv"
MPATHD_OPTS+="-v 3"
+ VDO_OPTS+="--verbose "
else
OUT="1>$DEV_DIR/null"
fi
@@ -509,6 +548,12 @@ set_env() {
MDADM_AVAILABLE=0
fi
+ if test -f $VDO; then
+ VDO_AVAILABLE=1
+ else
+ VDO_AVAILABLE=0
+ fi
+
MPATHD_RUNNING=0
test "$MPATHD_DO_DISABLEQUEUEING" -eq 1 && {
if test -f "$MPATHD"; then
@@ -528,6 +573,7 @@ while test $# -ne 0; do
"-l"|"--lvmoptions") get_lvmopts "$2" ; shift ;;
"-m"|"--mpathoptions") get_mpathopts "$2" ; shift ;;
"-r"|"--mdraidoptions") get_mdraidopts "$2"; shift ;;
+ "-o"|"--vdooptions") get_vdoopts "$2"; shift ;;
"-u"|"--umount") DO_UMOUNT=1 ;;
"-v"|"--verbose") VERBOSE=1 ; ERRORS=1 ;;
"-vv") VERBOSE=1 ; ERRORS=1 ; set -x ;;

View File

@ -1,180 +0,0 @@
From 7def94164ae6c18d84e40f00db2e2b74a7662b35 Mon Sep 17 00:00:00 2001
From: Marian Csontos <mcsontos@redhat.com>
Date: Tue, 5 May 2020 10:20:18 +0200
Subject: [PATCH] build: make generate
(cherry picked from commit bcc149048440dce5fc7962f88ed523469dd39a32)
---
man/lvconvert.8_pregen | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++
man/lvcreate.8_pregen | 53 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 116 insertions(+)
diff --git a/man/lvconvert.8_pregen b/man/lvconvert.8_pregen
index b676e72..7440984 100644
--- a/man/lvconvert.8_pregen
+++ b/man/lvconvert.8_pregen
@@ -163,6 +163,18 @@ lvconvert - Change logical volume layout
.ad b
.br
.ad l
+ \fB--raidintegrity\fP \fBy\fP|\fBn\fP
+.ad b
+.br
+.ad l
+ \fB--raidintegrityblocksize\fP \fINumber\fP
+.ad b
+.br
+.ad l
+ \fB--raidintegritymode\fP \fIString\fP
+.ad b
+.br
+.ad l
\fB-r\fP|\fB--readahead\fP \fBauto\fP|\fBnone\fP|\fINumber\fP
.ad b
.br
@@ -982,6 +994,28 @@ Poll LV to continue conversion.
.br
-
+Add or remove data integrity checksums to raid images.
+.br
+.P
+\fBlvconvert\fP \fB--raidintegrity\fP \fBy\fP|\fBn\fP \fILV\fP\fI_raid\fP
+.br
+.RS 4
+.ad l
+[ \fB--raidintegritymode\fP \fIString\fP ]
+.ad b
+.br
+.ad l
+[ \fB--raidintegrityblocksize\fP \fINumber\fP ]
+.ad b
+.br
+[ COMMON_OPTIONS ]
+.RE
+.br
+.RS 4
+[ \fIPV\fP ... ]
+.RE
+-
+
Common options for command:
.
.RS 4
@@ -1405,6 +1439,35 @@ Repeat once to also suppress any prompts with answer 'no'.
.ad b
.HP
.ad l
+\fB--raidintegrity\fP \fBy\fP|\fBn\fP
+.br
+Enable or disable data integrity checksums for raid images.
+.ad b
+.HP
+.ad l
+\fB--raidintegrityblocksize\fP \fINumber\fP
+.br
+The block size to use for dm-integrity on raid images.
+The integrity block size should usually match the device
+logical block size, or the file system block size.
+It may be less than the file system block size, but not
+less than the device logical block size.
+Possible values: 512, 1024, 2048, 4096.
+.ad b
+.HP
+.ad l
+\fB--raidintegritymode\fP \fIString\fP
+.br
+Use a journal (default) or bitmap for keeping integrity checksums consistent
+in case of a crash. The bitmap areas are recalculated after a crash, so corruption
+in those areas would not be detected. A journal does not have this problem.
+The journal mode doubles writes to storage, but can improve performance for
+scattered writes packed into a single journal write.
+bitmap mode can in theory achieve full write throughput of the device,
+but would not benefit from the potential scattered write optimization.
+.ad b
+.HP
+.ad l
\fB-r\fP|\fB--readahead\fP \fBauto\fP|\fBnone\fP|\fINumber\fP
.br
Sets read ahead sector count of an LV.
diff --git a/man/lvcreate.8_pregen b/man/lvcreate.8_pregen
index a80f9f5..be8e783 100644
--- a/man/lvcreate.8_pregen
+++ b/man/lvcreate.8_pregen
@@ -187,6 +187,18 @@ lvcreate - Create a logical volume
.ad b
.br
.ad l
+ \fB--raidintegrity\fP \fBy\fP|\fBn\fP
+.ad b
+.br
+.ad l
+ \fB--raidintegrityblocksize\fP \fINumber\fP
+.ad b
+.br
+.ad l
+ \fB--raidintegritymode\fP \fIString\fP
+.ad b
+.br
+.ad l
\fB-r\fP|\fB--readahead\fP \fBauto\fP|\fBnone\fP|\fINumber\fP
.ad b
.br
@@ -425,6 +437,18 @@ Create a raid LV (a specific raid level must be used, e.g. raid1).
[ \fB--[raid]maxrecoveryrate\fP \fISize\fP[k|UNIT] ]
.ad b
.br
+.ad l
+[ \fB--raidintegrity\fP \fBy\fP|\fBn\fP ]
+.ad b
+.br
+.ad l
+[ \fB--raidintegritymode\fP \fIString\fP ]
+.ad b
+.br
+.ad l
+[ \fB--raidintegrityblocksize\fP \fINumber\fP ]
+.ad b
+.br
[ COMMON_OPTIONS ]
.RE
.br
@@ -1420,6 +1444,35 @@ Repeat once to also suppress any prompts with answer 'no'.
.ad b
.HP
.ad l
+\fB--raidintegrity\fP \fBy\fP|\fBn\fP
+.br
+Enable or disable data integrity checksums for raid images.
+.ad b
+.HP
+.ad l
+\fB--raidintegrityblocksize\fP \fINumber\fP
+.br
+The block size to use for dm-integrity on raid images.
+The integrity block size should usually match the device
+logical block size, or the file system block size.
+It may be less than the file system block size, but not
+less than the device logical block size.
+Possible values: 512, 1024, 2048, 4096.
+.ad b
+.HP
+.ad l
+\fB--raidintegritymode\fP \fIString\fP
+.br
+Use a journal (default) or bitmap for keeping integrity checksums consistent
+in case of a crash. The bitmap areas are recalculated after a crash, so corruption
+in those areas would not be detected. A journal does not have this problem.
+The journal mode doubles writes to storage, but can improve performance for
+scattered writes packed into a single journal write.
+bitmap mode can in theory achieve full write throughput of the device,
+but would not benefit from the potential scattered write optimization.
+.ad b
+.HP
+.ad l
\fB-r\fP|\fB--readahead\fP \fBauto\fP|\fBnone\fP|\fINumber\fP
.br
Sets read ahead sector count of an LV.
--
1.8.3.1

View File

@ -1,17 +0,0 @@
tools/lvconvert.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index f6d9a29..bb40930 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -2388,7 +2388,8 @@ static int _lvconvert_thin_pool_repair(struct cmd_context *cmd,
goto deactivate_mlv;
}
- if (thin_dump[0]) {
+ /* Check matching transactionId when thin-pool is used by lvm2 (transactionId != 0) */
+ if (first_seg(pool_lv)->transaction_id && thin_dump[0]) {
argv[0] = thin_dump;
argv[1] = pms_path;
argv[2] = NULL;

View File

</
@ -1,641 +0,0 @@
From 945de675c47d891d1f181f15971d26ff959ac631 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Tue, 14 Jan 2020 14:12:20 -0600
Subject: [PATCH 1/3] move pv_list code into lib
(cherry picked from commit b6b4ad8e28eff7476cb04c4cb93312b06605b82f)
---
lib/Makefile.in | 1 +
lib/metadata/metadata-exported.h | 4 +
lib/metadata/pv_list.c | 291 +++++++++++++++++++++++++++++++++++++++
tools/toollib.c | 270 ------------------------------------
tools/toollib.h | 9 --
5 files changed, 296 insertions(+), 279 deletions(-)
create mode 100644 lib/metadata/pv_list.c
diff --git a/lib/Makefile.in b/lib/Makefile.in
index c037b41..2a064f3 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -74,6 +74,7 @@ SOURCES =\
metadata/mirror.c \
metadata/pool_manip.c \
metadata/pv.c \
+ metadata/pv_list.c \
metadata/pv_manip.c \
metadata/pv_map.c \
metadata/raid_manip.c \
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index c61c85c..35c1231 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -1385,4 +1385,8 @@ int vg_is_foreign(struct volume_group *vg);
void vg_write_commit_bad_mdas(struct cmd_context *cmd, struct volume_group *vg);
+struct dm_list *create_pv_list(struct dm_pool *mem, struct volume_group *vg, int argc,
+ char **argv, int allocatable_only);
+struct dm_list *clone_pv_list(struct dm_pool *mem, struct dm_list *pvsl);
+
#endif
diff --git a/lib/metadata/pv_list.c b/lib/metadata/pv_list.c
new file mode 100644
index 0000000..143b573
--- /dev/null
+++ b/lib/metadata/pv_list.c
@@ -0,0 +1,291 @@
+/*
+ * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
+ * Copyright (C) 2004-2017 Red Hat, Inc. All rights reserved.
+ *
+ * This file is part of LVM2.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License v.2.1.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "lib/misc/lib.h"
+#include "lib/misc/lvm-string.h"
+#include "lib/datastruct/str_list.h"
+#include "lib/device/device.h"
+#include "lib/metadata/metadata.h"
+
+/*
+ * Process physical extent range specifiers
+ */
+static int _add_pe_range(struct dm_pool *mem, const char *pvname,
+ struct dm_list *pe_ranges, uint32_t start, uint32_t count)
+{
+ struct pe_range *per;
+
+ log_debug("Adding PE range: start PE " FMTu32 " length " FMTu32 " on %s.",
+ start, count, pvname);
+
+ /* Ensure no overlap with existing areas */
+ dm_list_iterate_items(per, pe_ranges) {
+ if (((start < per->start) && (start + count - 1 >= per->start)) ||
+ ((start >= per->start) &&
+ (per->start + per->count - 1) >= start)) {
+ log_error("Overlapping PE ranges specified (" FMTu32
+ "-" FMTu32 ", " FMTu32 "-" FMTu32 ") on %s.",
+ start, start + count - 1, per->start,
+ per->start + per->count - 1, pvname);
+ return 0;
+ }
+ }
+
+ if (!(per = dm_pool_alloc(mem, sizeof(*per)))) {
+ log_error("Allocation of list failed.");
+ return 0;
+ }
+
+ per->start = start;
+ per->count = count;
+ dm_list_add(pe_ranges, &per->list);
+
+ return 1;
+}
+
+static int _xstrtouint32(const char *s, char **p, int base, uint32_t *result)
+{
+ unsigned long ul;
+
+ errno = 0;
+ ul = strtoul(s, p, base);
+
+ if (errno || *p == s || ul > UINT32_MAX)
+ return 0;
+
+ *result = ul;
+
+ return 1;
+}
+
+static int _parse_pes(struct dm_pool *mem, char *c, struct dm_list *pe_ranges,
+ const char *pvname, uint32_t size)
+{
+ char *endptr;
+ uint32_t start, end, len;
+
+ /* Default to whole PV */
+ if (!c) {
+ if (!_add_pe_range(mem, pvname, pe_ranges, UINT32_C(0), size))
+ return_0;
+ return 1;
+ }
+
+ while (*c) {
+ if (*c != ':')
+ goto error;
+
+ c++;
+
+ /* Disallow :: and :\0 */
+ if (*c == ':' || !*c)
+ goto error;
+
+ /* Default to whole range */
+ start = UINT32_C(0);
+ end = size - 1;
+
+ /* Start extent given? */
+ if (isdigit(*c)) {
+ if (!_xstrtouint32(c, &endptr, 10, &start))
+ goto error;
+ c = endptr;
+ /* Just one number given? */
+ if (!*c || *c == ':')
+ end = start;
+ }
+ /* Range? */
+ if (*c == '-') {
+ c++;
+ if (isdigit(*c)) {
+ if (!_xstrtouint32(c, &endptr, 10, &end))
+ goto error;
+ c = endptr;
+ }
+ } else if (*c == '+') { /* Length? */
+ c++;
+ if (isdigit(*c)) {
+ if (!_xstrtouint32(c, &endptr, 10, &len))
+ goto error;
+ c = endptr;
+ end = start + (len ? (len - 1) : 0);
+ }
+ }
+
+ if (*c && *c != ':')
+ goto error;
+
+ if ((start > end) || (end > size - 1)) {
+ log_error("PE range error: start extent %" PRIu32 " to "
+ "end extent %" PRIu32 ".", start, end);
+ return 0;
+ }
+
+ if (!_add_pe_range(mem, pvname, pe_ranges, start, end - start + 1))
+ return_0;
+
+ }
+
+ return 1;
+
+ error:
+ log_error("Physical extent parsing error at %s.", c);
+ return 0;
+}
+
+static int _create_pv_entry(struct dm_pool *mem, struct pv_list *pvl,
+ char *colon, int allocatable_only, struct dm_list *r)
+{
+ const char *pvname;
+ struct pv_list *new_pvl = NULL, *pvl2;
+ struct dm_list *pe_ranges;
+
+ pvname = pv_dev_name(pvl->pv);
+ if (allocatable_only && !(pvl->pv->status & ALLOCATABLE_PV)) {
+ log_warn("WARNING: Physical volume %s not allocatable.", pvname);
+ return 1;
+ }
+
+ if (allocatable_only && is_missing_pv(pvl->pv)) {
+ log_warn("WARNING: Physical volume %s is missing.", pvname);
+ return 1;
+ }
+
+ if (allocatable_only &&
+ (pvl->pv->pe_count == pvl->pv->pe_alloc_count)) {
+ log_warn("WARNING: No free extents on physical volume \"%s\".", pvname);
+ return 1;
+ }
+
+ dm_list_iterate_items(pvl2, r)
+ if (pvl->pv->dev == pvl2->pv->dev) {
+ new_pvl = pvl2;
+ break;
+ }
+
+ if (!new_pvl) {
+ if (!(new_pvl = dm_pool_alloc(mem, sizeof(*new_pvl)))) {
+ log_error("Unable to allocate physical volume list.");
+ return 0;
+ }
+
+ memcpy(new_pvl, pvl, sizeof(*new_pvl));
+
+ if (!(pe_ranges = dm_pool_alloc(mem, sizeof(*pe_ranges)))) {
+ log_error("Allocation of pe_ranges list failed.");
+ return 0;
+ }
+ dm_list_init(pe_ranges);
+ new_pvl->pe_ranges = pe_ranges;
+ dm_list_add(r, &new_pvl->list);
+ }
+
+ /* Determine selected physical extents */
+ if (!_parse_pes(mem, colon, new_pvl->pe_ranges, pv_dev_name(pvl->pv),
+ pvl->pv->pe_count))
+ return_0;
+
+ return 1;
+}
+
+struct dm_list *create_pv_list(struct dm_pool *mem, struct volume_group *vg, int argc,
+ char **argv, int allocatable_only)
+{
+ struct dm_list *r;
+ struct pv_list *pvl;
+ struct dm_list tagsl, arg_pvnames;
+ char *pvname = NULL;
+ char *colon, *at_sign, *tagname;
+ int i;
+
+ /* Build up list of PVs */
+ if (!(r = dm_pool_alloc(mem, sizeof(*r)))) {
+ log_error("Allocation of list failed.");
+ return NULL;
+ }
+ dm_list_init(r);
+
+ dm_list_init(&tagsl);
+ dm_list_init(&arg_pvnames);
+
+ for (i = 0; i < argc; i++) {
+ dm_unescape_colons_and_at_signs(argv[i], &colon, &at_sign);
+
+ if (at_sign && (at_sign == argv[i])) {
+ tagname = at_sign + 1;
+ if (!validate_tag(tagname)) {
+ log_error("Skipping invalid tag %s.", tagname);
+ continue;
+ }
+ dm_list_iterate_items(pvl, &vg->pvs) {
+ if (str_list_match_item(&pvl->pv->tags,
+ tagname)) {
+ if (!_create_pv_entry(mem, pvl, NULL,
+ allocatable_only,
+ r))
+ return_NULL;
+ }
+ }
+ continue;
+ }
+
+ pvname = argv[i];
+
+ if (colon && !(pvname = dm_pool_strndup(mem, pvname,
+ (unsigned) (colon - pvname)))) {
+ log_error("Failed to clone PV name.");
+ return NULL;
+ }
+
+ if (!(pvl = find_pv_in_vg(vg, pvname))) {
+ log_error("Physical Volume \"%s\" not found in "
+ "Volume Group \"%s\".", pvname, vg->name);
+ return NULL;
+ }
+ if (!_create_pv_entry(mem, pvl, colon, allocatable_only, r))
+ return_NULL;
+ }
+
+ if (dm_list_empty(r))
+ log_error("No specified PVs have space available.");
+
+ return dm_list_empty(r) ? NULL : r;
+}
+
+struct dm_list *clone_pv_list(struct dm_pool *mem, struct dm_list *pvsl)
+{
+ struct dm_list *r;
+ struct pv_list *pvl, *new_pvl;
+
+ /* Build up list of PVs */
+ if (!(r = dm_pool_alloc(mem, sizeof(*r)))) {
+ log_error("Allocation of list failed.");
+ return NULL;
+ }
+ dm_list_init(r);
+
+ dm_list_iterate_items(pvl, pvsl) {
+ if (!(new_pvl = dm_pool_zalloc(mem, sizeof(*new_pvl)))) {
+ log_error("Unable to allocate physical volume list.");
+ return NULL;
+ }
+
+ memcpy(new_pvl, pvl, sizeof(*new_pvl));
+ dm_list_add(r, &new_pvl->list);
+ }
+
+ return r;
+}
+
diff --git a/tools/toollib.c b/tools/toollib.c
index a5304bf..6386a69 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -457,276 +457,6 @@ const char *extract_vgname(struct cmd_context *cmd, const char *lv_name)
return vg_name;
}
-/*
- * Process physical extent range specifiers
- */
-static int _add_pe_range(struct dm_pool *mem, const char *pvname,
- struct dm_list *pe_ranges, uint32_t start, uint32_t count)
-{
- struct pe_range *per;
-
- log_debug("Adding PE range: start PE " FMTu32 " length " FMTu32 " on %s.",
- start, count, pvname);
-
- /* Ensure no overlap with existing areas */
- dm_list_iterate_items(per, pe_ranges) {
- if (((start < per->start) && (start + count - 1 >= per->start)) ||
- ((start >= per->start) &&
- (per->start + per->count - 1) >= start)) {
- log_error("Overlapping PE ranges specified (" FMTu32
- "-" FMTu32 ", " FMTu32 "-" FMTu32 ") on %s.",
- start, start + count - 1, per->start,
- per->start + per->count - 1, pvname);
- return 0;
- }
- }
-
- if (!(per = dm_pool_alloc(mem, sizeof(*per)))) {
- log_error("Allocation of list failed.");
- return 0;
- }
-
- per->start = start;
- per->count = count;
- dm_list_add(pe_ranges, &per->list);
-
- return 1;
-}
-
-static int _xstrtouint32(const char *s, char **p, int base, uint32_t *result)
-{
- unsigned long ul;
-
- errno = 0;
- ul = strtoul(s, p, base);
-
- if (errno || *p == s || ul > UINT32_MAX)
- return 0;
-
- *result = ul;
-
- return 1;
-}
-
-static int _parse_pes(struct dm_pool *mem, char *c, struct dm_list *pe_ranges,
- const char *pvname, uint32_t size)
-{
- char *endptr;
- uint32_t start, end, len;
-
- /* Default to whole PV */
- if (!c) {
- if (!_add_pe_range(mem, pvname, pe_ranges, UINT32_C(0), size))
- return_0;
- return 1;
- }
-
- while (*c) {
- if (*c != ':')
- goto error;
-
- c++;
-
- /* Disallow :: and :\0 */
- if (*c == ':' || !*c)
- goto error;
-
- /* Default to whole range */
- start = UINT32_C(0);
- end = size - 1;
-
- /* Start extent given? */
- if (isdigit(*c)) {
- if (!_xstrtouint32(c, &endptr, 10, &start))
- goto error;
- c = endptr;
- /* Just one number given? */
- if (!*c || *c == ':')
- end = start;
- }
- /* Range? */
- if (*c == '-') {
- c++;
- if (isdigit(*c)) {
- if (!_xstrtouint32(c, &endptr, 10, &end))
- goto error;
- c = endptr;
- }
- } else if (*c == '+') { /* Length? */
- c++;
- if (isdigit(*c)) {
- if (!_xstrtouint32(c, &endptr, 10, &len))
- goto error;
- c = endptr;
- end = start + (len ? (len - 1) : 0);
- }
- }
-
- if (*c && *c != ':')
- goto error;
-
- if ((start > end) || (end > size - 1)) {
- log_error("PE range error: start extent %" PRIu32 " to "
- "end extent %" PRIu32 ".", start, end);
- return 0;
- }
-
- if (!_add_pe_range(mem, pvname, pe_ranges, start, end - start + 1))
- return_0;
-
- }
-
- return 1;
-
- error:
- log_error("Physical extent parsing error at %s.", c);
- return 0;
-}
-
-static int _create_pv_entry(struct dm_pool *mem, struct pv_list *pvl,
- char *colon, int allocatable_only, struct dm_list *r)
-{
- const char *pvname;
- struct pv_list *new_pvl = NULL, *pvl2;
- struct dm_list *pe_ranges;
-
- pvname = pv_dev_name(pvl->pv);
- if (allocatable_only && !(pvl->pv->status & ALLOCATABLE_PV)) {
- log_warn("WARNING: Physical volume %s not allocatable.", pvname);
- return 1;
- }
-
- if (allocatable_only && is_missing_pv(pvl->pv)) {
- log_warn("WARNING: Physical volume %s is missing.", pvname);
- return 1;
- }
-
- if (allocatable_only &&
- (pvl->pv->pe_count == pvl->pv->pe_alloc_count)) {
- log_warn("WARNING: No free extents on physical volume \"%s\".", pvname);
- return 1;
- }
-
- dm_list_iterate_items(pvl2, r)
- if (pvl->pv->dev == pvl2->pv->dev) {
- new_pvl = pvl2;
- break;
- }
-
- if (!new_pvl) {
- if (!(new_pvl = dm_pool_alloc(mem, sizeof(*new_pvl)))) {
- log_error("Unable to allocate physical volume list.");
- return 0;
- }
-
- memcpy(new_pvl, pvl, sizeof(*new_pvl));
-
- if (!(pe_ranges = dm_pool_alloc(mem, sizeof(*pe_ranges)))) {
- log_error("Allocation of pe_ranges list failed.");
- return 0;
- }
- dm_list_init(pe_ranges);
- new_pvl->pe_ranges = pe_ranges;
- dm_list_add(r, &new_pvl->list);
- }
-
- /* Determine selected physical extents */
- if (!_parse_pes(mem, colon, new_pvl->pe_ranges, pv_dev_name(pvl->pv),
- pvl->pv->pe_count))
- return_0;
-
- return 1;
-}
-
-struct dm_list *create_pv_list(struct dm_pool *mem, struct volume_group *vg, int argc,
- char **argv, int allocatable_only)
-{
- struct dm_list *r;
- struct pv_list *pvl;
- struct dm_list tagsl, arg_pvnames;
- char *pvname = NULL;
- char *colon, *at_sign, *tagname;
- int i;
-
- /* Build up list of PVs */
- if (!(r = dm_pool_alloc(mem, sizeof(*r)))) {
- log_error("Allocation of list failed.");
- return NULL;
- }
- dm_list_init(r);
-
- dm_list_init(&tagsl);
- dm_list_init(&arg_pvnames);
-
- for (i = 0; i < argc; i++) {
- dm_unescape_colons_and_at_signs(argv[i], &colon, &at_sign);
-
- if (at_sign && (at_sign == argv[i])) {
- tagname = at_sign + 1;
- if (!validate_tag(tagname)) {
- log_error("Skipping invalid tag %s.", tagname);
- continue;
- }
- dm_list_iterate_items(pvl, &vg->pvs) {
- if (str_list_match_item(&pvl->pv->tags,
- tagname)) {
- if (!_create_pv_entry(mem, pvl, NULL,
- allocatable_only,
- r))
- return_NULL;
- }
- }
- continue;
- }
-
- pvname = argv[i];
-
- if (colon && !(pvname = dm_pool_strndup(mem, pvname,
- (unsigned) (colon - pvname)))) {
- log_error("Failed to clone PV name.");
- return NULL;
- }
-
- if (!(pvl = find_pv_in_vg(vg, pvname))) {
- log_error("Physical Volume \"%s\" not found in "
- "Volume Group \"%s\".", pvname, vg->name);
- return NULL;
- }
- if (!_create_pv_entry(mem, pvl, colon, allocatable_only, r))
- return_NULL;
- }
-
- if (dm_list_empty(r))
- log_error("No specified PVs have space available.");
-
- return dm_list_empty(r) ? NULL : r;
-}
-
-struct dm_list *clone_pv_list(struct dm_pool *mem, struct dm_list *pvsl)
-{
- struct dm_list *r;
- struct pv_list *pvl, *new_pvl;
-
- /* Build up list of PVs */
- if (!(r = dm_pool_alloc(mem, sizeof(*r)))) {
- log_error("Allocation of list failed.");
- return NULL;
- }
- dm_list_init(r);
-
- dm_list_iterate_items(pvl, pvsl) {
- if (!(new_pvl = dm_pool_zalloc(mem, sizeof(*new_pvl)))) {
- log_error("Unable to allocate physical volume list.");
- return NULL;
- }
-
- memcpy(new_pvl, pvl, sizeof(*new_pvl));
- dm_list_add(r, &new_pvl->list);
- }
-