import lvm2-2.03.14-1.el8

This commit is contained in:
CentOS Sources 2021-11-16 04:21:02 +00:00 committed by Stepan Oksanichenko
parent d0c184f9b5
commit 9f2ecbfba7
38 changed files with 31 additions and 4290 deletions

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/LVM2.2.03.12.tgz
SOURCES/LVM2.2.03.14.tgz

View File

@ -1 +1 @@
6d74d987b474dd0b45f239eb6dcc050622ad6962 SOURCES/LVM2.2.03.12.tgz
e5d4364e823d72b9a08b3aecc13cd677972830f0 SOURCES/LVM2.2.03.14.tgz

View File

@ -1,18 +0,0 @@
lib/device/device_id.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lib/device/device_id.c b/lib/device/device_id.c
index f158e4f..9cc82f1 100644
--- a/lib/device/device_id.c
+++ b/lib/device/device_id.c
@@ -308,6 +308,10 @@ const char *device_id_system_read(struct cmd_context *cmd, struct device *dev, u
if (!sysbuf[0])
_read_sys_block(cmd, dev, "wwid", sysbuf, sizeof(sysbuf));
+
+ /* scsi_debug wwid begins "t10.Linux scsi_debug ..." */
+ if (strstr(sysbuf, "scsi_debug"))
+ sysbuf[0] = '\0';
}
else if (idtype == DEV_ID_TYPE_SYS_SERIAL)

View File

