xfs/144: Use _qsetup instead of qsetup
[xfstests-dev.git] / tests / overlay / 062
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. 062
6 #
7 # Test file handle decode with multi lower layers on same fs
8 #
9 # This test is for a regression that was introduced in kernel v4.17 by
10 # commit 8b58924ad55c ("ovl: lookup in inode cache first when decoding
11 # lower file handle").
12 #
13 seq=`basename $0`
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
16
17 here=`pwd`
18 tmp=/tmp/$$
19 status=1        # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
21
22 _cleanup()
23 {
24         cd /
25         rm -f $tmp.*
26         $UMOUNT_PROG $lowertestdir
27 }
28
29 # get standard environment, filters and checks
30 . ./common/rc
31 . ./common/filter
32
33 # real QA test starts here
34
35 _supported_fs overlay
36 _require_scratch
37 _require_test_program "open_by_handle"
38 # We need to require all features together, because nfs_export cannot
39 # be enabled when index is disabled
40 _require_scratch_overlay_features index nfs_export
41
42 NUMFILES=1
43
44 # Create test dir and empty test files
45 create_test_files()
46 {
47         local dir=$1
48
49         mkdir -p $dir
50         $here/src/open_by_handle -cwp $dir $NUMFILES
51 }
52
53 # Test encode/decode file handles on overlay mount
54 test_file_handles()
55 {
56         local dir=$1
57
58         $here/src/open_by_handle -rp $dir $NUMFILES
59 }
60
61 _scratch_mkfs
62
63 # All lower layers are on scratch partition
64 lower=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
65 lower2=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER.2
66 lowertestdir=$lower2/testdir
67
68 create_test_files $lowertestdir
69
70 # bind mount to pin lower test dir dentry to dcache
71 $MOUNT_PROG --bind $lowertestdir $lowertestdir
72
73 # For non-upper overlay mount, nfs_export requires disabling redirect_dir.
74 $MOUNT_PROG -t overlay $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT \
75         -o ro,redirect_dir=nofollow,nfs_export=on,lowerdir=$lower:$lower2
76
77 # Decode an overlay directory file handle, whose underlying lower dir dentry
78 # is in dcache and connected and does not belong to the upper most lower layer.
79 # The test program drops caches, but $lowertestdir dcache in pinned, so only
80 # the overlay dentry is dropped.
81 test_file_handles $SCRATCH_MNT/testdir -rp
82
83 echo "Silence is golden"
84 status=0
85 exit