From patchwork Thu Nov 9 07:32:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hou Tao X-Patchwork-Id: 10050309 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 3D17D60381 for ; Thu, 9 Nov 2017 07:26:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D4AD29747 for ; Thu, 9 Nov 2017 07:26:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2260D2AB53; Thu, 9 Nov 2017 07:26:34 +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 0575F2A9E7 for ; Thu, 9 Nov 2017 07:26:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752539AbdKIH0b (ORCPT ); Thu, 9 Nov 2017 02:26:31 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:9983 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750984AbdKIH0a (ORCPT ); Thu, 9 Nov 2017 02:26:30 -0500 Received: from 172.30.72.59 (EHLO DGGEMS401-HUB.china.huawei.com) ([172.30.72.59]) by dggrg04-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DKM33799; Thu, 09 Nov 2017 15:26:17 +0800 (CST) Received: from huawei.com (10.175.124.28) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.361.1; Thu, 9 Nov 2017 15:26:16 +0800 From: Hou Tao To: CC: , , , Subject: [PATCH v3 2/4] dmflakey: support error_writes feature for dm-flakey Date: Thu, 9 Nov 2017 15:32:50 +0800 Message-ID: <20171109073252.36001-3-houtao1@huawei.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171109073252.36001-1-houtao1@huawei.com> References: <20171109073252.36001-1-houtao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.28] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090202.5A040319.015E, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: a7c0634c63f7a8883794fc5584d9ae10 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add _require_flakey_with_error_writes() to check the availability of dm-flakey target and its error_writes feature, and support for enabling FLAKEY_TABLE_ERROR table by passing FLAKEY_ERROR_WRITES to _load_flakey_table(). Signed-off-by: Hou Tao --- common/dmflakey | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/common/dmflakey b/common/dmflakey index 16b82d2..845b466 100644 --- a/common/dmflakey +++ b/common/dmflakey @@ -20,18 +20,43 @@ FLAKEY_ALLOW_WRITES=0 FLAKEY_DROP_WRITES=1 +FLAKEY_ERROR_WRITES=2 echo $MOUNT_OPTIONS | grep -q dax if [ $? -eq 0 ]; then _notrun "Cannot run tests with DAX on dmflakey devices" fi +_require_flakey_with_error_writes() +{ + local SIZE + local TABLE + local NAME=flakey-test + + _require_dm_target flakey + + SIZE=`blockdev --getsz $SCRATCH_DEV` + TABLE="0 $SIZE flakey $SCRATCH_DEV 0 0 180 1 error_writes" + + $DMSETUP_PROG create $NAME --table "$TABLE" >/dev/null 2>&1 + if [ $? -ne 0 ]; then + _notrun "This test requires error_writes feature in dm-flakey" + fi + $DMSETUP_PROG mknodes >/dev/null 2>&1 + + # copy from _cleanup_flakey() + $UDEV_SETTLE_PROG >/dev/null 2>&1 + $DMSETUP_PROG remove $NAME >/dev/null 2>&1 + $DMSETUP_PROG mknodes >/dev/null 2>&1 +} + _init_flakey() { local BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV` FLAKEY_DEV=/dev/mapper/flakey-test FLAKEY_TABLE="0 $BLK_DEV_SIZE flakey $SCRATCH_DEV 0 180 0" FLAKEY_TABLE_DROP="0 $BLK_DEV_SIZE flakey $SCRATCH_DEV 0 0 180 1 drop_writes" + FLAKEY_TABLE_ERROR="0 $BLK_DEV_SIZE flakey $SCRATCH_DEV 0 0 180 1 error_writes" $DMSETUP_PROG create flakey-test --table "$FLAKEY_TABLE" || \ _fatal "failed to create flakey device" $DMSETUP_PROG mknodes > /dev/null 2>&1 @@ -67,9 +92,9 @@ _cleanup_flakey() # table, so it simulates power failure. _load_flakey_table() { - table="$FLAKEY_TABLE" [ $1 -eq $FLAKEY_DROP_WRITES ] && table="$FLAKEY_TABLE_DROP" + [ $1 -eq $FLAKEY_ERROR_WRITES ] && table="$FLAKEY_TABLE_ERROR" suspend_opt="--nolockfs" [ $# -gt 1 ] && [ $2 -eq 1 ] && suspend_opt=""