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 \
72 $OVERLAY_MOUNT_OPTIONS
74 test_dir=$SCRATCH_MNT/test_dir/
76 # Verify d_ino of '.' and '..' before and after dir becomes impure.
77 impure_dir=$test_dir/impure_dir
78 mkdir -p $impure_dir/subdir
80 impure_dir_st_ino=$(stat -c '%i' $impure_dir)
81 impure_dir_parent_st_ino=$(stat -c '%i' $test_dir)
82 impure_subdir_st_ino=$(stat -c '%i' $impure_dir/subdir)
84 # Before $impure_dir becomes impure
85 parent_d=$($here/src/t_dir_type $impure_dir $impure_dir_parent_st_ino)
86 [[ $parent_d == ".. d" ]] || \
87 echo "Pure upper dir: Invalid d_ino reported for .."
89 current_d=$($here/src/t_dir_type $impure_dir $impure_dir_st_ino)
90 [[ $current_d == ". d" ]] || \
91 echo "Pure upper dir: Invalid d_ino reported for ."
93 subdir_d=$($here/src/t_dir_type $impure_dir $impure_subdir_st_ino)
94 [[ $subdir_d == "subdir d" ]] || \
95 echo "Pure upper dir: Invalid d_ino reported for subdir"
97 # Move a copied up file into pure dir to make it impure
98 mv $SCRATCH_MNT/test_file $impure_dir
99 test_file_st_ino=$(stat -c '%i' $impure_dir/test_file)
101 impure=$($GETFATTR_PROG --absolute-names --only-values -n 'trusted.overlay.impure' \
102 $upperdir/test_dir/impure_dir)
103 [[ $impure == "y" ]] || echo "Impure directory missing impure xattr"
105 # After $impure_dir becomes impure
106 parent_d=$($here/src/t_dir_type $impure_dir $impure_dir_parent_st_ino)
107 [[ $parent_d == ".. d" ]] || \
108 echo "Impure dir: Invalid d_ino reported for .."
110 current_d=$($here/src/t_dir_type $impure_dir $impure_dir_st_ino)
111 [[ $current_d == ". d" ]] || \
112 echo "Impure dir: Invalid d_ino reported for ."
114 subdir_d=$($here/src/t_dir_type $impure_dir $impure_subdir_st_ino)
115 [[ $subdir_d == "subdir d" ]] || \
116 echo "Impure dir: Invalid d_ino reported for subdir"
118 # Verify copy up file's d_ino
119 file_d=$($here/src/t_dir_type $impure_dir $test_file_st_ino)
120 [[ $file_d == "test_file f" ]] || \
121 echo "Impure dir: Invalid d_ino reported for entry with copy-up origin"
123 # Make $impure_dir pure
124 rm -rf $impure_dir/test_file
125 rm -rf $impure_dir/subdir
127 # Verify invalidation of readdir cache
128 $here/src/t_dir_type $impure_dir $test_file_st_ino
129 [[ $? != 0 ]] || echo "Directory's readdir cache has stale file entries"
130 $here/src/t_dir_type $impure_dir $impure_subdir_st_ino
131 [[ $? != 0 ]] || echo "Directory's readdir cache has stale subdir entries"
133 impure=$($GETFATTR_PROG --absolute-names --only-values -n 'trusted.overlay.impure' \
134 $upperdir/test_dir/impure_dir 2>/dev/null)
135 [[ -z $impure ]] || echo "Pure directory has impure xattr"
137 # Verify d_ino values of subdir entries of a pure lower dir.
138 parent_st_ino=$(stat -c '%i' $test_dir)
139 pure_lower_dir=$SCRATCH_MNT/test_dir/pure_lower_dir
140 pure_lower_dir_st_ino=$(stat -c '%i' $pure_lower_dir)
141 pure_lower_subdir_st_ino=$(stat -c '%i' $pure_lower_dir/subdir)
143 parent_d=$($here/src/t_dir_type $pure_lower_dir $parent_st_ino)
144 [[ $parent_d == ".. d" ]] || \
145 echo "Pure lower dir: Invalid d_ino reported for .."
147 current_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_dir_st_ino)
148 [[ $current_d == ". d" ]] || \
149 echo "Pure lower dir: Invalid d_ino reported for ."
151 subdir_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_subdir_st_ino)
152 [[ $subdir_d == "subdir d" ]] || \
153 echo "Pure lower dir: Invalid d_ino reported for subdir"
155 # Create a file in pure lower dir to make it a merge dir
156 touch $pure_lower_dir/newfile
158 parent_d=$($here/src/t_dir_type $pure_lower_dir $parent_st_ino)
159 [[ $parent_d == ".. d" ]] || \
160 echo "Merged dir: Invalid d_ino reported for .."
162 current_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_dir_st_ino)
163 [[ $current_d == ". d" ]] || \
164 echo "Merged dir: Invalid d_ino reported for ."
166 subdir_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_subdir_st_ino)
167 [[ $subdir_d == "subdir d" ]] || \
168 echo "Merged dir: Invalid d_ino reported for subdir"
172 # Verify pure lower residing in dir which has another lower layer
173 middir=$OVL_BASE_TEST_DIR/$seq-ovl-mid
174 lowerdir=$OVL_BASE_TEST_DIR/$seq-ovl-lower
180 mkdir -p $middir/test_dir
181 mkdir -p $lowerdir/test_dir/pure_lower_dir/subdir
185 upperdir=$OVL_BASE_SCRATCH_MNT/ovl-upper
186 workdir=$OVL_BASE_SCRATCH_MNT/ovl-work
188 _overlay_scratch_mount_dirs $middir:$lowerdir $upperdir $workdir \
189 $OVERLAY_MOUNT_OPTIONS
192 touch $test_dir/test_file
194 test_dir_st_ino=$(stat -c '%i' $test_dir)
195 pure_lower_dir=$test_dir/pure_lower_dir
196 pure_lower_dir_st_ino=$(stat -c '%i' $pure_lower_dir)
197 pure_lower_subdir_st_ino=$(stat -c '%i' $pure_lower_dir/subdir)
199 parent_d=$($here/src/t_dir_type $pure_lower_dir $test_dir_st_ino)
200 [[ $parent_d == ".. d" ]] || \
201 echo "Pure lower in dir which has another lower layer: Invalid d_ino reported for .."
203 current_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_dir_st_ino)
204 [[ $current_d == ". d" ]] || \
205 echo "Pure lower in dir which has another lower layer: Invalid d_ino reported for ."
207 subdir_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_subdir_st_ino)
208 [[ $subdir_d == "subdir d" ]] || \
209 echo "Pure lower in dir which has another lower layer: Invalid d_ino reported for subdir"
211 echo "Silence is golden"