[PATCH 2/3] dmerror: export configuration so that subprograms don't have to reinit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Darrick J. Wong <djwong@xxxxxxxxxx>

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@xxxxxxxxxx>
---
 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




[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux