summaryrefslogtreecommitdiff
path: root/tests/btrfs/238
blob: b85eb3400eddea8a266513a6e2d4efad4be1db56 (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
52
53
54
55
56
57
58
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2021 Oracle. All Rights Reserved.
#
# FS QA Test 238
#
# Check seed device integrity after fstrim on the sprout device.
#
. ./common/preamble
_begin_fstest auto quick seed trim

. ./common/filter

_supported_fs btrfs
_fixed_by_kernel_commit 5e753a817b2d \
	"btrfs: fix unmountable seed device after fstrim"
_require_command "$BTRFS_TUNE_PROG" btrfstune
_require_fstrim
_require_scratch_dev_pool 2
_scratch_dev_pool_get 2

seed=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $1}')
sprout=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}')

_mkfs_dev $seed
_mount $seed $SCRATCH_MNT

$XFS_IO_PROG -f -c "pwrite -S 0xab 0 1M" $SCRATCH_MNT/foo > /dev/null
_scratch_unmount
$BTRFS_TUNE_PROG -S 1 $seed

# Mount the seed device and add the rw device
_mount $seed $SCRATCH_MNT 2>&1 | _filter_ro_mount | _filter_scratch
md5sum $SCRATCH_MNT/foo | _filter_scratch

$BTRFS_UTIL_PROG device add -f $sprout $SCRATCH_MNT >> $seqres.full
_scratch_unmount

# Now remount writeable sprout device, create some data and run fstrim
_mount $sprout $SCRATCH_MNT
_require_batched_discard $SCRATCH_MNT

$FSTRIM_PROG $SCRATCH_MNT

_scratch_unmount

# Verify seed device is all ok
_mount $seed $SCRATCH_MNT 2>&1 | _filter_ro_mount | _filter_scratch
md5sum $SCRATCH_MNT/foo | _filter_scratch
_scratch_unmount

_check_btrfs_filesystem $seed

_scratch_dev_pool_put

# success, all done
status=0
exit