btrfs: convert tests to SPDX license tags
[xfstests-dev.git] / tests / btrfs / 148
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2017 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test No. btrfs/148
6 #
7 # Test that direct IO writes work on RAID5 and RAID6 filesystems.
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 tmp=/tmp/$$
14 status=1        # failure is the default!
15 trap "_cleanup; exit \$status" 0 1 2 3 15
16
17 _cleanup()
18 {
19         cd /
20         rm -f $tmp.*
21 }
22
23 # get standard environment, filters and checks
24 . ./common/rc
25 . ./common/filter
26
27 # real QA test starts here
28 _supported_fs btrfs
29 _supported_os Linux
30 _require_scratch
31 _require_scratch_dev_pool 4
32 _require_odirect
33
34 _scratch_dev_pool_get 4
35
36 rm -f $seqres.full
37
38 test_direct_io_write()
39 {
40         local mkfs_options=$1
41
42         _scratch_pool_mkfs $mkfs_options >>$seqres.full 2>&1
43         _scratch_mount
44
45         $XFS_IO_PROG -f -d -c "pwrite -S 0xab 0 1M" $SCRATCH_MNT/foo \
46                 | _filter_xfs_io
47
48         # Now read back the same data, we expect to get what we wrote before.
49         echo "File data after direct IO write:"
50         od -t x1 $SCRATCH_MNT/foo | _filter_scratch
51         _scratch_cycle_mount
52         echo "File data after umounting and mounting again the filesystem:"
53         od -t x1 $SCRATCH_MNT/foo | _filter_scratch
54
55         $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
56         if [ $? -ne 0 ]; then
57                 echo "Scrub found errors" | tee -a $seqres.full
58         fi
59
60         _scratch_unmount
61 }
62
63 echo "Testing RAID5..."
64 test_direct_io_write "-m raid5 -d raid5"
65 echo "Testing RAID6..."
66 test_direct_io_write "-m raid6 -d raid6"
67
68 status=0
69 exit