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
43 _require_test_program "open_by_handle"
44 # We need to require all features together, because nfs_export cannot
45 # be enabled when index is disabled
46 _require_scratch_overlay_features index nfs_export
47 _require_command "$KILLALL_PROG" killall
49 # All overlay dirs are on scratch partition
50 lower=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
51 upper=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
52 work=$OVL_BASE_SCRATCH_MNT/$OVL_WORK
54 # Keep this number > 1, because open_by_handle -rp does faccessat()
55 # on file file000000, which makes that dentry connected
58 # Create test dir and empty test files
65 $here/src/open_by_handle -cp $opt $dir $NUMFILES
68 # Test encode/decode file handles on overlay mount
74 echo test_file_handles $dir $* | _filter_scratch | \
76 $here/src/open_by_handle $* $dir $NUMFILES
79 # Create lower/upper dir and files
81 create_test_files $upper/uppertestdir -w
82 create_test_files $lower/lowertestdir -w
83 _scratch_mount -o "index=on,nfs_export=on"
84 # Encode upper file handles
85 test_file_handles $SCRATCH_MNT/uppertestdir -p -o $tmp.upper_file_handles
86 # Encode lower file handles
87 test_file_handles $SCRATCH_MNT/lowertestdir -p -o $tmp.lower_file_handles
89 # Check decode and read from stored file handles with warm caches -
90 # At this time, all non-dir dentries are connected, because the entries
91 # were created on lookup, before encoding the file handles.
92 test_file_handles $SCRATCH_MNT -rnp -i $tmp.upper_file_handles
93 test_file_handles $SCRATCH_MNT -rnp -i $tmp.lower_file_handles
95 # Check decode and read/readdir from stored file handles with cold caches -
96 # -s sleeps in the background to keep files open and keep disconnected
97 # overlay dentries in cache
98 _scratch_cycle_mount "index=on,nfs_export=on"
99 test_file_handles $SCRATCH_MNT -rnps -i $tmp.upper_file_handles &
100 # Give the above 1 second to get to sleep loop
102 test_file_handles $SCRATCH_MNT -rnps -i $tmp.lower_file_handles &
103 # Give the above 1 second to get to sleep loop
106 # Check decode and read/readdir from stored file handles with warm caches -
107 # At this time, all non-dir dentries are disconnected, because there was
108 # no lookup to the files since drop caches. The expection to this rule
109 # is lower and upper file000000. open_by_handle -rp above did faccessat()
110 # on file file000000, which created a connected dentry alias in addition
111 # to the disconnected dentry alias.
112 test_file_handles $SCRATCH_MNT -rnp -i $tmp.upper_file_handles
113 test_file_handles $SCRATCH_MNT -rnp -i $tmp.lower_file_handles
115 # SIGPIPE avoids Terminated/Killed message from bash
116 $KILLALL_PROG -q -13 open_by_handle