From patchwork Tue Aug 9 11:16:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eryu Guan X-Patchwork-Id: 9270903 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 9888260754 for ; Tue, 9 Aug 2016 11:16:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A75D27F95 for ; Tue, 9 Aug 2016 11:16:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7F2B027FAB; Tue, 9 Aug 2016 11:16:36 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 1CC9E27F95 for ; Tue, 9 Aug 2016 11:16:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752045AbcHILQf (ORCPT ); Tue, 9 Aug 2016 07:16:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55476 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751657AbcHILQe (ORCPT ); Tue, 9 Aug 2016 07:16:34 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3D4D73B716; Tue, 9 Aug 2016 11:16:34 +0000 (UTC) Received: from localhost (dhcp-13-153.nay.redhat.com [10.66.13.153]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u79BGXfv015166; Tue, 9 Aug 2016 07:16:33 -0400 From: Eryu Guan To: fstests@vger.kernel.org Cc: linux-unionfs@vger.kernel.org, Eryu Guan Subject: [PATCH 1/2] common/rc: introduce _overlay_mount_dirs helper Date: Tue, 9 Aug 2016 19:16:20 +0800 Message-Id: <1470741381-32610-1-git-send-email-eguan@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 09 Aug 2016 11:16:34 +0000 (UTC) Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Introduce a new _overlay_mount_dirs() helper to do the actual overlay mount operation and factor _overlay_scratch_mount and _overlay_mount code to use a single implemention of _overlay_mount_dirs(). Also convert all bare mount of overlay in tests to use it. Suggested-by: Dave Chinner Signed-off-by: Eryu Guan --- common/rc | 21 +++++++++++++++------ tests/overlay/005 | 6 ++---- tests/overlay/010 | 5 ++--- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/common/rc b/common/rc index b19b698..6c1c3ff 100644 --- a/common/rc +++ b/common/rc @@ -266,6 +266,18 @@ _scratch_mount_options() $SCRATCH_DEV $SCRATCH_MNT } +# helper function to do the actual overlayfs mount operation +_overlay_mount_dirs() +{ + local lowerdir=$1 + local upperdir=$2 + local workdir=$3 + shift 3 + + $MOUNT_PROG -t overlay -o lowerdir=$lowerdir -o upperdir=$upperdir \ + -o workdir=$workdir $* +} + # Given a dir, set up 3 subdirectories and mount on the given mnt. # The dir is used as the mount device so it can be seen from df or mount _overlay_mount() @@ -293,12 +305,9 @@ _overlay_mount() mkdir -p $dir/$OVERLAY_LOWER_DIR mkdir -p $dir/$OVERLAY_WORK_DIR - $MOUNT_PROG -t overlay $SELINUX_MOUNT_OPTIONS \ - -o lowerdir=$dir/$OVERLAY_LOWER_DIR \ - -o upperdir=$dir/$OVERLAY_UPPER_DIR \ - -o workdir=$dir/$OVERLAY_WORK_DIR \ - $OVERLAY_MOUNT_OPTIONS $* \ - $dir $mnt + _overlay_mount_dirs $dir/$OVERLAY_LOWER_DIR $dir/$OVERLAY_UPPER_DIR \ + $dir/$OVERLAY_WORK_DIR $OVERLAY_MOUNT_OPTIONS $* \ + $dir $mnt } _overlay_test_mount() diff --git a/tests/overlay/005 b/tests/overlay/005 index 495e7b5..522c6f0 100755 --- a/tests/overlay/005 +++ b/tests/overlay/005 @@ -93,10 +93,8 @@ $XFS_IO_PROG -f -c "truncate 48m" ${lowerd}/test_file \ >>$seqres.full 2>&1 # mount new overlayfs -$MOUNT_PROG -t overlay $SELINUX_MOUNT_OPTIONS \ - -o lowerdir=$lowerd -o upperdir=$upperd \ - -o workdir=$workd \ - $SCRATCH_DEV $SCRATCH_MNT +_overlay_mount_dirs $lowerd $upperd $workd $SELINUX_MOUNT_OPTIONS \ + $SCRATCH_DEV $SCRATCH_MNT # 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 5d1c2bd..a302d74 100755 --- a/tests/overlay/010 +++ b/tests/overlay/010 @@ -67,9 +67,8 @@ touch $lowerdir1/testdir/a $lowerdir1/testdir/b mknod $lowerdir2/testdir/a c 0 0 # Mount overlayfs and remove testdir, which led to kernel crash -$MOUNT_PROG -t overlay -o lowerdir=$lowerdir2:$lowerdir1 \ - -o upperdir=$upperdir,workdir=$workdir \ - $SCRATCH_DEV $SCRATCH_MNT +_overlay_mount_dirs "$lowerdir2:$lowerdir1" $upperdir $workdir \ + $SCRATCH_DEV $SCRATCH_MNT rm -rf $SCRATCH_MNT/testdir # success, all done