mrc0mmand / rpms / lvm2

Forked from rpms/lvm2 3 years ago
Clone

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

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