2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2017 IBM Corporation. All Rights Reserved.
7 # Test consistent d_ino numbers for samefs setup.
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
24 # get standard environment, filters and checks
29 # real QA test starts here
31 # Use non-default scratch underlying overlay dirs, we need to check
32 # them explicity after test.
33 _require_scratch_nocheck
34 _require_attrs trusted
35 _require_test_program "t_dir_type"
39 _scratch_mkfs >>$seqres.full 2>&1
41 # Create our test files.
42 upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
43 lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
46 mkdir -p $lowerdir/test_dir/pure_lower_dir/subdir
48 touch $lowerdir/test_file
52 test_dir=$SCRATCH_MNT/test_dir/
54 # Verify d_ino of '.' and '..' before and after dir becomes impure.
55 impure_dir=$test_dir/impure_dir
56 mkdir -p $impure_dir/subdir
58 impure_dir_st_ino=$(stat -c '%i' $impure_dir)
59 impure_dir_parent_st_ino=$(stat -c '%i' $test_dir)
60 impure_subdir_st_ino=$(stat -c '%i' $impure_dir/subdir)
62 # Before $impure_dir becomes impure
63 parent_d=$($here/src/t_dir_type $impure_dir $impure_dir_parent_st_ino)
64 [[ $parent_d == ".. d" ]] || \
65 echo "Pure upper dir: Invalid d_ino reported for .."
67 current_d=$($here/src/t_dir_type $impure_dir $impure_dir_st_ino)
68 [[ $current_d == ". d" ]] || \
69 echo "Pure upper dir: Invalid d_ino reported for ."
71 subdir_d=$($here/src/t_dir_type $impure_dir $impure_subdir_st_ino)
72 [[ $subdir_d == "subdir d" ]] || \
73 echo "Pure upper dir: Invalid d_ino reported for subdir"
75 # Move a copied up file into pure dir to make it impure
76 mv $SCRATCH_MNT/test_file $impure_dir
77 test_file_st_ino=$(stat -c '%i' $impure_dir/test_file)
79 impure=$(_getfattr --absolute-names --only-values -n 'trusted.overlay.impure' \
80 $upperdir/test_dir/impure_dir)
81 [[ $impure == "y" ]] || echo "Impure directory missing impure xattr"
83 # After $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 "Impure 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 "Impure 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 "Impure dir: Invalid d_ino reported for subdir"
96 # Verify copy up file's d_ino
97 file_d=$($here/src/t_dir_type $impure_dir $test_file_st_ino)
98 [[ $file_d == "test_file f" ]] || \
99 echo "Impure dir: Invalid d_ino reported for entry with copy-up origin"
101 # Make $impure_dir pure
102 rm -rf $impure_dir/test_file
103 rm -rf $impure_dir/subdir
105 # Verify invalidation of readdir cache
106 $here/src/t_dir_type $impure_dir $test_file_st_ino
107 [[ $? != 0 ]] || echo "Directory's readdir cache has stale file entries"
108 $here/src/t_dir_type $impure_dir $impure_subdir_st_ino
109 [[ $? != 0 ]] || echo "Directory's readdir cache has stale subdir entries"
111 impure=$(_getfattr --absolute-names --only-values -n 'trusted.overlay.impure' \
112 $upperdir/test_dir/impure_dir 2>/dev/null)
113 [[ -z $impure ]] || echo "Pure directory has impure xattr"
115 # Verify d_ino values of subdir entries of a pure lower dir.
116 parent_st_ino=$(stat -c '%i' $test_dir)
117 pure_lower_dir=$SCRATCH_MNT/test_dir/pure_lower_dir
118 pure_lower_dir_st_ino=$(stat -c '%i' $pure_lower_dir)
119 pure_lower_subdir_st_ino=$(stat -c '%i' $pure_lower_dir/subdir)
121 parent_d=$($here/src/t_dir_type $pure_lower_dir $parent_st_ino)
122 [[ $parent_d == ".. d" ]] || \
123 echo "Pure lower dir: Invalid d_ino reported for .."
125 current_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_dir_st_ino)
126 [[ $current_d == ". d" ]] || \
127 echo "Pure lower dir: Invalid d_ino reported for ."
129 subdir_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_subdir_st_ino)
130 [[ $subdir_d == "subdir d" ]] || \
131 echo "Pure lower dir: Invalid d_ino reported for subdir"
133 # Create a file in pure lower dir to make it a merge dir
134 touch $pure_lower_dir/newfile
136 parent_d=$($here/src/t_dir_type $pure_lower_dir $parent_st_ino)
137 [[ $parent_d == ".. d" ]] || \
138 echo "Merged dir: Invalid d_ino reported for .."
140 current_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_dir_st_ino)
141 [[ $current_d == ". d" ]] || \
142 echo "Merged dir: Invalid d_ino reported for ."
144 subdir_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_subdir_st_ino)
145 [[ $subdir_d == "subdir d" ]] || \
146 echo "Merged dir: Invalid d_ino reported for subdir"
153 # Verify pure lower residing in dir which has another lower layer
156 OVL_LOWER0=${OVL_LOWER}0
157 OVL_LOWER1=${OVL_LOWER}1
159 middir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER0
160 lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER1
161 upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
162 workdir=$OVL_BASE_SCRATCH_MNT/$OVL_WORK
169 mkdir -p $lowerdir/test_dir/pure_lower_dir/subdir
171 _overlay_scratch_mount_dirs "$middir:$lowerdir" $upperdir $workdir
174 touch $test_dir/test_file
176 test_dir_st_ino=$(stat -c '%i' $test_dir)
177 pure_lower_dir=$test_dir/pure_lower_dir
178 pure_lower_dir_st_ino=$(stat -c '%i' $pure_lower_dir)
179 pure_lower_subdir_st_ino=$(stat -c '%i' $pure_lower_dir/subdir)
181 parent_d=$($here/src/t_dir_type $pure_lower_dir $test_dir_st_ino)
182 [[ $parent_d == ".. d" ]] || \
183 echo "Pure lower in dir which has another lower layer: Invalid d_ino reported for .."
184 current_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_dir_st_ino)
185 [[ $current_d == ". d" ]] || \
186 echo "Pure lower in dir which has another lower layer: Invalid d_ino reported for ."
188 subdir_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_subdir_st_ino)
189 [[ $subdir_d == "subdir d" ]] || \
190 echo "Pure lower in dir which has another lower layer: Invalid d_ino reported for subdir"
193 _overlay_check_scratch_dirs "$middir:$lowerdir" $upperdir $workdir
195 echo "Silence is golden"