common/dmerror: fix nonsensical arguments handling

By default, _dmerror_load_*_table() suspends the dm device with
"--nolockfs" option. Callers have to feed two arguments to these
functions to change the behavior, with the second being 1, but the
first argument is not used at all, which doesn't make sense.

Fix it by checking if the first argument is "lockfs" and removing
"--nolockfs" option if so, or passing all options to dmsetup.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
This commit is contained in:
Zorro Lang
2016-07-05 17:30:23 +08:00
committed by Eryu Guan
parent 76eb2b1f6e
commit 4cd659be9c
+12 -2
View File
@@ -68,7 +68,12 @@ _dmerror_cleanup()
_dmerror_load_error_table()
{
suspend_opt="--nolockfs"
[ $# -gt 1 ] && [ $2 -eq 1 ] && suspend_opt=""
if [ "$1" = "lockfs" ]; then
suspend_opt=""
elif [ -n "$*" ]; then
suspend_opt="$*"
fi
$DMSETUP_PROG suspend $suspend_opt error-test
[ $? -ne 0 ] && _fail "dmsetup suspend failed"
@@ -83,7 +88,12 @@ _dmerror_load_error_table()
_dmerror_load_working_table()
{
suspend_opt="--nolockfs"
[ $# -gt 1 ] && [ $2 -eq 1 ] && suspend_opt=""
if [ "$1" = "lockfs" ]; then
suspend_opt=""
elif [ -n "$*" ]; then
suspend_opt="$*"
fi
$DMSETUP_PROG suspend $suspend_opt error-test
[ $? -ne 0 ] && _fail "dmsetup suspend failed"