import lvm2-2.03.12-10.el8

This commit is contained in:
CentOS Sources 2021-09-22 10:21:17 +00:00 committed by root
parent 12a2bc4c78
commit d0c184f9b5
11 changed files with 951 additions and 36 deletions

View File

@ -0,0 +1,25 @@
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

@ -0,0 +1,86 @@
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

@ -0,0 +1,28 @@
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

@ -0,0 +1,256 @@
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

@ -0,0 +1,28 @@
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

@ -0,0 +1,29 @@
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

@ -0,0 +1,27 @@
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

@ -0,0 +1,185 @@
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

@ -0,0 +1,28 @@
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

@ -0,0 +1,184 @@
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

@ -41,15 +41,6 @@
%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
@ -68,7 +59,7 @@ Version: 2.03.12
%if 0%{?from_snapshot}
Release: 0.1.20210426git%{shortcommit}%{?dist}%{?rel_suffix}
%else
Release: 8%{?dist}%{?rel_suffix}
Release: 10%{?dist}%{?rel_suffix}
%endif
License: GPLv2
URL: http://sourceware.org/lvm2
@ -114,6 +105,17 @@ 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}
@ -199,6 +201,16 @@ or more physical volumes and creating one or more logical volumes
%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
@ -208,48 +220,68 @@ or more physical volumes and creating one or more logical volumes
%global _udevdir %{_prefix}/lib/udev/rules.d
%global configure_udev --with-udevdir=%{_udevdir} --enable-udev_sync
%if %{enable_cache}
%global configure_cache --with-cache=internal
# 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} \
--with-default-pid-dir=%{_default_pid_dir} \
--with-default-locking-dir=%{_default_locking_dir} \
--with-usrlibdir=%{_libdir} \
--enable-fsadm \
--enable-write_install \
--with-user= \
--with-group= \
--with-device-uid=0 \
--with-device-gid=6 \
--with-device-mode=0660 \
--enable-pkgconfig \
--enable-cmdlib \
--enable-dmeventd \
--enable-blkid_wiping \
%{?configure_cluster} \
%{?configure_cmirror} \
--with-udevdir=%{_udevdir} --enable-udev_sync \
%if %{enable_thin}
%global configure_thin --with-thin=internal
--with-thin=internal \
%endif
%if %{enable_cache}
--with-cache=internal \
%endif
%if %{enable_lvmpolld}
--enable-lvmpolld \
%endif
%if %{enable_lockd_dlm}
%global configure_lockd_dlm --enable-lvmlockd-dlm --enable-lvmlockd-dlmcontrol
--enable-lvmlockd-dlm --enable-lvmlockd-dlmcontrol \
%endif
%if %{enable_lockd_sanlock}
%global configure_lockd_sanlock --enable-lvmlockd-sanlock
--enable-lvmlockd-sanlock \
%endif
%if %{enable_lvmpolld}
%global configure_lvmpolld --enable-lvmpolld
%endif
%if %{enable_lvmdbusd}
%global configure_lvmdbusd --enable-dbus-service --enable-notify-dbus
--enable-dbus-service --enable-notify-dbus \
%endif
%if %{enable_dmfilemapd}
%global configure_dmfilemapd --enable-dmfilemapd
--enable-dmfilemapd \
%endif
%if %{enable_vdo}
%global configure_vdo --with-vdo=internal --with-vdo-format=%{_bindir}/vdoformat
%endif
%if %{enable_writecache}
%global configure_writecache --with-writecache=internal
--with-writecache=internal \
%endif
%if %{enable_vdo}
--with-vdo=internal --with-vdo-format=%{_bindir}/vdoformat \
%endif
%{?configure_integrity} \
%if %{enable_integrity}
%global configure_integrity --with-integrity=internal
--with-integrity=internal \
%endif
%configure --with-default-dm-run-dir=%{_default_dm_run_dir} --with-default-run-dir=%{_default_run_dir} --with-default-pid-dir=%{_default_pid_dir} --with-default-locking-dir=%{_default_locking_dir} --with-usrlibdir=%{_libdir} --enable-fsadm --enable-write_install --with-user= --with-group= --with-device-uid=0 --with-device-gid=6 --with-device-mode=0660 --enable-pkgconfig --enable-cmdlib --enable-dmeventd --enable-blkid_wiping %{?configure_cluster} %{?configure_cmirror} %{?configure_udev} %{?configure_thin} %{?configure_cache} %{?configure_lvmpolld} %{?configure_lockd_dlm} %{?configure_lockd_sanlock} %{?configure_lvmdbusd} %{?configure_dmfilemapd} %{?configure_writecache} %{?configure_vdo} %{?configure_integrity} --disable-silent-rules
--disable-silent-rules
make %{?_smp_mflags}
@ -807,6 +839,13 @@ An extensive functional testsuite for LVM2.
%endif
%changelog
* Mon Sep 20 2021 Marian Csontos <mcsontos@redhat.com> - 2.03.12-10
- Fix incorrect memory free.
* Fri Sep 17 2021 Marian Csontos <mcsontos@redhat.com> - 2.03.12-9
- Fix various lvm_import_vdo issues.
- Fix conversion to vdo when virtual size is above 2TiB.
* Thu Aug 26 2021 Marian Csontos <mcsontos@redhat.com> - 2.03.12-8
- Rename vdoimport to lvm_import_vdo.