From patchwork Wed Mar 14 13:16:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Goyal X-Patchwork-Id: 10282149 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 230AB6038F for ; Wed, 14 Mar 2018 13:16:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 13334288E8 for ; Wed, 14 Mar 2018 13:16:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 082AC288EF; Wed, 14 Mar 2018 13:16:21 +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 7FB24288E8 for ; Wed, 14 Mar 2018 13:16:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751624AbeCNNQU (ORCPT ); Wed, 14 Mar 2018 09:16:20 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54950 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751488AbeCNNQT (ORCPT ); Wed, 14 Mar 2018 09:16:19 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BD7E581A8B74; Wed, 14 Mar 2018 13:16:18 +0000 (UTC) Received: from horse.redhat.com (unknown [10.18.25.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E5362166BAE; Wed, 14 Mar 2018 13:16:18 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id 413FE220175; Wed, 14 Mar 2018 09:16:18 -0400 (EDT) Date: Wed, 14 Mar 2018 09:16:18 -0400 From: Vivek Goyal To: eguan@redhat.com, fstests@vger.kernel.org, Amir Goldstein Cc: linux-unionfs@vger.kernel.org, Miklos Szeredi Subject: [PATCH V3] xfstest: overlay: Absolute redirect should be followed even if ancestor is opaque Message-ID: <20180314131618.GA1001@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 14 Mar 2018 13:16:18 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 14 Mar 2018 13:16:18 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'vgoyal@redhat.com' RCPT:'' Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Typically, when following absolute redirect, if an opauqe dentry is found, lookup in further lower directories is stopped. But if a child dentry has another absolute redirect, then lookup in further lower layers should continue. Say, following is example setup. upper: /redirect (redirect=/a/b/c) lower1: /a/[b]/c ([b] is opaque) (c has absolute redirect=/a/b/d/) lower0: /a/b/d/foo "redirect" directory in upper should merge with lower1:/a/b/c/ and lower0:/a/b/d/, despite lower1:/a/b/ being opaque. This example and kernel fix has come from Amir Goldstein. I am just putting a test for it to make sure its not broken down the line. v3: Took care of more comments from amir. - Added some comments. - Added _overlay_check_scratch_dirs call. Signed-off-by: Vivek Goyal Reviewed-by: Amir Goldstein --- tests/overlay/057 | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/overlay/057.out | 2 + tests/overlay/group | 1 3 files changed, 103 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: xfstests-dev/tests/overlay/057 =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ xfstests-dev/tests/overlay/057 2018-03-14 09:10:00.577179042 -0400 @@ -0,0 +1,100 @@ +#! /bin/bash +# FS QA Test No. 057 +# +# Test absolute redirect is followed even if ancestor is opaque +# +# Typically, when following absolute redirect, if an opauqe dentry is +# found, lookup in further lower directories is stopped. But if a +# child dentry has another absolute redirect, then lookup in further +# lower layers should continue. +# +# Say, following is example setup. +# upper: /redirect (redirect=/a/b/c) +# lower1: /a/[b]/c ([b] is opaque) (c has absolute redirect=/a/b/d/) +# lower0: /a/b/d/foo +# +# "redirect" directory in upper should merge with lower1:/a/b/c/ and +# lower0:/a/b/d/, despite lower1:/a/b/ being opaque. +# +#----------------------------------------------------------------------- +# Copyright (C) 2018 Red Hat, Inc. All Rights Reserved. +# Author: Vivek Goyal +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# + +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here +_supported_fs overlay +_supported_os Linux +# We use non-default scratch underlying overlay dirs, we need to check +# them explicity after test. +_require_scratch_nocheck +_require_scratch_overlay_features redirect_dir + +# remove all files from previous tests +_scratch_mkfs + +# Create test directories +lowerdir=$OVL_BASE_SCRATCH_MNT/lower +lowerdir2=$OVL_BASE_SCRATCH_MNT/lower2 +upperdir=$OVL_BASE_SCRATCH_MNT/upper +workdir=$OVL_BASE_SCRATCH_MNT/workdir +workdir2=$OVL_BASE_SCRATCH_MNT/workdir2 + +mkdir -p $lowerdir $lowerdir2 $upperdir $workdir $workdir2 +mkdir -p $lowerdir/origin +touch $lowerdir/origin/foo +_overlay_scratch_mount_dirs $lowerdir $lowerdir2 $workdir2 -o redirect_dir=on + +# Create opaque parent with absolute redirect child in middle layer +mkdir $SCRATCH_MNT/pure +mv $SCRATCH_MNT/origin $SCRATCH_MNT/pure/redirect +$UMOUNT_PROG $SCRATCH_MNT +_overlay_scratch_mount_dirs $lowerdir2:$lowerdir $upperdir $workdir -o redirect_dir=on +mv $SCRATCH_MNT/pure/redirect $SCRATCH_MNT/redirect + +# Verify that redirects are followed after mount cycle +$UMOUNT_PROG $SCRATCH_MNT +_overlay_scratch_mount_dirs $lowerdir2:$lowerdir $upperdir $workdir -o redirect_dir=on +ls $SCRATCH_MNT/redirect/ + +# check overlayfs +_overlay_check_scratch_dirs "$lowerdir2:$lowerdir" $upperdir $workdir -o redirect_dir=on + +# success, all done +status=0 +exit Index: xfstests-dev/tests/overlay/group =================================================================== --- xfstests-dev.orig/tests/overlay/group 2018-02-28 15:27:29.981693615 -0500 +++ xfstests-dev/tests/overlay/group 2018-03-12 09:31:45.692818432 -0400 @@ -59,3 +59,4 @@ 054 auto quick copyup redirect exportfs 055 auto quick copyup redirect exportfs nonsamefs 056 auto quick fsck +057 auto quick redirect Index: xfstests-dev/tests/overlay/057.out =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ xfstests-dev/tests/overlay/057.out 2018-03-12 13:09:42.061818432 -0400 @@ -0,0 +1,2 @@ +QA output created by 057 +foo