blob: f90a2a3448925deec2803544d2e3df09fdc682c6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0+
# Copyright (c) 2019, Oracle and/or its affiliates. All Rights Reserved.
#
# FS QA Test No. 537
#
# Ensure that we can't call fstrim on filesystems mounted norecovery, because
# FSTRIM implementations use free space metadata to drive the discard requests
# and we told the filesystem not to make sure the metadata are up to date.
#
# The following patches fixed the bug on ext4, xfs and btrfs
# ext4: prohibit fstrim in norecovery mode
# xfs: prohibit fstrim in norecovery mode
# Btrfs: do not allow trimming when a fs is mounted with the nologreplay option
. ./common/preamble
_begin_fstest auto quick trim
# Import common functions.
. ./common/filter
# real QA test starts here
_supported_fs generic
_require_scratch
_require_fstrim
_scratch_mkfs > $seqres.full 2>&1
_require_metadata_journaling $SCRATCH_DEV
echo "fstrim on regular mount"
_scratch_mount >> $seqres.full 2>&1
$FSTRIM_PROG -v $SCRATCH_MNT >> $seqres.full 2>&1 || \
_notrun "FSTRIM not supported"
_scratch_unmount
echo "fstrim on ro mount"
_scratch_mount -o ro >> $seqres.full 2>&1
$FSTRIM_PROG -v $SCRATCH_MNT >> $seqres.full 2>&1
_scratch_unmount
echo "fstrim on ro mount with no log replay"
norecovery="norecovery"
test $FSTYP = "btrfs" && norecovery=nologreplay
_scratch_mount -o ro,$norecovery >> $seqres.full 2>&1
$FSTRIM_PROG -v $SCRATCH_MNT >> $seqres.full 2>&1 && \
echo "fstrim with unrecovered metadata just ate your filesystem"
_scratch_unmount
# success, all done
status=0
exit
|