From patchwork Fri Jan 27 08:56:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 9540869 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 123D460429 for ; Fri, 27 Jan 2017 09:25:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0AB07282F5 for ; Fri, 27 Jan 2017 09:25:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F3F0327FC0; Fri, 27 Jan 2017 09:25:08 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 39AC2282F5 for ; Fri, 27 Jan 2017 09:25:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754584AbdA0JXy (ORCPT ); Fri, 27 Jan 2017 04:23:54 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:36721 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754771AbdA0JXV (ORCPT ); Fri, 27 Jan 2017 04:23:21 -0500 Received: by mail-wm0-f68.google.com with SMTP id r126so56803370wmr.3; Fri, 27 Jan 2017 01:23:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=miuuRtcyA60v9k1HjwNOxSxd5uqmsDTetUS6ax/B608=; b=dCfUm+chtcnGGYwuQRhamORyFjedQ1xT+vFhCdXDfP3LgR2rXvFDYguoySLhleIzDg WPWgiENEe8rCcNb4aVmAxGkPDxwc8ok4HRBROAaV19yGp/CuVL8UvCOZIIjgyhP4BLlH leGhYxKKz7AofkxI4b69yDBm9uRu327MpfiPgw/gI2yGNT2o0zrrJSizvhRwilXq3N0b FBuwPUkzdq+4GXt6G6Q37gZvJXyin3SEBEg7WJHFUZPUC5vWovaBO9Zw/+6tuDKhFRBR hRZCukPuu7zwv1qaKo1kWO7PqPCcRJNihGF/+Cn0VPL5QMYF2acNEnOQU7AEzNsl+LS/ gQ8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=miuuRtcyA60v9k1HjwNOxSxd5uqmsDTetUS6ax/B608=; b=AqZoe02w9s9KpS5NU9iPIEJ4q1myF/M3iYqeqAN7KZeUeMHRJZGnHVnuykgnmvlmHP ALhLbF91VmoSRwXpxi7FKCrg83MuP1E8ANM/w9TGk/3cs8byASTGhlH3g3X191rAGFgY jfk5rJCsZZH32c07QIwPYTsiZgV8gkNpDLiwgLH+FCXsnBvCwKzIfpmwmPGCr/A8Dh/3 H3GCa0KrMHu7MrX2YhwZZWzPyOjJRj7a0yH6RGXGTPBy37bLzcAKJfeHwdFaOoaoxtfc 6/bPH3rKFpcigeU7uvN1dfXs/wXLCeupCMlUJukEIArYHWRMvolo7KoUO/AsxidG8FcJ acag== X-Gm-Message-State: AIkVDXI2cFg/Wb9eArw7CvfSxe27KO2SNw2GLdhtATSGpT+8+a/BE/VBQufOaKKr5+MDfg== X-Received: by 10.28.57.86 with SMTP id g83mr275567wma.126.1485507378040; Fri, 27 Jan 2017 00:56:18 -0800 (PST) Received: from amir-VirtualBox.Home (bzq-79-176-143-83.red.bezeqint.net. [79.176.143.83]) by smtp.gmail.com with ESMTPSA id n13sm6697916wrn.40.2017.01.27.00.56.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 Jan 2017 00:56:17 -0800 (PST) From: Amir Goldstein To: Eryu Guan Cc: Miklos Szeredi , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH v2 1/3] overlay: configure base fs mount point for running tests Date: Fri, 27 Jan 2017 10:56:03 +0200 Message-Id: <1485507365-29012-2-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1485507365-29012-1-git-send-email-amir73il@gmail.com> References: <1485507365-29012-1-git-send-email-amir73il@gmail.com> Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of setting the vars TEST/SCRATCH_DEV to overlay base dirs, allow setting the vars SCRATCH/TEST_BASE_MNT, to configure where the base fs is mounted and where overlay dirs will be created. For example: -export TEST_DEV=/mnt/base/test/ovl -export SCRATCH_DEV=/mnt/base/scratch/ovl +export TEST_BASE_MNT=/mnt/base/test +export SCRATCH_BASE_MNT=/mnt/base/scratch export TEST_DIR=/mnt/test export SCRATCH_MNT=/mnt/scratch export FSTYP=overlay The new canonical vars SCRATCH/TEST_BASE_DIR are defined to refer to overlay base dir explicitly, whether it was set by old or new config method. Tests should always use these canonical vars and not the fake SCRATCH/TEST_DEV vars when referring to overlay based dir. An upcoming change is going to support mount/umount of base fs. Signed-off-by: Amir Goldstein --- common/config | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- common/rc | 20 +++++++++++--------- 2 files changed, 62 insertions(+), 10 deletions(-) diff --git a/common/config b/common/config index 0706aca..db5721c 100644 --- a/common/config +++ b/common/config @@ -35,6 +35,8 @@ # RMT_TAPE_DEV - the remote tape device for the xfsdump tests # RMT_IRIXTAPE_DEV- the IRIX remote tape device for the xfsdump tests # RMT_TAPE_USER - remote user for tape device +# TEST_BASE_MNT - mount point for base fs of overlay test dirs +# SCRATCH_BASE_MNT- mount point for base fs of overlay scratch dirs # # - These can be added to $HOST_CONFIG_DIR (witch default to ./config) # below or a separate local configuration file can be used (using @@ -77,6 +79,9 @@ export XFS_MKFS_OPTIONS=${XFS_MKFS_OPTIONS:=-bsize=4096} export TIME_FACTOR=${TIME_FACTOR:=1} export LOAD_FACTOR=${LOAD_FACTOR:=1} export DEBUGFS_MNT=${DEBUGFS_MNT:="/sys/kernel/debug"} +# directory inside TEST/SCRATCH_BASE_MNT where overlay dirs are created +export OVERLAY_BASE_DIR=${OVERLAY_BASE_DIR:="ovl"} +# directories created inside TEST/SCRATCH_BASE_DIR export OVERLAY_UPPER_DIR=${OVERLAY_UPPER_DIR:="upper"} export OVERLAY_LOWER_DIR=${OVERLAY_LOWER_DIR:="lower"} export OVERLAY_WORK_DIR=${OVERLAY_WORK_DIR:="work"} @@ -443,7 +448,7 @@ _check_device() echo $dev | grep -qE ":|//" > /dev/null 2>&1 network_dev=$? if [ "$FSTYP" == "overlay" ]; then - if [ ! -d "$dev" ]; then + if [ -z "$TEST_BASE_MNT" -a ! -d "$dev" ]; then _fatal "common/config: $name ($dev) is not a directory for overlay" fi elif [ ! -b "$dev" -a "$network_dev" != "0" ]; then @@ -451,6 +456,46 @@ _check_device() fi } +# Set SCRATCH/TEST_BASE_DIR either from legacy TEST/SCRATCH_DEV +# Or by deriving them from base fs if SCRATCH/TEST_BASE_MNT are defined. +# Tests should always use SCRATCH/TEST_BASE_DIR when referering to +# overlay base dir explicitly. +_config_overlay() +{ + # There are 2 options for testing overlayfs: + # + # 1. (legacy) set SCRATCH/TEST_DEV to existing directories + # on an already mounted fs. + # + [ -z "$TEST_DEV" ] || export TEST_BASE_DIR="$TEST_DEV" + [ -z "$SCRATCH_DEV" ] || export SCRATCH_BASE_DIR="$SCRATCH_DEV" + + # 2. set SCRATCH/TEST_BASE_MNT to configure base fs. + # SCRATCH/TEST_DEV are derived from SCRATCH/TEST_BASE_MNT + # and therein, overlay fs directories will be created. + [ -n "$TEST_BASE_MNT" ] || return + + if [ ! -d "$TEST_BASE_MNT" ]; then + echo "common/config: Error: \$TEST_BASE_MNT ($TEST_BASE_MNT) is not a directory" + exit 1 + fi + + export TEST_BASE_DIR="$TEST_BASE_MNT/$OVERLAY_BASE_DIR" + # Set TEST_DEV to base dir to satisfy common helpers + export TEST_DEV="$TEST_BASE_DIR" + + [ -n "$SCRATCH_BASE_MNT" ] || return + + if [ ! -d "$SCRATCH_BASE_MNT" ]; then + echo "common/config: Error: \$SCRATCH_BASE_MNT ($SCRATCH_BASE_MNT) is not a directory" + exit 1 + fi + + export SCRATCH_BASE_DIR="$SCRATCH_BASE_MNT/$OVERLAY_BASE_DIR" + # Set SCRATCH_DEV to base dir to satisfy common helpers + export SCRATCH_DEV="$SCRATCH_BASE_DIR" +} + # Parse config section options. This function will parse all the configuration # within a single section which name is passed as an argument. For section # name format see comments in get_config_sections(). @@ -525,6 +570,11 @@ get_next_config() { export RESULT_BASE="$here/results/" fi + # Maybe derive TEST_DEV from TEST_BASE_MNT + if [ "$FSTYP" == "overlay" ]; then + _config_overlay + fi + # Mandatory Config values. MC="" [ -z "$EMAIL" ] && MC="$MC EMAIL" diff --git a/common/rc b/common/rc index 862bc04..f5ab869 100644 --- a/common/rc +++ b/common/rc @@ -257,7 +257,7 @@ _scratch_mount_options() _scratch_options mount if [ "$FSTYP" == "overlay" ]; then - echo `_overlay_mount_options $SCRATCH_DEV` + echo `_overlay_mount_options $SCRATCH_BASE_DIR` return 0 fi echo `_common_dev_mount_options $*` $SCRATCH_OPTIONS \ @@ -322,12 +322,12 @@ _overlay_mount() _overlay_test_mount() { - _overlay_mount $TEST_DEV $TEST_DIR $* + _overlay_mount $TEST_BASE_DIR $TEST_DIR $* } _overlay_scratch_mount() { - _overlay_mount $SCRATCH_DEV $SCRATCH_MNT $* + _overlay_mount $SCRATCH_BASE_DIR $SCRATCH_MNT $* } _overlay_test_unmount() @@ -641,10 +641,12 @@ _scratch_cleanup_files() { case $FSTYP in overlay) - # $SCRATCH_DEV is a valid directory in overlay case - rm -rf $SCRATCH_DEV/* + # Avoid rm -rf /* if we messed up + [ -n "$SCRATCH_BASE_DIR" ] || return + rm -rf $SCRATCH_BASE_DIR/* ;; *) + [ -n "$SCRATCH_MNT" ] || return _scratch_mount rm -rf $SCRATCH_MNT/* _scratch_unmount @@ -1343,8 +1345,8 @@ _require_scratch_nocheck() fi ;; overlay) - if [ -z "$SCRATCH_DEV" -o ! -d "$SCRATCH_DEV" ]; then - _notrun "this test requires a valid \$SCRATCH_DEV as ovl base dir" + if [ -z "$SCRATCH_BASE_DIR" -o ! -d "$SCRATCH_BASE_DIR" ]; then + _notrun "this test requires a valid \$SCRATCH_BASE_DIR as ovl base dir" fi if [ ! -d "$SCRATCH_MNT" ]; then _notrun "this test requires a valid \$SCRATCH_MNT" @@ -1428,8 +1430,8 @@ _require_test() fi ;; overlay) - if [ -z "$TEST_DEV" -o ! -d "$TEST_DEV" ]; then - _notrun "this test requires a valid \$TEST_DEV as ovl base dir" + if [ -z "$TEST_BASE_DIR" -o ! -d "$TEST_BASE_DIR" ]; then + _notrun "this test requires a valid \$TEST_BASE_DIR as ovl base dir" fi if [ ! -d "$TEST_DIR" ]; then _notrun "this test requires a valid \$TEST_DIR"