4 # The unmerged and origined directories may contain invalid
5 # whiteouts when we change underlaying dir (e.g. clean up lowerdir)
6 # and remount overlay. This may lead to whiteouts exposure and
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2017 Huawei. All Rights Reserved.
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #-----------------------------------------------------------------------
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
33 status=1 # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
42 # create test directory and test file, mount overlayfs and remove
43 # testfile to create a whiteout in upper dir.
51 mkdir -p $lower/testdir
52 touch $lower/testdir/$file
54 _overlay_scratch_mount_dirs $lower $upper $work
56 rm -f $SCRATCH_MNT/testdir/$file
58 $UMOUNT_PROG $SCRATCH_MNT
61 # get standard environment, filters and checks
67 # real QA test starts here
70 _require_scratch_nocheck
72 # remove all files from previous runs
75 # create test directorys and whiteout
76 lowerdir1=$OVL_BASE_SCRATCH_MNT/lower1
77 lowerdir2=$OVL_BASE_SCRATCH_MNT/lower2
78 upperdir=$OVL_BASE_SCRATCH_MNT/upper
79 workdir=$OVL_BASE_SCRATCH_MNT/workdir
80 # When overlay inode index feature is enabled, a workdir cannot be reused
81 # with a different upperdir. workdir1 in this test is used as the workdir
82 # when lowerdir1 is used as the upperdir.
83 workdir1=$OVL_BASE_SCRATCH_MNT/workdir1
86 mkdir -p $lowerdir1 $lowerdir2 $upperdir $workdir $workdir1
88 create_whiteout $lowerdir1 $upperdir $workdir $testfile1
90 # clean up the lower directory and mount overlay again,
91 # whiteout will expose.
92 rm -rf $lowerdir1/testdir
94 _overlay_scratch_mount_dirs $lowerdir1 $upperdir $workdir
96 ls $SCRATCH_MNT/testdir
98 # try to remove test dir from overlay dir, trigger ovl_remove_upper,
99 # it will not clean up the dir and lead to rmdir failure.
100 rm -rf $SCRATCH_MNT/testdir 2>&1 | _filter_scratch
102 # umount overlay again, create a new file with the same name and
103 # mount overlay again.
104 $UMOUNT_PROG $SCRATCH_MNT
105 touch $lowerdir1/testdir
107 _overlay_scratch_mount_dirs $lowerdir1 $upperdir $workdir
109 # try to remove test dir from overlay dir, trigger ovl_remove_and_whiteout,
110 # it will not clean up the dir and lead to residue.
111 rm -rf $SCRATCH_MNT/testdir 2>&1 | _filter_scratch
114 $UMOUNT_PROG $SCRATCH_MNT
116 # let lower dir have invalid whiteouts, repeat ls and rmdir test again.
117 rm -rf $lowerdir1/testdir
118 rm -rf $upperdir/testdir
120 create_whiteout $lowerdir2 $lowerdir1 $workdir1 $testfile1
122 rm -rf $lowerdir2/testdir
124 _overlay_scratch_mount_dirs "$lowerdir1:$lowerdir2" $upperdir $workdir
126 ls $SCRATCH_MNT/testdir
127 rm -rf $SCRATCH_MNT/testdir 2>&1 | _filter_scratch
129 $UMOUNT_PROG $SCRATCH_MNT
131 # let lower dir and upper dir both have invalid whiteouts, repeat ls and rmdir again.
132 rm -rf $lowerdir1/testdir
133 rm -rf $upperdir/testdir
135 create_whiteout $lowerdir1 $upperdir $workdir $testfile1
137 rm -rf $lowerdir1/testdir/$testfile1
139 create_whiteout $lowerdir2 $lowerdir1 $workdir1 $testfile2
141 _overlay_scratch_mount_dirs $lowerdir1 $upperdir $workdir
143 ls $SCRATCH_MNT/testdir
144 rm -rf $SCRATCH_MNT/testdir 2>&1 | _filter_scratch
147 echo "Silence is golden"