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
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
74 impure_dir_st_ino=$(stat -c '%i' $impure_dir)
75 impure_dir_parent_st_ino=$(stat -c '%i' $test_dir)
77 # Before $impure_dir becomes impure
78 parent_d=$($here/src/t_dir_type $impure_dir $impure_dir_parent_st_ino)
79 [[ $parent_d == ".. d" ]] || \
80 echo "Pure upper dir: Invalid d_ino reported for .."
82 current_d=$($here/src/t_dir_type $impure_dir $impure_dir_st_ino)
83 [[ $current_d == ". d" ]] || \
84 echo "Pure upper dir: Invalid d_ino reported for ."
86 # Move a copied up file into pure dir to make it impure
87 mv $SCRATCH_MNT/test_file $impure_dir
88 test_file_st_ino=$(stat -c '%i' $impure_dir/test_file)
90 impure=$($GETFATTR_PROG --absolute-names --only-values -n 'trusted.overlay.impure' \
91 $upperdir/test_dir/impure_dir)
92 [[ $impure == "y" ]] || echo "Impure directory missing impure xattr"
94 # After $impure_dir becomes impure
95 parent_d=$($here/src/t_dir_type $impure_dir $impure_dir_parent_st_ino)
96 [[ $parent_d == ".. d" ]] || \
97 echo "Impure dir: Invalid d_ino reported for .."
99 current_d=$($here/src/t_dir_type $impure_dir $impure_dir_st_ino)
100 [[ $current_d == ". d" ]] || \
101 echo "Impure dir: Invalid d_ino reported for ."
103 # Verify copy up file's d_ino
104 file_d=$($here/src/t_dir_type $impure_dir $test_file_st_ino)
105 [[ $file_d == "test_file f" ]] || \
106 echo "Impure dir: Invalid d_ino reported for entry with copy-up origin"
108 # Make $impure_dir pure
109 rm -rf $impure_dir/test_file
111 # Verify invalidation of readdir cache
112 $here/src/t_dir_type $impure_dir $test_file_st_ino
113 [[ $? != 0 ]] || echo "Directory's readdir cache has stale file entries"
115 impure=$($GETFATTR_PROG --absolute-names --only-values -n 'trusted.overlay.impure' \
116 $upperdir/test_dir/impure_dir 2>/dev/null)
117 [[ -z $impure ]] || echo "Pure directory has impure xattr"
119 # Verify d_ino of '.' and '..' before and after dir becomes merge dir.
120 parent_st_ino=$(stat -c '%i' $test_dir)
121 pure_lower_dir=$SCRATCH_MNT/test_dir/pure_lower_dir
122 pure_lower_dir_st_ino=$(stat -c '%i' $pure_lower_dir)
124 parent_d=$($here/src/t_dir_type $pure_lower_dir $parent_st_ino)
125 [[ $parent_d == ".. d" ]] || \
126 echo "Pure lower dir: Invalid d_ino reported for .."
128 current_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_dir_st_ino)
129 [[ $current_d == ". d" ]] || \
130 echo "Pure lower dir: Invalid d_ino reported for ."
132 # Create a file in pure lower dir to make it a merge dir
133 touch $pure_lower_dir/newfile
135 parent_d=$($here/src/t_dir_type $pure_lower_dir $parent_st_ino)
136 [[ $parent_d == ".. d" ]] || \
137 echo "Merged dir: Invalid d_ino reported for .."
139 current_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_dir_st_ino)
140 [[ $current_d == ". d" ]] || \
141 echo "Merged dir: Invalid d_ino reported for ."
145 # Verify pure lower residing in dir which has another lower layer
148 OVL_LOWER0=${OVL_LOWER}0
149 OVL_LOWER1=${OVL_LOWER}1
151 middir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER0
152 lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER1
153 upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
154 workdir=$OVL_BASE_SCRATCH_MNT/$OVL_WORK
161 mkdir -p $middir/test_dir
162 mkdir -p $lowerdir/test_dir/pure_lower_dir
164 _overlay_scratch_mount_dirs "$middir:$lowerdir" $upperdir $workdir
167 touch $test_dir/test_file
169 test_dir_st_ino=$(stat -c '%i' $test_dir)
170 pure_lower_dir=$test_dir/pure_lower_dir
172 parent_d=$($here/src/t_dir_type $pure_lower_dir $test_dir_st_ino)
173 [[ $parent_d == ".. d" ]] || \
174 echo "Pure lower in dir which has another lower layer: Invalid d_ino reported for .."
176 echo "Silence is golden"