From: Eryu Guan Date: Thu, 8 Feb 2018 12:18:31 +0000 (+0800) Subject: overlay: renumber tests after merge X-Git-Tag: v2022.05.01~1652 X-Git-Url: http://git.apps.os.sepia.ceph.com/?p=xfstests-dev.git;a=commitdiff_plain;h=f03cfe78dac0750b1084216e3d5e4c46e0d337e8 overlay: renumber tests after merge Tests were merged with high seq numbers to avoid conflicts with other tests. Now renumber them to contiguous numbers, as all other tests have been merged correctly. This is easier to do than assigning the final seq numbers at commit time. Signed-off-by: Eryu Guan --- diff --git a/tests/overlay/045 b/tests/overlay/045 new file mode 100755 index 00000000..6158dbd5 --- /dev/null +++ b/tests/overlay/045 @@ -0,0 +1,230 @@ +#! /bin/bash +# FS QA Test No. 045 +# +# Test fsck.overlay how to deal with whiteouts in overlayfs. +# +#----------------------------------------------------------------------- +# Copyright (c) 2018 Huawei. All Rights Reserved. +# Author: zhangyi (F) +# +# 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 +. ./common/attr + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here +_supported_fs overlay +_supported_os Linux +_require_scratch_nocheck +_require_attrs +_require_command "$FSCK_OVERLAY_PROG" fsck.overlay + +OVL_XATTR_OPAQUE_VAL=y + +# remove all files from previous tests +_scratch_mkfs + +# Check whiteout +check_whiteout() +{ + for arg in $*; do + local ttype=`stat -c "%F:%t,%T" $arg` + + [[ "$ttype" == "character special file:0,0" ]] || \ + echo "Valid whiteout removed incorrectly" + done +} + +# Create a whiteout +make_whiteout() +{ + for arg in $*; do + mknod $arg c 0 0 + done +} + +# Create an opaque directory +make_opaque_dir() +{ + local target=$1 + + mkdir -p $target + $SETFATTR_PROG -n $OVL_XATTR_OPAQUE -v $OVL_XATTR_OPAQUE_VAL $target +} + +# Create a redirect directory +make_redirect_dir() +{ + local target=$1 + local value=$2 + + mkdir -p $target + $SETFATTR_PROG -n $OVL_XATTR_REDIRECT -v $value $target +} + +# 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 + +make_test_dirs() +{ + rm -rf $lowerdir $lowerdir2 $upperdir $workdir + mkdir -p $lowerdir $lowerdir2 $upperdir $workdir +} + +# Test orphan whiteout in lower and upper layer, should remove +echo "+ Orphan whiteout" +make_test_dirs +make_whiteout $lowerdir/foo $upperdir/{foo,bar} + +_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ + echo "fsck should not fail" +ls $lowerdir +ls $upperdir + +# Test valid whiteout covering lower target, should not remove +echo "+ Valid whiteout" +make_test_dirs +touch $lowerdir2/{foo,bar} +make_whiteout $upperdir/foo $lowerdir/bar + +_overlay_fsck_dirs "$lowerdir:$lowerdir2" $upperdir $workdir -p >> \ + $seqres.full 2>&1 || echo "fsck should not fail" +check_whiteout $upperdir/foo $lowerdir/bar + +# Test orphan whiteout in opaque directory, should remove +echo "+ Orphan whiteout(2)" +make_test_dirs +mkdir $lowerdir/testdir +touch $lowerdir/testdir/foo +make_opaque_dir $upperdir/testdir +make_whiteout $upperdir/testdir/foo + +_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ + echo "fsck should not fail" +ls $upperdir/testdir + +# Test orphan whiteout whose parent path is not an merged directory, +# should remove +echo "+ Orphan whiteout(3)" +make_test_dirs +mkdir $lowerdir2/{testdir1,testdir2,testdir3} +touch $lowerdir2/{testdir1/foo,testdir2/foo,testdir3/foo} +mkdir $upperdir/{testdir1,testdir2,testdir3,testdir4} +touch $lowerdir/testdir1 +make_whiteout $lowerdir/testdir2 +make_opaque_dir $lowerdir/testdir3 +make_whiteout $upperdir/{testdir1/foo,/testdir2/foo,testdir3/foo,testdir4/foo} + +_overlay_fsck_dirs "$lowerdir:$lowerdir2" $upperdir $workdir -p >> \ + $seqres.full 2>&1 || echo "fsck should not fail" +ls $upperdir/testdir1 +ls $upperdir/testdir2 +ls $upperdir/testdir3 +ls $upperdir/testdir4 + +# Test orphan whiteout in redirect directory, should remove +echo "+ Orphan whiteout(4)" +make_test_dirs +mkdir $lowerdir/{testdir,origin} +touch $lowerdir/testdir/foo +make_redirect_dir $upperdir/testdir "origin" +make_whiteout $upperdir/testdir/foo + +_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ + echo "fsck should not fail" +ls $upperdir/testdir + +# Test valid whiteout in redirect directory cover file in lower +# redirect origin directory, should not remove +echo "+ Valid whiteout(2)" +make_test_dirs +mkdir $lowerdir/origin +touch $lowerdir/origin/foo +make_redirect_dir $upperdir/testdir "origin" +make_whiteout $upperdir/testdir/foo + +_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ + echo "fsck should not fail" +check_whiteout $upperdir/testdir/foo + +# Test valid whiteout covering lower target whose parent directory +# merge with a redirect directory in the middle layer, should not remove. +echo "+ Valid whiteout(3)" +make_test_dirs +mkdir -p $lowerdir2/origin/subdir +touch $lowerdir2/origin/subdir/foo +make_redirect_dir $lowerdir/testdir "origin" +mkdir -p $upperdir/testdir/subdir +make_whiteout $upperdir/testdir/subdir/foo + +_overlay_fsck_dirs "$lowerdir:$lowerdir2" $upperdir $workdir -p \ + >> $seqres.full 2>&1 || echo "fsck should not fail" +check_whiteout $upperdir/testdir/subdir/foo + +# Test invalid whiteout in opaque subdirectory in a redirect directory, +# should remove +echo "+ Orphan whiteout(5)" +make_test_dirs +mkdir -p $lowerdir/origin/subdir +touch $lowerdir/origin/subdir/foo +make_redirect_dir $upperdir/testdir "origin" +make_opaque_dir $upperdir/testdir/subdir +make_whiteout $upperdir/testdir/subdir/foo + +_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ + echo "fsck should not fail" +ls $upperdir/testdir/subdir + +# Test valid whiteout in reidrect subdirectory in a opaque directory +# covering lower target, should not remove +echo "+ Valid whiteout(4)" +make_test_dirs +mkdir $lowerdir/origin +touch $lowerdir/origin/foo +make_opaque_dir $upperdir/testdir +make_redirect_dir $upperdir/testdir/subdir "/origin" +make_whiteout $upperdir/testdir/subdir/foo + +_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ + echo "fsck should not fail" +check_whiteout $upperdir/testdir/subdir/foo + +# success, all done +status=0 +exit diff --git a/tests/overlay/045.out b/tests/overlay/045.out new file mode 100644 index 00000000..cfb40388 --- /dev/null +++ b/tests/overlay/045.out @@ -0,0 +1,10 @@ +QA output created by 045 ++ Orphan whiteout ++ Valid whiteout ++ Orphan whiteout(2) ++ Orphan whiteout(3) ++ Orphan whiteout(4) ++ Valid whiteout(2) ++ Valid whiteout(3) ++ Orphan whiteout(5) ++ Valid whiteout(4) diff --git a/tests/overlay/046 b/tests/overlay/046 new file mode 100755 index 00000000..b0ede6cd --- /dev/null +++ b/tests/overlay/046 @@ -0,0 +1,266 @@ +#! /bin/bash +# FS QA Test No. 046 +# +# Test fsck.overlay how to deal with redirect xattr in overlayfs. +# +#----------------------------------------------------------------------- +# Copyright (c) 2018 Huawei. All Rights Reserved. +# Author: zhangyi (F) +# +# 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 +. ./common/attr + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here +_supported_fs overlay +_supported_os Linux +_require_scratch_nocheck +_require_attrs +_require_command "$FSCK_OVERLAY_PROG" fsck.overlay + +# remove all files from previous tests +_scratch_mkfs + +OVL_XATTR_OPAQUE_VAL=y + +# Create a redirect directory +make_redirect_dir() +{ + local target=$1 + local value=$2 + + mkdir -p $target + $SETFATTR_PROG -n $OVL_XATTR_REDIRECT -v $value $target +} + +# Check redirect xattr +check_redirect() +{ + local target=$1 + local expect=$2 + + value=$($GETFATTR_PROG --absolute-names --only-values -n \ + $OVL_XATTR_REDIRECT $target) + + [[ "$value" == "$expect" ]] || echo "Redirect xattr incorrect" +} + +check_no_redirect() +{ + local target=$1 + + value=$($GETFATTR_PROG --absolute-names -d -m \ + $OVL_XATTR_REDIRECT $target) + + [[ -z "$value" ]] || echo "Redirect xattr not empty" +} + +# Check opaque xattr +check_opaque() +{ + local target=$1 + + value=$($GETFATTR_PROG --absolute-names --only-values -n \ + $OVL_XATTR_OPAQUE $target) + + [[ "$value" == "$OVL_XATTR_OPAQUE_VAL" ]] || \ + echo "Opaque xattr incorrect" +} + +# Create a whiteout +make_whiteout() +{ + for arg in $*; do + mknod $arg c 0 0 + done +} + +# Check whiteout +check_whiteout() +{ + for arg in $*; do + local ttype=`stat -c "%F:%t,%T" $arg` + + [[ "$ttype" == "character special file:0,0" ]] || \ + echo "Valid whiteout removed incorrectly" + done +} + +# 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 + +make_test_dirs() +{ + rm -rf $lowerdir $lowerdir2 $upperdir $workdir + mkdir -p $lowerdir $lowerdir2 $upperdir $workdir +} + +# Test invalid redirect xattr point to a nonexistent origin, should remove +echo "+ Invalid redirect" +make_test_dirs +make_redirect_dir $upperdir/testdir "invalid" + +_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ + echo "fsck should not fail" +check_no_redirect $upperdir/testdir + +# Test invalid redirect xattr point to a file origin, should remove +echo "+ Invalid redirect(2)" +make_test_dirs +touch $lowerdir/origin +make_redirect_dir $upperdir/testdir "origin" + +_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ + echo "fsck should not fail" +check_no_redirect $upperdir/testdir + +# Test valid redirect xattr point to a directory origin in the same directory, +# should not remove +echo "+ Valid redirect" +make_test_dirs +mkdir $lowerdir/origin +make_whiteout $upperdir/origin +make_redirect_dir $upperdir/testdir "origin" + +_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ + echo "fsck should not fail" +check_redirect $upperdir/testdir "origin" + +# Test valid redirect xattr point to a directory origin in different directories +# should not remove +echo "+ Valid redirect(2)" +make_test_dirs +mkdir $lowerdir/origin +make_whiteout $upperdir/origin +make_redirect_dir $upperdir/testdir1/testdir2 "/origin" + +_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ + echo "fsck should not fail" +check_redirect $upperdir/testdir1/testdir2 "/origin" + +# Test valid redirect xattr but missing whiteout to cover lower target, +# should fix whiteout +echo "+ Missing whiteout" +make_test_dirs +mkdir $lowerdir/origin +make_redirect_dir $upperdir/testdir "origin" + +_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ + echo "fsck should not fail" +check_redirect $upperdir/testdir "origin" +check_whiteout $upperdir/origin + +# Test valid redirect xattrs exchanged by rename, should not remove +echo "+ Valid redirect(3)" +make_test_dirs +mkdir $lowerdir/{testdir1,testdir2} +make_redirect_dir $upperdir/testdir1 "testdir2" +make_redirect_dir $upperdir/testdir2 "testdir1" + +_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ + echo "fsck should not fail" +check_redirect $upperdir/testdir1 "testdir2" +check_redirect $upperdir/testdir2 "testdir1" + +# Test invalid redirect xattr with lower same name directory exists, +# should remove invalid redirect xattr and set opaque in yes mode +echo "+ Invalid redirect(3)" +make_test_dirs +mkdir $lowerdir/testdir +make_redirect_dir $upperdir/testdir "invalid" + +# Question get yes answer: Should set opaque dir ? +_overlay_fsck_dirs $lowerdir $upperdir $workdir -y >> $seqres.full 2>&1 || \ + echo "fsck should not fail" +check_no_redirect $upperdir/testdir +check_opaque $upperdir/testdir + +# Test duplicate redirect xattrs point to one origin, should fail in +# auto mode, and should remove either of the duplicates in yes mode +echo "+ Duplicate redirect" +make_test_dirs +mkdir $lowerdir2/origin +make_redirect_dir $lowerdir/testdir1 "origin" +make_redirect_dir $lowerdir/testdir2 "origin" +make_redirect_dir $upperdir/testdir3 "origin" + +_overlay_fsck_dirs "$lowerdir:$lowerdir2" $upperdir $workdir -p >> \ + $seqres.full 2>&1 && echo "fsck should fail" + +# Question get yes answer: Duplicate redirect directory, remove xattr ? +_overlay_fsck_dirs "$lowerdir:$lowerdir2" $upperdir $workdir -y >> \ + $seqres.full 2>&1 || echo "fsck should not fail" +redirect_1=`check_redirect $lowerdir/testdir1 "origin" 2>/dev/null` +redirect_2=`check_redirect $lowerdir/testdir2 "origin" 2>/dev/null` +[[ $redirect_1 == $redirect_2 ]] && echo "Redirect xattr incorrect" +check_no_redirect $upperdir/testdir3 + +# Test duplicate redirect xattr duplicate with merge directory, should +# fail in auto mode, and should remove the redirect xattr in yes mode +echo "+ Duplicate redirect(2)" +make_test_dirs +mkdir $lowerdir/origin $upperdir/origin +make_redirect_dir $upperdir/testdir "origin" + +_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 && \ + echo "fsck should fail" + +# Question get yes answer: Duplicate redirect directory, remove xattr ? +_overlay_fsck_dirs $lowerdir $upperdir $workdir -y >> $seqres.full 2>&1 || \ + echo "fsck should not fail" +check_no_redirect $upperdir/testdir + +# Test duplicate redirect xattr with lower same name directory exists, +# should remove the duplicate redirect xattr and set opaque in yes mode +echo "+ Duplicate redirect(3)" +make_test_dirs +mkdir $lowerdir/{origin,testdir} $upperdir/origin +make_redirect_dir $upperdir/testdir "invalid" + +# Question one get yes answer: Duplicate redirect directory, remove xattr? +# Question two get yes answer: Should set opaque dir ? +_overlay_fsck_dirs $lowerdir $upperdir $workdir -y >> $seqres.full 2>&1 || \ + echo "fsck should not fail" +check_no_redirect $upperdir/testdir +check_opaque $upperdir/testdir + +# success, all done +status=0 +exit diff --git a/tests/overlay/046.out b/tests/overlay/046.out new file mode 100644 index 00000000..4f69d557 --- /dev/null +++ b/tests/overlay/046.out @@ -0,0 +1,11 @@ +QA output created by 046 ++ Invalid redirect ++ Invalid redirect(2) ++ Valid redirect ++ Valid redirect(2) ++ Missing whiteout ++ Valid redirect(3) ++ Invalid redirect(3) ++ Duplicate redirect ++ Duplicate redirect(2) ++ Duplicate redirect(3) diff --git a/tests/overlay/056 b/tests/overlay/056 new file mode 100755 index 00000000..3a85c821 --- /dev/null +++ b/tests/overlay/056 @@ -0,0 +1,143 @@ +#! /bin/bash +# FS QA Test No. 056 +# +# Test fsck.overlay how to deal with impure xattr in overlayfs. +# +#----------------------------------------------------------------------- +# Copyright (c) 2018 Huawei. All Rights Reserved. +# Author: zhangyi (F) +# +# 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 +. ./common/attr + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here +_supported_fs overlay +_supported_os Linux +_require_scratch_nocheck +_require_attrs +_require_command "$FSCK_OVERLAY_PROG" fsck.overlay + +OVL_XATTR_IMPURE_VAL=y + +# remove all files from previous tests +_scratch_mkfs + +# Create a redirect directory +make_redirect_dir() +{ + local target=$1 + local value=$2 + + mkdir -p $target + $SETFATTR_PROG -n $OVL_XATTR_REDIRECT -v $value $target +} + +# Remove impure xattr +remove_impure() +{ + local target=$1 + + $SETFATTR_PROG -x $OVL_XATTR_IMPURE $target +} + +# Check impure xattr +check_impure() +{ + local target=$1 + + value=$($GETFATTR_PROG --absolute-names --only-values -n \ + $OVL_XATTR_IMPURE $target) + + [[ "$value" == "$OVL_XATTR_IMPURE_VAL" ]] || echo "Missing impure xattr" +} + +# 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 + +make_test_dirs() +{ + rm -rf $lowerdir $lowerdir2 $upperdir $workdir + mkdir -p $lowerdir $lowerdir2 $upperdir $workdir +} + +# Test missing impure xattr in directory which has origin targets, should fix +echo "+ Missing impure" +make_test_dirs +mkdir $lowerdir/{testdir1,testdir2} +mkdir $upperdir/{testdir1,testdir2} +touch $lowerdir/testdir1/foo +mkdir $lowerdir/testdir2/subdir +_overlay_scratch_mount_dirs $lowerdir $upperdir $workdir +touch $SCRATCH_MNT/testdir1/foo +touch $SCRATCH_MNT/testdir2/subdir +$UMOUNT_PROG $SCRATCH_MNT +remove_impure $upperdir/testdir1 +remove_impure $upperdir/testdir2 + +_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ + echo "fsck should not fail" +check_impure $upperdir/testdir1 +check_impure $upperdir/testdir2 + +# Test missing impure xattr in directory which has redirect directories, +# should fix +echo "+ Missing impure(2)" +make_test_dirs +mkdir $lowerdir/origin +make_redirect_dir $upperdir/testdir/subdir "/origin" + +_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ + echo "fsck should not fail" +check_impure $upperdir/testdir + +# Test missing impure xattr in directory which has merge directories, +# should fix +echo "+ Missing impure(3)" +make_test_dirs +mkdir $lowerdir/testdir $upperdir/testdir + +_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ + echo "fsck should not fail" +check_impure $upperdir + +# success, all done +status=0 +exit diff --git a/tests/overlay/056.out b/tests/overlay/056.out new file mode 100644 index 00000000..48eb1c91 --- /dev/null +++ b/tests/overlay/056.out @@ -0,0 +1,4 @@ +QA output created by 056 ++ Missing impure ++ Missing impure(2) ++ Missing impure(3) diff --git a/tests/overlay/201 b/tests/overlay/201 deleted file mode 100755 index 77e57187..00000000 --- a/tests/overlay/201 +++ /dev/null @@ -1,230 +0,0 @@ -#! /bin/bash -# FS QA Test 201 -# -# Test fsck.overlay how to deal with whiteouts in overlayfs. -# -#----------------------------------------------------------------------- -# Copyright (c) 2018 Huawei. All Rights Reserved. -# Author: zhangyi (F) -# -# 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 -. ./common/attr - -# remove previous $seqres.full before test -rm -f $seqres.full - -# real QA test starts here -_supported_fs overlay -_supported_os Linux -_require_scratch_nocheck -_require_attrs -_require_command "$FSCK_OVERLAY_PROG" fsck.overlay - -OVL_XATTR_OPAQUE_VAL=y - -# remove all files from previous tests -_scratch_mkfs - -# Check whiteout -check_whiteout() -{ - for arg in $*; do - local ttype=`stat -c "%F:%t,%T" $arg` - - [[ "$ttype" == "character special file:0,0" ]] || \ - echo "Valid whiteout removed incorrectly" - done -} - -# Create a whiteout -make_whiteout() -{ - for arg in $*; do - mknod $arg c 0 0 - done -} - -# Create an opaque directory -make_opaque_dir() -{ - local target=$1 - - mkdir -p $target - $SETFATTR_PROG -n $OVL_XATTR_OPAQUE -v $OVL_XATTR_OPAQUE_VAL $target -} - -# Create a redirect directory -make_redirect_dir() -{ - local target=$1 - local value=$2 - - mkdir -p $target - $SETFATTR_PROG -n $OVL_XATTR_REDIRECT -v $value $target -} - -# 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 - -make_test_dirs() -{ - rm -rf $lowerdir $lowerdir2 $upperdir $workdir - mkdir -p $lowerdir $lowerdir2 $upperdir $workdir -} - -# Test orphan whiteout in lower and upper layer, should remove -echo "+ Orphan whiteout" -make_test_dirs -make_whiteout $lowerdir/foo $upperdir/{foo,bar} - -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" -ls $lowerdir -ls $upperdir - -# Test valid whiteout covering lower target, should not remove -echo "+ Valid whiteout" -make_test_dirs -touch $lowerdir2/{foo,bar} -make_whiteout $upperdir/foo $lowerdir/bar - -_overlay_fsck_dirs "$lowerdir:$lowerdir2" $upperdir $workdir -p >> \ - $seqres.full 2>&1 || echo "fsck should not fail" -check_whiteout $upperdir/foo $lowerdir/bar - -# Test orphan whiteout in opaque directory, should remove -echo "+ Orphan whiteout(2)" -make_test_dirs -mkdir $lowerdir/testdir -touch $lowerdir/testdir/foo -make_opaque_dir $upperdir/testdir -make_whiteout $upperdir/testdir/foo - -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" -ls $upperdir/testdir - -# Test orphan whiteout whose parent path is not an merged directory, -# should remove -echo "+ Orphan whiteout(3)" -make_test_dirs -mkdir $lowerdir2/{testdir1,testdir2,testdir3} -touch $lowerdir2/{testdir1/foo,testdir2/foo,testdir3/foo} -mkdir $upperdir/{testdir1,testdir2,testdir3,testdir4} -touch $lowerdir/testdir1 -make_whiteout $lowerdir/testdir2 -make_opaque_dir $lowerdir/testdir3 -make_whiteout $upperdir/{testdir1/foo,/testdir2/foo,testdir3/foo,testdir4/foo} - -_overlay_fsck_dirs "$lowerdir:$lowerdir2" $upperdir $workdir -p >> \ - $seqres.full 2>&1 || echo "fsck should not fail" -ls $upperdir/testdir1 -ls $upperdir/testdir2 -ls $upperdir/testdir3 -ls $upperdir/testdir4 - -# Test orphan whiteout in redirect directory, should remove -echo "+ Orphan whiteout(4)" -make_test_dirs -mkdir $lowerdir/{testdir,origin} -touch $lowerdir/testdir/foo -make_redirect_dir $upperdir/testdir "origin" -make_whiteout $upperdir/testdir/foo - -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" -ls $upperdir/testdir - -# Test valid whiteout in redirect directory cover file in lower -# redirect origin directory, should not remove -echo "+ Valid whiteout(2)" -make_test_dirs -mkdir $lowerdir/origin -touch $lowerdir/origin/foo -make_redirect_dir $upperdir/testdir "origin" -make_whiteout $upperdir/testdir/foo - -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" -check_whiteout $upperdir/testdir/foo - -# Test valid whiteout covering lower target whose parent directory -# merge with a redirect directory in the middle layer, should not remove. -echo "+ Valid whiteout(3)" -make_test_dirs -mkdir -p $lowerdir2/origin/subdir -touch $lowerdir2/origin/subdir/foo -make_redirect_dir $lowerdir/testdir "origin" -mkdir -p $upperdir/testdir/subdir -make_whiteout $upperdir/testdir/subdir/foo - -_overlay_fsck_dirs "$lowerdir:$lowerdir2" $upperdir $workdir -p \ - >> $seqres.full 2>&1 || echo "fsck should not fail" -check_whiteout $upperdir/testdir/subdir/foo - -# Test invalid whiteout in opaque subdirectory in a redirect directory, -# should remove -echo "+ Orphan whiteout(5)" -make_test_dirs -mkdir -p $lowerdir/origin/subdir -touch $lowerdir/origin/subdir/foo -make_redirect_dir $upperdir/testdir "origin" -make_opaque_dir $upperdir/testdir/subdir -make_whiteout $upperdir/testdir/subdir/foo - -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" -ls $upperdir/testdir/subdir - -# Test valid whiteout in reidrect subdirectory in a opaque directory -# covering lower target, should not remove -echo "+ Valid whiteout(4)" -make_test_dirs -mkdir $lowerdir/origin -touch $lowerdir/origin/foo -make_opaque_dir $upperdir/testdir -make_redirect_dir $upperdir/testdir/subdir "/origin" -make_whiteout $upperdir/testdir/subdir/foo - -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" -check_whiteout $upperdir/testdir/subdir/foo - -# success, all done -status=0 -exit diff --git a/tests/overlay/201.out b/tests/overlay/201.out deleted file mode 100644 index 157bb85c..00000000 --- a/tests/overlay/201.out +++ /dev/null @@ -1,10 +0,0 @@ -QA output created by 201 -+ Orphan whiteout -+ Valid whiteout -+ Orphan whiteout(2) -+ Orphan whiteout(3) -+ Orphan whiteout(4) -+ Valid whiteout(2) -+ Valid whiteout(3) -+ Orphan whiteout(5) -+ Valid whiteout(4) diff --git a/tests/overlay/202 b/tests/overlay/202 deleted file mode 100755 index e411b942..00000000 --- a/tests/overlay/202 +++ /dev/null @@ -1,266 +0,0 @@ -#! /bin/bash -# FS QA Test 202 -# -# Test fsck.overlay how to deal with redirect xattr in overlayfs. -# -#----------------------------------------------------------------------- -# Copyright (c) 2018 Huawei. All Rights Reserved. -# Author: zhangyi (F) -# -# 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 -. ./common/attr - -# remove previous $seqres.full before test -rm -f $seqres.full - -# real QA test starts here -_supported_fs overlay -_supported_os Linux -_require_scratch_nocheck -_require_attrs -_require_command "$FSCK_OVERLAY_PROG" fsck.overlay - -# remove all files from previous tests -_scratch_mkfs - -OVL_XATTR_OPAQUE_VAL=y - -# Create a redirect directory -make_redirect_dir() -{ - local target=$1 - local value=$2 - - mkdir -p $target - $SETFATTR_PROG -n $OVL_XATTR_REDIRECT -v $value $target -} - -# Check redirect xattr -check_redirect() -{ - local target=$1 - local expect=$2 - - value=$($GETFATTR_PROG --absolute-names --only-values -n \ - $OVL_XATTR_REDIRECT $target) - - [[ "$value" == "$expect" ]] || echo "Redirect xattr incorrect" -} - -check_no_redirect() -{ - local target=$1 - - value=$($GETFATTR_PROG --absolute-names -d -m \ - $OVL_XATTR_REDIRECT $target) - - [[ -z "$value" ]] || echo "Redirect xattr not empty" -} - -# Check opaque xattr -check_opaque() -{ - local target=$1 - - value=$($GETFATTR_PROG --absolute-names --only-values -n \ - $OVL_XATTR_OPAQUE $target) - - [[ "$value" == "$OVL_XATTR_OPAQUE_VAL" ]] || \ - echo "Opaque xattr incorrect" -} - -# Create a whiteout -make_whiteout() -{ - for arg in $*; do - mknod $arg c 0 0 - done -} - -# Check whiteout -check_whiteout() -{ - for arg in $*; do - local ttype=`stat -c "%F:%t,%T" $arg` - - [[ "$ttype" == "character special file:0,0" ]] || \ - echo "Valid whiteout removed incorrectly" - done -} - -# 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 - -make_test_dirs() -{ - rm -rf $lowerdir $lowerdir2 $upperdir $workdir - mkdir -p $lowerdir $lowerdir2 $upperdir $workdir -} - -# Test invalid redirect xattr point to a nonexistent origin, should remove -echo "+ Invalid redirect" -make_test_dirs -make_redirect_dir $upperdir/testdir "invalid" - -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" -check_no_redirect $upperdir/testdir - -# Test invalid redirect xattr point to a file origin, should remove -echo "+ Invalid redirect(2)" -make_test_dirs -touch $lowerdir/origin -make_redirect_dir $upperdir/testdir "origin" - -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" -check_no_redirect $upperdir/testdir - -# Test valid redirect xattr point to a directory origin in the same directory, -# should not remove -echo "+ Valid redirect" -make_test_dirs -mkdir $lowerdir/origin -make_whiteout $upperdir/origin -make_redirect_dir $upperdir/testdir "origin" - -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" -check_redirect $upperdir/testdir "origin" - -# Test valid redirect xattr point to a directory origin in different directories -# should not remove -echo "+ Valid redirect(2)" -make_test_dirs -mkdir $lowerdir/origin -make_whiteout $upperdir/origin -make_redirect_dir $upperdir/testdir1/testdir2 "/origin" - -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" -check_redirect $upperdir/testdir1/testdir2 "/origin" - -# Test valid redirect xattr but missing whiteout to cover lower target, -# should fix whiteout -echo "+ Missing whiteout" -make_test_dirs -mkdir $lowerdir/origin -make_redirect_dir $upperdir/testdir "origin" - -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" -check_redirect $upperdir/testdir "origin" -check_whiteout $upperdir/origin - -# Test valid redirect xattrs exchanged by rename, should not remove -echo "+ Valid redirect(3)" -make_test_dirs -mkdir $lowerdir/{testdir1,testdir2} -make_redirect_dir $upperdir/testdir1 "testdir2" -make_redirect_dir $upperdir/testdir2 "testdir1" - -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" -check_redirect $upperdir/testdir1 "testdir2" -check_redirect $upperdir/testdir2 "testdir1" - -# Test invalid redirect xattr with lower same name directory exists, -# should remove invalid redirect xattr and set opaque in yes mode -echo "+ Invalid redirect(3)" -make_test_dirs -mkdir $lowerdir/testdir -make_redirect_dir $upperdir/testdir "invalid" - -# Question get yes answer: Should set opaque dir ? -_overlay_fsck_dirs $lowerdir $upperdir $workdir -y >> $seqres.full 2>&1 || \ - echo "fsck should not fail" -check_no_redirect $upperdir/testdir -check_opaque $upperdir/testdir - -# Test duplicate redirect xattrs point to one origin, should fail in -# auto mode, and should remove either of the duplicates in yes mode -echo "+ Duplicate redirect" -make_test_dirs -mkdir $lowerdir2/origin -make_redirect_dir $lowerdir/testdir1 "origin" -make_redirect_dir $lowerdir/testdir2 "origin" -make_redirect_dir $upperdir/testdir3 "origin" - -_overlay_fsck_dirs "$lowerdir:$lowerdir2" $upperdir $workdir -p >> \ - $seqres.full 2>&1 && echo "fsck should fail" - -# Question get yes answer: Duplicate redirect directory, remove xattr ? -_overlay_fsck_dirs "$lowerdir:$lowerdir2" $upperdir $workdir -y >> \ - $seqres.full 2>&1 || echo "fsck should not fail" -redirect_1=`check_redirect $lowerdir/testdir1 "origin" 2>/dev/null` -redirect_2=`check_redirect $lowerdir/testdir2 "origin" 2>/dev/null` -[[ $redirect_1 == $redirect_2 ]] && echo "Redirect xattr incorrect" -check_no_redirect $upperdir/testdir3 - -# Test duplicate redirect xattr duplicate with merge directory, should -# fail in auto mode, and should remove the redirect xattr in yes mode -echo "+ Duplicate redirect(2)" -make_test_dirs -mkdir $lowerdir/origin $upperdir/origin -make_redirect_dir $upperdir/testdir "origin" - -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 && \ - echo "fsck should fail" - -# Question get yes answer: Duplicate redirect directory, remove xattr ? -_overlay_fsck_dirs $lowerdir $upperdir $workdir -y >> $seqres.full 2>&1 || \ - echo "fsck should not fail" -check_no_redirect $upperdir/testdir - -# Test duplicate redirect xattr with lower same name directory exists, -# should remove the duplicate redirect xattr and set opaque in yes mode -echo "+ Duplicate redirect(3)" -make_test_dirs -mkdir $lowerdir/{origin,testdir} $upperdir/origin -make_redirect_dir $upperdir/testdir "invalid" - -# Question one get yes answer: Duplicate redirect directory, remove xattr? -# Question two get yes answer: Should set opaque dir ? -_overlay_fsck_dirs $lowerdir $upperdir $workdir -y >> $seqres.full 2>&1 || \ - echo "fsck should not fail" -check_no_redirect $upperdir/testdir -check_opaque $upperdir/testdir - -# success, all done -status=0 -exit diff --git a/tests/overlay/202.out b/tests/overlay/202.out deleted file mode 100644 index 99d2b328..00000000 --- a/tests/overlay/202.out +++ /dev/null @@ -1,11 +0,0 @@ -QA output created by 202 -+ Invalid redirect -+ Invalid redirect(2) -+ Valid redirect -+ Valid redirect(2) -+ Missing whiteout -+ Valid redirect(3) -+ Invalid redirect(3) -+ Duplicate redirect -+ Duplicate redirect(2) -+ Duplicate redirect(3) diff --git a/tests/overlay/203 b/tests/overlay/203 deleted file mode 100755 index 70dd7fdc..00000000 --- a/tests/overlay/203 +++ /dev/null @@ -1,143 +0,0 @@ -#! /bin/bash -# FS QA Test 203 -# -# Test fsck.overlay how to deal with impure xattr in overlayfs. -# -#----------------------------------------------------------------------- -# Copyright (c) 2018 Huawei. All Rights Reserved. -# Author: zhangyi (F) -# -# 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 -. ./common/attr - -# remove previous $seqres.full before test -rm -f $seqres.full - -# real QA test starts here -_supported_fs overlay -_supported_os Linux -_require_scratch_nocheck -_require_attrs -_require_command "$FSCK_OVERLAY_PROG" fsck.overlay - -OVL_XATTR_IMPURE_VAL=y - -# remove all files from previous tests -_scratch_mkfs - -# Create a redirect directory -make_redirect_dir() -{ - local target=$1 - local value=$2 - - mkdir -p $target - $SETFATTR_PROG -n $OVL_XATTR_REDIRECT -v $value $target -} - -# Remove impure xattr -remove_impure() -{ - local target=$1 - - $SETFATTR_PROG -x $OVL_XATTR_IMPURE $target -} - -# Check impure xattr -check_impure() -{ - local target=$1 - - value=$($GETFATTR_PROG --absolute-names --only-values -n \ - $OVL_XATTR_IMPURE $target) - - [[ "$value" == "$OVL_XATTR_IMPURE_VAL" ]] || echo "Missing impure xattr" -} - -# 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 - -make_test_dirs() -{ - rm -rf $lowerdir $lowerdir2 $upperdir $workdir - mkdir -p $lowerdir $lowerdir2 $upperdir $workdir -} - -# Test missing impure xattr in directory which has origin targets, should fix -echo "+ Missing impure" -make_test_dirs -mkdir $lowerdir/{testdir1,testdir2} -mkdir $upperdir/{testdir1,testdir2} -touch $lowerdir/testdir1/foo -mkdir $lowerdir/testdir2/subdir -_overlay_scratch_mount_dirs $lowerdir $upperdir $workdir -touch $SCRATCH_MNT/testdir1/foo -touch $SCRATCH_MNT/testdir2/subdir -$UMOUNT_PROG $SCRATCH_MNT -remove_impure $upperdir/testdir1 -remove_impure $upperdir/testdir2 - -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" -check_impure $upperdir/testdir1 -check_impure $upperdir/testdir2 - -# Test missing impure xattr in directory which has redirect directories, -# should fix -echo "+ Missing impure(2)" -make_test_dirs -mkdir $lowerdir/origin -make_redirect_dir $upperdir/testdir/subdir "/origin" - -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" -check_impure $upperdir/testdir - -# Test missing impure xattr in directory which has merge directories, -# should fix -echo "+ Missing impure(3)" -make_test_dirs -mkdir $lowerdir/testdir $upperdir/testdir - -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" -check_impure $upperdir - -# success, all done -status=0 -exit diff --git a/tests/overlay/203.out b/tests/overlay/203.out deleted file mode 100644 index dd81788e..00000000 --- a/tests/overlay/203.out +++ /dev/null @@ -1,4 +0,0 @@ -QA output created by 203 -+ Missing impure -+ Missing impure(2) -+ Missing impure(3) diff --git a/tests/overlay/group b/tests/overlay/group index e8f2d419..65f1fe63 100644 --- a/tests/overlay/group +++ b/tests/overlay/group @@ -47,6 +47,8 @@ 042 auto quick copyup hardlink 043 auto quick copyup nonsamefs 044 auto quick copyup hardlink nonsamefs +045 auto quick fsck +046 auto quick fsck 047 auto quick copyup hardlink 048 auto quick copyup hardlink 049 auto quick copyup redirect @@ -56,6 +58,4 @@ 053 auto quick copyup redirect exportfs nonsamefs 054 auto quick copyup redirect exportfs 055 auto quick copyup redirect exportfs nonsamefs -201 auto quick fsck -202 auto quick fsck -203 auto quick fsck +056 auto quick fsck