From patchwork Wed Sep 27 07:04:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 9973235 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 840A46037F for ; Wed, 27 Sep 2017 07:03:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 78B7F23B3C for ; Wed, 27 Sep 2017 07:03:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6DA02290CB; Wed, 27 Sep 2017 07:03:52 +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 088B729057 for ; Wed, 27 Sep 2017 07:03:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752071AbdI0HDt (ORCPT ); Wed, 27 Sep 2017 03:03:49 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:36422 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751396AbdI0HDp (ORCPT ); Wed, 27 Sep 2017 03:03:45 -0400 Received: by mail-wm0-f68.google.com with SMTP id r136so10580717wmf.3; Wed, 27 Sep 2017 00:03:44 -0700 (PDT) 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=1O2YvBda7BMh/yfU9d9dPWlVqBteE1Tf+LHxb96jyHc=; b=PYwD5dfWzUalgakzwsLTPVVOM+Kavt19FNiOi7DyRrCSS1BgPYg3NjKznwWo2F9SwR /ZGhyDFR5xCre/bZyyDvgIQa555aS8Dk1AWeYTM9dHzbvawtImJbj6mc0twNCbeG0Thi P2dIxxc1dRI7Ez9oiYl1BI0RjwyUlxeStSwicrjfgAxjX2THzJNwJMpocDdcItSe2iQx PvMYb4czXi+D+ghDGRyembKfoBuyWxXHo2vNrnjgh+UA96syVTMVfmiipCkB+0l7N3IV MXl93g341CjZNMiATYCw76IvysO9o5Peirm9DqutfejZX4sHywYj0UROVx0ZCzhPx3xw KBHA== 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=1O2YvBda7BMh/yfU9d9dPWlVqBteE1Tf+LHxb96jyHc=; b=hdtEWpG8+b4R0e6DlHtP5EDKfGJdcGQb3l4DrvbEk46q0btO5pdOXdYjs+AFh4oQhS 4zB+Rc7Odef6pHlkTE4GklFaFRmVFx7Ctt6tFlb2j95LOv5nNnwJZ+fFRNFQovHv8dYX 2s+hnP1uGU/rb0RA68SvDq6r2EIkYPpf+N0bYo/AipW28c8sgsQeHUkXuk0MjvkzUJ/d KTKAwwroKCAoBb6jpYL6k5Z6aOOEKFTCS512XSEJJix9y5xQnnIVcoe8NbXQeobNyLTL F2bmGOIGvHO05FRl5xpoZNMPfQMPKnk2YW/xhSVxA4SZIcxREDLC92GAXr2RZwYdnJvI RBEg== X-Gm-Message-State: AHPjjUiw2sJlheL97ER2jNEOrPsnVraNYO2TolJEDA5JzAWsCBlL/Liq a548zrCljOPjU76Duc105QwsXg== X-Google-Smtp-Source: AOwi7QBFwpm4NbxE+2F/QKBdP4mdRrqdILMX8S3ZaYmOz+3JEDaqEpPAXdHnvebzLtALtMfKtl526w== X-Received: by 10.28.50.200 with SMTP id y191mr593201wmy.74.1506495823554; Wed, 27 Sep 2017 00:03:43 -0700 (PDT) Received: from localhost.localdomain (bzq-166-168-31-246.red.bezeqint.net. [31.168.166.246]) by smtp.gmail.com with ESMTPSA id m4sm9239535wrb.35.2017.09.27.00.03.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 27 Sep 2017 00:03:43 -0700 (PDT) From: Amir Goldstein To: Eryu Guan Cc: Miklos Szeredi , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH 3/4] overlay: create helper _overlay_scratch_mount_dirs() Date: Wed, 27 Sep 2017 10:04:11 +0300 Message-Id: <1506495852-7295-4-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1506495852-7295-1-git-send-email-amir73il@gmail.com> References: <1506495852-7295-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 A helper to mount with same options/mnt/dev of scratch mount, but optionally with different lower/upper/work dirs. use instead of _overlay_mount_dirs() in all tests where applicable. Signed-off-by: Amir Goldstein --- common/rc | 13 +++++++++++++ tests/overlay/005 | 2 +- tests/overlay/010 | 3 +-- tests/overlay/014 | 8 +++----- tests/overlay/031 | 11 +++++------ tests/overlay/035 | 3 +-- tests/overlay/037 | 14 ++++++-------- tests/overlay/038 | 3 +-- 8 files changed, 31 insertions(+), 26 deletions(-) diff --git a/common/rc b/common/rc index b30c4b9..54f81d3 100644 --- a/common/rc +++ b/common/rc @@ -345,6 +345,19 @@ _overlay_mount_dirs() -o workdir=$workdir `_common_dev_mount_options $*` } +# Mount with same options/mnt/dev of scratch mount, but optionally +# with different lower/upper/work dirs +_overlay_scratch_mount_dirs() +{ + local lowerdir=$1 + local upperdir=$2 + local workdir=$3 + shift 3 + + _overlay_mount_dirs $lowerdir $upperdir $workdir \ + $* $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT +} + _overlay_mkdirs() { local dir=$1 diff --git a/tests/overlay/005 b/tests/overlay/005 index f885fdc..17992a3 100755 --- a/tests/overlay/005 +++ b/tests/overlay/005 @@ -93,7 +93,7 @@ $XFS_IO_PROG -f -c "truncate 48m" ${lowerd}/test_file \ >>$seqres.full 2>&1 # mount new overlayfs -_overlay_mount_dirs $lowerd $upperd $workd $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT +_overlay_scratch_mount_dirs $lowerd $upperd $workd # the open call triggers copy-up and it will fail ENOSPC $XFS_IO_PROG -f -c "o" ${SCRATCH_MNT}/test_file \ diff --git a/tests/overlay/010 b/tests/overlay/010 index dee99cf..f55ebec 100755 --- a/tests/overlay/010 +++ b/tests/overlay/010 @@ -67,8 +67,7 @@ touch $lowerdir1/testdir/a $lowerdir1/testdir/b mknod $lowerdir2/testdir/a c 0 0 # Mount overlayfs and remove testdir, which led to kernel crash -_overlay_mount_dirs "$lowerdir2:$lowerdir1" $upperdir $workdir \ - $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT +_overlay_scratch_mount_dirs "$lowerdir2:$lowerdir1" $upperdir $workdir rm -rf $SCRATCH_MNT/testdir # success, all done diff --git a/tests/overlay/014 b/tests/overlay/014 index cd76835..9f308d3 100755 --- a/tests/overlay/014 +++ b/tests/overlay/014 @@ -72,7 +72,7 @@ mkdir -p $lowerdir1/testdir/d # mount overlay with $lowerdir2 as upperdir, and remove & recreate testdir, # make testdir on $lowerdir2 opaque -_overlay_mount_dirs $lowerdir1 $lowerdir2 $workdir2 $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT +_overlay_scratch_mount_dirs $lowerdir1 $lowerdir2 $workdir2 rm -rf $SCRATCH_MNT/testdir mkdir -p $SCRATCH_MNT/testdir/visibledir # unmount overlayfs but not base fs @@ -81,15 +81,13 @@ $UMOUNT_PROG $SCRATCH_MNT # mount overlay again, with lowerdir1 and lowerdir2 as multiple lowerdirs, # and create a new file in testdir, triggers copyup from lowerdir, # copyup should not copy overlayfs private xattr -_overlay_mount_dirs "$lowerdir2:$lowerdir1" $upperdir $workdir \ - $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT +_overlay_scratch_mount_dirs "$lowerdir2:$lowerdir1" $upperdir $workdir touch $SCRATCH_MNT/testdir/visiblefile # umount and mount overlay again, buggy kernel treats the copied-up dir as # opaque, visibledir is not seen in merged dir. $UMOUNT_PROG $SCRATCH_MNT -_overlay_mount_dirs "$lowerdir2:$lowerdir1" $upperdir $workdir \ - $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT +_overlay_scratch_mount_dirs "$lowerdir2:$lowerdir1" $upperdir $workdir ls $SCRATCH_MNT/testdir # success, all done diff --git a/tests/overlay/031 b/tests/overlay/031 index 70ee299..186b409 100755 --- a/tests/overlay/031 +++ b/tests/overlay/031 @@ -51,7 +51,7 @@ create_whiteout() mkdir -p $lower/testdir touch $lower/testdir/$file - _overlay_mount_dirs $lower $upper $work $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT + _overlay_scratch_mount_dirs $lower $upper $work rm -f $SCRATCH_MNT/testdir/$file @@ -91,7 +91,7 @@ create_whiteout $lowerdir1 $upperdir $workdir $testfile1 # whiteout will expose. rm -rf $lowerdir1/testdir -_overlay_mount_dirs $lowerdir1 $upperdir $workdir $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT +_overlay_scratch_mount_dirs $lowerdir1 $upperdir $workdir ls $SCRATCH_MNT/testdir @@ -104,7 +104,7 @@ rm -rf $SCRATCH_MNT/testdir 2>&1 | _filter_scratch $UMOUNT_PROG $SCRATCH_MNT touch $lowerdir1/testdir -_overlay_mount_dirs $lowerdir1 $upperdir $workdir $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT +_overlay_scratch_mount_dirs $lowerdir1 $upperdir $workdir # try to remove test dir from overlay dir, trigger ovl_remove_and_whiteout, # it will not clean up the dir and lead to residue. @@ -121,8 +121,7 @@ create_whiteout $lowerdir2 $lowerdir1 $workdir1 $testfile1 rm -rf $lowerdir2/testdir -_overlay_mount_dirs "$lowerdir1:$lowerdir2" $upperdir $workdir \ - $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT +_overlay_scratch_mount_dirs "$lowerdir1:$lowerdir2" $upperdir $workdir ls $SCRATCH_MNT/testdir rm -rf $SCRATCH_MNT/testdir 2>&1 | _filter_scratch @@ -139,7 +138,7 @@ rm -rf $lowerdir1/testdir/$testfile1 create_whiteout $lowerdir2 $lowerdir1 $workdir1 $testfile2 -_overlay_mount_dirs $lowerdir1 $upperdir $workdir $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT +_overlay_scratch_mount_dirs $lowerdir1 $upperdir $workdir ls $SCRATCH_MNT/testdir rm -rf $SCRATCH_MNT/testdir 2>&1 | _filter_scratch diff --git a/tests/overlay/035 b/tests/overlay/035 index 0ef91c6..64fcd70 100755 --- a/tests/overlay/035 +++ b/tests/overlay/035 @@ -77,8 +77,7 @@ $CHATTR_PROG +i $workdir # Mount overlay with upper and workdir and expect failure to re-create workdir. # Verify that overlay is mounted read-only and that it cannot be remounted rw. -_overlay_mount_dirs $lowerdir2 $upperdir $workdir \ - $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT +_overlay_scratch_mount_dirs $lowerdir2 $upperdir $workdir touch $SCRATCH_MNT/bar 2>&1 | _filter_scratch _scratch_remount rw 2>&1 | _filter_scratch diff --git a/tests/overlay/037 b/tests/overlay/037 index 6be9a26..7287329 100755 --- a/tests/overlay/037 +++ b/tests/overlay/037 @@ -71,23 +71,21 @@ mkdir -p $lowerdir $lowerdir2 $upperdir $upperdir2 $workdir # Mount overlay with lowerdir, upperdir, workdir and index=on # to store the file handles of lowerdir and upperdir in overlay.origin xattr -_overlay_mount_dirs $lowerdir $upperdir $workdir \ - $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT -oindex=on +_overlay_scratch_mount_dirs $lowerdir $upperdir $workdir -oindex=on $UMOUNT_PROG $SCRATCH_MNT # Try to mount an overlay with the same upperdir and different lowerdir - expect ESTALE -_overlay_mount_dirs $lowerdir2 $upperdir $workdir \ - $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT -oindex=on 2>&1 | _filter_scratch +_overlay_scratch_mount_dirs $lowerdir2 $upperdir $workdir -oindex=on \ + 2>&1 | _filter_scratch $UMOUNT_PROG $SCRATCH_MNT 2>/dev/null # Try to mount an overlay with the same workdir and different upperdir - expect ESTALE -_overlay_mount_dirs $lowerdir $upperdir2 $workdir \ - $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT -oindex=on 2>&1 | _filter_scratch +_overlay_scratch_mount_dirs $lowerdir $upperdir2 $workdir -oindex=on \ + 2>&1 | _filter_scratch $UMOUNT_PROG $SCRATCH_MNT 2>/dev/null # Mount overlay with original lowerdir, upperdir, workdir and index=on - expect success -_overlay_mount_dirs $lowerdir $upperdir $workdir \ - $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT -oindex=on +_overlay_scratch_mount_dirs $lowerdir $upperdir $workdir -oindex=on # success, all done status=0 diff --git a/tests/overlay/038 b/tests/overlay/038 index 69fd76a..a281691 100755 --- a/tests/overlay/038 +++ b/tests/overlay/038 @@ -177,8 +177,7 @@ mkdir -p $workdir mkdir -p $middir/test_dir mkdir -p $lowerdir/test_dir/pure_lower_dir -$MOUNT_PROG -t overlay overlay -o lowerdir=$middir:$lowerdir \ - -o upperdir=$upperdir -o workdir=$workdir $SCRATCH_MNT +_overlay_scratch_mount_dirs "$middir:$lowerdir" $upperdir $workdir # Copy up test_dir touch $SCRATCH_MNT/test_dir/test_file