4 # Test consistent d_ino numbers for samefs setup.
6 #-----------------------------------------------------------------------
8 # Copyright (C) 2017 IBM Corporation. All Rights Reserved.
9 # Author: Chandan Rajendra <chandan@linux.vnet.ibm.com>
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation.
15 # This program is distributed in the hope that it would be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write the Free Software Foundation,
22 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #-----------------------------------------------------------------------
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
32 status=1 # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
41 # get standard environment, filters and checks
46 # real QA test starts here
51 _require_test_program "t_dir_type"
55 _scratch_mkfs >>$seqres.full 2>&1
57 # Create our test files.
58 upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
59 lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
62 mkdir -p $lowerdir/test_dir/pure_lower_dir/subdir
64 touch $lowerdir/test_file
68 test_dir=$SCRATCH_MNT/test_dir/
70 # Verify d_ino of '.' and '..' before and after dir becomes impure.
71 impure_dir=$test_dir/impure_dir
72 mkdir -p $impure_dir/subdir
74 impure_dir_st_ino=$(stat -c '%i' $impure_dir)
75 impure_dir_parent_st_ino=$(stat -c '%i' $test_dir)
76 impure_subdir_st_ino=$(stat -c '%i' $impure_dir/subdir)
78 # Before $impure_dir becomes impure
79 parent_d=$($here/src/t_dir_type $impure_dir $impure_dir_parent_st_ino)
80 [[ $parent_d == ".. d" ]] || \
81 echo "Pure upper dir: Invalid d_ino reported for .."
83 current_d=$($here/src/t_dir_type $impure_dir $impure_dir_st_ino)
84 [[ $current_d == ". d" ]] || \
85 echo "Pure upper dir: Invalid d_ino reported for ."
87 subdir_d=$($here/src/t_dir_type $impure_dir $impure_subdir_st_ino)
88 [[ $subdir_d == "subdir d" ]] || \
89 echo "Pure upper dir: Invalid d_ino reported for subdir"
91 # Move a copied up file into pure dir to make it impure
92 mv $SCRATCH_MNT/test_file $impure_dir
93 test_file_st_ino=$(stat -c '%i' $impure_dir/test_file)
95 impure=$($GETFATTR_PROG --absolute-names --only-values -n 'trusted.overlay.impure' \
96 $upperdir/test_dir/impure_dir)
97 [[ $impure == "y" ]] || echo "Impure directory missing impure xattr"
99 # After $impure_dir becomes impure
100 parent_d=$($here/src/t_dir_type $impure_dir $impure_dir_parent_st_ino)
101 [[ $parent_d == ".. d" ]] || \
102 echo "Impure dir: Invalid d_ino reported for .."
104 current_d=$($here/src/t_dir_type $impure_dir $impure_dir_st_ino)
105 [[ $current_d == ". d" ]] || \
106 echo "Impure dir: Invalid d_ino reported for ."
108 subdir_d=$($here/src/t_dir_type $impure_dir $impure_subdir_st_ino)
109 [[ $subdir_d == "subdir d" ]] || \
110 echo "Impure dir: Invalid d_ino reported for subdir"
112 # Verify copy up file's d_ino
113 file_d=$($here/src/t_dir_type $impure_dir $test_file_st_ino)
114 [[ $file_d == "test_file f" ]] || \
115 echo "Impure dir: Invalid d_ino reported for entry with copy-up origin"
117 # Make $impure_dir pure
118 rm -rf $impure_dir/test_file
119 rm -rf $impure_dir/subdir
121 # Verify invalidation of readdir cache
122 $here/src/t_dir_type $impure_dir $test_file_st_ino
123 [[ $? != 0 ]] || echo "Directory's readdir cache has stale file entries"
124 $here/src/t_dir_type $impure_dir $impure_subdir_st_ino
125 [[ $? != 0 ]] || echo "Directory's readdir cache has stale subdir entries"
127 impure=$($GETFATTR_PROG --absolute-names --only-values -n 'trusted.overlay.impure' \
128 $upperdir/test_dir/impure_dir 2>/dev/null)
129 [[ -z $impure ]] || echo "Pure directory has impure xattr"
131 # Verify d_ino values of subdir entries of a pure lower dir.
132 parent_st_ino=$(stat -c '%i' $test_dir)
133 pure_lower_dir=$SCRATCH_MNT/test_dir/pure_lower_dir
134 pure_lower_dir_st_ino=$(stat -c '%i' $pure_lower_dir)
135 pure_lower_subdir_st_ino=$(stat -c '%i' $pure_lower_dir/subdir)
137 parent_d=$($here/src/t_dir_type $pure_lower_dir $parent_st_ino)
138 [[ $parent_d == ".. d" ]] || \
139 echo "Pure lower dir: Invalid d_ino reported for .."
141 current_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_dir_st_ino)
142 [[ $current_d == ". d" ]] || \
143 echo "Pure lower dir: Invalid d_ino reported for ."
145 subdir_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_subdir_st_ino)
146 [[ $subdir_d == "subdir d" ]] || \
147 echo "Pure lower dir: Invalid d_ino reported for subdir"
149 # Create a file in pure lower dir to make it a merge dir
150 touch $pure_lower_dir/newfile
152 parent_d=$($here/src/t_dir_type $pure_lower_dir $parent_st_ino)
153 [[ $parent_d == ".. d" ]] || \
154 echo "Merged dir: Invalid d_ino reported for .."
156 current_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_dir_st_ino)
157 [[ $current_d == ". d" ]] || \
158 echo "Merged dir: Invalid d_ino reported for ."
160 subdir_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_subdir_st_ino)
161 [[ $subdir_d == "subdir d" ]] || \
162 echo "Merged dir: Invalid d_ino reported for subdir"
166 # Verify pure lower residing in dir which has another lower layer
169 OVL_LOWER0=${OVL_LOWER}0
170 OVL_LOWER1=${OVL_LOWER}1
172 middir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER0
173 lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER1
174 upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
175 workdir=$OVL_BASE_SCRATCH_MNT/$OVL_WORK
182 mkdir -p $lowerdir/test_dir/pure_lower_dir/subdir
184 _overlay_scratch_mount_dirs "$middir:$lowerdir" $upperdir $workdir
187 touch $test_dir/test_file
189 test_dir_st_ino=$(stat -c '%i' $test_dir)
190 pure_lower_dir=$test_dir/pure_lower_dir
191 pure_lower_dir_st_ino=$(stat -c '%i' $pure_lower_dir)
192 pure_lower_subdir_st_ino=$(stat -c '%i' $pure_lower_dir/subdir)
194 parent_d=$($here/src/t_dir_type $pure_lower_dir $test_dir_st_ino)
195 [[ $parent_d == ".. d" ]] || \
196 echo "Pure lower in dir which has another lower layer: Invalid d_ino reported for .."
197 current_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_dir_st_ino)
198 [[ $current_d == ". d" ]] || \
199 echo "Pure lower in dir which has another lower layer: Invalid d_ino reported for ."
201 subdir_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_subdir_st_ino)
202 [[ $subdir_d == "subdir d" ]] || \
203 echo "Pure lower in dir which has another lower layer: Invalid d_ino reported for subdir"
205 echo "Silence is golden"