xfs/{263,106}: erase max warnings printout
[xfstests-dev.git] / tests / overlay / 058
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2018 CTERA Networks. All Rights Reserved.
4 #
5 # FS QA Test No. 058
6 #
7 # Test decoding overlay file handles with warm/cold dentry cache
8 #
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.
14 #
15 # This test requires and enables overlayfs NFS export support.
16 # NFS export support depends on and requires overlayfs index feature.
17 #
18 seq=`basename $0`
19 seqres=$RESULT_DIR/$seq
20 echo "QA output created by $seq"
21
22 here=`pwd`
23 tmp=/tmp/$$
24 status=1        # failure is the default!
25 trap "_cleanup; exit \$status" 0 1 2 3 15
26
27 _cleanup()
28 {
29         $KILLALL_PROG -9 open_by_handle >/dev/null 2>&1
30         wait
31         cd /
32         rm -f $tmp.*
33 }
34
35 # get standard environment, filters and checks
36 . ./common/rc
37 . ./common/filter
38
39 # real QA test starts here
40
41 _supported_fs overlay
42 _supported_os Linux
43 _require_scratch
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
49
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
54
55 # Keep this number > 1, because open_by_handle -rp does faccessat()
56 # on file file000000, which makes that dentry connected
57 NUMFILES=10
58
59 # Create test dir and empty test files
60 create_test_files()
61 {
62         local dir=$1
63         local opt=$2
64
65         mkdir -p $dir
66         $here/src/open_by_handle -cp $opt $dir $NUMFILES
67 }
68
69 # Test encode/decode file handles on overlay mount
70 test_file_handles()
71 {
72         local dir=$1
73         shift
74
75         echo test_file_handles $dir $* | _filter_scratch | \
76                                 sed -e "s,$tmp\.,,g"
77         $here/src/open_by_handle $* $dir $NUMFILES
78 }
79
80 # Create lower/upper dir and files
81 _scratch_mkfs
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
89
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
95
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
102 sleep 1
103 test_file_handles $SCRATCH_MNT -rnps -i $tmp.lower_file_handles &
104 # Give the above 1 second to get to sleep loop
105 sleep 1
106
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
115
116 # SIGPIPE avoids Terminated/Killed message from bash
117 $KILLALL_PROG -q -13 open_by_handle
118 wait
119
120 status=0
121 exit