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.
8 #-----------------------------------------------------------------------
10 # Copyright (C) 2017 IBM Corporation. All Rights Reserved.
11 # Author: Chandan Rajendra <chandan@linux.vnet.ibm.com>
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.
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.
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 #-----------------------------------------------------------------------
29 seqres=$RESULT_DIR/$seq
30 echo "QA output created by $seq"
34 status=1 # failure is the default!
35 trap "_cleanup; exit \$status" 0 1 2 3 15
43 # get standard environment, filters and checks
48 # real QA test starts here
54 _require_test_program "t_dir_type"
58 lowerdir=$OVL_BASE_TEST_DIR/$seq-ovl-lower
62 # Create our test files.
63 mkdir -p $lowerdir/test_dir/pure_lower_dir/subdir
64 touch $lowerdir/test_file
68 upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
69 workdir=$OVL_BASE_SCRATCH_MNT/$OVL_WORK
71 _overlay_scratch_mount_dirs $lowerdir $upperdir $workdir
73 test_dir=$SCRATCH_MNT/test_dir/
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
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)
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 .."
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 ."
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"
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)
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"
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 .."
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 ."
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"
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"
122 # Make $impure_dir pure
123 rm -rf $impure_dir/test_file
124 rm -rf $impure_dir/subdir
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"
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"
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)
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 .."
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 ."
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"
154 # Create a file in pure lower dir to make it a merge dir
155 touch $pure_lower_dir/newfile
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 .."
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 ."
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"
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
179 mkdir -p $middir/test_dir
180 mkdir -p $lowerdir/test_dir/pure_lower_dir/subdir
184 upperdir=$OVL_BASE_SCRATCH_MNT/ovl-upper
185 workdir=$OVL_BASE_SCRATCH_MNT/ovl-work
187 _overlay_scratch_mount_dirs $middir:$lowerdir $upperdir $workdir
190 touch $test_dir/test_file
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)
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 .."
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 ."
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"
209 echo "Silence is golden"