generic: test MADV_POPULATE_READ with IO errors
[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 . ./common/preamble
14 _begin_fstest auto quick exportfs
15
16 # Override the default cleanup function.
17 _cleanup()
18 {
19         cd /
20         rm -f $tmp.*
21         $UMOUNT_PROG $lowertestdir
22 }
23
24 # Import common functions.
25 . ./common/filter
26
27 # real QA test starts here
28
29 _supported_fs overlay
30 _require_scratch
31 _require_test_program "open_by_handle"
32 # We need to require all features together, because nfs_export cannot
33 # be enabled when index is disabled
34 _require_scratch_overlay_features index nfs_export
35
36 NUMFILES=1
37
38 # Create test dir and empty test files
39 create_test_files()
40 {
41         local dir=$1
42
43         mkdir -p $dir
44         $here/src/open_by_handle -cwp $dir $NUMFILES
45 }
46
47 # Test encode/decode file handles on overlay mount
48 test_file_handles()
49 {
50         local dir=$1
51
52         $here/src/open_by_handle -rp $dir $NUMFILES
53 }
54
55 _scratch_mkfs
56
57 # All lower layers are on scratch partition
58 lower=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
59 lower2=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER.2
60 lowertestdir=$lower2/testdir
61
62 create_test_files $lowertestdir
63
64 # bind mount to pin lower test dir dentry to dcache
65 $MOUNT_PROG --bind $lowertestdir $lowertestdir
66
67 # For non-upper overlay mount, nfs_export requires disabling redirect_dir.
68 _overlay_scratch_mount_opts \
69         -o ro,redirect_dir=nofollow,nfs_export=on,lowerdir=$lower:$lower2
70
71 # Decode an overlay directory file handle, whose underlying lower dir dentry
72 # is in dcache and connected and does not belong to the upper most lower layer.
73 # The test program drops caches, but $lowertestdir dcache in pinned, so only
74 # the overlay dentry is dropped.
75 test_file_handles $SCRATCH_MNT/testdir -rp
76
77 echo "Silence is golden"
78 status=0
79 exit