btrfs/139: require 2GB scratch dev
[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 _require_btrfs_fs_feature raid56
34
35 _scratch_dev_pool_get 4
36
37 rm -f $seqres.full
38
39 test_direct_io_write()
40 {
41         local mkfs_options=$1
42
43         _scratch_pool_mkfs $mkfs_options >>$seqres.full 2>&1
44         _scratch_mount
45
46         $XFS_IO_PROG -f -d -c "pwrite -S 0xab 0 1M" $SCRATCH_MNT/foo \
47                 | _filter_xfs_io
48
49         # Now read back the same data, we expect to get what we wrote before.
50         echo "File data after direct IO write:"
51         od -t x1 $SCRATCH_MNT/foo | _filter_scratch
52         _scratch_cycle_mount
53         echo "File data after umounting and mounting again the filesystem:"
54         od -t x1 $SCRATCH_MNT/foo | _filter_scratch
55
56         $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
57         if [ $? -ne 0 ]; then
58                 echo "Scrub found errors" | tee -a $seqres.full
59         fi
60
61         _scratch_unmount
62 }
63
64 echo "Testing RAID5..."
65 test_direct_io_write "-m raid5 -d raid5"
66 echo "Testing RAID6..."
67 test_direct_io_write "-m raid6 -d raid6"
68
69 _scratch_dev_pool_put
70
71 status=0
72 exit