]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
dmerror: export configuration so that subprograms don't have to reinit
authorDarrick J. Wong <djwong@kernel.org>
Tue, 20 Jul 2021 01:09:13 +0000 (18:09 -0700)
committerEryu Guan <guaneryu@gmail.com>
Sun, 8 Aug 2021 14:59:59 +0000 (22:59 +0800)
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>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
common/dmerror
src/dmerror

index 7d12e0a1843cd6c21ac5ddc3207bb9470f8dee69..01a4c8b5e52d3cd4469bfd911504577a7dd25c5a 100644 (file)
@@ -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()
index c34d1a9a99f301e20eed884ac47efdb9a165d255..cde2b42843598d4d5f06bd067369a0a7dde5e0c3 100755 (executable)
@@ -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