main - vdo: prompt with no return failure
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=3b24c0fe4e197383101...
Commit: 3b24c0fe4e197383101eae53b14f19586cf2eda1
Parent: 812653d59806439379d80bb8124f6962ae42d46a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Sep 10 22:39:23 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Sep 13 12:34:41 2021 +0200
vdo: prompt with no return failure
Exit 1 (failure) when prompt for conversion is answered as 'No'.
---
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 a72056721..06cdb106d 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
2 years, 7 months
main - vdo: man page updates
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=812653d59806439379d...
Commit: 812653d59806439379d80bb8124f6962ae42d46a
Parent: 9db4ddabc1cf912dee30e0e6293767f01c976a4a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Sep 10 01:15:01 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Sep 13 12:34:41 2021 +0200
vdo: man page updates
---
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 d970eeb40..c812c5e01 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
2 years, 7 months
main - vdo: lvm_import_vdo script needs to continue when vgname does not exist
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9db4ddabc1cf912dee3...
Commit: 9db4ddabc1cf912dee30e0e6293767f01c976a4a
Parent: bd2dae464386033241afa35934cdeddfe47f6a77
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Sep 9 18:10:13 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Sep 13 12:34:41 2021 +0200
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.
---
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 39a320c84..a72056721 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
2 years, 7 months
main - tests: check lvm2 parses vdo statistics
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=bd2dae464386033241a...
Commit: bd2dae464386033241afa35934cdeddfe47f6a77
Parent: e6f735d411e5911de186a610932c9bb9638275eb
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Sep 9 15:22:20 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Sep 9 15:24:21 2021 +0200
tests: check lvm2 parses vdo statistics
---
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 9fb2959db..44f8bf094 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
2 years, 7 months
main - vdo: read new sysfs path
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e6f735d411e5911de18...
Commit: e6f735d411e5911de186a610932c9bb9638275eb
Parent: 89595a366554191c3df1a18e1f82b79c450a21ad
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Sep 9 14:59:38 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Sep 9 15:24:15 2021 +0200
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.
---
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 feed7f53d..7d4cea1d6 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.14 -
==================================
+ Support newer location for VDO statistics.
Add support for VDO async-unsage write policy.
Improve lvm_import_vdo script.
Support VDO LV with lvcreate -ky.
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 2ada9b525..a8516d661 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 96a9533d2..7bac5b900 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -1365,7 +1365,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 673db98e2..fa9c893cb 100644
--- a/lib/metadata/vdo_manip.c
+++ b/lib/metadata/vdo_manip.c
@@ -125,48 +125,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;
@@ -190,15 +198,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,
2 years, 7 months
main - vdo: more lvm_import_vdo fixes
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=89595a366554191c3df...
Commit: 89595a366554191c3df1a18e1f82b79c450a21ad
Parent: 3287d37f440ca272b52f900fc60ee5effcf73697
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Sep 6 15:06:32 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Sep 6 15:19:51 2021 +0200
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.)
---
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 685821f13..39a320c84 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 493f415d4..632f86a36 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(a)loop0.service: Main process exited, code=exited, status=1/FAILURE
+# vdo-start-by-dev(a)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"
2 years, 8 months
main - vdo: better message for missing device
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=3287d37f440ca272b52...
Commit: 3287d37f440ca272b52f900fc60ee5effcf73697
Parent: 8d5b7de54f21ce5e34d533599f9d5a42f2977cd5
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Sep 1 15:46:04 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Sep 6 15:19:51 2021 +0200
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.
---
scripts/lvm_import_vdo.sh | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/scripts/lvm_import_vdo.sh b/scripts/lvm_import_vdo.sh
index 65d2eee38..685821f13 100755
--- a/scripts/lvm_import_vdo.sh
+++ b/scripts/lvm_import_vdo.sh
@@ -19,7 +19,7 @@
# Needed utilities:
# lvm, dmsetup,
# vdo,
-# grep, awk, sed, blockdev, readlink, mkdir
+# 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
2 years, 8 months
main - vdo: lvm_import_vdo fix max_discard size
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8d5b7de54f21ce5e34d...
Commit: 8d5b7de54f21ce5e34d533599f9d5a42f2977cd5
Parent: 79427151dc5ffb5faff133c57e058acbad00dd10
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Sep 6 14:57:43 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Sep 6 15:19:51 2021 +0200
vdo: lvm_import_vdo fix max_discard size
Use correct 4K units in lvm2 for max_discard VDO option.
---
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 ae2892949..65d2eee38 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
2 years, 8 months
main - vdo: add support for auto-unsafe writePolicy
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=79427151dc5ffb5faff...
Commit: 79427151dc5ffb5faff133c57e058acbad00dd10
Parent: 337053c56a2d288337449067510301d5a2e4eec5
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Sep 6 13:56:40 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Sep 6 15:19:51 2021 +0200
vdo: add support for auto-unsafe writePolicy
This vdoWritePolicy policy missed matching support in lvm2.
---
WHATS_NEW | 1 +
conf/example.conf.in | 2 ++
device_mapper/libdm-deptree.c | 3 ++-
device_mapper/vdo/target.h | 3 ++-
device_mapper/vdo/vdo_target.c | 1 +
lib/config/config_settings.h | 4 +++-
lib/metadata/vdo_manip.c | 4 ++++
7 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 90fe1b676..feed7f53d 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.14 -
==================================
+ Add support for VDO async-unsage write policy.
Improve lvm_import_vdo script.
Support VDO LV with lvcreate -ky.
Fix lvconvert for VDO LV bigger then 2T.
diff --git a/conf/example.conf.in b/conf/example.conf.in
index 2dc6dd9e6..5bcbc65e7 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -713,6 +713,8 @@ allocation {
# This policy is not supported if the underlying storage is not also synchronous.
# async - Writes are acknowledged after data has been cached for writing to stable storage.
# Data which has not been flushed is not guaranteed to persist in this mode.
+ # async-unsafe - Writes are handled like 'async' but there is no guarantee of the atomicity async provides.
+ # This mode should only be used for better performance when atomicity is not required.
# This configuration option has an automatic default value.
# vdo_write_policy = "auto"
diff --git a/device_mapper/libdm-deptree.c b/device_mapper/libdm-deptree.c
index 70acfb093..c759c4e46 100644
--- a/device_mapper/libdm-deptree.c
+++ b/device_mapper/libdm-deptree.c
@@ -2885,7 +2885,8 @@ static int _vdo_emit_segment_line(struct dm_task *dmt,
seg->vdo_params.block_map_era_length,
seg->vdo_params.use_metadata_hints ? "on" : "off" ,
(seg->vdo_params.write_policy == DM_VDO_WRITE_POLICY_SYNC) ? "sync" :
- (seg->vdo_params.write_policy == DM_VDO_WRITE_POLICY_ASYNC) ? "async" : "auto", // policy
+ (seg->vdo_params.write_policy == DM_VDO_WRITE_POLICY_ASYNC) ? "async" :
+ (seg->vdo_params.write_policy == DM_VDO_WRITE_POLICY_ASYNC_UNSAFE) ? "async-unsafe" : "auto", // policy
seg->vdo_name,
seg->vdo_params.max_discard,
seg->vdo_params.ack_threads,
diff --git a/device_mapper/vdo/target.h b/device_mapper/vdo/target.h
index 776798389..51dde3f4d 100644
--- a/device_mapper/vdo/target.h
+++ b/device_mapper/vdo/target.h
@@ -69,7 +69,8 @@ bool dm_vdo_status_parse(struct dm_pool *mem, const char *input,
enum dm_vdo_write_policy {
DM_VDO_WRITE_POLICY_AUTO = 0,
DM_VDO_WRITE_POLICY_SYNC,
- DM_VDO_WRITE_POLICY_ASYNC
+ DM_VDO_WRITE_POLICY_ASYNC,
+ DM_VDO_WRITE_POLICY_ASYNC_UNSAFE
};
// FIXME: review whether we should use the createParams from the userlib
diff --git a/device_mapper/vdo/vdo_target.c b/device_mapper/vdo/vdo_target.c
index 946be5aa7..2ffd29145 100644
--- a/device_mapper/vdo/vdo_target.c
+++ b/device_mapper/vdo/vdo_target.c
@@ -100,6 +100,7 @@ bool dm_vdo_validate_target_params(const struct dm_vdo_target_params *vtp,
switch (vtp->write_policy) {
case DM_VDO_WRITE_POLICY_SYNC:
case DM_VDO_WRITE_POLICY_ASYNC:
+ case DM_VDO_WRITE_POLICY_ASYNC_UNSAFE:
case DM_VDO_WRITE_POLICY_AUTO:
break;
default:
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index fa87bea23..c0e491cad 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -796,7 +796,9 @@ cfg(allocation_vdo_write_policy_CFG, "vdo_write_policy", allocation_CFG_SECTION,
"sync - Writes are acknowledged only after data is stably written.\n"
" This policy is not supported if the underlying storage is not also synchronous.\n"
"async - Writes are acknowledged after data has been cached for writing to stable storage.\n"
- " Data which has not been flushed is not guaranteed to persist in this mode.\n")
+ " Data which has not been flushed is not guaranteed to persist in this mode.\n"
+ "async-unsafe - Writes are handled like 'async' but there is no guarantee of the atomicity async provides.\n"
+ " This mode should only be used for better performance when atomicity is not required.\n")
cfg(allocation_vdo_max_discard_CFG, "vdo_max_discard", allocation_CFG_SECTION, CFG_PROFILABLE | CFG_PROFILABLE_METADATA | CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, DEFAULT_VDO_MAX_DISCARD, VDO_1ST_VSN, NULL, 0, NULL,
"Specified the maximum size of discard bio accepted, in 4096 byte blocks.\n"
diff --git a/lib/metadata/vdo_manip.c b/lib/metadata/vdo_manip.c
index 3f2de1a01..673db98e2 100644
--- a/lib/metadata/vdo_manip.c
+++ b/lib/metadata/vdo_manip.c
@@ -81,6 +81,8 @@ const char *get_vdo_write_policy_name(enum dm_vdo_write_policy policy)
return "sync";
case DM_VDO_WRITE_POLICY_ASYNC:
return "async";
+ case DM_VDO_WRITE_POLICY_ASYNC_UNSAFE:
+ return "async-unsafe";
default:
log_debug(INTERNAL_ERROR "Unrecognized VDO write policy: %u.", policy);
/* Fall through */
@@ -441,6 +443,8 @@ int set_vdo_write_policy(enum dm_vdo_write_policy *vwp, const char *policy)
*vwp = DM_VDO_WRITE_POLICY_SYNC;
else if (strcasecmp(policy, "async") == 0)
*vwp = DM_VDO_WRITE_POLICY_ASYNC;
+ else if (strcasecmp(policy, "async-unsafe") == 0)
+ *vwp = DM_VDO_WRITE_POLICY_ASYNC_UNSAFE;
else if (strcasecmp(policy, "auto") == 0)
*vwp = DM_VDO_WRITE_POLICY_AUTO;
else {
2 years, 8 months
main - tests: remove all debug logs when using die
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=337053c56a2d2883374...
Commit: 337053c56a2d288337449067510301d5a2e4eec5
Parent: 52b56204764e421b693d94fa38834d71e29deced
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Sep 6 14:59:10 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Sep 6 15:01:11 2021 +0200
tests: remove all debug logs when using die
Since die is called from a shell script, there is no need
to report any recent lvm2 command debug traces.
---
test/lib/utils.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/lib/utils.sh b/test/lib/utils.sh
index 0e41589bd..1d1ed48bf 100644
--- a/test/lib/utils.sh
+++ b/test/lib/utils.sh
@@ -15,7 +15,7 @@ IFS_NL='
'
die() {
- rm -f debug.log
+ rm -f debug.log*
echo -e "$@" >&2
return 1
}
2 years, 8 months