From patchwork Fri May 13 11:21:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 9090781 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2A72CBF29F for ; Fri, 13 May 2016 11:52:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4F13D2022D for ; Fri, 13 May 2016 11:52:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D970320221 for ; Fri, 13 May 2016 11:52:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932105AbcEMLv6 (ORCPT ); Fri, 13 May 2016 07:51:58 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:51440 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751139AbcEMLv4 (ORCPT ); Fri, 13 May 2016 07:51:56 -0400 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u4DBps49030211 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 13 May 2016 11:51:55 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.13.8/8.13.8) with ESMTP id u4DBpsm3018343 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 13 May 2016 11:51:54 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u4DBprD4003919; Fri, 13 May 2016 11:51:53 GMT Received: from arch2.sg.oracle.com (/10.186.101.65) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 13 May 2016 04:51:53 -0700 From: Anand Jain To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org Subject: [PATCH 3/3] fstests: btrfs: 027 make use of new device get and put helper functions Date: Fri, 13 May 2016 19:21:14 +0800 Message-Id: <1463138474-15990-3-git-send-email-anand.jain@oracle.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1463138474-15990-1-git-send-email-anand.jain@oracle.com> References: <1463138474-15990-1-git-send-email-anand.jain@oracle.com> X-Source-IP: aserv0022.oracle.com [141.146.126.234] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Below patches added helper function to get the requested number of devices for scratch and spare device fstest: btrfs: add functions to get and put a device for replace target fstests: btrfs: add functions to set and reset required number of SCRATCH_DEV_POOL This patch makes use of them. Signed-off-by: Anand Jain --- tests/btrfs/027 | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/tests/btrfs/027 b/tests/btrfs/027 index f0844a14f8e6..905dc0ebaa27 100755 --- a/tests/btrfs/027 +++ b/tests/btrfs/027 @@ -57,17 +57,22 @@ _require_command "$WIPEFS_PROG" wipefs run_test() { local mkfs_opts=$1 - local saved_scratch_dev_pool=$SCRATCH_DEV_POOL - local replace_dev=`echo $SCRATCH_DEV_POOL | awk '{print $NF}'` + local ndevs=`echo $SCRATCH_DEV_POOL | wc -w` + + # reserve one for replace target + ((ndevs--)) + + _scratch_dev_pool_get $ndevs + _spare_dev_get echo "Test $mkfs_opts" >>$seqres.full - SCRATCH_DEV_POOL=`echo $SCRATCH_DEV_POOL | sed -e "s# *$replace_dev *##"` _scratch_pool_mkfs $mkfs_opts >>$seqres.full 2>&1 # make sure we created btrfs with desired options if [ $? -ne 0 ]; then echo "mkfs $mkfs_opts failed" - SCRATCH_DEV_POOL=$saved_scratch_dev_pool + _spare_dev_put + _scratch_dev_pool_put return fi _scratch_mount >>$seqres.full 2>&1 @@ -89,17 +94,19 @@ run_test() _scratch_mount -o degraded >>$seqres.full 2>&1 # replace $missing_dev with $replace_dev and scrub it to double-check - $BTRFS_UTIL_PROG replace start -B -r $missing_dev_id $replace_dev \ + $BTRFS_UTIL_PROG replace start -B -r $missing_dev_id $SPARE_DEV \ $SCRATCH_MNT -f >>$seqres.full 2>&1 if [ $? -ne 0 ]; then echo "btrfs replace failed" - SCRATCH_DEV_POOL=$saved_scratch_dev_pool + _spare_dev_put + _scratch_dev_pool_put return fi $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 if [ $? -ne 0 ]; then echo "btrfs scrub failed" - SCRATCH_DEV_POOL=$saved_scratch_dev_pool + _spare_dev_put + _scratch_dev_pool_put return fi @@ -107,7 +114,8 @@ run_test() # we called _require_scratch_nocheck instead of _require_scratch # do check after test for each profile config _check_scratch_fs - SCRATCH_DEV_POOL=$saved_scratch_dev_pool + _spare_dev_put + _scratch_dev_pool_put } echo "Silence is golden"