4 # Test encode/decode overlay file handle of dir with non-indexed ancestor
6 # Overlayfs with nfs_export enabled, indexes all directories on copy up.
7 # Directory index is requires for decoding lower directory file handles
8 # in case ancestors have been renamed.
10 # When enabling nfs_export on an overlay that already has non-indexed
11 # merge dirs, the possibility of non-indexed ancestor rename requires
12 # special handling when encoding lower directory file handles.
14 # - Check encode/decode/read file handles of non-indexed merge dir
15 # - Check encode/decode/read file handles of dir with non-indexed parent
16 # - Check encode/decode/read file handles of dir with non-indexed grandparent
17 # - Check decode/read of file handles after rename of non-indexed merge dir
18 # - Check decode/read of file handles after rename of non-indexed parent
19 # - Check decode/read of file handles after rename of non-indexed grandparent
21 # This test requires and enables overlayfs NFS export support and merge
22 # dir rename support (redirect_dir).
23 # NFS export support depends on and requires overlayfs index feature.
25 #-----------------------------------------------------------------------
26 # Copyright (C) 2018 CTERA Networks. All Rights Reserved.
27 # Author: Amir Goldstein <amir73il@gmail.com>
29 # This program is free software; you can redistribute it and/or
30 # modify it under the terms of the GNU General Public License as
31 # published by the Free Software Foundation.
33 # This program is distributed in the hope that it would be useful,
34 # but WITHOUT ANY WARRANTY; without even the implied warranty of
35 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36 # GNU General Public License for more details.
38 # You should have received a copy of the GNU General Public License
39 # along with this program; if not, write the Free Software Foundation,
40 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
41 #-----------------------------------------------------------------------
45 seqres=$RESULT_DIR/$seq
46 echo "QA output created by $seq"
50 status=1 # failure is the default!
51 trap "_cleanup; exit \$status" 0 1 2 3 15
59 # get standard environment, filters and checks
63 # real QA test starts here
68 _require_test_program "open_by_handle"
69 # We need to require all features together, because nfs_export cannot
70 # be enabled when index is disabled
71 _require_scratch_overlay_features index nfs_export redirect_dir
73 # All overlay dirs are on scratch partition
74 lower=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
75 upper=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
76 work=$OVL_BASE_SCRATCH_MNT/$OVL_WORK
80 # Create test dir and empty test files
87 $here/src/open_by_handle -cp $opt $dir $NUMFILES
90 # Test encode/decode file handles on overlay mount
96 echo test_file_handles $dir $* | _filter_scratch | \
98 $here/src/open_by_handle $* $dir $NUMFILES
101 # Re-create lower/upper/work dirs
107 # Mount an overlay on $SCRATCH_MNT with all layers on scratch partition
110 _scratch_mount -o "index=on,nfs_export=on,redirect_dir=on"
113 # Unmount the overlay without unmounting base fs
116 $UMOUNT_PROG $SCRATCH_MNT
119 # Check encode/decode/read file handles of dir with non-indexed ancestor
121 create_test_files $lower/merged -w
122 create_test_files $lower/merged/dir -w
123 create_test_files $lower/merged/dir/subdir -w
124 create_test_files $lower/merged/parent/child -w
125 # Create non-indexed merge dir
128 # Check encode/decode/read file handles of non-indexed merge dir
129 # This is expected to encode an upper file handle
130 test_file_handles $SCRATCH_MNT/merged -p -o $tmp.merged_file_handles
131 # Check encode/decode/read file handles of dir with non-indexed parent
132 # This is expected to copy up merged/dir and encode an upper file handle
133 test_file_handles $SCRATCH_MNT/merged/dir -p -o $tmp.dir_file_handles
134 test -d $upper/merged/dir || echo "merged/dir not copied up"
135 # Check encode/decode/read file handles of dir with non-indexed grandparent
136 # This is expected to encode a lower file handle
137 test_file_handles $SCRATCH_MNT/merged/dir/subdir -p -o $tmp.subdir_file_handles
138 test -d $upper/merged/dir/subdir && echo "merged/dir/subdir unexpected copy up"
139 # This is expected to copy up parent and encode a lower file handle
140 test_file_handles $SCRATCH_MNT/merged/parent/child -p -o $tmp.child_file_handles
141 test -d $upper/merged/parent || echo "merged/parent not copied up"
142 test -d $upper/merged/parent/child && echo "merged/parent/child unexpected copy up"
144 # Rename non-indexed merge dir
145 mv $SCRATCH_MNT/merged $SCRATCH_MNT/merged.new/
146 # Check open, read and readdir from stored file handles
147 # (testdir argument is the mount point and NOT the dir
148 # we are trying to open by stored file handle)
149 test_file_handles $SCRATCH_MNT -rp -i $tmp.merged_file_handles
150 test_file_handles $SCRATCH_MNT -rp -i $tmp.dir_file_handles
151 test_file_handles $SCRATCH_MNT -rp -i $tmp.subdir_file_handles
152 test_file_handles $SCRATCH_MNT -rp -i $tmp.child_file_handles
153 # Retry decoding lower subdir file handles when indexed ancestor is in dcache
154 # (providing the ancestor dir argument pins the ancestor to dcache)
155 test_file_handles $SCRATCH_MNT/merged.new/dir -rp -i $tmp.subdir_file_handles
156 test_file_handles $SCRATCH_MNT/merged.new/parent -rp -i $tmp.child_file_handles