ovelray: drop explicit use of OVERLAY_MOUNT_OPTIONS
[xfstests-dev.git] / tests / overlay / 041
1 #! /bin/bash
2 # FSQA Test No. 041
3 #
4 # Test consistent d_ino numbers on non-samefs setup
5 # This is a variant of overlay/038 to test consistent d_ino numbers
6 # for non-samefs setup.
7 #
8 #-----------------------------------------------------------------------
9 #
10 # Copyright (C) 2017 IBM Corporation. All Rights Reserved.
11 # Author: Chandan Rajendra <chandan@linux.vnet.ibm.com>
12 #
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License as
15 # published by the Free Software Foundation.
16 #
17 # This program is distributed in the hope that it would be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 # GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write the Free Software Foundation,
24 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
25 #-----------------------------------------------------------------------
26 #
27
28 seq=`basename $0`
29 seqres=$RESULT_DIR/$seq
30 echo "QA output created by $seq"
31
32 here=`pwd`
33 tmp=/tmp/$$
34 status=1        # failure is the default!
35 trap "_cleanup; exit \$status" 0 1 2 3 15
36
37 _cleanup()
38 {
39         cd /
40         rm -f $tmp.*
41 }
42
43 # get standard environment, filters and checks
44 . ./common/rc
45 . ./common/filter
46 . ./common/attr
47
48 # real QA test starts here
49 _supported_fs overlay
50 _supported_os Linux
51 _require_scratch
52 _require_test
53 _require_attrs
54 _require_test_program "t_dir_type"
55
56 rm -f $seqres.full
57
58 lowerdir=$OVL_BASE_TEST_DIR/$seq-ovl-lower
59 rm -rf $lowerdir
60 mkdir $lowerdir
61
62 # Create our test files.
63 mkdir -p $lowerdir/test_dir/pure_lower_dir/subdir
64 touch $lowerdir/test_file
65
66 _scratch_mkfs
67
68 upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
69 workdir=$OVL_BASE_SCRATCH_MNT/$OVL_WORK
70
71 _overlay_scratch_mount_dirs $lowerdir $upperdir $workdir
72
73 test_dir=$SCRATCH_MNT/test_dir/
74
75 # Verify d_ino of '.' and '..' before and after dir becomes impure.
76 impure_dir=$test_dir/impure_dir
77 mkdir -p $impure_dir/subdir
78
79 impure_dir_st_ino=$(stat -c '%i' $impure_dir)
80 impure_dir_parent_st_ino=$(stat -c '%i' $test_dir)
81 impure_subdir_st_ino=$(stat -c '%i' $impure_dir/subdir)
82
83 # Before $impure_dir becomes impure
84 parent_d=$($here/src/t_dir_type $impure_dir $impure_dir_parent_st_ino)
85 [[ $parent_d == ".. d" ]] || \
86     echo "Pure upper dir: Invalid d_ino reported for .."
87
88 current_d=$($here/src/t_dir_type $impure_dir $impure_dir_st_ino)
89 [[ $current_d == ". d" ]] || \
90     echo "Pure upper dir: Invalid d_ino reported for ."
91
92 subdir_d=$($here/src/t_dir_type $impure_dir $impure_subdir_st_ino)
93 [[ $subdir_d == "subdir d" ]] || \
94     echo "Pure upper dir: Invalid d_ino reported for subdir"
95
96 # Move a copied up file into pure dir to make it impure
97 mv $SCRATCH_MNT/test_file $impure_dir
98 test_file_st_ino=$(stat -c '%i' $impure_dir/test_file)
99
100 impure=$($GETFATTR_PROG --absolute-names --only-values -n 'trusted.overlay.impure' \
101                         $upperdir/test_dir/impure_dir)
102 [[ $impure == "y" ]] || echo "Impure directory missing impure xattr"
103
104 # After $impure_dir becomes impure
105 parent_d=$($here/src/t_dir_type $impure_dir $impure_dir_parent_st_ino)
106 [[ $parent_d == ".. d" ]] || \
107     echo "Impure dir: Invalid d_ino reported for .."
108
109 current_d=$($here/src/t_dir_type $impure_dir $impure_dir_st_ino)
110 [[ $current_d == ". d" ]] || \
111     echo "Impure dir: Invalid d_ino reported for ."
112
113 subdir_d=$($here/src/t_dir_type $impure_dir $impure_subdir_st_ino)
114 [[ $subdir_d == "subdir d" ]] || \
115     echo "Impure dir: Invalid d_ino reported for subdir"
116
117 # Verify copy up file's d_ino
118 file_d=$($here/src/t_dir_type $impure_dir $test_file_st_ino)
119 [[ $file_d == "test_file f" ]] || \
120         echo "Impure dir: Invalid d_ino reported for entry with copy-up origin"
121
122 # Make $impure_dir pure
123 rm -rf $impure_dir/test_file
124 rm -rf $impure_dir/subdir
125
126 # Verify invalidation of readdir cache
127 $here/src/t_dir_type $impure_dir $test_file_st_ino
128 [[ $? != 0 ]] || echo "Directory's readdir cache has stale file entries"
129 $here/src/t_dir_type $impure_dir $impure_subdir_st_ino
130 [[ $? != 0 ]] || echo "Directory's readdir cache has stale subdir entries"
131
132 impure=$($GETFATTR_PROG --absolute-names --only-values -n 'trusted.overlay.impure' \
133                         $upperdir/test_dir/impure_dir 2>/dev/null)
134 [[ -z $impure ]] || echo "Pure directory has impure xattr"
135
136 # Verify d_ino values of subdir entries of a pure lower dir.
137 parent_st_ino=$(stat -c '%i' $test_dir)
138 pure_lower_dir=$SCRATCH_MNT/test_dir/pure_lower_dir
139 pure_lower_dir_st_ino=$(stat -c '%i' $pure_lower_dir)
140 pure_lower_subdir_st_ino=$(stat -c '%i' $pure_lower_dir/subdir)
141
142 parent_d=$($here/src/t_dir_type $pure_lower_dir $parent_st_ino)
143 [[ $parent_d == ".. d" ]] || \
144         echo "Pure lower dir: Invalid d_ino reported for .."
145
146 current_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_dir_st_ino)
147 [[ $current_d == ". d" ]] || \
148         echo "Pure lower dir: Invalid d_ino reported for ."
149
150 subdir_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_subdir_st_ino)
151 [[ $subdir_d == "subdir d" ]] || \
152         echo "Pure lower dir: Invalid d_ino reported for subdir"
153
154 # Create a file in pure lower dir to make it a merge dir
155 touch $pure_lower_dir/newfile
156
157 parent_d=$($here/src/t_dir_type $pure_lower_dir $parent_st_ino)
158 [[ $parent_d == ".. d" ]] || \
159         echo "Merged dir: Invalid d_ino reported for .."
160
161 current_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_dir_st_ino)
162 [[ $current_d == ". d" ]] || \
163         echo "Merged dir: Invalid d_ino reported for ."
164
165 subdir_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_subdir_st_ino)
166 [[ $subdir_d == "subdir d" ]] || \
167         echo "Merged dir: Invalid d_ino reported for subdir"
168
169 _scratch_unmount
170
171 # Verify pure lower residing in dir which has another lower layer
172 middir=$OVL_BASE_TEST_DIR/$seq-ovl-mid
173 lowerdir=$OVL_BASE_TEST_DIR/$seq-ovl-lower
174 rm -rf $middir
175 rm -rf $lowerdir
176 mkdir $middir
177 mkdir $lowerdir
178
179 mkdir -p $middir/test_dir
180 mkdir -p $lowerdir/test_dir/pure_lower_dir/subdir
181
182 _scratch_mkfs
183
184 upperdir=$OVL_BASE_SCRATCH_MNT/ovl-upper
185 workdir=$OVL_BASE_SCRATCH_MNT/ovl-work
186
187 _overlay_scratch_mount_dirs $middir:$lowerdir $upperdir $workdir
188
189 # Copy up test_dir
190 touch $test_dir/test_file
191
192 test_dir_st_ino=$(stat -c '%i' $test_dir)
193 pure_lower_dir=$test_dir/pure_lower_dir
194 pure_lower_dir_st_ino=$(stat -c '%i' $pure_lower_dir)
195 pure_lower_subdir_st_ino=$(stat -c '%i' $pure_lower_dir/subdir)
196
197 parent_d=$($here/src/t_dir_type $pure_lower_dir $test_dir_st_ino)
198 [[ $parent_d == ".. d" ]] || \
199         echo "Pure lower in dir which has another lower layer: Invalid d_ino reported for .."
200
201 current_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_dir_st_ino)
202 [[ $current_d == ". d" ]] || \
203         echo "Pure lower in dir which has another lower layer: Invalid d_ino reported for ."
204
205 subdir_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_subdir_st_ino)
206 [[ $subdir_d == "subdir d" ]] || \
207         echo "Pure lower in dir which has another lower layer: Invalid d_ino reported for subdir"
208
209 echo "Silence is golden"
210 status=0
211 exit