All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zdenek Kabelac <zkabelac@sourceware.org>
To: lvm-devel@redhat.com
Subject: main - tests: add aux remove_dm_devs
Date: Sun, 28 Mar 2021 12:23:14 +0000 (GMT)	[thread overview]
Message-ID: <20210328122314.9B789385703C@sourceware.org> (raw)

Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d9b97510324e7c16cf8ec61f511b6f5d71bff767
Commit:        d9b97510324e7c16cf8ec61f511b6f5d71bff767
Parent:        0ddbc4c5cdbef0cc57b79c164b22b34c0bc6a27a
Author:        Zdenek Kabelac <zkabelac@redhat.com>
AuthorDate:    Sun Mar 28 13:29:44 2021 +0200
Committer:     Zdenek Kabelac <zkabelac@redhat.com>
CommitterDate: Sun Mar 28 14:22:11 2021 +0200

tests: add aux remove_dm_devs

Add function to remove DM devices and dies
if some device can't be removed.
---
 test/lib/aux.sh | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 38191842d..6177de4d4 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -1110,6 +1110,28 @@ enable_dev() {
 	finish_udev_transaction
 }
 
+# Try to remove list of DM device from table
+remove_dm_devs() {
+	local remove=( "$@" )
+	local held
+	local i
+
+	for i in {1..50}; do
+		held=()
+		for d in "${remove[@]}" ; do
+			dmsetup remove "$d" 2>/dev/null || {
+				dmsetup info -c "$d" 2>/dev/null && {
+					held+=( "$d" )
+					dmsetup status "$d"
+				}
+			}
+		done
+		test ${#held[@]} -eq 0 && return
+		remove=( "${held[@]}" )
+	done
+	die "Can't remove device(s) ${held[@]}"
+}
+
 # Throttle down performance of kcopyd when mirroring i.e. disk image
 throttle_sys="/sys/module/dm_mirror/parameters/raid1_resync_throttle"
 throttle_dm_mirror() {



                 reply	other threads:[~2021-03-28 12:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210328122314.9B789385703C@sourceware.org \
    --to=zkabelac@sourceware.org \
    --cc=lvm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.