4 # Test constant d_ino numbers
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 "af_unix"
52 _require_test_program "t_dir_type"
56 _scratch_mkfs >>$seqres.full 2>&1
58 # Create our test files.
59 upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
60 lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
63 mkdir $lowerdir/test_dir/
64 mkdir $lowerdir/test_dir/pure_lower_dir
65 mkdir $lowerdir/test_dir/merged_dir
67 touch $lowerdir/test_file
71 test_dir=$SCRATCH_MNT/test_dir/
72 merged_dir=$test_dir/merged_dir
73 pure_upper_dir=$merged_dir/pure_upper_dir
75 mkdir -p $pure_upper_dir
77 merged_dir_st_ino=$(stat -c '%i' $merged_dir)
79 # Pure dir's parent d_ino must always be calculated because
80 # it can be residing inside a merged dir.
81 parent_d=$($here/src/t_dir_type $pure_upper_dir $merged_dir_st_ino)
82 [[ $parent_d == ".. d" ]] || \
83 echo "Pure dir inside a merged dir: Invalid d_ino reported for .."
85 # d_ino for "." must always be calculated because the present
86 # directory can have a copy-up origin.
87 current_d=$($here/src/t_dir_type $merged_dir $merged_dir_st_ino)
88 [[ $current_d == ". d" ]] || echo "Merged dir: Invalid d_ino reported for ."
90 # Verify d_ino of '.' and '..' before and after dir becomes impure.
91 impure_dir=$test_dir/impure_dir
94 impure_dir_st_ino=$(stat -c '%i' $impure_dir)
95 impure_dir_parent_st_ino=$(stat -c '%i' $test_dir)
97 # Before $impure_dir becomes impure
98 parent_d=$($here/src/t_dir_type $impure_dir $impure_dir_parent_st_ino)
99 [[ $parent_d == ".. d" ]] || \
100 echo "Before dir becomes impure: Invalid d_ino reported for .."
102 current_d=$($here/src/t_dir_type $impure_dir $impure_dir_st_ino)
103 [[ $current_d == ". d" ]] || \
104 echo "Before dir becomes impure: Invalid d_ino reported for ."
106 chown -h 100 $SCRATCH_MNT/test_file
107 test_file_st_ino=$(stat -c '%i' $SCRATCH_MNT/test_file)
109 mv $SCRATCH_MNT/test_file $impure_dir
111 $GETFATTR_PROG --absolute-names -n 'trusted.overlay.impure' \
112 $upperdir/test_dir/impure_dir >>$seqres.full 2>&1
113 [[ $? == 0 ]] || echo "Impure directory missing impure xattr"
115 # After $impure_dir becomes impure
116 parent_d=$($here/src/t_dir_type $impure_dir $impure_dir_parent_st_ino)
117 [[ $parent_d == ".. d" ]] || \
118 echo "After dir becomes impure: Invalid d_ino reported for .."
120 current_d=$($here/src/t_dir_type $impure_dir $impure_dir_st_ino)
121 [[ $current_d == ". d" ]] || \
122 echo "After dir becomes impure: Invalid d_ino reported for ."
124 # Verify copy up file's d_ino
125 file_d=$($here/src/t_dir_type $impure_dir $test_file_st_ino)
126 [[ $file_d == "test_file f" ]] || \
127 echo "Impure dir: Invalid d_ino reported for entry with copy-up origin"
129 # Make $impure_dir pure
130 rm -rf $impure_dir/test_file
132 # Verify invalidation of readdir cache
133 $here/src/t_dir_type $impure_dir $test_file_st_ino
134 [[ $? != 0 ]] || echo "Directory's readdir cache has stale entries"
136 $GETFATTR_PROG --absolute-names -n 'trusted.overlay.impure' \
137 $upperdir/test_dir/impure_dir >>$seqres.full 2>&1
138 [[ $? != 0 ]] || echo "Pure directory has impure xattr"
140 # Verify d_ino values corresponding to "." and ".." entries of a
142 parent_st_ino=$(stat -c '%i' $SCRATCH_MNT/test_dir)
143 pure_lower_dir=$SCRATCH_MNT/test_dir/pure_lower_dir
145 parent_d=$($here/src/t_dir_type $pure_lower_dir $parent_st_ino)
146 [[ $parent_d == ".. d" ]] || echo "Pure lower dir: Invalid d_ino reported for .."
148 pure_lower_dir_st_ino=$(stat -c '%i' $pure_lower_dir)
150 current_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_dir_st_ino)
151 [[ $current_d == ". d" ]] || echo "Pure lower dir: Invalid d_ino reported for ."
153 # Verify d_ino of ".." entry of a merged dir.
154 merged_dir=$SCRATCH_MNT/test_dir/merged_dir
156 parent_d=$($here/src/t_dir_type $merged_dir $parent_st_ino)
157 [[ $parent_d == ".. d" ]] || echo "Merged dir: Invalid d_ino reported for .."
161 # Verify pure lower residing in dir which has another lower layer
164 OVL_LOWER0=${OVL_LOWER}0
165 OVL_LOWER1=${OVL_LOWER}1
167 middir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER0
168 lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER1
169 upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
170 workdir=$OVL_BASE_SCRATCH_MNT/$OVL_WORK
177 mkdir -p $middir/test_dir
178 mkdir -p $lowerdir/test_dir/pure_lower_dir
180 $MOUNT_PROG -t overlay overlay -o lowerdir=$middir:$lowerdir \
181 -o upperdir=$upperdir -o workdir=$workdir $SCRATCH_MNT
184 touch $SCRATCH_MNT/test_dir/test_file
186 test_dir_st_ino=$(stat -c '%i' $SCRATCH_MNT/test_dir)
188 parent_d=$($here/src/t_dir_type $SCRATCH_MNT/test_dir/pure_lower_dir $test_dir_st_ino)
189 [[ $parent_d == ".. d" ]] || \
190 echo "Pure lower in dir which has another lower layer: Invalid d_ino reported for .."
192 $UMOUNT_PROG $SCRATCH_MNT
194 echo "Silence is golden"