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

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