mrc0mmand / rpms / lvm2

Forked from rpms/lvm2 3 years ago
Clone

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

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