2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2018 CTERA Networks. All Rights Reserved.
7 # Test decoding overlay file handles with warm/cold dentry cache
9 # When opening a non-dir by file handle and the decoded inode/dentry
10 # are not in cache, the resulting dentry is "disconnected" (i.e. unknown
11 # path). This is a common case that is already covered by previous tests.
12 # This test covers the case of decoding an overlay file handle, while a
13 # disconnected dentry is still in cache.
15 # This test requires and enables overlayfs NFS export support.
16 # NFS export support depends on and requires overlayfs index feature.
19 seqres=$RESULT_DIR/$seq
20 echo "QA output created by $seq"
24 status=1 # failure is the default!
25 trap "_cleanup; exit \$status" 0 1 2 3 15
29 $KILLALL_PROG -9 open_by_handle >/dev/null 2>&1
35 # get standard environment, filters and checks
39 # real QA test starts here
44 _require_test_program "open_by_handle"
45 # We need to require all features together, because nfs_export cannot
46 # be enabled when index is disabled
47 _require_scratch_overlay_features index nfs_export
48 _require_command "$KILLALL_PROG" killall
50 # All overlay dirs are on scratch partition
51 lower=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
52 upper=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
53 work=$OVL_BASE_SCRATCH_MNT/$OVL_WORK
55 # Keep this number > 1, because open_by_handle -rp does faccessat()
56 # on file file000000, which makes that dentry connected
59 # Create test dir and empty test files
66 $here/src/open_by_handle -cp $opt $dir $NUMFILES
69 # Test encode/decode file handles on overlay mount
75 echo test_file_handles $dir $* | _filter_scratch | \
77 $here/src/open_by_handle $* $dir $NUMFILES
80 # Create lower/upper dir and files
82 create_test_files $upper/uppertestdir -w
83 create_test_files $lower/lowertestdir -w
84 _scratch_mount -o "index=on,nfs_export=on"
85 # Encode upper file handles
86 test_file_handles $SCRATCH_MNT/uppertestdir -p -o $tmp.upper_file_handles
87 # Encode lower file handles
88 test_file_handles $SCRATCH_MNT/lowertestdir -p -o $tmp.lower_file_handles
90 # Check decode and read from stored file handles with warm caches -
91 # At this time, all non-dir dentries are connected, because the entries
92 # were created on lookup, before encoding the file handles.
93 test_file_handles $SCRATCH_MNT -rnp -i $tmp.upper_file_handles
94 test_file_handles $SCRATCH_MNT -rnp -i $tmp.lower_file_handles
96 # Check decode and read/readdir from stored file handles with cold caches -
97 # -s sleeps in the background to keep files open and keep disconnected
98 # overlay dentries in cache
99 _scratch_cycle_mount "index=on,nfs_export=on"
100 test_file_handles $SCRATCH_MNT -rnps -i $tmp.upper_file_handles &
101 # Give the above 1 second to get to sleep loop
103 test_file_handles $SCRATCH_MNT -rnps -i $tmp.lower_file_handles &
104 # Give the above 1 second to get to sleep loop
107 # Check decode and read/readdir from stored file handles with warm caches -
108 # At this time, all non-dir dentries are disconnected, because there was
109 # no lookup to the files since drop caches. The expection to this rule
110 # is lower and upper file000000. open_by_handle -rp above did faccessat()
111 # on file file000000, which created a connected dentry alias in addition
112 # to the disconnected dentry alias.
113 test_file_handles $SCRATCH_MNT -rnp -i $tmp.upper_file_handles
114 test_file_handles $SCRATCH_MNT -rnp -i $tmp.lower_file_handles
116 # SIGPIPE avoids Terminated/Killed message from bash
117 $KILLALL_PROG -q -13 open_by_handle