From patchwork Fri May 13 11:21:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 9090741 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 AF1BA9F441 for ; Fri, 13 May 2016 11:52:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CC5EF20221 for ; Fri, 13 May 2016 11:51:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E2FAE201BC for ; Fri, 13 May 2016 11:51:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751741AbcEMLvy (ORCPT ); Fri, 13 May 2016 07:51:54 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:29299 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750907AbcEMLvx (ORCPT ); Fri, 13 May 2016 07:51:53 -0400 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u4DBppuV016626 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 13 May 2016 11:51:52 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.13.8/8.13.8) with ESMTP id u4DBppBn018267 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 13 May 2016 11:51:51 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u4DBpoZD031985; Fri, 13 May 2016 11:51:51 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:50 -0700 From: Anand Jain To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org Subject: [PATCH 1/3] [RFC] fstests: btrfs: add functions to set and reset required number of SCRATCH_DEV_POOL Date: Fri, 13 May 2016 19:21:12 +0800 Message-Id: <1463138474-15990-1-git-send-email-anand.jain@oracle.com> X-Mailer: git-send-email 2.7.0 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 This patch provides functions _scratch_dev_pool_get() _scratch_dev_pool_put() Which will help to set/reset SCRATCH_DEV_POOL with the required number of devices. SCRATCH_DEV_POOL_SAVED will hold all the devices. Usage: _scratch_dev_pool_get() :: do stuff _scratch_dev_pool_put() Signed-off-by: Anand Jain --- common/rc | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/common/rc b/common/rc index 91e8f1c8e693..33632fd8e4a3 100644 --- a/common/rc +++ b/common/rc @@ -786,6 +786,53 @@ _scratch_mkfs() esac } +# +# $1 Number of the scratch devs required +# +_scratch_dev_pool_get() +{ + if [ $# != 1 ]; then + _fail "Usage: _scratch_dev_pool_get ndevs" + fi + + local test_ndevs=$1 + local config_ndevs=`echo $SCRATCH_DEV_POOL| wc -w` + local devs[]="( $SCRATCH_DEV_POOL )" + + typeset -p config_ndevs >/dev/null 2>&1 + if [ $? != 0 ]; then + _fail "Bug: unset val, must call _scratch_dev_pool_get before _scratch_dev_pool_put" + fi + + # _require_scratch_dev_pool $test_ndevs + # must have already checked the min required devices + # but just in case, trap here for any potential bugs + # perpetuating any further + if [ $config_ndevs -lt $test_ndevs ]; then + _notrun "Need at least test requested number of ndevs $test_ndevs" + fi + + SCRATCH_DEV_POOL_SAVED=${SCRATCH_DEV_POOL} + export SCRATCH_DEV_POOL_SAVED + SCRATCH_DEV_POOL=${devs[@]:0:$test_ndevs} + export SCRATCH_DEV_POOL +} + +_scratch_dev_pool_put() +{ + typeset -p SCRATCH_DEV_POOL_SAVED >/dev/null 2>&1 + if [ $? != 0 ]; then + _fail "Bug: unset val, must call _scratch_dev_pool_get before _scratch_dev_pool_put" + fi + + if [ -z "$SCRATCH_DEV_POOL_SAVED" ]; then + _fail "Bug: str empty, must call _scratch_dev_pool_get before _scratch_dev_pool_put" + fi + + export SCRATCH_DEV_POOL=$SCRATCH_DEV_POOL_SAVED + export SCRATCH_DEV_POOL_SAVED="" +} + _scratch_pool_mkfs() { case $FSTYP in