From patchwork Fri Sep 1 14:23:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Rajendra X-Patchwork-Id: 9934379 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 C13996038C for ; Fri, 1 Sep 2017 14:23:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B381D2867D for ; Fri, 1 Sep 2017 14:23:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A816928684; Fri, 1 Sep 2017 14:23:59 +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 E6A212867D for ; Fri, 1 Sep 2017 14:23:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751964AbdIAOXU (ORCPT ); Fri, 1 Sep 2017 10:23:20 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:52990 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752127AbdIAOXM (ORCPT ); Fri, 1 Sep 2017 10:23:12 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v81EKBia034152 for ; Fri, 1 Sep 2017 10:23:12 -0400 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cq90vh128-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 01 Sep 2017 10:23:11 -0400 Received: from localhost by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 1 Sep 2017 08:23:11 -0600 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 1 Sep 2017 08:23:09 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v81EN8D360620898; Fri, 1 Sep 2017 07:23:08 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8582978051; Fri, 1 Sep 2017 08:23:08 -0600 (MDT) Received: from localhost.localdomain.com (unknown [9.85.72.156]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP id 0CAA778037; Fri, 1 Sep 2017 08:23:05 -0600 (MDT) From: Chandan Rajendra To: amir73il@gmail.com, eguan@redhat.com Cc: Chandan Rajendra , fstests@vger.kernel.org, miklos@szeredi.hu, linux-unionfs@vger.kernel.org Subject: [PATCH V3] overlay: Test constant d_ino feature Date: Fri, 1 Sep 2017 19:53:41 +0530 X-Mailer: git-send-email 2.9.5 X-TM-AS-GCONF: 00 x-cbid: 17090114-0012-0000-0000-000014F1DB25 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007647; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00910717; UDB=6.00456880; IPR=6.00690997; BA=6.00005563; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016961; XFM=3.00000015; UTC=2017-09-01 14:23:11 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17090114-0013-0000-0000-00004F50D77E Message-Id: <20170901142341.28872-1-chandan@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-09-01_04:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1709010205 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This commit adds a test to verify constant d_ino feature. The following scenarios are checked, - Parent's (i.e. "..") d_ino must always be calculated because a pure dir can be residing inside a merged dir. - d_ino for "." must always be calculated because the present directory can have a copy-up origin. - Verify d_ino of '.' and '..' before and after dir becomes impure. While at it also verify if trusted.overlay.impure xattr is set/reset appropriately and invalidation of readdir cache. - Verify copied up file's (inside a impure dir) d_ino. - Verify d_ino values corresponding to "." and ".." entries of a pure lower dir. - Verify d_ino of ".." entry of a merged dir. - Verify pure lower residing in dir which has another lower layer Signed-off-by: Chandan Rajendra --- Changelog: v2->v3: 1. Add the following new test scenarios. - Verify d_ino of '.' and '..' before and after dir becomes impure. - Verify copied up file's (inside a impure dir) d_ino. 2. For the "Verify pure lower residing in dir which has another lower layer" test, use sane variable names. Once again, Thanks to Amir for his suggestions. v1->v2: 1. Removed tests copied over from overlay/017. 2. Removed src/t_dir_ino.c. 3. Add code for testing, - d_ino of . and .. entries of pure_lower_dir. - d_ino of .. entry of merged_dir. - Verify pure lower residing in dir which has another lower layer. Thanks to Amir for suggesting these tests. tests/overlay/037 | 190 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/overlay/037.out | 2 + tests/overlay/group | 1 + 3 files changed, 193 insertions(+) create mode 100755 tests/overlay/037 create mode 100644 tests/overlay/037.out diff --git a/tests/overlay/037 b/tests/overlay/037 new file mode 100755 index 0000000..0ef5e74 --- /dev/null +++ b/tests/overlay/037 @@ -0,0 +1,190 @@ +#! /bin/bash +# FSQA Test No. 037 +# +# Test constant d_ino numbers +# +#----------------------------------------------------------------------- +# +# Copyright (C) 2017 IBM Corporation. All Rights Reserved. +# Author: Chandan Rajendra +# +# 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 + +# real QA test starts here +_supported_fs overlay +_supported_os Linux +_require_scratch +_require_test_program "af_unix" +_require_test_program "t_dir_type" + +rm -f $seqres.full + +_scratch_mkfs >>$seqres.full 2>&1 + +# Create our test files. +upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER +lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER +mkdir -p $lowerdir + +mkdir $lowerdir/test_dir/ +mkdir $lowerdir/test_dir/pure_lower_dir +mkdir $lowerdir/test_dir/merged_dir + +touch $lowerdir/test_file + +_scratch_mount + +test_dir=$SCRATCH_MNT/test_dir/ +merged_dir=$test_dir/merged_dir +pure_upper_dir=$merged_dir/pure_upper_dir + +mkdir -p $pure_upper_dir + +merged_dir_st_ino=$(stat -c '%i' $merged_dir) + +# Pure dir's parent d_ino must always be calculated because +# it can be residing inside a merged dir. +parent_d=$($here/src/t_dir_type $pure_upper_dir $merged_dir_st_ino) +[[ $parent_d != ".. d" ]] && \ + echo "Pure dir inside a merged dir: Invalid d_ino reported for .." + +# d_ino for "." must always be calculated because the present +# directory can have a copy-up origin. +current_d=$($here/src/t_dir_type $merged_dir $merged_dir_st_ino) +[[ $current_d != ". d" ]] && echo "Merged dir: Invalid d_ino reported for ." + +# Verify d_ino of '.' and '..' before and after dir becomes impure. +impure_dir=$test_dir/impure_dir +mkdir -p $impure_dir + +impure_dir_st_ino=$(stat -c '%i' $impure_dir) +impure_dir_parent_st_ino=$(stat -c '%i' $test_dir) + +# Before $impure_dir becomes impure +parent_d=$($here/src/t_dir_type $impure_dir $impure_dir_parent_st_ino) +[[ $parent_d != ".. d" ]] && echo "Before dir becomes impure: Invalid d_ino reported for .." + +current_d=$($here/src/t_dir_type $impure_dir $impure_dir_st_ino) +[[ $current_d != ". d" ]] && echo "Before dir becomes impure: Invalid d_ino reported for ." + +chown -h 100 $SCRATCH_MNT/test_file +test_file_st_ino=$(stat -c '%i' $SCRATCH_MNT/test_file) + +mv $SCRATCH_MNT/test_file $impure_dir + +$GETFATTR_PROG --absolute-names --dump -m trusted $upperdir/test_dir/impure_dir \ + | grep -q -F 'trusted.overlay.impure' +[[ $? != 0 ]] && echo "Impure directory missing impure xattr" + +# After $impure_dir becomes impure +parent_d=$($here/src/t_dir_type $impure_dir $impure_dir_parent_st_ino) +[[ $parent_d != ".. d" ]] && echo "After dir becomes impure: Invalid d_ino reported for .." + +current_d=$($here/src/t_dir_type $impure_dir $impure_dir_st_ino) +[[ $current_d != ". d" ]] && echo "After dir becomes impure: Invalid d_ino reported for ." + +# Verify copy up file's d_ino +file_d=$($here/src/t_dir_type $impure_dir $test_file_st_ino) +[[ $file_d != "test_file f" ]] && \ + echo "Impure dir: Invalid d_ino reported for entry with copy-up origin" + +# Make $impure_dir pure +rm -rf $impure_dir/test_file + +# Verify invalidation of readdir cache +$here/src/t_dir_type $impure_dir $test_file_st_ino +[[ $? == 0 ]] && echo "Directory's readdir cache has stale entries" + +$GETFATTR_PROG --absolute-names --dump -m trusted $upperdir/test_dir/impure_dir \ + | grep -q -F 'trusted.overlay.impure' +[[ $? == 0 ]] && echo "Pure directory has impure xattr" + +# Verify d_ino values corresponding to "." and ".." entries of a +# pure lower dir. +parent_st_ino=$(stat -c '%i' $SCRATCH_MNT/test_dir) +pure_lower_dir=$SCRATCH_MNT/test_dir/pure_lower_dir + +parent_d=$($here/src/t_dir_type $pure_lower_dir $parent_st_ino) +[[ $parent_d != ".. d" ]] && echo "Pure lower dir: Invalid d_ino reported for .." + +pure_lower_dir_st_ino=$(stat -c '%i' $pure_lower_dir) + +current_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_dir_st_ino) +[[ $current_d != ". d" ]] && echo "Pure lower dir: Invalid d_ino reported for ." + +# Verify d_ino of ".." entry of a merged dir. +merged_dir=$SCRATCH_MNT/test_dir/merged_dir + +parent_d=$($here/src/t_dir_type $merged_dir $parent_st_ino) +[[ $parent_d != ".. d" ]] && echo "Merged dir: Invalid d_ino reported for .." + +_scratch_unmount + +# Verify pure lower residing in dir which has another lower layer +_scratch_mkfs + +OVL_LOWER0=${OVL_LOWER}0 +OVL_LOWER1=${OVL_LOWER}1 + +middir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER0 +lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER1 +upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER +workdir=$OVL_BASE_SCRATCH_MNT/$OVL_WORK + +mkdir -p $middir +mkdir -p $lowerdir +mkdir -p $upperdir +mkdir -p $workdir + +mkdir -p $middir/dir0 +mkdir -p $lowerdir/dir0/dir1 + +$MOUNT_PROG -t overlay overlay -o lowerdir=$middir:$lowerdir \ + -o upperdir=$upperdir -o workdir=$workdir $SCRATCH_MNT + +# Copy up dir0 +touch $SCRATCH_MNT/dir0/test_file + +dir0_st_ino=$(stat -c '%i' $SCRATCH_MNT/dir0) + +parent_d=$($here/src/t_dir_type $SCRATCH_MNT/dir0/dir1 $dir0_st_ino) +[[ $parent_d != ".. d" ]] && \ + echo "Pure lower in dir which has another lower layer: Invalid d_ino reported for .." + +$UMOUNT_PROG $SCRATCH_MNT + +echo "Silence is golden" +status=0 +exit diff --git a/tests/overlay/037.out b/tests/overlay/037.out new file mode 100644 index 0000000..5c3a30a --- /dev/null +++ b/tests/overlay/037.out @@ -0,0 +1,2 @@ +QA output created by 037 +Silence is golden diff --git a/tests/overlay/group b/tests/overlay/group index 4cc1d74..b2460e1 100644 --- a/tests/overlay/group +++ b/tests/overlay/group @@ -39,3 +39,4 @@ 034 auto quick copyup hardlink 035 auto quick mount 036 auto quick mount +037 auto quick copyup