generic/395: remove workarounds for wrong error codes
[xfstests-dev.git] / tests / generic / 537
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0+
3 # Copyright (c) 2019, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 537
6 #
7 # Ensure that we can't call fstrim on filesystems mounted norecovery, because
8 # FSTRIM implementations use free space metadata to drive the discard requests
9 # and we told the filesystem not to make sure the metadata are up to date.
10 #
11 # The following patches fixed the bug on ext4, xfs and btrfs
12 # ext4: prohibit fstrim in norecovery mode
13 # xfs: prohibit fstrim in norecovery mode
14 # Btrfs: do not allow trimming when a fs is mounted with the nologreplay option
15
16 seq=`basename $0`
17 seqres=$RESULT_DIR/$seq
18 echo "QA output created by $seq"
19
20 here=`pwd`
21 tmp=/tmp/$$
22 status=1    # failure is the default!
23 trap "_cleanup; exit \$status" 0 1 2 3 15
24
25 _cleanup()
26 {
27         cd /
28         rm -rf $tmp.*
29 }
30
31 # get standard environment, filters and checks
32 . ./common/rc
33 . ./common/filter
34
35 # real QA test starts here
36 _supported_fs generic
37 _require_scratch
38 _require_fstrim
39
40 rm -f $seqres.full
41
42 _scratch_mkfs > $seqres.full 2>&1
43 _require_metadata_journaling $SCRATCH_DEV
44
45 echo "fstrim on regular mount"
46 _scratch_mount >> $seqres.full 2>&1
47 $FSTRIM_PROG -v $SCRATCH_MNT >> $seqres.full 2>&1 || \
48         _notrun "FSTRIM not supported"
49 _scratch_unmount
50
51 echo "fstrim on ro mount"
52 _scratch_mount -o ro >> $seqres.full 2>&1
53 $FSTRIM_PROG -v $SCRATCH_MNT >> $seqres.full 2>&1
54 _scratch_unmount
55
56 echo "fstrim on ro mount with no log replay"
57 norecovery="norecovery"
58 test $FSTYP = "btrfs" && norecovery=nologreplay
59 _scratch_mount -o ro,$norecovery >> $seqres.full 2>&1
60 $FSTRIM_PROG -v $SCRATCH_MNT >> $seqres.full 2>&1 && \
61         echo "fstrim with unrecovered metadata just ate your filesystem"
62 _scratch_unmount
63
64 # success, all done
65 status=0
66 exit