@ -1,21 +0,0 @@
lib/device/device_id.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lib/device/device_id.c b/lib/device/device_id.c
index 67f72e5..1b98487 100644
--- a/lib/device/device_id.c
+++ b/lib/device/device_id.c
@@ -325,8 +325,12 @@ const char *device_id_system_read(struct cmd_context *cmd, struct device *dev, u
else if (idtype == DEV_ID_TYPE_MD_UUID)
_read_sys_block(cmd, dev, "md/uuid", sysbuf, sizeof(sysbuf));
- else if (idtype == DEV_ID_TYPE_LOOP_FILE)
+ else if (idtype == DEV_ID_TYPE_LOOP_FILE) {
_read_sys_block(cmd, dev, "loop/backing_file", sysbuf, sizeof(sysbuf));
+ /* if backing file is deleted, fall back to devname */
+ if (strstr(sysbuf, "(deleted)"))
+ sysbuf[0] = '\0';
+ }
else if (idtype == DEV_ID_TYPE_DEVNAME) {
if (!(idname = strdup(dev_name(dev))))

View File

@ -1,25 +0,0 @@
tools/command-lines.in | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/command-lines.in b/tools/command-lines.in
index 1107c1e..67c37ff 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -534,7 +534,7 @@ RULE: all and lv_is_visible
---
-lvconvert --type thin-pool LV_linear_striped_raid_cache_error_zero
+lvconvert --type thin-pool LV_linear_striped_raid_cache_writecache_error_zero
OO: --stripes_long Number, --stripesize SizeKB,
OO_LVCONVERT_THINPOOL, OO_LVCONVERT_POOL, OO_LVCONVERT
OP: PV ...
@@ -566,7 +566,7 @@ RULE: --poolmetadata not --readahead --stripesize --stripes_long
# This command syntax is deprecated, and the primary forms
# of creating a pool or swapping metadata should be used.
-lvconvert --thinpool LV_linear_striped_raid_cache_thinpool
+lvconvert --thinpool LV_linear_striped_raid_cache_writecache_thinpool
OO: --stripes_long Number, --stripesize SizeKB,
OO_LVCONVERT_THINPOOL, OO_LVCONVERT_POOL, OO_LVCONVERT
OP: PV ...

View File

@ -1,16 +0,0 @@
tools/lvconvert.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 8dd8a15..6066d1f 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -4803,7 +4803,7 @@ static int _lvconvert_to_pool_or_swap_metadata_single(struct cmd_context *cmd,
switch (cmd->command->command_enum) {
case lvconvert_to_thinpool_or_swap_metadata_CMD:
- if (lv_is_cache(lv))
+ if (lv_is_cache(lv) || lv_is_writecache(lv))
/* For cached LV check the cache origin LV type */
lvt_enum = get_lvt_enum(seg_lv(first_seg(lv), 0));
to_thinpool = 1;

View File

@ -1,17 +0,0 @@
lib/metadata/vdo_manip.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/metadata/vdo_manip.c b/lib/metadata/vdo_manip.c
index 7d5a2cb..afc513a 100644
--- a/lib/metadata/vdo_manip.c
+++ b/lib/metadata/vdo_manip.c
@@ -393,7 +393,8 @@ struct logical_volume *convert_vdo_pool_lv(struct logical_volume *data_lv,
} else {
log_verbose("Skiping VDO formating %s.", display_lvname(data_lv));
/* TODO: parse existing VDO data and retrieve vdo_logical_size */
- vdo_logical_size = data_lv->size;
+ if (!*virtual_extents)
+ vdo_logical_size = data_lv->size;
}
if (!deactivate_lv(data_lv->vg->cmd, data_lv)) {

View File

@ -1,211 +0,0 @@
lib/device/device_id.c | 32 ++++++++++++++----------
man/lvmdevices.8_des | 68 +++++++++++++++++++++++++++++++++++++++-----------
tools/args.h | 5 ++++
tools/command-lines.in | 1 +
tools/lvmdevices.c | 7 ++++--
5 files changed, 84 insertions(+), 29 deletions(-)
diff --git a/lib/device/device_id.c b/lib/device/device_id.c
index 1b98487..f158e4f 100644
--- a/lib/device/device_id.c
+++ b/lib/device/device_id.c
@@ -931,6 +931,7 @@ int device_id_add(struct cmd_context *cmd, struct device *dev, const char *pvid_
/*
* Choose the device_id type for the device being added.
*
+ * 0. use an idtype specified by the user
* 1. use an idtype specific to a special/virtual device type
* e.g. loop, mpath, crypt, lvmlv, md, etc.
* 2. use an idtype specified by user option.
@@ -939,6 +940,24 @@ int device_id_add(struct cmd_context *cmd, struct device *dev, const char *pvid_
* 5. use devname as the last resort.
*/
+ if (idtype_arg) {
+ if (!(idtype = idtype_from_str(idtype_arg)))
+ log_warn("WARNING: ignoring unknown device_id type %s.", idtype_arg);
+ else {
+ if (id_arg) {
+ if ((idname = strdup(id_arg)))
+ goto id_done;
+ log_warn("WARNING: ignoring device_id name %s.", id_arg);
+ }
+
+ if ((idname = device_id_system_read(cmd, dev, idtype)))
+ goto id_done;
+
+ log_warn("WARNING: ignoring deviceidtype %s which is not available for device.", idtype_arg);
+ idtype = 0;
+ }
+ }
+
if (MAJOR(dev->dev) == cmd->dev_types->device_mapper_major) {
if (_dev_has_mpath_uuid(cmd, dev, &idname)) {
idtype = DEV_ID_TYPE_MPATH_UUID;
@@ -972,19 +991,6 @@ int device_id_add(struct cmd_context *cmd, struct device *dev, const char *pvid_
log_warn("Missing support for DRBD idtype");
}
- if (idtype_arg) {
- if (!(idtype = idtype_from_str(idtype_arg)))
- log_warn("WARNING: ignoring unknown device_id type %s.", idtype_arg);
- else {
- if (id_arg) {
- if (!(idname = strdup(id_arg)))
- stack;
- goto id_done;
- }
- goto id_name;
- }
- }
-
/*
* No device-specific, existing, or user-specified idtypes,
* so use first available of sys_wwid / sys_serial / devname.
diff --git a/man/lvmdevices.8_des b/man/lvmdevices.8_des
index 015aa11..2335456 100644
--- a/man/lvmdevices.8_des
+++ b/man/lvmdevices.8_des
@@ -9,18 +9,18 @@ remove it from the devices file with lvmdevices --deldev. The
vgimportdevices(8) command adds all PVs from a VG to the devices file,
and updates the VG metadata to include device IDs of the PVs.
.P
-Commands adding new devices to the devices file necessarily look outside
-the existing devices file to find the devices to add. pvcreate, vgcreate,
-and vgextend also look outside the devices file to create new PVs and add
-them to the devices file.
+Commands that add new devices to the devices file necessarily look outside
+the existing devices file to find the devices being added. pvcreate,
+vgcreate, and vgextend also look outside the devices file to create new
+PVs and add those PVs to the devices file.
.P
LVM records devices in the devices file using hardware-specific IDs, such
as the WWID, and attempts to use subsystem-specific IDs for virtual device
-types (which also aim to be as unique and stable as possible.)
-These device IDs are also written in the VG metadata. When no hardware or
+types (which also aim to be as unique and stable as possible.) These
+device IDs are also written in the VG metadata. When no hardware or
virtual ID is available, lvm falls back using the unstable device name as
-the device ID. When devnames are used, lvm performs extra scanning to
-find devices if their devname changes, e.g. after reboot.
+the device ID. When devnames are used as IDs, lvm performs extra scanning
+to find devices if their devname changes, e.g. after reboot.
.P
When proper device IDs are used, an lvm command will not look at devices
outside the devices file, but when devnames are used as a fallback, lvm
@@ -34,12 +34,13 @@ overriding the devices file. The listed devices act as a sort of devices
file in terms of limiting which devices lvm will see and use. Devices
that are not listed will appear to be missing to the lvm command.
.P
-Multiple devices files can be kept in \fI#DEFAULT_SYS_DIR#/devices\fP, which allows lvm
-to be used with different sets of devices, e.g. system devices do not need
-to be exposed to a specific application, and the application can use lvm on
-its own devices that are not exposed to the system. The option
---devicesfile <filename> is used to select the devices file to use with the
-command. Without the option set, the default system devices file is used.
+Multiple devices files can be kept \fI#DEFAULT_SYS_DIR#/devices\fP, which
+allows lvm to be used with different sets of devices. For example, system
+devices do not need to be exposed to a specific application, and the
+application can use lvm on its own devices that are not exposed to the
+system. The option --devicesfile <filename> is used to select the devices
+file to use with the command. Without the option set, the default system
+devices file is used.
.P
Setting --devicesfile "" causes lvm to not use a devices file.
.P
@@ -59,3 +60,42 @@ if it does not yet exist.
.P
It is recommended to use lvm commands to make changes to the devices file to
ensure proper updates.
+.P
+The device ID and device ID type are included in the VG metadata and can
+be reported with pvs -o deviceid,deviceidtype. (Note that the lvmdevices
+command does not update VG metadata, but subsequent lvm commands modifying
+the metadata will include the device ID.)
+.P
+Possible device ID types are:
+.br
+.IP \[bu] 2
+.B sys_wwid
+uses the wwid reported by sysfs. This is the first choice for non-virtual
+devices.
+.IP \[bu] 2
+.B sys_serial
+uses the serial number reported by sysfs. This is the second choice for
+non-virtual devices.
+.IP \[bu] 2
+.B mpath_uuid
+is used for dm multipath devices, reported by sysfs.
+.IP \[bu] 2
+.B crypt_uuid
+is used for dm crypt devices, reported by sysfs.
+.IP \[bu] 2
+.B md_uuid
+is used for md devices, reported by sysfs.
+.B lvmlv_uuid
+is used if a PV is placed on top of an lvm LV, reported by sysfs.
+.IP \[bu] 2
+.B loop_file
+is used for loop devices, the backing file name repored by sysfs.
+.IP \[bu] 2
+.B devname
+the device name is used if no other type applies.
+.P
+
+The default choice for device ID type can be overriden using lvmdevices
+--addev --deviceidtype <type>. If the specified type is available for the
+device it will be used, otherwise the device will be added using the type
+that would otherwise be chosen.
diff --git a/tools/args.h b/tools/args.h
index 741c82b..d4f23f8 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -228,6 +228,11 @@ arg(detachprofile_ARG, '\0', "detachprofile", 0, 0, 0,
"Detaches a metadata profile from a VG or LV.\n"
"See \\fBlvm.conf\\fP(5) for more information about profiles.\n")
+arg(deviceidtype_ARG, '\0', "deviceidtype", string_VAL, 0, 0,
+ "The type of device ID to use for the device.\n"
+ "If the specified type is available for the device,\n"
+ "then it will override the default type that lvm would use.\n")
+
arg(devices_ARG, '\0', "devices", pv_VAL, ARG_GROUPABLE, 0,
"Devices that the command can use. This option can be repeated\n"
"or accepts a comma separated list of devices. This overrides\n"
diff --git a/tools/command-lines.in b/tools/command-lines.in
index 67c37ff..8607305 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -1430,6 +1430,7 @@ ID: lvmdevices_update
DESC: Update the devices file to fix incorrect values.
lvmdevices --adddev PV
+OO: --deviceidtype String
ID: lvmdevices_edit
DESC: Add a device to the devices file.
diff --git a/tools/lvmdevices.c b/tools/lvmdevices.c
index 6b3e056..3448bdd 100644
--- a/tools/lvmdevices.c
+++ b/tools/lvmdevices.c
@@ -265,6 +265,7 @@ int lvmdevices(struct cmd_context *cmd, int argc, char **argv)
if (arg_is_set(cmd, adddev_ARG)) {
const char *devname;
+ const char *deviceidtype;
if (!(devname = arg_str_value(cmd, adddev_ARG, NULL)))
goto_bad;
@@ -311,8 +312,10 @@ int lvmdevices(struct cmd_context *cmd, int argc, char **argv)
dev_name(dev), dev_filtered_reason(dev));
}
- /* allow deviceidtype_ARG/deviceid_ARG ? */
- if (!device_id_add(cmd, dev, dev->pvid, NULL, NULL))
+ /* also allow deviceid_ARG ? */
+ deviceidtype = arg_str_value(cmd, deviceidtype_ARG, NULL);
+
+ if (!device_id_add(cmd, dev, dev->pvid, deviceidtype, NULL))
goto_bad;
if (!device_ids_write(cmd))
goto_bad;

View File

@ -1,150 +0,0 @@
lib/metadata/lv_manip.c | 19 +++++++++
lib/metadata/metadata-exported.h | 2 +
lib/metadata/thin_manip.c | 12 ++++++
test/shell/lvremove-thindata-caches.sh | 71 ++++++++++++++++++++++++++++++++++
4 files changed, 104 insertions(+)
create mode 100644 test/shell/lvremove-thindata-caches.sh
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 508f78c..37dd361 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6692,6 +6692,25 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
return_0;
}
+ /* if thin pool data lv is writecache, then detach and remove the writecache */
+ if (lv_is_thin_pool(lv)) {
+ struct logical_volume *data_lv = data_lv_from_thin_pool(lv);
+
+ if (data_lv && lv_is_writecache(data_lv)) {
+ struct logical_volume *cachevol_lv = first_seg(data_lv)->writecache;
+
+ if (!lv_detach_writecache_cachevol(data_lv, 1)) {
+ log_error("Failed to detach writecache from %s", display_lvname(data_lv));
+ return 0;
+ }
+
+ if (!lv_remove_single(cmd, cachevol_lv, force, 1)) {
+ log_error("Failed to remove cachevol %s.", display_lvname(cachevol_lv));
+ return 0;
+ }
+ }
+ }
+
if (lv_is_writecache(lv)) {
struct logical_volume *cachevol_lv = first_seg(lv)->writecache;
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index c611635..54bc0d0 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -927,6 +927,8 @@ int handle_pool_metadata_spare(struct volume_group *vg, uint32_t extents,
int vg_set_pool_metadata_spare(struct logical_volume *lv);
int vg_remove_pool_metadata_spare(struct volume_group *vg);
+struct logical_volume *data_lv_from_thin_pool(struct logical_volume *pool_lv);
+
int attach_thin_external_origin(struct lv_segment *seg,
struct logical_volume *external_lv);
int detach_thin_external_origin(struct lv_segment *seg);
diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c
index 451c382..6ce88bd 100644
--- a/lib/metadata/thin_manip.c
+++ b/lib/metadata/thin_manip.c
@@ -21,6 +21,18 @@
#include "lib/config/defaults.h"
#include "lib/display/display.h"
+struct logical_volume *data_lv_from_thin_pool(struct logical_volume *pool_lv)
+{
+ struct lv_segment *seg_thinpool = first_seg(pool_lv);
+
+ if (!seg_thinpool || !seg_is_thin_pool(seg_thinpool)) {
+ log_error(INTERNAL_ERROR "data_lv_from_thin_pool arg not thin pool %s", pool_lv->name);
+ return NULL;
+ }
+
+ return seg_thinpool->areas[0].u.lv.lv;
+}
+
/* TODO: drop unused no_update */
int attach_pool_message(struct lv_segment *pool_seg, dm_thin_message_t type,
struct logical_volume *lv, uint32_t delete_id,
diff --git a/test/shell/lvremove-thindata-caches.sh b/test/shell/lvremove-thindata-caches.sh
new file mode 100644
index 0000000..ba099c3
--- /dev/null
+++ b/test/shell/lvremove-thindata-caches.sh
@@ -0,0 +1,71 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2017-2020 Red Hat, Inc. All rights reserved.
+#
+# 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 General Public License v.2.
+#
+# You should have received a copy of the GNU 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
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+aux have_cache 1 10 0 || skip
+aux have_writecache 1 0 0 || skip
+which mkfs.xfs || skip
+
+aux prepare_devs 6 70 # want 64M of usable space from each dev
+
+vgcreate $SHARED $vg "$dev1" "$dev2" "$dev3" "$dev4" "$dev5" "$dev6"
+
+# lv1 is thinpool LV: 128M
+# lv2 is fast LV: 64M
+# lv3 is thin LV: 1G
+
+#
+# Test lvremove of a thinpool that uses cache|writecache on data
+#
+
+# attach writecache to thinpool data
+lvcreate --type thin-pool -n $lv1 -L128M --poolmetadataspare n $vg "$dev1" "$dev2"
+lvcreate --type thin -n $lv3 -V1G --thinpool $lv1 $vg
+lvcreate -n $lv2 -L64M -an $vg "$dev3"
+lvconvert -y --type writecache --cachevol $lv2 $vg/$lv1
+lvchange -ay $vg/$lv1
+lvs -a $vg
+mkfs.xfs -f -s size=4096 "$DM_DEV_DIR/$vg/$lv3"
+lvremove -y $vg/$lv1
+
+# attach cache/writeback (cachevol) to thinpool data
+lvcreate --type thin-pool -n $lv1 -L128M --poolmetadataspare n $vg "$dev1" "$dev2"
+lvcreate --type thin -n $lv3 -V1G --thinpool $lv1 $vg
+lvcreate -n $lv2 -L64M -an $vg "$dev3"
+lvconvert -y --type cache --cachevol $lv2 --cachemode writeback $vg/$lv1
+lvchange -ay $vg/$lv1
+mkfs.xfs -f -s size=4096 "$DM_DEV_DIR/$vg/$lv3"
+lvremove -y $vg/$lv1
+
+# attach cache/writethrough (cachevol) to thinpool data
+lvcreate --type thin-pool -n $lv1 -L128M --poolmetadataspare n $vg "$dev1" "$dev2"
+lvcreate --type thin -n $lv3 -V1G --thinpool $lv1 $vg
+lvcreate -n $lv2 -L64M -an $vg "$dev3"
+lvconvert -y --type cache --cachevol $lv2 --cachemode writethrough $vg/$lv1
+lvchange -ay $vg/$lv1
+mkfs.xfs -f -s size=4096 "$DM_DEV_DIR/$vg/$lv3"
+lvremove -y $vg/$lv1
+
+# attach cache (cachepool) to thinpool data
+lvcreate --type thin-pool -n $lv1 -L128M --poolmetadataspare n $vg "$dev1" "$dev2"
+lvcreate --type thin -n $lv3 -V1G --thinpool $lv1 $vg
+lvcreate -y --type cache-pool -n $lv2 -L64M --poolmetadataspare n $vg "$dev3" "$dev6"
+lvconvert -y --type cache --cachepool $lv2 --poolmetadataspare n $vg/$lv1
+lvchange -ay $vg/$lv1
+mkfs.xfs -f -s size=4096 "$DM_DEV_DIR/$vg/$lv3"
+lvremove -y $vg/$lv1
+
+vgremove -f $vg
+

View File

@ -1,102 +0,0 @@
man/vdoimport.8_main | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 92 insertions(+)
create mode 100644 man/vdoimport.8_main
diff --git a/man/vdoimport.8_main b/man/vdoimport.8_main
new file mode 100644
index 0000000..1f32909
--- /dev/null
+++ b/man/vdoimport.8_main
@@ -0,0 +1,92 @@
+.TH "FSADM" "8" "LVM TOOLS #VERSION#" "Red Hat, Inc" "\""
+.
+.SH "NAME"
+.
+vdoimport \(em utility to import VDO volumes into a new volume group.
+.
+.SH SYNOPSIS
+.
+.PD 0
+.ad l
+.TP 10
+.B vdoimport
+.RI [ options ]
+.IR device
+.
+.PD
+.
+.SH DESCRIPTION
+.
+vdoimport utility imports VDO volumes created and managed by
+.BR vdo (8)
+manager into
+.BR lvm2 (8)
+managed VDO LV. This is realized by moving VDO superblock by 2MiB
+and creating lvm2 metadata at the front of this device. The operation is not reversible,
+thus after conversion to lvm2 the access to VDO data is only possible with
+.BR lvm2 (8)
+commands,
+.BR vdo (8)
+manager no longer control such volume.
+.
+.SH OPTIONS
+.
+.TP
+.BR -f | --force
+Bypass some sanity checks.
+.
+.TP
+.BR -h | --help
+Display the help text.
+.
+.TP
+.BR -n | --name
+Specifies the name of converted VDO LV. When the name is not specified,
+some automatic name is selected. In case the converted VDO volume is
+already using LV a backend device, the name of this LV is used for VDO LV.
+In this case also the of volume group must stay same.
+.
+.TP
+.BR -v | --verbose
+Be more verbose.
+.
+.TP
+.BR -y | --yes
+Answer "yes" at any prompts.
+.
+.TP
+.BR --dry-run
+Print commands without running them.
+.
+.
+.SH DIAGNOSTICS
+.
+On successful completion, the status code is 0.
+A status code of 1 is used for failure.
+.
+.SH EXAMPLES
+.
+Convert VDO volume created by vdo manager into logical volume LV1 with within volume group VG1.
+.P
+#
+.B vdoimport --name VG1/LV1 /dev/mapper/vdo-volume
+.
+.SH ENVIRONMENT VARIABLES
+.
+.TP
+.B TMPDIR
+The temporary directory name for mount points. Defaults to "\fI/tmp\fP".
+.TP
+.B DM_DEV_DIR
+The device directory name.
+Defaults to "\fI/dev\fP" and must be an absolute path.
+.
+.SH SEE ALSO
+.
+.nh
+.ad l
+.BR lvm (8),
+.BR lvm.conf (5),
+.P
+.BR vdo (8),
+.BR vdo2lvm (8),

View File

@ -1,61 +0,0 @@
test/shell/vgsplit-cache.sh | 47 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/test/shell/vgsplit-cache.sh b/test/shell/vgsplit-cache.sh
index eba85be..202e4b5 100644
--- a/test/shell/vgsplit-cache.sh
+++ b/test/shell/vgsplit-cache.sh
@@ -75,6 +75,53 @@ lvremove -y $vg
vgremove -ff $vg
vgremove -ff $vg1
+#
+# Check we handle pmspare for splitted VGs
+#
+aux prepare_vg 7
+
+# Create cache-pool and pmspare on single PV1
+lvcreate -L10 --type cache-pool $vg/cpool "$dev1"
+# Move spare to separate PV3
+pvmove -n $vg/lvol0_pmspare "$dev1" "$dev3"
+# Create origin on PV2
+lvcreate -L10 -n orig $vg "$dev2"
+lvconvert -H -y --cachepool $vg/cpool $vg/orig
+
+vgchange -an $vg
+
+# Check we do not create new _pmspare
+vgsplit --poolmetadataspare n $vg $vg1 "$dev2" "$dev1"
+
+check lv_exists $vg/lvol0_pmspare
+check lv_not_exists $vg1/lvol0_pmspare
+
+vgremove $vg
+vgremove -f $vg1
+
+
+aux prepare_vg 7
+
+# Again - now with handling _pmspare by vgsplit
+lvcreate -L10 --type cache-pool $vg/cpool "$dev1"
+# Move spare to separate PV3
+pvmove -n $vg/lvol0_pmspare "$dev1" "$dev3"
+# Create origin on PV2
+lvcreate -L10 -n orig $vg "$dev2"
+lvconvert -H -y --cachepool $vg/cpool $vg/orig
+
+vgchange -an $vg
+
+# Handle _pmspare (default)
+vgsplit --poolmetadataspare y $vg $vg1 "$dev2" "$dev1"
+
+check lv_not_exists $vg/lvol0_pmspare
+check lv_exists $vg1/lvol0_pmspare
+
+vgremove $vg
+vgremove -f $vg1
+
+
vgcreate $vg "$dev1" "$dev2" "$dev3" "$dev4"
lvcreate -L6 -n $lv1 -an $vg "$dev2"

View File

@ -1,53 +0,0 @@
test/shell/vgmerge-operation.sh | 42 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/test/shell/vgmerge-operation.sh b/test/shell/vgmerge-operation.sh
index 21889e9..0bf517d 100644
--- a/test/shell/vgmerge-operation.sh
+++ b/test/shell/vgmerge-operation.sh
@@ -80,3 +80,45 @@ grep "Duplicate logical volume name \"$lv1\" in \"$vg2\" and \"$vg1" err
check pvlv_counts $vg1 2 1 0
check pvlv_counts $vg2 2 1 0
vgremove -f $vg1 $vg2
+
+
+# 'vgmerge' handle pmspare for merged VG
+if aux have_thin 1 5 0; then
+
+# With disabled pmspare nothing is created
+vgcreate $vg1 "$dev1" "$dev2"
+vgcreate $vg2 "$dev3" "$dev4"
+lvcreate -T -L8M $vg1/pool1 --poolmetadatasize 8M --poolmetadataspare n
+lvcreate -T -L8M $vg2/pool2 --poolmetadatasize 4M --poolmetadataspare n
+vgchange -an $vg1 $vg2
+
+vgmerge --poolmetadataspare n $vg1 $vg2
+check lv_not_exists $vg/lvol0_pmspare
+vgremove -ff $vg1
+
+
+# With pmspare handling there are one created
+vgcreate $vg1 "$dev1" "$dev2"
+vgcreate $vg2 "$dev3" "$dev4"
+lvcreate -T -L8M $vg1/pool1 --poolmetadatasize 8M --poolmetadataspare n
+lvcreate -T -L8M $vg2/pool2 --poolmetadatasize 4M --poolmetadataspare n
+vgchange -an $vg1 $vg2
+
+vgmerge $vg1 $vg2
+check lv_field $vg1/lvol0_pmspare size "8.00m"
+vgremove -ff $vg1
+
+
+# When merged, bigger pmspare is preserved
+vgcreate $vg1 "$dev1" "$dev2"
+vgcreate $vg2 "$dev3" "$dev4"
+lvcreate -T -L8M $vg1/pool1 --poolmetadatasize 8M
+lvcreate -T -L8M $vg2/pool2 --poolmetadatasize 4M
+vgchange -an $vg1 $vg2
+
+vgmerge $vg1 $vg2
+
+check lv_field $vg1/lvol0_pmspare size "8.00m"
+vgremove -ff $vg1
+
+fi

View File

@ -1,63 +0,0 @@
WHATS_NEW | 1 +
lib/activate/activate.c | 5 ++++-
test/shell/lvconvert-cache-thin.sh | 22 ++++++++++++++++++++++
3 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 5806ecb..097160e 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.13 -
===============================
+ Fix detection of active components of external origin volume.
Add vdoimport tool to support conversion of VDO volumes.
Support configurable allocation/vdo_pool_header_size.
Fix handling of lvconvert --type vdo-pool --virtualsize.
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 6bda738..94fc944 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -2740,7 +2740,10 @@ static int _component_cb(struct logical_volume *lv, void *data)
(lv_is_thin_pool(lv) && pool_is_active(lv)))
return -1;
- if (lv_is_active(lv)) {
+ /* External origin is activated through thinLV and uses -real suffix.
+ * Note: for old clustered logic we would need to check for all thins */
+ if ((lv_is_external_origin(lv) && lv_info(lv->vg->cmd, lv, 1, NULL, 0, 0)) ||
+ lv_is_active(lv)) {
if (!lv_is_component(lv) || lv_is_visible(lv))
return -1; /* skip whole subtree */
diff --git a/test/shell/lvconvert-cache-thin.sh b/test/shell/lvconvert-cache-thin.sh
index 7dda6e6..9254239 100644
--- a/test/shell/lvconvert-cache-thin.sh
+++ b/test/shell/lvconvert-cache-thin.sh
@@ -67,4 +67,26 @@ fail lvconvert --yes --thinpool $vg/$lv1 --poolmetadata $vg/$lv
# Thin-pool CAN use cached data LV
lvconvert --yes --thinpool $vg/$lv
+lvremove -f $vg
+
+# Check we can active snapshot of cached external origin (BZ: 1967744)
+lvcreate -T -L10M $vg/pool "$dev1"
+
+lvcreate -L10M -n origin $vg "$dev1"
+lvcreate -H -L4M -n CPOOL $vg/origin "$dev2"
+
+# Use cached origin as external origin
+lvconvert -y -T --thinpool $vg/pool --originname extorig origin
+
+# Check we can easily create snapshot of such LV
+lvcreate -y -kn -n snap -s $vg/origin
+
+# Deactivate everything and do a component activation of _cmeta volume
+lvchange -an $vg
+lvchange -ay -y $vg/CPOOL_cpool_cmeta
+
+# Now this must fail since component volume is active
+not lvcreate -y -kn -n snap2 -s $vg/origin |& tee err
+grep "cmeta is active" err
+
vgremove -f $vg

View File

@ -1,729 +0,0 @@
WHATS_NEW | 3 +
configure | 25 +++
configure.ac | 15 ++
include/configure.h.in | 3 +
man/Makefile.in | 7 +-
scripts/Makefile.in | 4 +
scripts/vdoimport.sh | 376 ++++++++++++++++++++++++++++++++++++++++++++++
test/Makefile.in | 1 +
test/shell/vdo-convert.sh | 110 ++++++++++++++
9 files changed, 543 insertions(+), 1 deletion(-)
create mode 100755 scripts/vdoimport.sh
create mode 100644 test/shell/vdo-convert.sh
diff --git a/WHATS_NEW b/WHATS_NEW
index 04c6dcd..5806ecb 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,8 @@
Version 2.03.13 -
===============================
+ Add vdoimport tool to support conversion of VDO volumes.
+ Support configurable allocation/vdo_pool_header_size.
+ Fix handling of lvconvert --type vdo-pool --virtualsize.
Fix load of kvdo target when it is not present in memory (2.03.12).
Version 2.03.12 - 07th May 2021
diff --git a/configure b/configure
index 7c6bd48..661702d 100755
--- a/configure
+++ b/configure
@@ -643,6 +643,8 @@ WRITE_INSTALL
WRITECACHE
VDO_LIB
VDO_INCLUDE
+VDOIMPORT_PATH
+VDOIMPORT
VDO
VALGRIND_POOL
USRSBINDIR
@@ -966,6 +968,7 @@ enable_dbus_service
enable_pkgconfig
enable_write_install
enable_fsadm
+enable_vdoimport
enable_blkdeactivate
enable_dmeventd
enable_selinux
@@ -1701,6 +1704,7 @@ Optional Features:
--enable-pkgconfig install pkgconfig support
--enable-write_install install user writable files
--disable-fsadm disable fsadm
+ --disable-vdoimport disable vdoimport
--disable-blkdeactivate disable blkdeactivate
--enable-dmeventd enable the device-mapper event daemon
--disable-selinux disable selinux support
@@ -3128,6 +3132,7 @@ case "$host_os" in
DM_IOCTLS=yes
SELINUX=yes
FSADM=yes
+ VDOIMPORT=yes
BLKDEACTIVATE=yes
;;
darwin*)
@@ -3141,6 +3146,7 @@ case "$host_os" in
DM_IOCTLS=no
SELINUX=no
FSADM=no
+ VDOIMPORT=no
BLKDEACTIVATE=no
;;
*)
@@ -12371,6 +12377,18 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $FSADM" >&5
$as_echo "$FSADM" >&6; }
+
+################################################################################
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to install vdoimport" >&5
+$as_echo_n "checking whether to install vdoimport... " >&6; }
+# Check whether --enable-vdoimport was given.
+if test "${enable_vdoimport+set}" = set; then :
+ enableval=$enable_vdoimport; VDOIMPORT=$enableval
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $VDOIMPORT" >&5
+$as_echo "$VDOIMPORT" >&6; }
+
################################################################################
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to install blkdeactivate" >&5
$as_echo_n "checking whether to install blkdeactivate... " >&6; }
@@ -13857,6 +13875,13 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
+VDOIMPORT_PATH="$SBINDIR/vdoimport"
+
+cat >>confdefs.h <<_ACEOF
+#define VDOIMPORT_PATH "$VDOIMPORT_PATH"
+_ACEOF
+
+
################################################################################
if test "$BUILD_DMEVENTD" = yes; then
diff --git a/configure.ac b/configure.ac
index 1a49e7f..5a8b486 100644
--- a/configure.ac
+++ b/configure.ac
@@ -45,6 +45,7 @@ case "$host_os" in
DM_IOCTLS=yes
SELINUX=yes
FSADM=yes
+ VDOIMPORT=yes
BLKDEACTIVATE=yes
;;
darwin*)
@@ -58,6 +59,7 @@ case "$host_os" in
DM_IOCTLS=no
SELINUX=no
FSADM=no
+ VDOIMPORT=no
BLKDEACTIVATE=no
;;
*)
@@ -1291,6 +1293,14 @@ AC_ARG_ENABLE(fsadm, AC_HELP_STRING([--disable-fsadm], [disable fsadm]),
FSADM=$enableval)
AC_MSG_RESULT($FSADM)
+
+################################################################################
+dnl -- Enable vdoimport
+AC_MSG_CHECKING(whether to install vdoimport)
+AC_ARG_ENABLE(vdoimport, AC_HELP_STRING([--disable-vdoimport], [disable vdoimport]),
+ VDOIMPORT=$enableval)
+AC_MSG_RESULT($VDOIMPORT)
+
################################################################################
dnl -- Enable blkdeactivate
AC_MSG_CHECKING(whether to install blkdeactivate)
@@ -1646,6 +1656,9 @@ USRSBINDIR="$(eval echo $(eval echo $usrsbindir))"
FSADM_PATH="$SBINDIR/fsadm"
AC_DEFINE_UNQUOTED(FSADM_PATH, ["$FSADM_PATH"], [Path to fsadm binary.])
+VDOIMPORT_PATH="$SBINDIR/vdoimport"
+AC_DEFINE_UNQUOTED(VDOIMPORT_PATH, ["$VDOIMPORT_PATH"], [Path to vdoimport binary.])
+
################################################################################
dnl -- dmeventd pidfile and executable path
if test "$BUILD_DMEVENTD" = yes; then
@@ -1882,6 +1895,8 @@ AC_SUBST(SILENT_RULES)
AC_SUBST(USRSBINDIR)
AC_SUBST(VALGRIND_POOL)
AC_SUBST(VDO)
+AC_SUBST(VDOIMPORT)
+AC_SUBST(VDOIMPORT_PATH)
AC_SUBST(VDO_FORMAT_CMD)
AC_SUBST(VDO_INCLUDE)
AC_SUBST(VDO_LIB)
diff --git a/include/configure.h.in b/include/configure.h.in
index 671d201..6df8d89 100644
--- a/include/configure.h.in
+++ b/include/configure.h.in
@@ -684,6 +684,9 @@
/* Enable a valgrind aware build of pool */
#undef VALGRIND_POOL
+/* Path to vdoimport binary. */
+#undef VDOIMPORT_PATH
+
/* The path to 'vdoformat', if available. */
#undef VDO_FORMAT_CMD
diff --git a/man/Makefile.in b/man/Makefile.in
index 29afc77..d60a92c 100644
--- a/man/Makefile.in
+++ b/man/Makefile.in
@@ -23,6 +23,7 @@ else
endif
FSADMMAN = fsadm.8
+VDOIMPORTMAN = vdoimport.8
BLKDEACTIVATEMAN = blkdeactivate.8
DMEVENTDMAN = dmeventd.8
DMFILEMAPDMAN = dmfilemapd.8
@@ -50,7 +51,7 @@ MAN8SYSTEMD_GENERATORS=lvm2-activation-generator.8
ifeq (,$(findstring $(MAKECMDGOALS), distclean all_man install_all_man))
MAN7 += lvmcache.7 lvmthin.7 lvmvdo.7
- MAN8+=$(FSADMMAN) $(LVMPOLLDMAN) $(LVMLOCKDMAN) $(LVMDBUSDMAN)
+ MAN8+=$(FSADMMAN) $(LVMPOLLDMAN) $(LVMLOCKDMAN) $(LVMDBUSDMAN) $(VDOIMPORTMAN)
MAN8DM+=$(BLKDEACTIVATEMAN) $(DMEVENTDMAN) $(DMFILEMAPDMAN)
MAN8CLUSTER+=$(CMIRRORDMAN)
else
@@ -58,6 +59,10 @@ else
MAN8+=$(FSADMMAN)
endif
+ ifeq ("@VDOIMPORT@", "yes")
+ MAN8+=$(VDOIMPORTMAN)
+ endif
+
ifeq ("@BUILD_LVMDBUSD@", "yes")
MAN8+=$(LVMDBUSDMAN)
endif
diff --git a/scripts/Makefile.in b/scripts/Makefile.in
index e8f6742..1fe88ca 100644
--- a/scripts/Makefile.in
+++ b/scripts/Makefile.in
@@ -31,6 +31,10 @@ ifeq ("@FSADM@", "yes")
LVM_SCRIPTS += fsadm.sh
endif
+ifeq ("@VDOIMPORT@", "yes")
+ LVM_SCRIPTS += vdoimport.sh
+endif
+
ifeq ("@BLKDEACTIVATE@", "yes")
DM_SCRIPTS += blkdeactivate.sh
endif
diff --git a/scripts/vdoimport.sh b/scripts/vdoimport.sh
new file mode 100755
index 0000000..ef96591
--- /dev/null
+++ b/scripts/vdoimport.sh
@@ -0,0 +1,376 @@
+#!/bin/bash
+#
+# Copyright (C) 2021 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 General Public License v.2.
+#
+# You should have received a copy of the GNU 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
+#
+# Author: Zdenek Kabelac <zkabelac at redhat.com>
+#
+# Script for converting VDO volumes to lvm2 VDO LVs
+#
+# Needed utilities:
+# lvm, dmsetup,
+# vdo, vdo2lvm,
+# grep, awk, sed, blockdev, readlink, mkdir
+#
+# Conversion is using 'vdo convert' support from VDO manager to move
+# existing VDO header by 2M which makes space to place in PV header
+# and VG metadata area, and then create VDOPOOL LV and VDO LV in such VG.
+#
+
+set -euE -o pipefail
+
+TOOL=vdoimport
+
+_SAVEPATH=$PATH
+PATH="/sbin:/usr/sbin:/bin:/usr/sbin:$PATH"
+
+# user may override lvm location by setting LVM_BINARY
+LVM=${LVM_BINARY:-lvm}
+VDO=${VDO_BINARY:-vdo}
+VDOCONF=${VDOCONF:-}
+BLOCKDEV="blockdev"
+READLINK="readlink"
+READLINK_E="-e"
+MKDIR="mkdir"
+
+TEMPDIR="${TMPDIR:-/tmp}/${TOOL}_${RANDOM}$$"
+DM_DEV_DIR="${DM_DEV_DIR:-/dev}"
+
+DRY=0
+VERB=""
+FORCE=""
+YES=""
+
+# default name for converted VG and its VDO LV
+NAME="vdovg/vdolvol"
+
+# help message
+tool_usage() {
+ echo "${TOOL}: Utility to convert VDO volume to VDO LV."
+ echo
+ echo " ${TOOL} [options] <vdo_device_path>"
+ echo
+ echo " Options:"
+ echo " -f | --force Bypass sanity checks"
+ echo " -h | --help Show this help message"
+ echo " -n | --name Specifies VG/LV name for converted VDO volume"
+ echo " -v | --verbose Be verbose"
+ echo " -y | --yes Answer \"yes\" at any prompts"
+ echo " --dry-run Print commands without running them"
+
+ exit
+}
+
+verbose() {
+ test -z "$VERB" || echo "$TOOL:" "$@"
+}
+
+# Support multi-line error messages
+error() {
+ for i in "$@" ; do
+ echo "$TOOL: $i" >&2
+ done
+ cleanup 1
+}
+
+dry() {
+ if [ "$DRY" -ne 0 ]; then
+ verbose "Dry execution" "$@"
+ return 0
+ fi
+ verbose "Executing" "$@"
+ "$@"
+}
+
+cleanup() {
+ trap '' 2
+
+ rm -rf "$TEMPDIR"
+ # error exit status for break
+ exit "${1:-1}"
+}
+
+get_enabled_value_() {
+ case "$1" in
+ enabled) echo "1" ;;
+ *) echo "0" ;;
+ esac
+}
+
+get_kb_size_with_unit_() {
+ case "$1" in
+ *[kK]) echo $(( ${1%[kK]} )) ;;
+ *[mM]) echo $(( ${1%[mM]} * 1024 )) ;;
+ *[gG]) echo $(( ${1%[gG]} * 1024 * 1024 )) ;;
+ *[tT]) echo $(( ${1%[tT]} * 1024 * 1024 * 1024 )) ;;
+ *[pP]) echo $(( ${1%[pP]} * 1024 * 1024 * 1024 * 1024 )) ;;
+ esac
+}
+
+get_mb_size_with_unit_() {
+ case "$1" in
+ *[mM]) echo $(( ${1%[mM]} )) ;;
+ *[gG]) echo $(( ${1%[gG]} * 1024 )) ;;
+ *[tT]) echo $(( ${1%[tT]} * 1024 * 1024 )) ;;
+ *[pP]) echo $(( ${1%[pP]} * 1024 * 1024 * 1024 )) ;;
+ esac
+}
+
+# Figure out largest possible extent size usable for VG
+# $1 physical size
+# $2 logical size
+get_largest_extent_size_() {
+ local max=4
+ local i
+ local d
+
+ for i in 8 16 32 64 128 256 512 1024 2048 4096 ; do
+ d=$(( $1 / i ))
+ test $(( d * i )) -eq "$1" || break
+ d=$(( $2 / i ))
+ test $(( d * i )) -eq "$2" || break
+ max=$i
+ done
+ echo "$max"
+}
+
+# detect LV on the given device
+# dereference device name if it is symbolic link
+detect_lv_() {
+ local DEVICE=$1
+ local MAJOR
+ local MINOR
+ local SYSVOLUME
+ local MAJORMINOR
+
+ DEVICE=${1/#"${DM_DEV_DIR}/"/}
+ DEVICE=$("$READLINK" $READLINK_E "$DM_DEV_DIR/$DEVICE")
+ test -n "$DEVICE" || error "Cannot get readlink \"$1\"."
+ RDEVICE=$DEVICE
+ case "$RDEVICE" in
+ # hardcoded /dev since udev does not create these entries elsewhere
+ /dev/dm-[0-9]*)
+ read -r <"/sys/block/${RDEVICE#/dev/}/dm/name" SYSVOLUME 2>&1 && DEVICE="$DM_DEV_DIR/mapper/$SYSVOLUME"
+ read -r <"/sys/block/${RDEVICE#/dev/}/dev" MAJORMINOR 2>&1 || error "Cannot get major:minor for \"$DEVICE\"."
+ MAJOR=${MAJORMINOR%%:*}
+ MINOR=${MAJORMINOR##*:}
+ ;;
+ *)
+ STAT=$(stat --format "MAJOR=\$((0x%t)) MINOR=\$((0x%T))" "$RDEVICE")
+ test -n "$STAT" || error "Cannot get major:minor for \"$DEVICE\"."
+ eval "$STAT"
+ ;;
+ esac
+
+ eval "$(dmsetup info -c -j "$MAJOR" -m "$MINOR" -o uuid,name --noheadings --nameprefixes --separator ' ')"
+}
+
+# parse yaml config files into 'prefix_yaml_part_names=("value")' strings
+parse_yaml_() {
+ local yaml_file=$1
+ local prefix=$2
+ local s
+ local w
+ local fs
+
+ s='[[:space:]]*'
+ w='[a-zA-Z0-9_.-]*'
+ fs="$(echo @|tr @ '\034')"
+
+ (
+ sed -ne '/^--/s|--||g; s|\"|\\\"|g; s/[[:space:]]*$//g;' \
+ -e 's/\$/\\\$/g' \
+ -e "/#.*[\"\']/!s| #.*||g; /^#/s|#.*||g;" \
+ -e "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
+ -e "s|^\($s\)\($w\)${s}[:-]$s\(.*\)$s\$|\1$fs\2$fs\3|p" |
+
+ awk -F"$fs" '{
+ indent = length($1)/2;
+ if (length($2) == 0) { conj[indent]="+";} else {conj[indent]="";}
+ vname[indent] = $2;
+ for (i in vname) {if (i > indent) {delete vname[i]}}
+ if (length($3) > 0) {
+ vn=""; for (i=0; i<indent; i++) {vn=(vn)(vname[i])("_")}
+ printf("%s%s%s%s=(\"%s\")\n", "'"$prefix"'",vn, $2, conj[indent-1], $3);
+ }
+ }' |
+
+ sed -e 's/_=/+=/g' |
+
+ awk 'BEGIN {
+ FS="=";
+ OFS="="
+ }
+ /(-|\.).*=/ {
+ gsub("-|\\.", "_", $1)
+ }
+ { print }'
+ ) < "$yaml_file"
+}
+
+# convert existing VDO volume into lvm2 volume
+convert2lvm_() {
+ local DEVICE=$1
+ local VGNAME=${NAME%/*}
+ local LVNAME=${NAME#*/}
+ local VDONAME
+ local TRVDONAME
+ local EXTENTSZ
+ local IS_LV=1
+
+ DM_UUID=""
+ detect_lv_ "$DEVICE"
+ case "$DM_UUID" in
+ LVM-*) eval "$(dmsetup splitname --nameprefixes --noheadings --separator ' ' "$DM_NAME")"
+ if [ -z "$VGNAME" ] || [ "$VGNAME" = "$LVNAME" ] ; then
+ VGNAME=$DM_VG_NAME
+ elif test "$VGNAME" != "$DM_VG_NAME" ; then
+ error "Volume group name \"$VGNAME\" does not match name \"$DM_VG_NAME\" for device \"$DEVICE\"."
+ fi
+ ;;
+ *) IS_LV=0
+ # Check $VGNANE does not already exists
+ "$LVM" vgs "$VGNAME" && error "Cannot use already existing volume group name \"$VGNAME\"."
+ ;;
+ esac
+
+ verbose "Checked whether device $1 is already LV ($IS_LV)."
+
+ "$MKDIR" -p -m 0000 "$TEMPDIR" || error "Failed to create $TEMPDIR."
+
+ verbose "Getting YAML VDO configuration."
+ "$VDO" printConfigFile $VDOCONF >"$TEMPDIR/vdoconf.yml"
+
+ VDONAME=$(awk -v DNAME="$DEVICE" '/.*VDOService$/ {VNAME=substr($1, 0, length($1) - 1)} /[[:space:]]*device:/ { if ($2 ~ DNAME) {print VNAME}}' "$TEMPDIR/vdoconf.yml")
+ TRVDONAME=$(echo "$VDONAME" | tr '-' '_')
+
+ # When VDO volume is 'active', check it's not mounted/being used
+ eval "$(dmsetup info -c -o open "$VDONAME" --noheadings --nameprefixes || true)"
+ test "${DM_OPEN:-0}" -eq 0 || error "Cannot converted VDO volume \"$VDONAME\" which is in use!"
+
+ #parse_yaml_ "$TEMPDIR/vdoconf.yml" _
+ eval "$(parse_yaml_ "$TEMPDIR/vdoconf.yml" _ | grep "$TRVDONAME" | sed -e "s/_config_vdos_$TRVDONAME/vdo/g")"
+
+ vdo_logicalSize=$(get_kb_size_with_unit_ "$vdo_logicalSize")
+ vdo_physicalSize=$(get_kb_size_with_unit_ "$vdo_physicalSize")
+
+ verbose "Going to convert physical sized VDO device $vdo_physicalSize KiB."
+ verbose "With logical volume of size $vdo_logicalSize KiB."
+
+ PARAMS=$(cat <<EOF
+allocation {
+ vdo_use_compression = $(get_enabled_value_ "$vdo_compression")
+ vdo_use_deduplication = $(get_enabled_value_ "$vdo_deduplication")
+ vdo_use_metadata_hints=1
+ vdo_minimum_io_size = $vdo_logicalBlockSize
+ vdo_block_map_cache_size_mb = $(get_mb_size_with_unit_ "$vdo_blockMapCacheSize")
+ vdo_block_map_period = $vdo_blockMapPeriod
+ vdo_check_point_frequency = $vdo_indexCfreq
+ vdo_use_sparse_index = $(get_enabled_value_ "$vdo_indexSparse")
+ vdo_index_memory_size_mb = $(awk "BEGIN {print $vdo_indexMemory * 1024}")
+ vdo_slab_size_mb = $(get_mb_size_with_unit_ "$vdo_blockMapCacheSize")
+ vdo_ack_threads = $vdo_ackThreads
+ vdo_bio_threads = $vdo_bioThreads
+ vdo_bio_rotation = $vdo_bioRotationInterval
+ vdo_cpu_threads = $vdo_cpuThreads
+ vdo_hash_zone_threads = $vdo_hashZoneThreads
+ vdo_logical_threads = $vdo_logicalThreads
+ vdo_physical_threads = $vdo_physicalThreads
+ vdo_write_policy = $vdo_writePolicy
+ vdo_max_discard = $(( $(get_kb_size_with_unit_ "$vdo_maxDiscardSize") * 1024 ))
+ vdo_pool_header_size = 0
+}
+EOF
+)
+ verbose "VDO conversion paramaters: $PARAMS"
+
+ verbose "Stopping VDO volume."
+ dry "$VDO" stop $VDOCONF --name "$VDONAME"
+
+ if [ "$IS_LV" = "0" ]; then
+ verbose "Moving VDO header by 2MiB."
+ dry "$VDO" convert $VDOCONF --force --name "$VDONAME"
+
+ dry "$LVM" pvcreate $YES --dataalignment 2M "$DEVICE" || {
+ error "Creation of PV on \"$DEVICE\" failed, while VDO header has been already moved!"
+ }
+
+ # Obtain free space in this new PV
+ # after 'vdo convert/vdo2lvm' call there is +2M free space at the front of the device
+ case "$DRY" in
+ 0) pvfree=$("$LVM" pvs -o devsize --units b --nosuffix --noheadings "$DEVICE") ;;
+ *) pvfree=$("$BLOCKDEV" --getsize64 "$DEVICE") ;;
+ esac
+
+ pvfree=$(( pvfree / 1024 - 2048 )) # to KiB
+ else
+ pvfree=$("$LVM" lvs -o size --units b --nosuffix --noheadings "$VGNAME/$LVNAME")
+ pvfree=$(( pvfree / 1024 )) # to KiB
+ fi
+
+ # select largest possible extent size that can exactly express both sizes
+ EXTENTSZ=$(get_largest_extent_size_ "$pvfree" "$vdo_logicalSize")
+
+ if [ "$IS_LV" = "0" ]; then
+ verbose "Creating VG \"${NAME%/*}\" with extent size $EXTENTSZ KiB."
+ dry "$LVM" vgcreate $YES $VERB -s "${EXTENTSZ}k" "$VGNAME" "$DEVICE" || {
+ error "Creation of VG \"$VGNAME\" failed, while VDO header has been already moved!"
+ }
+
+ verbose "Creating VDO pool data LV from all extents in volume group $VGNAME."
+ dry "$LVM" lvcreate -Zn -Wn $YES $VERB -l100%VG -n "${LVNAME}_vpool" "$VGNAME"
+ else
+ # validate existing VG extent_size can express virtual VDO size
+ vg_extent_size=$("$LVM" vgs -o vg_extent_size --units b --nosuffix --noheadings "$VGNAME" || true)
+ vg_extent_size=$(( vg_extent_size / 1024 ))
+
+ test "$vg_extent_size" -le "$EXTENTSZ" || {
+ error "Please vgchange extent_size to at most $EXTENTSZ KiB or extend and align virtual size on $vg_extent_size KiB."
+ }
+ verbose "Renaming existing LV to be used as _vdata volume for VDO pool LV."
+ dry "$LVM" lvrename $YES $VERB "$VGNAME/$LVNAME" "$VGNAME/${LVNAME}_vpool" || {
+ error "Rename of LV \"$VGNAME/$LVNAME\" failed, while VDO header has been already moved!"
+ }
+ fi
+
+ verbose "Converting to VDO pool."
+ dry "$LVM" lvconvert $YES $VERB $FORCE --config "$PARAMS" -Zn -V "${vdo_logicalSize}k" -n "$LVNAME" --type vdo-pool "$VGNAME/${LVNAME}_vpool"
+
+ rm -fr "$TEMPDIR"
+}
+
+#############################
+# start point of this script
+# - parsing parameters
+#############################
+trap "cleanup 2" 2
+
+test "$#" -eq 0 && tool_usage
+
+while [ "$#" -ne 0 ]
+do
+ case "$1" in
+ "") ;;
+ "-f"|"--force" ) FORCE="-f" ;;
+ "-h"|"--help" ) tool_usage ;;
+ "-n"|"--name" ) shift; NAME=$1 ;;
+ "-v"|"--verbose") VERB="-v" ;;
+ "-y"|"--yes" ) YES="-y" ;;
+ "--dry-run" ) DRY="1" ;;
+ "-*") error "Wrong argument \"$1\". (see: $TOOL --help)" ;;
+ *) DEVICENAME=$1 ;; # device name does not start with '-'
+ esac
+ shift
+done
+
+# do conversion
+convert2lvm_ "$DEVICENAME"
diff --git a/test/Makefile.in b/test/Makefile.in
index e4cd3aa..6be03aa 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -353,6 +353,7 @@ LIB = $(addprefix lib/, $(LIB_SECURETEST) $(LIB_DMSECURETEST) $(LIB_SHARED) $(LI
$(Q) $(LN_S) -f $(abs_top_srcdir)/conf/lvmdbusd.profile lib/
$(Q) $(LN_S) -f $(abs_top_srcdir)/conf/thin-performance.profile lib/
$(Q) $(LN_S) -f $(abs_top_srcdir)/scripts/fsadm.sh lib/fsadm
+ $(Q) $(LN_S) -f $(abs_top_srcdir)/scripts/vdoimport.sh lib/vdoimport
@test "$(srcdir)" = . || \
for i in $(LIB_LVMLOCKD_CONF) $(LIB_MKE2FS_CONF); do \
test -n "$(Q)" || echo "$(LN_S) -f $(abs_top_srcdir)/test/lib/$$i lib/"; \
diff --git a/test/shell/vdo-convert.sh b/test/shell/vdo-convert.sh
new file mode 100644
index 0000000..538147b
--- /dev/null
+++ b/test/shell/vdo-convert.sh
@@ -0,0 +1,110 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2021 Red Hat, Inc. All rights reserved.
+#
+# 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 General Public License v.2.
+#
+# You should have received a copy of the GNU 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
+
+# Test conversion of VDO volumes made by vdo manager into VDO LV.
+
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+# Use local for this test vdo configuratoin
+VDOCONF="-f vdotestconf.yml"
+#VDOCONF=""
+export VDOCONF
+VDONAME="${PREFIX}-TESTVDO"
+
+# VDO automatically starts dmeventd
+aux prepare_dmeventd
+
+#
+# Main
+#
+which vdo || skip
+which mkfs.ext4 || skip
+export MKE2FS_CONFIG="$TESTDIR/lib/mke2fs.conf"
+
+aux have_vdo 6 2 0 || skip
+
+aux prepare_devs 2 10000
+
+aux extend_filter_LVMTEST
+
+
+#
+# Check conversion of VDO volume made on some LV
+#
+# In this case we do not need to move any VDO headers.
+#
+vgcreate $vg "$dev1"
+
+lvcreate -L5G -n $lv1 $vg
+
+vdo create $VDOCONF --name "$VDONAME" --device="$DM_DEV_DIR/$vg/$lv1" --vdoLogicalSize=10G
+
+mkfs -E nodiscard "$DM_DEV_DIR/mapper/$VDONAME"
+
+# Different VG name fails
+not vdoimport -y -v --name $vg1/$lv1 "$DM_DEV_DIR/$vg/$lv1"
+
+# Try just dry run and observe logging
+vdoimport --dry-run -y -v --name $lv1 "$DM_DEV_DIR/$vg/$lv1"
+
+vdoimport -y --name $lv1 "$DM_DEV_DIR/$vg/$lv1"
+
+# ATM needed - since we do not call 'vdo convert' in this case
+vdo remove $VDOCONF --force --name "$VDONAME" || true
+
+vgremove -f $vg
+
+aux wipefs_a "$dev1"
+
+# prepare 'unused' $vg2
+vgcreate $vg2 "$dev2"
+
+#
+# Check conversion of VDO volume on non-LV device
+#
+vdo create $VDOCONF --name "$VDONAME" --device="$dev1" --vdoLogicalSize=31G
+
+mkfs -E nodiscard "$DM_DEV_DIR/mapper/$VDONAME"
+
+# Fail with an already existing volume group $vg2
+not vdoimport --dry-run -y -v --name $vg2/$lv1 "$dev1" |& tee err
+grep "already existing volume group" err
+
+# User can also convert already stopped VDO volume
+vdo stop $VDOCONF --name "$VDONAME"
+
+vdoimport -y -v --name $vg/$lv1 "$dev1"
+
+fsck -n "$DM_DEV_DIR/$vg/$lv1"
+
+vgremove -f $vg
+
+
+#
+# Try once again with different vgname/lvname and sizes
+#
+aux teardown_devs
+aux prepare_devs 1 23456
+
+vdo create $VDOCONF --name "$VDONAME" --device="$dev1" --vdoLogicalSize=23G
+
+mkfs -E nodiscard "$DM_DEV_DIR/mapper/$VDONAME"
+
+vdoimport -y -v --name $vg1/$lv2 "$dev1"
+
+fsck -n "$DM_DEV_DIR/$vg1/$lv2"
+
+vgremove -f $vg1
+

View File

@ -1,37 +0,0 @@
WHATS_NEW | 4 ++++
lib/activate/activate.c | 10 +++-------
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 6f339a5..04c6dcd 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,3 +1,7 @@
+Version 2.03.13 -
+===============================
+ Fix load of kvdo target when it is not present in memory (2.03.12).
+
Version 2.03.12 - 07th May 2021
===============================
Allow attaching cache to thin data volume.
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 71db981..6bda738 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -574,13 +574,9 @@ int module_present(struct cmd_context *cmd, const char *target_name)
}
#ifdef MODPROBE_CMD
- if (strcmp(target_name, MODULE_NAME_VDO) == 0) {
- argv[1] = target_name; /* ATM kvdo is without dm- prefix */
- if ((ret = exec_cmd(cmd, argv, NULL, 0)))
- return ret;
- }
-
- if (dm_snprintf(module, sizeof(module), "dm-%s", target_name) < 0) {
+ if (strcmp(target_name, TARGET_NAME_VDO) == 0)
+ argv[1] = MODULE_NAME_VDO; /* ATM kvdo is without dm- prefix */
+ else if (dm_snprintf(module, sizeof(module), "dm-%s", target_name) < 0) {
log_error("module_present module name too long: %s",
target_name);
return 0;

View File

@ -1,50 +0,0 @@
tools/lvconvert.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 6066d1f..8488596 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -5438,7 +5438,7 @@ static int _lvconvert_to_vdopool_single(struct cmd_context *cmd,
struct processing_handle *handle)
{
const char *vg_name = NULL;
- unsigned int zero_vdopool;
+ unsigned int vdo_pool_zero;
struct volume_group *vg = lv->vg;
struct logical_volume *vdo_lv;
struct dm_vdo_target_params vdo_params; /* vdo */
@@ -5497,12 +5497,12 @@ static int _lvconvert_to_vdopool_single(struct cmd_context *cmd,
goto out;
}
- zero_vdopool = arg_int_value(cmd, zero_ARG, 1);
+ vdo_pool_zero = arg_int_value(cmd, zero_ARG, 1);
log_warn("WARNING: Converting logical volume %s to VDO pool volume %s formating.",
- display_lvname(lv), zero_vdopool ? "with" : "WITHOUT");
+ display_lvname(lv), vdo_pool_zero ? "with" : "WITHOUT");
- if (zero_vdopool)
+ if (vdo_pool_zero)
log_warn("THIS WILL DESTROY CONTENT OF LOGICAL VOLUME (filesystem etc.)");
else
log_warn("WARNING: Using invalid VDO pool data MAY DESTROY YOUR DATA!");
@@ -5514,7 +5514,7 @@ static int _lvconvert_to_vdopool_single(struct cmd_context *cmd,
goto out;
}
- if (zero_vdopool) {
+ if (vdo_pool_zero) {
if (!wipe_lv(lv, (struct wipe_params) { .do_zero = 1, .do_wipe_signatures = 1,
.yes = arg_count(cmd, yes_ARG),
.force = arg_count(cmd, force_ARG)})) {
@@ -5526,7 +5526,7 @@ static int _lvconvert_to_vdopool_single(struct cmd_context *cmd,
if (!archive(vg))
goto_out;
- if (!convert_vdo_pool_lv(lv, &vdo_params, &lvc.virtual_extents, zero_vdopool))
+ if (!convert_vdo_pool_lv(lv, &vdo_params, &lvc.virtual_extents, vdo_pool_zero))
goto_out;
dm_list_init(&lvc.tags);

View File

@ -1,197 +0,0 @@
conf/example.conf.in | 5 +++++
lib/config/config_settings.h | 3 +++
lib/config/defaults.h | 3 +--
lib/metadata/lv_manip.c | 3 ++-
lib/metadata/metadata-exported.h | 5 ++++-
lib/metadata/vdo_manip.c | 13 ++++++++-----
tools/lvconvert.c | 6 ++++--
tools/lvcreate.c | 2 +-
8 files changed, 28 insertions(+), 12 deletions(-)
diff --git a/conf/example.conf.in b/conf/example.conf.in
index aaf73a4..78547a6 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -734,6 +734,11 @@ allocation {
# The default and minimum is 1. The maximum is UINT_MAX / 4096.
# This configuration option has an automatic default value.
# vdo_max_discard = 1
+
+ # Configuration option allocation/vdo_pool_header_size.
+ # Specified the emptry header size in KiB at the front and end of vdo pool device.
+ # This configuration option has an automatic default value.
+ # vdo_pool_header_size = 512
}
# Configuration section log.
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index f5dac4d..5217da8 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -816,6 +816,9 @@ cfg(allocation_vdo_max_discard_CFG, "vdo_max_discard", allocation_CFG_SECTION, C
"increased latency for the individual discard requests.\n"
"The default and minimum is 1. The maximum is UINT_MAX / 4096.\n")
+cfg(allocation_vdo_pool_header_size_CFG, "vdo_pool_header_size", allocation_CFG_SECTION, CFG_PROFILABLE | CFG_PROFILABLE_METADATA | CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, DEFAULT_VDO_POOL_HEADER_SIZE_KB, vsn(2, 3, 12), NULL, 0, NULL,
+ "Specified the emptry header size in KiB at the front and end of vdo pool device.\n")
+
cfg(log_report_command_log_CFG, "report_command_log", log_CFG_SECTION, CFG_PROFILABLE | CFG_DEFAULT_COMMENTED | CFG_DISALLOW_INTERACTIVE, CFG_TYPE_BOOL, DEFAULT_COMMAND_LOG_REPORT, vsn(2, 2, 158), NULL, 0, NULL,
"Enable or disable LVM log reporting.\n"
"If enabled, LVM will collect a log of operations, messages,\n"
diff --git a/lib/config/defaults.h b/lib/config/defaults.h
index 2870dee..d5e5b3b 100644
--- a/lib/config/defaults.h
+++ b/lib/config/defaults.h
@@ -181,8 +181,7 @@
* VDO pool will reverve some sectors in the front and the back of pool device to avoid
* seeing same device twice in the system.
*/
-#define DEFAULT_VDO_POOL_HEADER_SIZE (1024) // 512KiB
-
+#define DEFAULT_VDO_POOL_HEADER_SIZE_KB (512)
#define DEFAULT_FSADM_PATH FSADM_PATH
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 37dd361..43af474 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -8766,7 +8766,8 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
}
if (seg_is_vdo_pool(lp)) {
- if (!convert_vdo_pool_lv(lv, &lp->vdo_params, &lp->virtual_extents, 1)) {
+ if (!convert_vdo_pool_lv(lv, &lp->vdo_params, &lp->virtual_extents,
+ 1, lp->vdo_pool_header_size)) {
stack;
goto deactivate_and_revert_new_lv;
}
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 54bc0d0..adbbe76 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -1033,6 +1033,7 @@ struct lvcreate_params {
int approx_alloc; /* all */
alloc_policy_t alloc; /* all */
struct dm_vdo_target_params vdo_params; /* vdo */
+ uint64_t vdo_pool_header_size; /* VDO */
int raidintegrity;
const char *raidintegritymode;
@@ -1367,10 +1368,12 @@ int parse_vdo_pool_status(struct dm_pool *mem, const struct logical_volume *vdo_
struct logical_volume *convert_vdo_pool_lv(struct logical_volume *data_lv,
const struct dm_vdo_target_params *vtp,
uint32_t *virtual_extents,
- int format);
+ int format,
+ uint64_t vdo_pool_header_size);
int set_vdo_write_policy(enum dm_vdo_write_policy *vwp, const char *policy);
int fill_vdo_target_params(struct cmd_context *cmd,
struct dm_vdo_target_params *vtp,
+ uint64_t *vdo_pool_header_size,
struct profile *profile);
/* -- metadata/vdo_manip.c */
diff --git a/lib/metadata/vdo_manip.c b/lib/metadata/vdo_manip.c
index afc513a..3f2de1a 100644
--- a/lib/metadata/vdo_manip.c
+++ b/lib/metadata/vdo_manip.c
@@ -356,9 +356,9 @@ static int _format_vdo_pool_data_lv(struct logical_volume *data_lv,
struct logical_volume *convert_vdo_pool_lv(struct logical_volume *data_lv,
const struct dm_vdo_target_params *vtp,
uint32_t *virtual_extents,
- int format)
+ int format,
+ uint64_t vdo_pool_header_size)
{
- const uint64_t header_size = DEFAULT_VDO_POOL_HEADER_SIZE;
const uint32_t extent_size = data_lv->vg->extent_size;
struct cmd_context *cmd = data_lv->vg->cmd;
struct logical_volume *vdo_pool_lv = data_lv;
@@ -379,7 +379,7 @@ struct logical_volume *convert_vdo_pool_lv(struct logical_volume *data_lv,
if (*virtual_extents)
vdo_logical_size =
- _get_virtual_size(*virtual_extents, extent_size, header_size);
+ _get_virtual_size(*virtual_extents, extent_size, vdo_pool_header_size);
if (!dm_vdo_validate_target_params(vtp, vdo_logical_size))
return_0;
@@ -403,7 +403,7 @@ struct logical_volume *convert_vdo_pool_lv(struct logical_volume *data_lv,
return NULL;
}
- vdo_logical_size -= 2 * header_size;
+ vdo_logical_size -= 2 * vdo_pool_header_size;
if (vdo_logical_size < extent_size) {
if (!*virtual_extents)
@@ -426,7 +426,7 @@ struct logical_volume *convert_vdo_pool_lv(struct logical_volume *data_lv,
vdo_pool_seg = first_seg(vdo_pool_lv);
vdo_pool_seg->segtype = vdo_pool_segtype;
vdo_pool_seg->vdo_params = *vtp;
- vdo_pool_seg->vdo_pool_header_size = DEFAULT_VDO_POOL_HEADER_SIZE;
+ vdo_pool_seg->vdo_pool_header_size = vdo_pool_header_size;
vdo_pool_seg->vdo_pool_virtual_extents = *virtual_extents;
vdo_pool_lv->status |= LV_VDO_POOL;
@@ -453,6 +453,7 @@ int set_vdo_write_policy(enum dm_vdo_write_policy *vwp, const char *policy)
int fill_vdo_target_params(struct cmd_context *cmd,
struct dm_vdo_target_params *vtp,
+ uint64_t *vdo_pool_header_size,
struct profile *profile)
{
const char *policy;
@@ -501,5 +502,7 @@ int fill_vdo_target_params(struct cmd_context *cmd,
if (!set_vdo_write_policy(&vtp->write_policy, policy))
return_0;
+ *vdo_pool_header_size = 2 * find_config_tree_int64(cmd, allocation_vdo_pool_header_size_CFG, profile);
+
return 1;
}
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 8488596..f87ee78 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -5439,6 +5439,7 @@ static int _lvconvert_to_vdopool_single(struct cmd_context *cmd,
{
const char *vg_name = NULL;
unsigned int vdo_pool_zero;
+ uint64_t vdo_pool_header_size;
struct volume_group *vg = lv->vg;
struct logical_volume *vdo_lv;
struct dm_vdo_target_params vdo_params; /* vdo */
@@ -5481,7 +5482,7 @@ static int _lvconvert_to_vdopool_single(struct cmd_context *cmd,
goto out;
}
- if (!fill_vdo_target_params(cmd, &vdo_params, vg->profile))
+ if (!fill_vdo_target_params(cmd, &vdo_params, &vdo_pool_header_size, vg->profile))
goto_out;
if (arg_is_set(cmd, compression_ARG))
@@ -5526,7 +5527,8 @@ static int _lvconvert_to_vdopool_single(struct cmd_context *cmd,
if (!archive(vg))
goto_out;
- if (!convert_vdo_pool_lv(lv, &vdo_params, &lvc.virtual_extents, vdo_pool_zero))
+ if (!convert_vdo_pool_lv(lv, &vdo_params, &lvc.virtual_extents,
+ vdo_pool_zero, vdo_pool_header_size))
goto_out;
dm_list_init(&lvc.tags);
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index a28f093..0def236 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -1097,7 +1097,7 @@ static int _lvcreate_params(struct cmd_context *cmd,
// FIXME: prefiling here - this is wrong place
// but will work for this moment
- if (!fill_vdo_target_params(cmd, &lp->vdo_params, NULL))
+ if (!fill_vdo_target_params(cmd, &lp->vdo_params, &lp->vdo_pool_header_size, NULL))
return_0;
if (arg_is_set(cmd, compression_ARG))

View File

@ -1,28 +0,0 @@
tools/vgmerge.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/tools/vgmerge.c b/tools/vgmerge.c
index 895018a..884ad4b 100644
--- a/tools/vgmerge.c
+++ b/tools/vgmerge.c
@@ -92,6 +92,20 @@ static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to,
}
}
+ if (vg_from->pool_metadata_spare_lv &&
+ vg_to->pool_metadata_spare_lv) {
+ if (vg_from->pool_metadata_spare_lv->le_count >
+ vg_to->pool_metadata_spare_lv->le_count)
+ /* Preserve bigger pmspare from VG_FROM */
+ lv = vg_to->pool_metadata_spare_lv;
+ else
+ lv = vg_from->pool_metadata_spare_lv;
+
+ log_debug_metadata("Removing pool metadata spare %s.", display_lvname(lv));
+ if (!lv_remove_single(cmd, lv, DONT_PROMPT, 0))
+ return_ECMD_FAILED;
+ }
+
if (!vgs_are_compatible(cmd, vg_from, vg_to))
goto_bad;

View File

@ -1,82 +0,0 @@
WHATS_NEW | 2 +-
man/vgmerge.8_pregen | 9 +++++++++
tools/command-lines.in | 2 +-
tools/vgmerge.c | 6 ++++++
4 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 0b8e3f2..5556789 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,6 +1,6 @@
Version 2.03.13 -
===============================
- Support --poolmetadataspare with vgsplit.
+ Support --poolmetadataspare with vgsplit and vgmerge.
Fix detection of active components of external origin volume.
Add vdoimport tool to support conversion of VDO volumes.
Support configurable allocation/vdo_pool_header_size.
diff --git a/man/vgmerge.8_pregen b/man/vgmerge.8_pregen
index 1264bb5..e229218 100644
--- a/man/vgmerge.8_pregen
+++ b/man/vgmerge.8_pregen
@@ -27,6 +27,8 @@ of both VGs fit into the destination VG's limits.
.br
[ \fB-l\fP|\fB--list\fP ]
.br
+[ \fB--poolmetadataspare\fP \fBy\fP|\fBn\fP ]
+.br
[ COMMON_OPTIONS ]
.ad b
.RE
@@ -147,6 +149,13 @@ Display long help text.
Disable locking.
.
.HP
+\fB--poolmetadataspare\fP \fBy\fP|\fBn\fP
+.br
+Enable or disable the automatic creation and management of a
+spare pool metadata LV in the VG. A spare metadata LV is reserved
+space that can be used when repairing a pool.
+.
+.HP
\fB--profile\fP \fIString\fP
.br
An alias for --commandprofile or --metadataprofile, depending
diff --git a/tools/command-lines.in b/tools/command-lines.in
index a4785b3..0bc5a49 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -1847,7 +1847,7 @@ DESC: Add devices from all accessible VGs to the devices file.
---
vgmerge VG VG
-OO: --autobackup Bool, --list
+OO: --autobackup Bool, --list, --poolmetadataspare Bool
ID: vgmerge_general
---
diff --git a/tools/vgmerge.c b/tools/vgmerge.c
index 884ad4b..08615cd 100644
--- a/tools/vgmerge.c
+++ b/tools/vgmerge.c
@@ -64,6 +64,8 @@ static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to,
struct lv_list *lvl1, *lvl2;
int r = ECMD_FAILED;
int lock_vg_from_first = 0;
+ struct logical_volume *lv;
+ int poolmetadataspare = arg_int_value(cmd, poolmetadataspare_ARG, DEFAULT_POOL_METADATA_SPARE);
if (!strcmp(vg_name_to, vg_name_from)) {
log_error("Duplicate volume group name \"%s\"", vg_name_from);
@@ -185,6 +187,10 @@ static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to,
/* Flag up that some PVs have moved from another VG */
vg_to->old_name = vg_from->name;
+ /* Check whether size of pmspare is big enough now for merged VG */
+ if (!handle_pool_metadata_spare(vg_to, 0, &vg_to->pvs, poolmetadataspare))
+ goto_bad;
+
/* store it on disks */
log_verbose("Writing out updated volume group");
if (!vg_write(vg_to) || !vg_commit(vg_to))

View File

@ -1,18 +0,0 @@
tools/vgremove.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/vgremove.c b/tools/vgremove.c
index 8f73297..b6685ae 100644
--- a/tools/vgremove.c
+++ b/tools/vgremove.c
@@ -65,6 +65,10 @@ static int _vgremove_single(struct cmd_context *cmd, const char *vg_name,
}
}
+ if (vg->pool_metadata_spare_lv &&
+ !lvremove_single(cmd, vg->pool_metadata_spare_lv, &void_handle))
+ return_ECMD_FAILED;
+
if (!lockd_free_vg_before(cmd, vg, 0))
return_ECMD_FAILED;

View File

@ -1,106 +0,0 @@
WHATS_NEW | 1 +
lib/metadata/pool_manip.c | 11 +++++++++++
man/vgsplit.8_pregen | 9 +++++++++
tools/command-lines.in | 2 +-
tools/vgsplit.c | 8 ++++++++
5 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 097160e..0b8e3f2 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.13 -
===============================
+ Support --poolmetadataspare with vgsplit.
Fix detection of active components of external origin volume.
Add vdoimport tool to support conversion of VDO volumes.
Support configurable allocation/vdo_pool_header_size.
diff --git a/lib/metadata/pool_manip.c b/lib/metadata/pool_manip.c
index 9ceec3a..e451e92 100644
--- a/lib/metadata/pool_manip.c
+++ b/lib/metadata/pool_manip.c
@@ -722,6 +722,17 @@ int handle_pool_metadata_spare(struct volume_group *vg, uint32_t extents,
return 1;
}
+ if (!extents) {
+ /* pmspare is not needed */
+ if (lv) {
+ log_debug_metadata("Dropping unused pool metadata spare LV %s.",
+ display_lvname(lv));
+ if (!lv_remove_single(vg->cmd, lv, DONT_PROMPT, 0))
+ return_0;
+ }
+ return 1;
+ }
+
if (extents > MAX_SIZE)
extents = MAX_SIZE;
diff --git a/man/vgsplit.8_pregen b/man/vgsplit.8_pregen
index 331c6e4..8a0ae59 100644
--- a/man/vgsplit.8_pregen
+++ b/man/vgsplit.8_pregen
@@ -70,6 +70,8 @@ Common options for command:
.hy
]
.br
+[ \fB--poolmetadataspare\fP \fBy\fP|\fBn\fP ]
+.br
[ \fB--\fP[\fBvg\fP]\fBmetadatacopies\fP \fBall\fP|\fBunmanaged\fP|\fINumber\fP ]
.ad b
.RE
@@ -235,6 +237,13 @@ Move only PVs used by the named LV.
Disable locking.
.
.HP
+\fB--poolmetadataspare\fP \fBy\fP|\fBn\fP
+.br
+Enable or disable the automatic creation and management of a
+spare pool metadata LV in the VG. A spare metadata LV is reserved
+space that can be used when repairing a pool.
+.
+.HP
\fB--profile\fP \fIString\fP
.br
An alias for --commandprofile or --metadataprofile, depending
diff --git a/tools/command-lines.in b/tools/command-lines.in
index 8607305..a4785b3 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -1912,7 +1912,7 @@ ID: vgscan_general
---
-OO_VGSPLIT: --autobackup Bool
+OO_VGSPLIT: --autobackup Bool, --poolmetadataspare Bool
# used only when the destination VG is new
OO_VGSPLIT_NEW: --alloc Alloc,
diff --git a/tools/vgsplit.c b/tools/vgsplit.c
index 296248e..a085ac2 100644
--- a/tools/vgsplit.c
+++ b/tools/vgsplit.c
@@ -525,6 +525,7 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
int existing_vg = 0;
int r = ECMD_FAILED;
const char *lv_name;
+ int poolmetadataspare = arg_int_value(cmd, poolmetadataspare_ARG, DEFAULT_POOL_METADATA_SPARE);
if ((arg_is_set(cmd, name_ARG) + argc) < 3) {
log_error("Existing VG, new VG and either physical volumes "
@@ -699,6 +700,13 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
*/
vg_to->status |= EXPORTED_VG;
+
+ if (!handle_pool_metadata_spare(vg_to, 0, &vg_to->pvs, poolmetadataspare))
+ goto_bad;
+
+ if (!handle_pool_metadata_spare(vg_from, 0, &vg_from->pvs, poolmetadataspare))
+ goto_bad;
+
if (!archive(vg_to))
goto_bad;

View File

@ -1,23 +0,0 @@
tools/pvmove.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/tools/pvmove.c b/tools/pvmove.c
index da635a6..bb372f7 100644
--- a/tools/pvmove.c
+++ b/tools/pvmove.c
@@ -387,6 +387,15 @@ static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd,
return NULL;
}
+ if (lv_is_writecache(lv)) {
+ struct logical_volume *lv_cachevol = first_seg(lv)->writecache;
+ if (lv_is_on_pvs(lv_cachevol, source_pvl)) {
+ log_error("Unable to move device used for writecache cachevol %s.", display_lvname(lv_cachevol));
+ return NULL;
+ }
+
+ }
+
if (lv_is_raid(lv) && lv_raid_has_integrity(lv)) {
log_error("Unable to pvmove device used for raid with integrity.");
return NULL;

View File

@ -1,17 +0,0 @@
lib/metadata/metadata.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 002d80c..1f65045 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -4402,6 +4402,9 @@ int lv_on_pmem(struct logical_volume *lv)
dm_list_iterate_items(seg, &lv->segments) {
for (s = 0; s < seg->area_count; s++) {
+ if (seg_type(seg, s) != AREA_PV)
+ continue;
+
pv = seg_pv(seg, s);
if (dev_is_pmem(lv->vg->cmd->dev_types, pv->dev)) {

View File

@ -1,25 +0,0 @@
From 155d8c55086b09528de799425e77f7aeafd9b165 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Thu, 9 Sep 2021 15:22:20 +0200
Subject: [PATCH 2/5] tests: check lvm2 parses vdo statistics
(cherry picked from commit bd2dae464386033241afa35934cdeddfe47f6a77)
---
test/shell/lvcreate-vdo.sh | 1 +
1 file changed, 1 insertion(+)
diff --git a/test/shell/lvcreate-vdo.sh b/test/shell/lvcreate-vdo.sh
index d66e353..5b370fb 100644
--- a/test/shell/lvcreate-vdo.sh
+++ b/test/shell/lvcreate-vdo.sh
@@ -47,6 +47,7 @@ fi
check lv_field $vg/$lv1 size "<1.24g"
check lv_field $vg/${lv2} size "4.00g"
check lv_field $vg/${lv2}_vdata size "4.00g"
+check lv_field $vg/${lv1} data_percent "0.00"
lvremove -ff $vg
--
1.8.3.1

View File

@ -1,86 +0,0 @@
From deb36d236e2dd86ddc16b33d5ca8c648cc8ed369 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Wed, 1 Sep 2021 15:46:04 +0200
Subject: [PATCH 3/5] vdo: better message for missing device
Show readable message when passed device cannot be accessed.
And use STAT shell var wrapper to call 'stat' command.
(cherry picked from commit 3287d37f440ca272b52f900fc60ee5effcf73697)
Conflicts:
scripts/lvm_import_vdo.sh
---
scripts/lvm_import_vdo.sh | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/scripts/lvm_import_vdo.sh b/scripts/lvm_import_vdo.sh
index f8dd71f..dec32bc 100755
--- a/scripts/lvm_import_vdo.sh
+++ b/scripts/lvm_import_vdo.sh
@@ -18,8 +18,8 @@
#
# Needed utilities:
# lvm, dmsetup,
-# vdo, vdo2lvm,
-# grep, awk, sed, blockdev, readlink, mkdir
+# vdo,
+# grep, awk, sed, blockdev, readlink, stat, mkdir
#
# Conversion is using 'vdo convert' support from VDO manager to move
# existing VDO header by 2M which makes space to place in PV header
@@ -40,6 +40,7 @@ VDOCONF=${VDOCONF:-}
BLOCKDEV="blockdev"
READLINK="readlink"
READLINK_E="-e"
+STAT="stat"
MKDIR="mkdir"
DMSETUP="dmsetup"
@@ -156,8 +157,8 @@ detect_lv_() {
local MAJORMINOR
DEVICE=${1/#"${DM_DEV_DIR}/"/}
- DEVICE=$("$READLINK" $READLINK_E "$DM_DEV_DIR/$DEVICE")
- test -n "$DEVICE" || error "Cannot get readlink \"$1\"."
+ DEVICE=$("$READLINK" $READLINK_E "$DM_DEV_DIR/$DEVICE" || true)
+ test -n "$DEVICE" || error "Readlink cannot access device \"$1\"."
RDEVICE=$DEVICE
case "$RDEVICE" in
# hardcoded /dev since udev does not create these entries elsewhere
@@ -168,9 +169,9 @@ detect_lv_() {
DEVMINOR=${MAJORMINOR##*:}
;;
*)
- STAT=$(stat --format "DEVMAJOR=\$((0x%t)) DEVMINOR=\$((0x%T))" "$RDEVICE")
- test -n "$STAT" || error "Cannot get major:minor for \"$DEVICE\"."
- eval "$STAT"
+ RSTAT=$("$STAT" --format "DEVMAJOR=\$((0x%t)) DEVMINOR=\$((0x%T))" "$RDEVICE" || true)
+ test -n "$RSTAT" || error "Cannot get major:minor for \"$DEVICE\"."
+ eval "$RSTAT"
;;
esac
@@ -269,8 +270,8 @@ convert2lvm_() {
for i in $(awk '/.*device:/ {print $2}' "$TEMPDIR/vdoconf.yml") ; do
local DEV
DEV=$("$READLINK" $READLINK_E "$i") || continue
- STAT=$(stat --format "MAJOR=\$((0x%t)) MINOR=\$((0x%T))" "$DEV" 2>/dev/null) || continue
- eval "$STAT"
+ RSTAT=$("$STAT" --format "MAJOR=\$((0x%t)) MINOR=\$((0x%T))" "$DEV" 2>/dev/null) || continue
+ eval "$RSTAT"
test "$MAJOR" = "$DEVMAJOR" && test "$MINOR" = "$DEVMINOR" && {
test -z "$FOUND" || error "VDO configuration contains duplicate entries $FOUND and $i"
FOUND=$i
@@ -287,7 +288,7 @@ convert2lvm_() {
DM_OPEN="$("$DMSETUP" info -c -o open "$VDONAME" --noheadings --nameprefixes 2>/dev/null || true)"
case "$DM_OPEN" in
Device*) ;; # no devices
- *) eval "$DM_OPEN"
+ *) eval "$DM_OPEN"
test "${DM_OPEN:-0}" -eq 0 || error "Cannot converted VDO volume \"$VDONAME\" which is in use!"
;;
esac
--
1.8.3.1

View File

@ -1,28 +0,0 @@
From 70467e905cea0811c269faf7e84f24d4e1c758cc Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Mon, 30 Aug 2021 18:12:59 +0200
Subject: [PATCH 5/5] vdo: fix conversion of large virtual sizes
Properly accept virtual sizes above 2TiB.
(cherry picked from commit 4afe872fd6c43fcfcd519c862574d010cdbda653)
---
tools/lvconvert.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index f87ee78..518b48f 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -5462,7 +5462,7 @@ static int _lvconvert_to_vdopool_single(struct cmd_context *cmd,
return_0;
lvc.virtual_extents = extents_from_size(cmd,
- arg_uint_value(cmd, virtualsize_ARG, 0),
+ arg_uint64_value(cmd, virtualsize_ARG, UINT64_C(0)),
vg->extent_size);
if (!(lvc.segtype = get_segtype_from_string(cmd, SEG_TYPE_NAME_VDO)))
--
1.8.3.1

View File

@ -1,256 +0,0 @@
From 5d0756fc33bced8453fb5cf5807c5a3fa2b59dbb Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Tue, 31 Aug 2021 20:52:26 +0200
Subject: [PATCH 1/5] vdo: fixes
Better identify VDO device with major:minor.
Handle different LV name from originally converted origin LV.
Improve --dry-run handling.
(cherry picked from commit 1ae157a0f67e984ef3037d19d62b84a3b0201c84)
---
WHATS_NEW | 4 +++
scripts/lvm_import_vdo.sh | 70 +++++++++++++++++++++++++++++++++++------------
test/shell/vdo-convert.sh | 28 ++++++++++++++-----
3 files changed, 78 insertions(+), 24 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 3637e31..b751009 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,9 @@
Version 2.03.14 -
==================================
+ Improve lvm_import_vdo script.
+ Support VDO LV with lvcreate -ky.
+ Fix lvconvert for VDO LV bigger then 2T.
+ Create VDO LVs automatically without zeroing.
Rename vdoimport to lvm_import_vdo.
Version 2.03.13 -
diff --git a/scripts/lvm_import_vdo.sh b/scripts/lvm_import_vdo.sh
index 35140a0..bc73306 100755
--- a/scripts/lvm_import_vdo.sh
+++ b/scripts/lvm_import_vdo.sh
@@ -41,10 +41,15 @@ BLOCKDEV="blockdev"
READLINK="readlink"
READLINK_E="-e"
MKDIR="mkdir"
+DMSETUP="dmsetup"
TEMPDIR="${TMPDIR:-/tmp}/${TOOL}_${RANDOM}$$"
DM_DEV_DIR="${DM_DEV_DIR:-/dev}"
+DEVICENAME=""
+DEVMAJOR=0
+DEVMINOR=0
+
DRY=0
VERB=""
FORCE=""
@@ -147,8 +152,6 @@ get_largest_extent_size_() {
# dereference device name if it is symbolic link
detect_lv_() {
local DEVICE=$1
- local MAJOR
- local MINOR
local SYSVOLUME
local MAJORMINOR
@@ -161,17 +164,21 @@ detect_lv_() {
/dev/dm-[0-9]*)
read -r <"/sys/block/${RDEVICE#/dev/}/dm/name" SYSVOLUME 2>&1 && DEVICE="$DM_DEV_DIR/mapper/$SYSVOLUME"
read -r <"/sys/block/${RDEVICE#/dev/}/dev" MAJORMINOR 2>&1 || error "Cannot get major:minor for \"$DEVICE\"."
- MAJOR=${MAJORMINOR%%:*}
- MINOR=${MAJORMINOR##*:}
+ DEVMAJOR=${MAJORMINOR%%:*}
+ DEVMINOR=${MAJORMINOR##*:}
;;
*)
- STAT=$(stat --format "MAJOR=\$((0x%t)) MINOR=\$((0x%T))" "$RDEVICE")
+ STAT=$(stat --format "DEVMAJOR=\$((0x%t)) DEVMINOR=\$((0x%T))" "$RDEVICE")
test -n "$STAT" || error "Cannot get major:minor for \"$DEVICE\"."
eval "$STAT"
;;
esac
- eval "$(dmsetup info -c -j "$MAJOR" -m "$MINOR" -o uuid,name --noheadings --nameprefixes --separator ' ')"
+ DEV="$("$DMSETUP" info -c -j "$DEVMAJOR" -m "$DEVMINOR" -o uuid,name --noheadings --nameprefixes --separator ' ' 2>/dev/null)"
+ case "$DEV" in
+ Device*) ;; # no devices
+ *) eval "$DEV" ;;
+ esac
}
# parse yaml config files into 'prefix_yaml_part_names=("value")' strings
@@ -226,20 +233,26 @@ convert2lvm_() {
local TRVDONAME
local EXTENTSZ
local IS_LV=1
+ local FOUND=""
+ local MAJOR=0
+ local MINOR=0
+ local DM_VG_NAME
+ local DM_LV_NAME
DM_UUID=""
detect_lv_ "$DEVICE"
case "$DM_UUID" in
- LVM-*) eval "$(dmsetup splitname --nameprefixes --noheadings --separator ' ' "$DM_NAME")"
+ LVM-*) eval "$("$DMSETUP" splitname --nameprefixes --noheadings --separator ' ' "$DM_NAME")"
if [ -z "$VGNAME" ] || [ "$VGNAME" = "$LVNAME" ] ; then
VGNAME=$DM_VG_NAME
+ LVNAME=$DM_LV_NAME
elif test "$VGNAME" != "$DM_VG_NAME" ; then
error "Volume group name \"$VGNAME\" does not match name \"$DM_VG_NAME\" for device \"$DEVICE\"."
fi
;;
*) IS_LV=0
# Check $VGNANE does not already exists
- "$LVM" vgs "$VGNAME" && error "Cannot use already existing volume group name \"$VGNAME\"."
+ "$LVM" vgs "$VGNAME" >/dev/null 2>&1 && error "Cannot use already existing volume group name \"$VGNAME\"."
;;
esac
@@ -247,15 +260,37 @@ convert2lvm_() {
"$MKDIR" -p -m 0000 "$TEMPDIR" || error "Failed to create $TEMPDIR."
+ # TODO: might use directly /etc/vdoconf.yml (avoding need of 'vdo' manager)
verbose "Getting YAML VDO configuration."
"$VDO" printConfigFile $VDOCONF >"$TEMPDIR/vdoconf.yml"
- VDONAME=$(awk -v DNAME="$DEVICE" '/.*VDOService$/ {VNAME=substr($1, 0, length($1) - 1)} /[[:space:]]*device:/ { if ($2 ~ DNAME) {print VNAME}}' "$TEMPDIR/vdoconf.yml")
+ # Check list of devices in VDO configure file for their major:minor
+ # and match with given $DEVICE devmajor:devminor
+ for i in $(awk '/.*device:/ {print $2}' "$TEMPDIR/vdoconf.yml") ; do
+ local DEV
+ DEV=$("$READLINK" $READLINK_E "$i") || continue
+ STAT=$(stat --format "MAJOR=\$((0x%t)) MINOR=\$((0x%T))" "$DEV" 2>/dev/null) || continue
+ eval "$STAT"
+ test "$MAJOR" = "$DEVMAJOR" && test "$MINOR" = "$DEVMINOR" && {
+ test -z "$FOUND" || error "VDO configuration contains duplicate entries $FOUND and $i"
+ FOUND=$i
+ }
+ done
+
+ test -n "$FOUND" || error "Can't find matching device in vdo configuration file."
+ verbose "Found matching device $FOUND $MAJOR:$MINOR"
+
+ VDONAME=$(awk -v DNAME="$FOUND" '/.*VDOService$/ {VNAME=substr($1, 0, length($1) - 1)} /[[:space:]]*device:/ { if ($2 ~ DNAME) {print VNAME}}' "$TEMPDIR/vdoconf.yml")
TRVDONAME=$(echo "$VDONAME" | tr '-' '_')
# When VDO volume is 'active', check it's not mounted/being used
- eval "$(dmsetup info -c -o open "$VDONAME" --noheadings --nameprefixes || true)"
- test "${DM_OPEN:-0}" -eq 0 || error "Cannot converted VDO volume \"$VDONAME\" which is in use!"
+ DM_OPEN="$("$DMSETUP" info -c -o open "$VDONAME" --noheadings --nameprefixes 2>/dev/null || true)"
+ case "$DM_OPEN" in
+ Device*) ;; # no devices
+ *) eval "$DM_OPEN"
+ test "${DM_OPEN:-0}" -eq 0 || error "Cannot converted VDO volume \"$VDONAME\" which is in use!"
+ ;;
+ esac
#parse_yaml_ "$TEMPDIR/vdoconf.yml" _
eval "$(parse_yaml_ "$TEMPDIR/vdoconf.yml" _ | grep "$TRVDONAME" | sed -e "s/_config_vdos_$TRVDONAME/vdo/g")"
@@ -263,8 +298,7 @@ convert2lvm_() {
vdo_logicalSize=$(get_kb_size_with_unit_ "$vdo_logicalSize")
vdo_physicalSize=$(get_kb_size_with_unit_ "$vdo_physicalSize")
- verbose "Going to convert physical sized VDO device $vdo_physicalSize KiB."
- verbose "With logical volume of size $vdo_logicalSize KiB."
+ verbose "Converted VDO device has logical/physical size $vdo_logicalSize/$vdo_physicalSize KiB."
PARAMS=$(cat <<EOF
allocation {
@@ -313,7 +347,7 @@ EOF
pvfree=$(( pvfree / 1024 - 2048 )) # to KiB
else
- pvfree=$("$LVM" lvs -o size --units b --nosuffix --noheadings "$VGNAME/$LVNAME")
+ pvfree=$("$LVM" lvs -o size --units b --nosuffix --noheadings "$DM_VG_NAME/$DM_LV_NAME")
pvfree=$(( pvfree / 1024 )) # to KiB
fi
@@ -334,11 +368,11 @@ EOF
vg_extent_size=$(( vg_extent_size / 1024 ))
test "$vg_extent_size" -le "$EXTENTSZ" || {
- error "Please vgchange extent_size to at most $EXTENTSZ KiB or extend and align virtual size on $vg_extent_size KiB."
+ error "Please vgchange extent_size to at most $EXTENTSZ KiB or extend and align virtual size of VDO device on $vg_extent_size KiB."
}
verbose "Renaming existing LV to be used as _vdata volume for VDO pool LV."
- dry "$LVM" lvrename $YES $VERB "$VGNAME/$LVNAME" "$VGNAME/${LVNAME}_vpool" || {
- error "Rename of LV \"$VGNAME/$LVNAME\" failed, while VDO header has been already moved!"
+ dry "$LVM" lvrename $YES $VERB "$VGNAME/$DM_LV_NAME" "$VGNAME/${LVNAME}_vpool" || {
+ error "Rename of LV \"$VGNAME/$DM_LV_NAME\" failed, while VDO header has been already moved!"
}
fi
@@ -372,5 +406,7 @@ do
shift
done
+test -n "$DEVICENAME" || error "Device name is not specified. (see: $TOOL --help)"
+
# do conversion
convert2lvm_ "$DEVICENAME"
diff --git a/test/shell/vdo-convert.sh b/test/shell/vdo-convert.sh
index 2d16c97..493f415 100644
--- a/test/shell/vdo-convert.sh
+++ b/test/shell/vdo-convert.sh
@@ -61,22 +61,36 @@ lvm_import_vdo --dry-run -y -v --name $lv1 "$DM_DEV_DIR/$vg/$lv1"
lvm_import_vdo -y --name $lv1 "$DM_DEV_DIR/$vg/$lv1"
-# ATM needed - since we do not call 'vdo convert' in this case
-vdo remove $VDOCONF --force --name "$VDONAME" || true
+# ensure VDO device is not left in config file
+vdo remove $VDOCONF --force --name "$VDONAME" 2>/dev/null || true
+
+lvremove -f $vg
+
+
+# Test user can specify different VDO LV name (so the original LV is renamed)
+lvcreate -y -L5G -n $lv1 $vg
+
+vdo create $VDOCONF --name "$VDONAME" --device="$DM_DEV_DIR/$vg/$lv1" --vdoLogicalSize=10G
+
+lvm_import_vdo -y --name $vg/$lv2 "$DM_DEV_DIR/$vg/$lv1"
+
+check lv_exists $vg $lv2
+check lv_not_exists $vg $lv1
vgremove -f $vg
+# ensure VDO device is not left in config file
+vdo remove $VDOCONF --force --name "$VDONAME" 2>/dev/null || true
+
aux wipefs_a "$dev1"
# prepare 'unused' $vg2
vgcreate $vg2 "$dev2"
#
-# Check conversion of VDO volume on non-LV device
+# Check conversion of VDO volume on non-LV device and with >2T size
#
-vdo create $VDOCONF --name "$VDONAME" --device="$dev1" --vdoLogicalSize=31G
-
-mkfs -E nodiscard "$DM_DEV_DIR/mapper/$VDONAME"
+vdo create $VDOCONF --name "$VDONAME" --device="$dev1" --vdoLogicalSize=3T
# Fail with an already existing volume group $vg2
not lvm_import_vdo --dry-run -y -v --name $vg2/$lv1 "$dev1" |& tee err
@@ -87,7 +101,7 @@ vdo stop $VDOCONF --name "$VDONAME"
lvm_import_vdo -y -v --name $vg/$lv1 "$dev1"
-fsck -n "$DM_DEV_DIR/$vg/$lv1"
+check lv_field $vg/$lv1 size "3.00t"
vgremove -f $vg
--
1.8.3.1

View File

@ -1,28 +0,0 @@
From 60eb37394b536e3b969496611ff4b59b71123476 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Mon, 6 Sep 2021 14:57:43 +0200
Subject: [PATCH 2/5] vdo: lvm_import_vdo fix max_discard size
Use correct 4K units in lvm2 for max_discard VDO option.
(cherry picked from commit 8d5b7de54f21ce5e34d533599f9d5a42f2977cd5)
---
scripts/lvm_import_vdo.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/lvm_import_vdo.sh b/scripts/lvm_import_vdo.sh
index bc73306..f8dd71f 100755
--- a/scripts/lvm_import_vdo.sh
+++ b/scripts/lvm_import_vdo.sh
@@ -320,7 +320,7 @@ allocation {
vdo_logical_threads = $vdo_logicalThreads
vdo_physical_threads = $vdo_physicalThreads
vdo_write_policy = $vdo_writePolicy
- vdo_max_discard = $(( $(get_kb_size_with_unit_ "$vdo_maxDiscardSize") * 1024 ))
+ vdo_max_discard = $(( $(get_kb_size_with_unit_ "$vdo_maxDiscardSize") / 4 ))
vdo_pool_header_size = 0
}
EOF
--
1.8.3.1

View File

@ -1,29 +0,0 @@
From 4cf3e8bd846a171b4b945f289bf0c6f9c7b5864c Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Thu, 9 Sep 2021 18:10:13 +0200
Subject: [PATCH 3/5] vdo: lvm_import_vdo script needs to continue when vgname
does not exist
When the script cannot find vgname - it needs to continue to run.
(cherry picked from commit 9db4ddabc1cf912dee30e0e6293767f01c976a4a)
---
scripts/lvm_import_vdo.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/lvm_import_vdo.sh b/scripts/lvm_import_vdo.sh
index 70904f7..e5b30d8 100755
--- a/scripts/lvm_import_vdo.sh
+++ b/scripts/lvm_import_vdo.sh
@@ -262,7 +262,7 @@ convert2lvm_() {
if [ -z "$VGNAME" ] || [ "$VGNAME" = "$LVNAME" ] ; then
VGNAME=${DEFAULT_NAME%/*}
# Find largest matching VG name to our 'default' vgname
- LASTVGNAME=$(LC_ALL=C "$LVM" vgs -oname -O-name --noheadings -S name=~${VGNAME} | grep -E "$VGNAME[0-9]? ?" | head -1)
+ LASTVGNAME=$(LC_ALL=C "$LVM" vgs -oname -O-name --noheadings -S name=~${VGNAME} | grep -E "$VGNAME[0-9]? ?" | head -1 || true)
if test -n "$LASTVGNAME" ; then
LASTVGNAME=${LASTVGNAME#*${VGNAME}}
# If the number is becoming too high, try some random number
--
1.8.3.1

View File

@ -1,27 +0,0 @@
From 073cdd0ba8c39a0330e73773c92d78546d06e687 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Fri, 10 Sep 2021 01:15:01 +0200
Subject: [PATCH 4/5] vdo: man page updates
(cherry picked from commit 812653d59806439379d80bb8124f6962ae42d46a)
---
man/lvm_import_vdo.8_main | 3 +++
1 file changed, 3 insertions(+)
diff --git a/man/lvm_import_vdo.8_main b/man/lvm_import_vdo.8_main
index ee817a0..c6cb5c3 100644
--- a/man/lvm_import_vdo.8_main
+++ b/man/lvm_import_vdo.8_main
@@ -45,6 +45,9 @@ Specifies the name of converted VDO LV. When the name is not specified,
some automatic name is selected. In case the converted VDO volume is
already using LV a backend device, the name of this LV is used for VDO LV.
In this case also the of volume group must stay same.
+Automatic name may change between releases and currently selects
+"vdolv" as LV name and VG name is selected from sequence
+"vdovg", "vdovg1", ...
.
.TP
.BR -v | --verbose
--
1.8.3.1

View File

@ -1,185 +0,0 @@
From 6621116b61f4c9ee53166a994be2ef7d80a3c346 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Mon, 6 Sep 2021 15:06:32 +0200
Subject: [PATCH 4/5] vdo: more lvm_import_vdo fixes
Do not call 'dmsetup info' for non-dm devices.
Better handling for VGNAME and LVNAME - so when convering LV as
backend device automatically recognize it and reuse LV name for VDOLV.
Add prompt for final confirmation before actual conversion is started
(once confirmed, lvm2 commands no longer prompts to avoid leaving
conversion in the middle of its process.)
(cherry picked from commit 89595a366554191c3df1a18e1f82b79c450a21ad)
---
scripts/lvm_import_vdo.sh | 48 ++++++++++++++++++++++++++++++++++------
test/shell/vdo-convert.sh | 56 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 97 insertions(+), 7 deletions(-)
diff --git a/scripts/lvm_import_vdo.sh b/scripts/lvm_import_vdo.sh
index dec32bc..70904f7 100755
--- a/scripts/lvm_import_vdo.sh
+++ b/scripts/lvm_import_vdo.sh
@@ -50,6 +50,7 @@ DM_DEV_DIR="${DM_DEV_DIR:-/dev}"
DEVICENAME=""
DEVMAJOR=0
DEVMINOR=0
+PROMPTING=""
DRY=0
VERB=""
@@ -57,7 +58,8 @@ FORCE=""
YES=""
# default name for converted VG and its VDO LV
-NAME="vdovg/vdolvol"
+DEFAULT_NAME="vdovg/vdolvol"
+NAME=""
# help message
tool_usage() {
@@ -100,6 +102,7 @@ dry() {
cleanup() {
trap '' 2
+ test -z "$PROMPTING" || echo "No"
rm -rf "$TEMPDIR"
# error exit status for break
exit "${1:-1}"
@@ -175,7 +178,9 @@ detect_lv_() {
;;
esac
- DEV="$("$DMSETUP" info -c -j "$DEVMAJOR" -m "$DEVMINOR" -o uuid,name --noheadings --nameprefixes --separator ' ' 2>/dev/null)"
+ test "$DEVMAJOR" != "$(grep device-mapper /proc/devices | cut -f1 -d' ')" && return
+
+ DEV="$("$DMSETUP" info -c -j "$DEVMAJOR" -m "$DEVMINOR" -o uuid,name --noheadings --nameprefixes --separator ' ')"
case "$DEV" in
Device*) ;; # no devices
*) eval "$DEV" ;;
@@ -244,15 +249,31 @@ convert2lvm_() {
detect_lv_ "$DEVICE"
case "$DM_UUID" in
LVM-*) eval "$("$DMSETUP" splitname --nameprefixes --noheadings --separator ' ' "$DM_NAME")"
- if [ -z "$VGNAME" ] || [ "$VGNAME" = "$LVNAME" ] ; then
+ if [ -z "$VGNAME" ] || [ "$VGNAME" = "$LVNAME" ] ; then
VGNAME=$DM_VG_NAME
- LVNAME=$DM_LV_NAME
+ verbose "Using existing volume group name $VGNAME."
+ test -n "$LVNAME" || LVNAME=$DM_LV_NAME
elif test "$VGNAME" != "$DM_VG_NAME" ; then
- error "Volume group name \"$VGNAME\" does not match name \"$DM_VG_NAME\" for device \"$DEVICE\"."
+ error "Volume group name \"$VGNAME\" does not match name \"$DM_VG_NAME\" for VDO device \"$DEVICE\"."
fi
;;
- *) IS_LV=0
- # Check $VGNANE does not already exists
+ *) IS_LV=0
+ # Check if we need to generate unused $VGNANE
+ if [ -z "$VGNAME" ] || [ "$VGNAME" = "$LVNAME" ] ; then
+ VGNAME=${DEFAULT_NAME%/*}
+ # Find largest matching VG name to our 'default' vgname
+ LASTVGNAME=$(LC_ALL=C "$LVM" vgs -oname -O-name --noheadings -S name=~${VGNAME} | grep -E "$VGNAME[0-9]? ?" | head -1)
+ if test -n "$LASTVGNAME" ; then
+ LASTVGNAME=${LASTVGNAME#*${VGNAME}}
+ # If the number is becoming too high, try some random number
+ test "$LASTVGNAME" -gt 99999999 2>/dev/null && LASTVGNAME=$RANDOM
+ # Generate new unused VG name
+ VGNAME="${VGNAME}$(( ${LASTVGNAME} + 1 ))"
+ verbose "Selected unused volume group name $VGNAME."
+ fi
+ fi
+ # New VG is created, LV name should be always unused.
+ test -n "$LVNAME" || LVNAME=${DEFAULT_NAME#*/}
"$LVM" vgs "$VGNAME" >/dev/null 2>&1 && error "Cannot use already existing volume group name \"$VGNAME\"."
;;
esac
@@ -328,6 +349,19 @@ EOF
)
verbose "VDO conversion paramaters: $PARAMS"
+ # If user has not provided '--yes', prompt before conversion
+ if test -z "$YES" ; then
+ PROMPTING=yes
+ echo -n "Convert VDO device \"$DEVICE\" to VDO LV \"$VGNAME/$LVNAME\"? [y|N]: "
+ read -n 1 -s ANSWER
+ case "${ANSWER:0:1}" in
+ y|Y ) echo "Yes" ;;
+ * ) echo "No" ; PROMPTING=""; exit ;;
+ esac
+ PROMPTING=""
+ YES="-y" # From now, now prompting
+ fi
+
verbose "Stopping VDO volume."
dry "$VDO" stop $VDOCONF --name "$VDONAME"
diff --git a/test/shell/vdo-convert.sh b/test/shell/vdo-convert.sh
index 493f415..632f86a 100644
--- a/test/shell/vdo-convert.sh
+++ b/test/shell/vdo-convert.sh
@@ -122,3 +122,59 @@ fsck -n "$DM_DEV_DIR/$vg1/$lv2"
vgremove -f $vg1
+aux teardown_devs
+
+
+# Check with some real non-DM device from system
+# this needs to dropping DM_DEV_DIR
+
+aux prepare_loop 60000 || skip
+
+test -f LOOP
+LOOP=$(< LOOP)
+
+aux extend_filter "a|$LOOP|"
+aux extend_devices "$LOOP"
+
+#
+# Unfortunatelly generates this in syslog:
+#
+# vdo-start-by-dev@loop0.service: Main process exited, code=exited, status=1/FAILURE
+# vdo-start-by-dev@loop0.service: Failed with result 'exit-code'.
+# Failed to start Start VDO volume backed by loop0.
+#
+# TODO: Could be handled by:
+#
+# systemctl mask vdo-start-by-dev@
+# systemctl unmask vdo-start-by-dev@
+#
+# automate...
+#
+vdo create $VDOCONF --name "$VDONAME" --device="$LOOP" --vdoLogicalSize=23G \
+ --blockMapCacheSize 192 \
+ --blockMapPeriod 2048 \
+ --emulate512 disabled \
+ --indexMem 0.5 \
+ --maxDiscardSize 10 \
+ --sparseIndex disabled \
+ --vdoAckThreads 2 \
+ --vdoBioRotationInterval 8 \
+ --vdoBioThreads 2 \
+ --vdoCpuThreads 5 \
+ --vdoHashZoneThreads 3 \
+ --vdoLogicalThreads 3 \
+ --writePolicy async-unsafe
+
+# Get VDO table line
+dmsetup table "$VDONAME" | tr " " "\n" | sed -e '5,6d' -e '12d' | tee vdo-orig
+
+DM_DEV_DIR= lvm_import_vdo -y --name $vg/$lv "$LOOP"
+lvs -a $vg
+
+dmsetup table "$vg-${lv}_vpool-vpool" | tr " " "\n" | sed -e '5,6d' -e '12d' | tee new-vdo-lv
+
+# Check there is a match between VDO and LV managed volume
+# (when differentiating parameters are deleted first)
+diff -u vdo-orig new-vdo-lv || die "Found mismatching VDO table lines!"
+
+check lv_field $vg/$lv size "23.00g"
--
1.8.3.1

View File

@ -1,28 +0,0 @@
From f3f99d45b89d415528e21a66f94ab4576f95ba56 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Fri, 10 Sep 2021 22:39:23 +0200
Subject: [PATCH 5/5] vdo: prompt with no return failure
Exit 1 (failure) when prompt for conversion is answered as 'No'.
(cherry picked from commit 3b24c0fe4e197383101eae53b14f19586cf2eda1)
---
scripts/lvm_import_vdo.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/lvm_import_vdo.sh b/scripts/lvm_import_vdo.sh
index e5b30d8..06a043c 100755
--- a/scripts/lvm_import_vdo.sh
+++ b/scripts/lvm_import_vdo.sh
@@ -356,7 +356,7 @@ EOF
read -n 1 -s ANSWER
case "${ANSWER:0:1}" in
y|Y ) echo "Yes" ;;
- * ) echo "No" ; PROMPTING=""; exit ;;
+ * ) echo "No" ; PROMPTING=""; exit 1 ;;
esac
PROMPTING=""
YES="-y" # From now, now prompting
--
1.8.3.1

View File

@ -1,184 +0,0 @@
From 1c6992d37eff5af7134a11b662eacc1bab538ac2 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Thu, 9 Sep 2021 14:59:38 +0200
Subject: [PATCH 1/5] vdo: read new sysfs path
New versions of kvdo module exposes statistics at new location:
/sys/block/dm-XXX/vdo/statistics/...
Enhance lvm2 to access this location first.
Also if the statistic info is missing - make it 'debug' level info,
so it is not failing 'lvs' command.
(cherry picked from commit e6f735d411e5911de186a610932c9bb9638275eb)
Conflicts:
WHATS_NEW
---
WHATS_NEW | 1 +
lib/activate/dev_manager.c | 7 +++---
lib/metadata/metadata-exported.h | 3 ++-
lib/metadata/vdo_manip.c | 46 ++++++++++++++++++++++------------------
4 files changed, 32 insertions(+), 25 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index b751009..c5a5ca5 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.14 -
==================================
+ Support newer location for VDO statistics.
Improve lvm_import_vdo script.
Support VDO LV with lvcreate -ky.
Fix lvconvert for VDO LV bigger then 2T.
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index c4a6739..0d954d1 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -157,6 +157,7 @@ out:
static int _get_segment_status_from_target_params(const char *target_name,
const char *params,
+ const struct dm_info *dminfo,
struct lv_seg_status *seg_status)
{
const struct lv_segment *seg = seg_status->seg;
@@ -216,7 +217,7 @@ static int _get_segment_status_from_target_params(const char *target_name,
return_0;
seg_status->type = SEG_STATUS_SNAPSHOT;
} else if (segtype_is_vdo_pool(segtype)) {
- if (!parse_vdo_pool_status(seg_status->mem, seg->lv, params, &seg_status->vdo_pool))
+ if (!parse_vdo_pool_status(seg_status->mem, seg->lv, params, dminfo, &seg_status->vdo_pool))
return_0;
seg_status->type = SEG_STATUS_VDO_POOL;
} else if (segtype_is_writecache(segtype)) {
@@ -320,7 +321,7 @@ static int _info_run(const char *dlid, struct dm_info *dminfo,
} while (target);
if (!target_name ||
- !_get_segment_status_from_target_params(target_name, target_params, seg_status))
+ !_get_segment_status_from_target_params(target_name, target_params, dminfo, seg_status))
stack;
}
@@ -1886,7 +1887,7 @@ int dev_manager_vdo_pool_status(struct dev_manager *dm,
goto out;
}
- if (!parse_vdo_pool_status(dm->mem, lv, params, *status))
+ if (!parse_vdo_pool_status(dm->mem, lv, params, &info, *status))
goto_out;
(*status)->mem = dm->mem;
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index adbbe76..7c21b4d 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -1364,7 +1364,8 @@ const char *get_vdo_write_policy_name(enum dm_vdo_write_policy policy);
uint64_t get_vdo_pool_virtual_size(const struct lv_segment *vdo_pool_seg);
int update_vdo_pool_virtual_size(struct lv_segment *vdo_pool_seg);
int parse_vdo_pool_status(struct dm_pool *mem, const struct logical_volume *vdo_pool_lv,
- const char *params, struct lv_status_vdo *status);
+ const char *params, const struct dm_info *dminfo,
+ struct lv_status_vdo *status);
struct logical_volume *convert_vdo_pool_lv(struct logical_volume *data_lv,
const struct dm_vdo_target_params *vtp,
uint32_t *virtual_extents,
diff --git a/lib/metadata/vdo_manip.c b/lib/metadata/vdo_manip.c
index 3f2de1a..2917f29 100644
--- a/lib/metadata/vdo_manip.c
+++ b/lib/metadata/vdo_manip.c
@@ -123,48 +123,56 @@ int update_vdo_pool_virtual_size(struct lv_segment *vdo_pool_seg)
return 1;
}
-static int _sysfs_get_kvdo_value(const char *dm_name, const char *vdo_param, uint64_t *value)
+static int _sysfs_get_kvdo_value(const char *dm_name, const struct dm_info *dminfo,
+ const char *vdo_param, uint64_t *value)
{
char path[PATH_MAX];
char temp[64];
int fd, size, r = 0;
- if (dm_snprintf(path, sizeof(path), "%skvdo/%s/%s",
- dm_sysfs_dir(), dm_name, vdo_param) < 0) {
- log_error("Failed to build kmod path.");
+ if (dm_snprintf(path, sizeof(path), "%s/block/dm-%d/vdo/%s",
+ dm_sysfs_dir(), dminfo->minor, vdo_param) < 0) {
+ log_debug("Failed to build kvdo path.");
return 0;
}
if ((fd = open(path, O_RDONLY)) < 0) {
- if (errno != ENOENT)
- log_sys_error("open", path);
- else
+ /* try with older location */
+ if (dm_snprintf(path, sizeof(path), "%skvdo/%s/%s",
+ dm_sysfs_dir(), dm_name, vdo_param) < 0) {
+ log_debug("Failed to build kvdo path.");
+ return 0;
+ }
+
+ if ((fd = open(path, O_RDONLY)) < 0) {
log_sys_debug("open", path);
- goto bad;
+ goto bad;
+ }
}
if ((size = read(fd, temp, sizeof(temp) - 1)) < 0) {
- log_sys_error("read", path);
+ log_sys_debug("read", path);
goto bad;
}
temp[size] = 0;
errno = 0;
*value = strtoll(temp, NULL, 0);
if (errno) {
- log_sys_error("strtool", path);
+ log_sys_debug("strtool", path);
goto bad;
}
r = 1;
bad:
if (fd >= 0 && close(fd))
- log_sys_error("close", path);
+ log_sys_debug("close", path);
return r;
}
int parse_vdo_pool_status(struct dm_pool *mem, const struct logical_volume *vdo_pool_lv,
- const char *params, struct lv_status_vdo *status)
+ const char *params, const struct dm_info *dminfo,
+ struct lv_status_vdo *status)
{
struct dm_vdo_status_parse_result result;
char *dm_name;
@@ -188,15 +196,11 @@ int parse_vdo_pool_status(struct dm_pool *mem, const struct logical_volume *vdo_
status->vdo = result.status;
- if (result.status->operating_mode == DM_VDO_MODE_NORMAL) {
- if (!_sysfs_get_kvdo_value(dm_name, "statistics/data_blocks_used",
- &status->data_blocks_used))
- return_0;
-
- if (!_sysfs_get_kvdo_value(dm_name, "statistics/logical_blocks_used",
- &status->logical_blocks_used))
- return_0;
-
+ if ((result.status->operating_mode == DM_VDO_MODE_NORMAL) &&
+ _sysfs_get_kvdo_value(dm_name, dminfo, "statistics/data_blocks_used",
+ &status->data_blocks_used) &&
+ _sysfs_get_kvdo_value(dm_name, dminfo, "statistics/logical_blocks_used",
+ &status->logical_blocks_used)) {
status->usage = dm_make_percent(result.status->used_blocks,
result.status->total_blocks);
status->saving = dm_make_percent(status->logical_blocks_used - status->data_blocks_used,
--
1.8.3.1

View File

@ -1,146 +0,0 @@
man/lvconvert.8_pregen | 2 +-
man/lvmdevices.8_pregen | 79 ++++++++++++++++++++++++++++++++++++++++---------
2 files changed, 66 insertions(+), 15 deletions(-)
diff --git a/man/lvconvert.8_pregen b/man/lvconvert.8_pregen
index d733ab6..4fafe5d 100644
--- a/man/lvconvert.8_pregen
+++ b/man/lvconvert.8_pregen
@@ -670,7 +670,7 @@ Convert LV to type thin-pool.
.RE
.P
.RS 4
-LV1 types: linear striped cache raid error zero
+LV1 types: linear striped cache raid error zero writecache
.RE
.P
\(em
diff --git a/man/lvmdevices.8_pregen b/man/lvmdevices.8_pregen
index 267ce96..fa85362 100644
--- a/man/lvmdevices.8_pregen
+++ b/man/lvmdevices.8_pregen
@@ -28,6 +28,8 @@ lvmdevices \(em Manage the devices file
.br
\fB--delpvid\fP \fIString\fP
.br
+ \fB--deviceidtype\fP \fIString\fP
+.br
\fB--devices\fP \fIPV\fP
.br
\fB--devicesfile\fP \fIString\fP
@@ -70,18 +72,18 @@ remove it from the devices file with lvmdevices --deldev. The
vgimportdevices(8) command adds all PVs from a VG to the devices file,
and updates the VG metadata to include device IDs of the PVs.
.P
-Commands adding new devices to the devices file necessarily look outside
-the existing devices file to find the devices to add. pvcreate, vgcreate,
-and vgextend also look outside the devices file to create new PVs and add
-them to the devices file.
+Commands that add new devices to the devices file necessarily look outside
+the existing devices file to find the devices being added. pvcreate,
+vgcreate, and vgextend also look outside the devices file to create new
+PVs and add those PVs to the devices file.
.P
LVM records devices in the devices file using hardware-specific IDs, such
as the WWID, and attempts to use subsystem-specific IDs for virtual device
-types (which also aim to be as unique and stable as possible.)
-These device IDs are also written in the VG metadata. When no hardware or
+types (which also aim to be as unique and stable as possible.) These
+device IDs are also written in the VG metadata. When no hardware or
virtual ID is available, lvm falls back using the unstable device name as
-the device ID. When devnames are used, lvm performs extra scanning to
-find devices if their devname changes, e.g. after reboot.
+the device ID. When devnames are used as IDs, lvm performs extra scanning
+to find devices if their devname changes, e.g. after reboot.
.P
When proper device IDs are used, an lvm command will not look at devices
outside the devices file, but when devnames are used as a fallback, lvm
@@ -95,12 +97,13 @@ overriding the devices file. The listed devices act as a sort of devices
file in terms of limiting which devices lvm will see and use. Devices
that are not listed will appear to be missing to the lvm command.
.P
-Multiple devices files can be kept in \fI#DEFAULT_SYS_DIR#/devices\fP, which allows lvm
-to be used with different sets of devices, e.g. system devices do not need
-to be exposed to a specific application, and the application can use lvm on
-its own devices that are not exposed to the system. The option
---devicesfile <filename> is used to select the devices file to use with the
-command. Without the option set, the default system devices file is used.
+Multiple devices files can be kept \fI#DEFAULT_SYS_DIR#/devices\fP, which
+allows lvm to be used with different sets of devices. For example, system
+devices do not need to be exposed to a specific application, and the
+application can use lvm on its own devices that are not exposed to the
+system. The option --devicesfile <filename> is used to select the devices
+file to use with the command. Without the option set, the default system
+devices file is used.
.P
Setting --devicesfile "" causes lvm to not use a devices file.
.P
@@ -120,6 +123,45 @@ if it does not yet exist.
.P
It is recommended to use lvm commands to make changes to the devices file to
ensure proper updates.
+.P
+The device ID and device ID type are included in the VG metadata and can
+be reported with pvs -o deviceid,deviceidtype. (Note that the lvmdevices
+command does not update VG metadata, but subsequent lvm commands modifying
+the metadata will include the device ID.)
+.P
+Possible device ID types are:
+.br
+.IP \[bu] 2
+.B sys_wwid
+uses the wwid reported by sysfs. This is the first choice for non-virtual
+devices.
+.IP \[bu] 2
+.B sys_serial
+uses the serial number reported by sysfs. This is the second choice for
+non-virtual devices.
+.IP \[bu] 2
+.B mpath_uuid
+is used for dm multipath devices, reported by sysfs.
+.IP \[bu] 2
+.B crypt_uuid
+is used for dm crypt devices, reported by sysfs.
+.IP \[bu] 2
+.B md_uuid
+is used for md devices, reported by sysfs.
+.B lvmlv_uuid
+is used if a PV is placed on top of an lvm LV, reported by sysfs.
+.IP \[bu] 2
+.B loop_file
+is used for loop devices, the backing file name repored by sysfs.
+.IP \[bu] 2
+.B devname
+the device name is used if no other type applies.
+.P
+
+The default choice for device ID type can be overriden using lvmdevices
+--addev --deviceidtype <type>. If the specified type is available for the
+device it will be used, otherwise the device will be added using the type
+that would otherwise be chosen.
.
.SH USAGE
.
@@ -169,6 +211,8 @@ Add a device to the devices file.
.br
.RS 4
.ad l
+[ \fB--deviceidtype\fP \fIString\fP ]
+.br
[ COMMON_OPTIONS ]
.ad b
.RE
@@ -308,6 +352,13 @@ Remove a device from the devices file.
Remove a device with the PVID from the devices file.
.
.HP
+\fB--deviceidtype\fP \fIString\fP
+.br
+The type of device ID to use for the device.
+If the specified type is available for the device,
+then it will override the default type that lvm would use.
+.
+.HP
\fB--devices\fP \fIPV\fP
.br
Devices that the command can use. This option can be repeated

View File

@ -3,16 +3,16 @@
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/VERSION b/VERSION
index d9c3e23..2610861 100644
index 0a36180..57ed15e 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.03.12(2) (2021-05-07)
+2.03.12(2)-RHEL8 (2021-05-19)
-2.03.14(2) (2021-10-20)
+2.03.14(2)-RHEL8 (2021-10-20)
diff --git a/VERSION_DM b/VERSION_DM
index 6105a0f..0991c69 100644
index 52cb622..bf97bda 100644
--- a/VERSION_DM
+++ b/VERSION_DM
@@ -1 +1 @@
-1.02.177 (2021-05-07)
+1.02.177-RHEL8 (2021-05-19)
-1.02.181 (2021-10-20)
+1.02.181-RHEL8 (2021-10-20)

View File

@ -3,10 +3,10 @@
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/conf/example.conf.in b/conf/example.conf.in
index b4a55ae..aaf73a4 100644
index a78ed73..2c6ff25 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -121,8 +121,9 @@ devices {
@@ -116,8 +116,9 @@ devices {
#
# Example
# preferred_names = [ "^/dev/mpath/", "^/dev/mapper/mpath", "^/dev/[hs]d" ]
@ -19,10 +19,10 @@ index b4a55ae..aaf73a4 100644
# Configuration option devices/use_devicesfile.
# Enable or disable the use of a devices file.
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index d3a42a1..f5dac4d 100644
index d280e7a..1e6c20f 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -269,7 +269,7 @@ cfg(devices_hints_CFG, "hints", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_
@@ -257,7 +257,7 @@ cfg(devices_hints_CFG, "hints", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_
" Use no hints.\n"
"#\n")

View File

@ -1,4 +1,4 @@
%global device_mapper_version 1.02.177
%global device_mapper_version 1.02.181
%global enable_cache 1
%global enable_cluster 1
@ -41,6 +41,15 @@
%endif
%endif
%if %{enable_cluster}
%global configure_cluster --with-cluster=internal
%if %{enable_cmirror}
%global configure_cmirror --enable-cmirrord
%endif
%else
%global configure_cluster --with-cluster=internal
%endif
%global from_snapshot 0
%if 0%{?from_snapshot}
%global commit 4dc5d4ac7e7a9457ccc46ff04796b347e58bf4da
@ -55,11 +64,11 @@ Name: lvm2
%if 0%{?rhel}
Epoch: %{rhel}
%endif
Version: 2.03.12
Version: 2.03.14
%if 0%{?from_snapshot}
Release: 0.1.20210426git%{shortcommit}%{?dist}%{?rel_suffix}
%else
Release: 10%{?dist}%{?rel_suffix}
Release: 1%{?dist}%{?rel_suffix}
%endif
License: GPLv2
URL: http://sourceware.org/lvm2
@ -71,51 +80,6 @@ Patch0: lvm2-rhel8.patch
%endif
Patch1: lvm2-set-default-preferred_names.patch
Patch2: lvm2-test-skip-problematic-tests.patch
# BZ 1961890
Patch3: lvm2-2_03_13-vdo-fix-preload-of-kvdo.patch
# BZ 1964622:
Patch4: lvm2-2_03_13-lvremove-fix-removing-thin-pool-with-writecache-on-d.patch
# BZ 1957898:
Patch5: lvm2-2_03_13-enable-command-syntax-for-thin-and-writecache.patch
# BZ 1872903:
Patch6: lvm2-2_03_13-writecache-fix-lv_on_pmem.patch
Patch7: lvm2-2_03_13-writecache-don-t-pvmove-device-used-by-writecache.patch
# BZ 1957898:
Patch8: lvm2-2_03_13-lvconvert-allow-writecache-with-other-thinpool-comma.patch
# BZ 1922312:
Patch9: lvm2-2_03_13-devices-don-t-use-deleted-loop-backing-file-for-devi.patch
Patch10: lvm2-2_03_13-lvmdevices-add-deviceidtype-option.patch
# BZ 1974901:
Patch11: lvm2-2_03_13-device_id-handle-scsi_debug-wwid.patch
# BZ 1930261:
Patch12: lvm2-2_03_13-lvconvert-fix-vdo-virtual-size-when-specified.patch
Patch13: lvm2-2_03_13-vdo-rename-variable-vdo_pool_zero.patch
Patch14: lvm2-2_03_13-vdo-support-vdo_pool_header_size.patch
Patch15: lvm2-2_03_13-vdo-add-vdoimport-support.patch
Patch16: lvm2-2_03_13-man-vdoimport-page.patch
Patch17: lvm2-make-generate.patch
# BZ 1967744:
Patch18: lvm2-2_03_13-thin-fix-component-detection-of-external-origin.patch
# BZ 1899263:
Patch19: lvm2-2_03_13-vgremove-remove-forgotten-pmspare.patch
Patch20: lvm2-2_03_13-vgsplit-add-support-for-option-poolmetadataspare.patch
Patch21: lvm2-2_03_13-test.patch
Patch22: lvm2-2_03_13-vgmerge-remove-one-of-merge-pmspare-LVs.patch
Patch23: lvm2-2_03_13-vgmerge-support-option-poolmetadataspare.patch
Patch24: lvm2-2_03_13-tests-extend-vgmerge-testing.patch
# BZ 1986930:
Patch25: lvm2-2_03_14-vdo-Rename-vdoimport-to-lvm_import_vdo.patch
# BZs #1930261 #1986885 #1986915 #1988504 #1989650 #1996227:
Patch26: lvm2-2_03_14-vdo-fixes.patch
Patch27: lvm2-2_03_14-vdo-lvm_import_vdo-fix-max_discard-size.patch
Patch28: lvm2-2_03_14-vdo-better-message-for-missing-device.patch
Patch29: lvm2-2_03_14-vdo-more-lvm_import_vdo-fixes.patch
Patch30: lvm2-2_03_14-vdo-fix-conversion-of-large-virtual-sizes.patch
Patch31: lvm2-2_03_14-vdo-read-new-sysfs-path.patch
Patch32: lvm2-2_03_14-tests-check-lvm2-parses-vdo-statistics.patch
Patch33: lvm2-2_03_14-vdo-lvm_import_vdo-script-needs-to-continue-when-vgn.patch
Patch34: lvm2-2_03_14-vdo-man-page-updates.patch
Patch35: lvm2-2_03_14-vdo-prompt-with-no-return-failure.patch
BuildRequires: gcc
%if %{enable_testsuite}
@ -178,39 +142,6 @@ or more physical volumes and creating one or more logical volumes
%endif
%patch1 -p1 -b .backup1
%patch2 -p1 -b .backup2
%patch3 -p1 -b .backup3
%patch4 -p1 -b .backup4
%patch5 -p1 -b .backup5
%patch6 -p1 -b .backup6
%patch7 -p1 -b .backup7
%patch8 -p1 -b .backup8
%patch9 -p1 -b .backup9
%patch10 -p1 -b .backup10
%patch11 -p1 -b .backup11
%patch12 -p1 -b .backup12
%patch13 -p1 -b .backup13
%patch14 -p1 -b .backup14
%patch15 -p1 -b .backup15
%patch16 -p1 -b .backup16
%patch17 -p1 -b .backup17
%patch18 -p1 -b .backup18
%patch19 -p1 -b .backup19
%patch20 -p1 -b .backup20
%patch21 -p1 -b .backup21
%patch22 -p1 -b .backup22
%patch23 -p1 -b .backup23
%patch24 -p1 -b .backup24
%patch25 -p1 -b .backup25
%patch26 -p1 -b .backup26
%patch27 -p1 -b .backup27
%patch28 -p1 -b .backup28
%patch29 -p1 -b .backup29
%patch30 -p1 -b .backup30
%patch31 -p1 -b .backup31
%patch32 -p1 -b .backup32
%patch33 -p1 -b .backup33
%patch34 -p1 -b .backup34
%patch35 -p1 -b .backup35
%build
%global _default_pid_dir /run
@ -220,16 +151,6 @@ or more physical volumes and creating one or more logical volumes
%global _udevdir %{_prefix}/lib/udev/rules.d
# FIXME: Dropped in rhel9, do we need to keep this for "compatibility"?
%if %{enable_cluster}
%global configure_cluster --with-cluster=internal
%if %{enable_cmirror}
%global configure_cmirror --enable-cmirrord
%endif
%else
%global configure_cluster --with-cluster=internal
%endif
%configure \
--with-default-dm-run-dir=%{_default_dm_run_dir} \
--with-default-run-dir=%{_default_run_dir} \
@ -277,7 +198,6 @@ or more physical volumes and creating one or more logical volumes
%if %{enable_vdo}
--with-vdo=internal --with-vdo-format=%{_bindir}/vdoformat \
%endif
%{?configure_integrity} \
%if %{enable_integrity}
--with-integrity=internal \
%endif
@ -457,7 +377,7 @@ systemctl start lvm2-lvmpolld.socket >/dev/null 2>&1 || :
%{_mandir}/man8/vgscan.8.gz
%{_mandir}/man8/vgsplit.8.gz
%{_udevdir}/11-dm-lvm.rules
%{_udevdir}/69-dm-lvm-metad.rules
%{_udevdir}/69-dm-lvm.rules
%if %{enable_lvmpolld}
%{_mandir}/man8/lvmpolld.8.gz
%{_mandir}/man8/lvm-lvpoll.8.gz
@ -483,7 +403,7 @@ systemctl start lvm2-lvmpolld.socket >/dev/null 2>&1 || :
%{_tmpfilesdir}/%{name}.conf
%{_unitdir}/blk-availability.service
%{_unitdir}/lvm2-monitor.service
%{_unitdir}/lvm2-pvscan@.service
#%%{_unitdir}/lvm2-pvscan@.service
%attr(555, -, -) %{_prefix}/lib/systemd/system-generators/lvm2-activation-generator
%if %{enable_lvmpolld}
%{_unitdir}/lvm2-lvmpolld.socket
@ -839,6 +759,10 @@ An extensive functional testsuite for LVM2.
%endif
%changelog
* Wed Oct 20 2021 Marian Csontos <mcsontos@redhat.com> - 2.03.14-1
- Update to upstream version 2.03.14.
- See WHATS_NEW for list of changes.
* Mon Sep 20 2021 Marian Csontos <mcsontos@redhat.com> - 2.03.12-10
- Fix incorrect memory free.