From patchwork Wed Jan 25 06:51:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 9536477 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 D77D46046A for ; Wed, 25 Jan 2017 06:51:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BBAA626E3E for ; Wed, 25 Jan 2017 06:51:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AFAAA26E75; Wed, 25 Jan 2017 06:51:39 +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 3464826E3E for ; Wed, 25 Jan 2017 06:51:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751292AbdAYGvi (ORCPT ); Wed, 25 Jan 2017 01:51:38 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:36021 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751286AbdAYGvi (ORCPT ); Wed, 25 Jan 2017 01:51:38 -0500 Received: by mail-wm0-f66.google.com with SMTP id r126so40348572wmr.3; Tue, 24 Jan 2017 22:51:37 -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; bh=j8127oakRqIcQWaUjAGFytrGTg4nJuQle3FkZPHP+iA=; b=OP038jhg+PFJXxB1+VGeXKGag21+UMUrVtihXwINQddfZwzKHskTGTTC4b1gNALOZw UHKjoITyWAx1j8bCGWQtUzZj84Ega+2Zyffb4T/Dusjo9WF/O40Uk2GQcyrBQWXsVVCs a1mzUYY2QTAGHlepR2WuBCU1o8SUOK0kmWxYhNcjtU/kbeyLfefMU6s7S7mXyWg5Wxlw MLfTN9UlE4Yn8Z8diUGOAbzW8paQEPE28sTCifA31+3nhQfiXt1P23kgf/3p9LKqXdsV C48gTF18XhY0XwRgO++BW0EM6FF7UqODZJDWHb5dqBXUKNwAaMAOZ3mMBmDqOJWwOSH2 DxTQ== 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; bh=j8127oakRqIcQWaUjAGFytrGTg4nJuQle3FkZPHP+iA=; b=ulyXmTmta/r1dSDoHUVf6j3LlxOPC+9owTT60jfQdzA13QgQ3Hvi7Ch7h+08hjiFw/ p5Fd19Z/OW+VpZOL7LZ/64No7mgkJzaxGsiXDTs16fslgygte0zPiJm8MfUGV6hB2sdQ tjCagALUzM38gXJtJD4qj6nitdsbAGGBWirU9r/3CGOWyCboVjViIYyKeguc6oVkmFoJ 6vXJv/hKHbdCElNkt83CxjaA6wiqi4Z1/YNJ4Bx8AtqgC8frO+vKbADD5vTp1bh5sPH7 ZG734ZawgWVBUsdFSM2ZS7wGBCvHsN+gJiHvozCyJz0XnvHarfddJcxud3bb2Re1ec09 VAuw== X-Gm-Message-State: AIkVDXKmc6p11CPzoqhI71TF/ZDWXtWFjCRot/hRt5YkOjn5IoD1H11j2gh7MjK4U4pqOw== X-Received: by 10.28.222.11 with SMTP id v11mr20389698wmg.1.1485327096210; Tue, 24 Jan 2017 22:51:36 -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 y145sm29776427wmc.17.2017.01.24.22.51.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 Jan 2017 22:51:35 -0800 (PST) From: Amir Goldstein To: Eryu Guan Cc: Miklos Szeredi , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [RFC][PATCH] common: mount overlay base fs for running tests Date: Wed, 25 Jan 2017 08:51:24 +0200 Message-Id: <1485327084-26190-1-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 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 fake TEST/SCRATCH_DEV vars to existing overlay directories, allow setting the vars OVERLAY_BASE_DEV/MNT, to configure the base fs where overlay directories are created. For example: -export TEST_DEV=/mnt/xfs/ovl/test -export SCRATCH_DEV=/mnt/xfs/ovl/scratch +export OVERLAY_BASE_DEV=/dev/mapper/test-xfs +export OVERLAY_BASE_MNT=/mnt/xfs export TEST_DIR=/mnt/test export SCRATCH_MNT=/mnt/scratch export FSTYP=overlay With this change, the base fs is mounted before running the tests unmounted after running the tests and recycled on _test_cycle_mount. This helps catching overlayfs bugs related to leaking objects in underlying (base) fs. Signed-off-by: Amir Goldstein --- common/config | 35 ++++++++++++++++++++++++++++++++++- common/rc | 8 ++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) Eryu, I was planning to also support _test_mkfs for base fs (as kvm-xfstests does), but decided to make a RFC rest stop after _test_mount, which seems useful in its own right. The main point to consider is whether it is worth separating OVERLAY_BASE_DEV to test and scratch base devices. This patch (with shared dev) is much simpler to configure to I am sending it out to see if folk think it is sufficiently useful as is. The limitation of keepong this patch as is, is not being able to recycle base fs on _scratch_mount/umount/recycle and not being able to mkfs base fs on _scratch_mkfs. Thought? Amir. diff --git a/common/config b/common/config index 0706aca..d63c22a 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 +# OVERLAY_BASE_DEV- device for base fs containing overlay directories +# OVERLAY_BASE_MNT- mount point for base fs of overlay directories # # - 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 $OVERLAY_BASE_MNT where TEST/SCRATCH_DEV dirs are created +export OVERLAY_BASE_DIR=${OVERLAY_BASE_DIR:="ovl"} +# directories created inside TEST/SCRATCH_DEV 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 "$OVERLAY_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,29 @@ _check_device() fi } +# Derive TEST/SCRATCH_DEV from base fs if OVERLAY_BASE_MNT is defined +_config_overlay() +{ + # There are 2 options for testing overlayfs: + # + # 1. (legacy) set SCRATCH/TEST_DEV to existing directories + # on an already mounted fs. + # + # 2. set OVERLAY_BASE_DEV/MNT to configure base fs. + # SCRATCH/TEST_DEV are derived from OVERLAY_BASE_MNT and therein, + # overlay fs directories will be created. + [ -n "$OVERLAY_BASE_MNT" ] || return + + _check_device OVERLAY_BASE_DEV required $OVERLAY_BASE_DEV + if [ ! -d "$OVERLAY_BASE_MNT" ]; then + echo "common/config: Error: \$OVERLAY_BASE_MNT ($OVERLAY_BASE_MNT) is not a directory" + exit 1 + fi + + export TEST_DEV="$OVERLAY_BASE_MNT/$OVERLAY_BASE_DIR/test" + export SCRATCH_DEV="$OVERLAY_BASE_MNT/$OVERLAY_BASE_DIR/scratch" +} + # 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 +553,11 @@ get_next_config() { export RESULT_BASE="$here/results/" fi + # Maybe derive TEST_DEV from OVERLAY_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..8c403e3 100644 --- a/common/rc +++ b/common/rc @@ -322,6 +322,11 @@ _overlay_mount() _overlay_test_mount() { + if [ -n "$OVERLAY_BASE_MNT" ]; then + _mount $OVERLAY_BASE_MOUNT_OPTIONS \ + $SELINUX_MOUNT_OPTIONS \ + $OVERLAY_BASE_DEV $OVERLAY_BASE_MNT + fi _overlay_mount $TEST_DEV $TEST_DIR $* } @@ -333,6 +338,9 @@ _overlay_scratch_mount() _overlay_test_unmount() { $UMOUNT_PROG $TEST_DIR + if [ -n "$OVERLAY_BASE_MNT" ]; then + $UMOUNT_PROG $OVERLAY_BASE_MNT + fi } _overlay_scratch_unmount()