generic: test for creating duplicate filenames in encrypted dir
[xfstests-dev.git] / tests / generic / 413
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Red Hat Inc.  All Rights Reserved.
4 #
5 # FS QA Test 413
6 #
7 # mmap direct/buffered io between DAX and non-DAX mountpoints.
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20         cd /
21         rm -f $tmp.*
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27
28 # remove previous $seqres.full before test
29 rm -f $seqres.full
30
31 _supported_fs generic
32 _require_test
33 _require_scratch_dax_mountopt "dax"
34 _require_test_program "feature"
35 _require_test_program "t_mmap_dio"
36 _require_xfs_io_command "falloc"
37
38 prep_files()
39 {
40         rm -f $SCRATCH_MNT/tf_{s,d}
41         rm -f $TEST_DIR/tf_{s,d}
42
43         $XFS_IO_PROG -f -c "falloc 0 $tsize" \
44                 $SCRATCH_MNT/tf_{s,d} >> $seqres.full 2>&1
45         $XFS_IO_PROG -f -c "falloc 0 $tsize" \
46                 $TEST_DIR/tf_{s,d} >> $seqres.full 2>&1
47 }
48
49 t_both_dax()
50 {
51         prep_files
52         # with O_DIRECT first
53         $here/src/t_mmap_dio $SCRATCH_MNT/tf_{s,d} $1 "dio both dax"
54
55         prep_files
56         # again with buffered IO
57         $here/src/t_mmap_dio -b $SCRATCH_MNT/tf_{s,d} \
58                 $1 "buffered both dax"
59 }
60
61 t_nondax_to_dax()
62 {
63         prep_files
64         $here/src/t_mmap_dio $TEST_DIR/tf_s \
65                 $SCRATCH_MNT/tf_d $1 "dio nondax to dax"
66
67         prep_files
68         $here/src/t_mmap_dio -b $TEST_DIR/tf_s \
69                 $SCRATCH_MNT/tf_d $1 "buffered nondax to dax"
70 }
71
72 t_dax_to_nondax()
73 {
74         prep_files
75         $here/src/t_mmap_dio $SCRATCH_MNT/tf_s \
76                 $TEST_DIR/tf_d $1 "dio dax to nondax"
77
78         prep_files
79         $here/src/t_mmap_dio -b $SCRATCH_MNT/tf_s \
80                 $TEST_DIR/tf_d $1 "buffered dax to nondax"
81 }
82
83 t_both_nondax()
84 {
85         prep_files
86         $here/src/t_mmap_dio $TEST_DIR/tf_{s,d} $1 "dio both nondax"
87
88         prep_files
89         $here/src/t_mmap_dio -b $TEST_DIR/tf_{s,d} \
90                 $1 "buffered both nondax"
91 }
92
93 # $1 mmap read/write size
94 t_mmap_dio_dax()
95 {
96         t_both_dax $1
97         t_dax_to_nondax $1
98         t_nondax_to_dax $1
99         t_both_nondax $1
100 }
101
102 do_tests()
103 {
104         # less than page size
105         t_mmap_dio_dax 1024
106         # page size
107         t_mmap_dio_dax `$here/src/feature -s`
108         # bigger sizes, for PMD faults
109         t_mmap_dio_dax $((16 * 1024 * 1024))
110         t_mmap_dio_dax $((64 * 1024 * 1024))
111 }
112
113 # make fs aligned for PMD fault testing
114 _scratch_mkfs_geom $(_get_hugepagesize) 1 >> $seqres.full 2>&1
115
116 # mount SCRATCH_DEV with dax option, TEST_DEV not
117 export MOUNT_OPTIONS=""
118 export TEST_FS_MOUNT_OPTS=""
119 _test_cycle_mount
120 _fs_options $TEST_DEV | grep -qw "dax" && \
121         _notrun "we need $TEST_DEV mount without dax"
122 _scratch_mount "-o dax"
123
124 tsize=$((128 * 1024 * 1024))
125
126 do_tests
127
128 # success, all done
129 echo "Silence is golden"
130 status=0
131 exit