]> sourceware.org Git - lvm2.git/commitdiff
vdo: enhance import script for devices file
authorZdenek Kabelac <zkabelac@redhat.com>
Sat, 2 Sep 2023 19:25:20 +0000 (21:25 +0200)
committerZdenek Kabelac <zkabelac@redhat.com>
Sun, 3 Sep 2023 20:03:33 +0000 (22:03 +0200)
When the import is used on a system, that uses devices file,
the final activation was impossible for the case the converted
volume was not present in devices file.
Currently add volume automatically in such case.

Also add some more debugging output from the script.

TODO: Consider enhnacing lvconvert with extending devices file.

scripts/lvm_import_vdo.sh

index a72c9a1045bdbea820f7bc3624d547c04fa89726..65bd29dd05a19131085d59287aab596890ef65b2 100755 (executable)
@@ -121,8 +121,13 @@ dry() {
 
 cleanup() {
        trap '' 2
-
-       test -n "$VDO_DM_SNAPSHOT_NAME" && { "$DMSETUP" remove "$VDO_DM_SNAPSHOT_NAME" || true ; }
+       test -n "$VDO_DM_SNAPSHOT_NAME" && {
+               for i in {1..20} ; do
+                       test "$("$DMSETUP" info --noheading -co open "$VDO_DM_SNAPSHOT_NAME")" = "0" && break
+                       sleep .1
+               done
+               "$DMSETUP" remove "$VDO_DM_SNAPSHOT_NAME" || true
+       }
        test -n "$VDO_SNAPSHOT_LOOP" && { "$LOSETUP" -d "$VDO_SNAPSHOT_LOOP" || true ; }
 
        test -z "$PROMPTING" || echo "No"
@@ -370,7 +375,13 @@ convert_non_lv_() {
        fi
 
        verbose "Moving VDO header."
-       output=$(dry "$VDO" convert $VDOCONF $VERB --force --name "$VDONAME")
+
+       output=$(dry "$VDO" convert $VDOCONF $VERB --force --name "$VDONAME" 2>&1) || {
+               echo "$output"
+               error "Failed to convert VDO volume \"$DEVICE\" (exit code $?)."
+       }
+
+       echo "$output"
 
        if [ "$ABORT_AFTER_VDO_CONVERT" != "0" ] ; then
                verbose "Aborting VDO conversion after moving VDO header, volume is useless!"
@@ -456,12 +467,19 @@ convert_non_lv_() {
                dry snapshot_merge_ "$DEVICE"
                if [ -e "$TEMPDIR/vdo_snap.yml" ]; then
                        dry cp "$TEMPDIR/vdo_snap.yml" "$VDO_CONFIG"
-               else
+               elif [ -e "$VDO_CONFIG" ]; then
                        dry rm -f "$VDO_CONFIG"
                fi
                verbose "Merging of VDO device finished."
        fi
 
+       output=$(dry "$LVM" pvs "$DEVICE" 2>&1) || {
+               if echo "$output" | grep -q "not in devices file" ; then
+                       verbose "Adding \"$DEVICE\" to devices file."
+                       dry "$LVM" lvmdevices --adddev "$DEVICE"
+               fi
+       }
+
        dry "$LVM" lvchange -ay $VERB $FORCE "$VGNAME/$LVNAME"
 }
 
This page took 0.034251 seconds and 5 git commands to generate.