mrc0mmand / rpms / lvm2

Forked from rpms/lvm2 2 years ago
Clone

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

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