Blame SOURCES/lvm2-2_02_188-blkdeactivate-add-support-for-VDO-in-blkdeactivate-script.patch

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