xfs/{263,106}: erase max warnings printout
[xfstests-dev.git] / tests / btrfs / 146
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017, Jeff Layton <jlayton@redhat.com>
4 #
5 # FS QA Test No. 146
6 #
7 # Open a file several times, write to it, fsync on all fds and make sure that
8 # they all return 0. Change the device to start throwing errors. Write again
9 # on all fds and fsync on all fds. Ensure that we get errors on all of them.
10 # Then fsync on all one last time and verify that all return 0.
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1    # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
20
21 _cleanup()
22 {
23     cd /
24     rm -rf $tmp.* $testdir
25     _dmerror_cleanup
26 }
27
28 # get standard environment, filters and checks
29 . ./common/rc
30 . ./common/filter
31 . ./common/dmerror
32
33 # real QA test starts here
34 _supported_os Linux
35 _supported_fs btrfs
36 _require_dm_target error
37 _require_test_program fsync-err
38 _require_test_program dmerror
39
40 # bring up dmerror device
41 _dmerror_init
42
43 # Replace first device with error-test device
44 old_SCRATCH_DEV=$SCRATCH_DEV
45 SCRATCH_DEV_POOL=`echo $SCRATCH_DEV_POOL | perl -pe "s#$SCRATCH_DEV#$DMERROR_DEV#"`
46 SCRATCH_DEV=$DMERROR_DEV
47
48 _require_scratch
49 _require_scratch_dev_pool
50
51 rm -f $seqres.full
52
53 echo "Format and mount"
54
55 # Build a filesystem with 2 devices that stripes the data across
56 # both devices, but mirrors metadata across both. Then, make one
57 # of the devices fail and test what it does.
58 _scratch_pool_mkfs "-d raid0 -m raid1" > $seqres.full 2>&1
59 _scratch_mount
60
61 # How much do we need to write? We need to hit all of the stripes. btrfs uses a
62 # fixed 64k stripesize, so write enough to hit each one. In the case of
63 # compression, each 128K input data chunk will be compressed to 4K (because of
64 # the characters written are duplicate). Therefore we have to write
65 # (128K * 16) = 2048K to make sure every stripe can be hit.
66 number_of_devices=`echo $SCRATCH_DEV_POOL | wc -w`
67 write_kb=$(($number_of_devices * 2048))
68 _require_fs_space $SCRATCH_MNT $write_kb
69
70 testfile=$SCRATCH_MNT/fsync-err-test
71
72 SCRATCH_DEV=$old_SCRATCH_DEV
73 $here/src/fsync-err -b $(($write_kb * 1024)) -d $here/src/dmerror $testfile
74
75 # success, all done
76 _dmerror_load_working_table
77
78 # fs may be corrupt after this -- attempt to repair it
79 _repair_scratch_fs >> $seqres.full
80
81 # remove dmerror device
82 _dmerror_cleanup
83
84 status=0
85 exit