linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: djwong@kernel.org, guaneryu@gmail.com
Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org, guan@eryu.me,
	tytso@mit.edu
Subject: [PATCH 2/3] dmerror: export configuration so that subprograms don't have to reinit
Date: Mon, 19 Jul 2021 18:09:13 -0700	[thread overview]
Message-ID: <162674335368.2651055.3174851724980962325.stgit@magnolia> (raw)
In-Reply-To: <162674334277.2651055.14927938006488444114.stgit@magnolia>

From: Darrick J. Wong <djwong@kernel.org>

Export the dmerror configuration variables so that subprograms don't
have to reinitialize the configuration in their own subprograms before
calling the helpers.  In the next patch (where we allow dmerror for log
and rt devices) it will become important to avoid these
reinitializations.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 common/dmerror |    8 +++++---
 src/dmerror    |   13 +++++--------
 2 files changed, 10 insertions(+), 11 deletions(-)


diff --git a/common/dmerror b/common/dmerror
index 6f1bef09..7f6800c0 100644
--- a/common/dmerror
+++ b/common/dmerror
@@ -10,11 +10,11 @@ _dmerror_setup()
 
 	local blk_dev_size=`blockdev --getsz $dm_backing_dev`
 
-	DMERROR_DEV='/dev/mapper/error-test'
+	export DMERROR_DEV='/dev/mapper/error-test'
 
-	DMLINEAR_TABLE="0 $blk_dev_size linear $dm_backing_dev 0"
+	export DMLINEAR_TABLE="0 $blk_dev_size linear $dm_backing_dev 0"
 
-	DMERROR_TABLE="0 $blk_dev_size error $dm_backing_dev 0"
+	export DMERROR_TABLE="0 $blk_dev_size error $dm_backing_dev 0"
 }
 
 _dmerror_init()
@@ -42,6 +42,8 @@ _dmerror_cleanup()
 	$DMSETUP_PROG resume error-test > /dev/null 2>&1
 	$UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1
 	_dmsetup_remove error-test
+
+	unset DMERROR_DEV DMLINEAR_TABLE DMERROR_TABLE
 }
 
 _dmerror_load_error_table()
diff --git a/src/dmerror b/src/dmerror
index c34d1a9a..cde2b428 100755
--- a/src/dmerror
+++ b/src/dmerror
@@ -5,15 +5,12 @@
 . ./common/config
 . ./common/dmerror
 
-_dmerror_setup
+if [ -z "$DMERROR_DEV" ]; then
+	echo "Caller should have run _dmerror_init."
+	exit 1
+fi
 
 case $1 in
-cleanup)
-	_dmerror_cleanup
-	;;
-init)
-	_dmerror_init
-	;;
 load_error_table)
 	_dmerror_load_error_table
 	;;
@@ -21,7 +18,7 @@ load_working_table)
 	_dmerror_load_working_table
 	;;
 *)
-	echo "Usage: $0 {init|cleanup|load_error_table|load_working_table}"
+	echo "Usage: $0 {load_error_table|load_working_table}"
 	exit 1
 	;;
 esac


  parent reply	other threads:[~2021-07-20  1:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-20  1:09 [PATCHSET 0/3] common/dm*: support external log and rt devices Darrick J. Wong
2021-07-20  1:09 ` [PATCH 1/3] dmflakey: support external log and realtime devices Darrick J. Wong
2021-07-20  1:09 ` Darrick J. Wong [this message]
2021-07-20  1:09 ` [PATCH 3/3] " Darrick J. Wong
2021-08-08 15:27   ` Eryu Guan
2021-08-10  4:16     ` Darrick J. Wong

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=162674335368.2651055.3174851724980962325.stgit@magnolia \
    --to=djwong@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=guan@eryu.me \
    --cc=guaneryu@gmail.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).