common/dmerror: always try to resume device
authorDarrick J. Wong <darrick.wong@oracle.com>
Wed, 11 Dec 2019 05:38:31 +0000 (21:38 -0800)
committerEryu Guan <guaneryu@gmail.com>
Mon, 6 Jan 2020 06:36:04 +0000 (14:36 +0800)
When we're reloading the error-target dm table, always resume the device
even if the reload fails because (a) we shouldn't leave dm state for the
callers to clean up and (b) the caller don't clean up the state which
just leads to the scratch filesystem hanging on the suspended dm error
device.

Resume the dm device when we're cleaning up so that cleaning up the
scratch filesystem won't hang.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
common/dmerror

index 8c52e1277fbd388451abe7d541b3db2b921da8b1..426f1e96d3a151b1d57074fa6e1abdc0740fd27b 100644 (file)
@@ -44,12 +44,16 @@ _dmerror_unmount()
 
 _dmerror_cleanup()
 {
+       $DMSETUP_PROG resume error-test > /dev/null 2>&1
        $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1
        _dmsetup_remove error-test
 }
 
 _dmerror_load_error_table()
 {
+       local load_res=0
+       local resume_res=0
+
        suspend_opt="--nolockfs"
 
        if [ "$1" = "lockfs" ]; then
@@ -62,14 +66,20 @@ _dmerror_load_error_table()
        [ $? -ne 0 ] && _fail  "dmsetup suspend failed"
 
        $DMSETUP_PROG load error-test --table "$DMERROR_TABLE"
-       [ $? -ne 0 ] && _fail "dmsetup failed to load error table"
+       load_res=$?
 
        $DMSETUP_PROG resume error-test
-       [ $? -ne 0 ] && _fail  "dmsetup resume failed"
+       resume_res=$?
+
+       [ $load_res -ne 0 ] && _fail "dmsetup failed to load error table"
+       [ $resume_res -ne 0 ] && _fail  "dmsetup resume failed"
 }
 
 _dmerror_load_working_table()
 {
+       local load_res=0
+       local resume_res=0
+
        suspend_opt="--nolockfs"
 
        if [ "$1" = "lockfs" ]; then
@@ -82,8 +92,11 @@ _dmerror_load_working_table()
        [ $? -ne 0 ] && _fail  "dmsetup suspend failed"
 
        $DMSETUP_PROG load error-test --table "$DMLINEAR_TABLE"
-       [ $? -ne 0 ] && _fail "dmsetup failed to load error table"
+       load_res=$?
 
        $DMSETUP_PROG resume error-test
-       [ $? -ne 0 ] && _fail  "dmsetup resume failed"
+       resume_res=$?
+
+       [ $load_res -ne 0 ] && _fail "dmsetup failed to load error table"
+       [ $resume_res -ne 0 ] && _fail  "dmsetup resume failed"
 }