From patchwork Tue May 17 14:32:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 9112741 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1048F9F1C3 for ; Tue, 17 May 2016 14:32:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 36D432021B for ; Tue, 17 May 2016 14:32:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 776F3202F0 for ; Tue, 17 May 2016 14:32:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932430AbcEQOcc (ORCPT ); Tue, 17 May 2016 10:32:32 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:49700 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932358AbcEQOca (ORCPT ); Tue, 17 May 2016 10:32:30 -0400 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u4HEWSxJ002102 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 17 May 2016 14:32:29 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.13.8) with ESMTP id u4HEWSxI031620 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 17 May 2016 14:32:28 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u4HEWRKh015040; Tue, 17 May 2016 14:32:28 GMT Received: from arch2.localdomain (/14.96.10.156) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 17 May 2016 07:32:26 -0700 From: Anand Jain To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Anand Jain Subject: [PATCH 3/6] fstests: btrfs: 027 make use of new device get and put helper functions Date: Tue, 17 May 2016 22:32:07 +0800 Message-Id: <1463495530-425-3-git-send-email-anand.jain@oracle.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1463495530-425-1-git-send-email-anand.jain@oracle.com> References: <1463495530-425-1-git-send-email-anand.jain@oracle.com> X-Source-IP: userv0022.oracle.com [156.151.31.74] 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"