From patchwork Tue Jul 5 09:30:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zorro Lang X-Patchwork-Id: 9213907 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B164560752 for ; Tue, 5 Jul 2016 09:30:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A24CF28996 for ; Tue, 5 Jul 2016 09:30:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 95AB528998; Tue, 5 Jul 2016 09:30:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 260DD28996 for ; Tue, 5 Jul 2016 09:30:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754599AbcGEJae (ORCPT ); Tue, 5 Jul 2016 05:30:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54915 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754556AbcGEJab (ORCPT ); Tue, 5 Jul 2016 05:30:31 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 136F63B71B for ; Tue, 5 Jul 2016 09:30:31 +0000 (UTC) Received: from localhost (dhcp-13-217.nay.redhat.com [10.66.13.217]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u659UT6G019618; Tue, 5 Jul 2016 05:30:30 -0400 From: Zorro Lang To: fstests@vger.kernel.org Cc: eguan@redhat.com, Zorro Lang Subject: [PATCH v5 1/2] common/dmerror: fix nonsensical arguments handling Date: Tue, 5 Jul 2016 17:30:23 +0800 Message-Id: <1467711024-12702-1-git-send-email-zlang@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 05 Jul 2016 09:30:31 +0000 (UTC) Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- Hi, At first, I want to change the code just likes: suspend_opts="$*" But after talked with Darrick J. Wong(the original author of dmerror), he suggest to keep use --nolockfs as default: i used --nolockfs so that dmsetup doesn't try to flush the fs on the device that we're deliberately erroring (most probably the test is midway through its own fsync, so dmsetup trying to sync the fs will just get hung up on the io errors) So follow this suggestion, and keep --nolockfs still as the default option. Thanks, Zorro common/dmerror | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/common/dmerror b/common/dmerror index 6df87bd..5ad9994 100644 --- a/common/dmerror +++ b/common/dmerror @@ -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"