summaryrefslogtreecommitdiff
path: root/tests/btrfs/217
blob: 92bbba2336ad6a202419b55f9b13164b73ea1357 (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
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2020 SUSE Linux Products GmbH. All Rights Reserved.
#
# FS QA Test 217
#
# Test if the following workload would cause problem:
# - fstrim
# - shrink device
# - fstrim
#
. ./common/preamble
_begin_fstest auto quick trim dangerous

# Import common functions.
. ./common/filter

# real QA test starts here

# Modify as appropriate.
_supported_fs btrfs
_require_scratch_size $((5 * 1024 * 1024)) #kB
_require_fstrim

# Create a 5G fs
_scratch_mkfs_sized $((5 * 1024 * 1024 * 1024)) >> $seqres.full
_scratch_mount

# Fstrim to populate the device->alloc_status CHUNK_TRIMMED bits
$FSTRIM_PROG -v $SCRATCH_MNT >> $seqres.full 2>&1 || \
	_notrun "FSTRIM not supported"

# Shrink the fs to 4G, so the existing CHUNK_TRIMMED bits are beyond
# device boundary
$BTRFS_UTIL_PROG filesystem resize 1:-1G "$SCRATCH_MNT" >> $seqres.full

# Do fstrim again to trigger the bug
$FSTRIM_PROG -v $SCRATCH_MNT >> $seqres.full

echo "Silence is golden"

# success, all done
status=0
exit