blob: e69ed7062b74e314a1f4b4866641e96606f07a69 (
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
|
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2020 SUSE Linux Products GmbH. All Rights Reserved.
#
# FS QA Test No. btrfs/223
#
# Test that after replacing a device, if we run fstrim against the filesystem
# we do not trim/discard allocated chunks in the new device. We verify that
# allocated chunks in the new device were not trim/discarded by mounting the
# new device only in degraded mode, as this is the easiest way to verify it.
#
. ./common/preamble
_begin_fstest auto quick replace trim
. ./common/filter
_supported_fs btrfs
_require_scratch_dev_pool 3
_require_command "$WIPEFS_PROG" wipefs
_scratch_dev_pool_get 2
_spare_dev_get
dev1=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{ print $1 }')
dev2=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{ print $2 }')
_scratch_pool_mkfs "-m raid1 -d raid1"
_scratch_mount
_require_batched_discard $SCRATCH_MNT
# Add a test file with some data.
$XFS_IO_PROG -f -c "pwrite -S 0xab 0 10M" $SCRATCH_MNT/foo | _filter_xfs_io
# Replace the first device, $dev1, with a new device.
$BTRFS_UTIL_PROG replace start -Bf $dev1 $SPARE_DEV $SCRATCH_MNT >> $seqres.full
# Run fstrim, it should not trim/discard allocated extents in the new device.
$FSTRIM_PROG $SCRATCH_MNT
# Unmount the filesystem.
_scratch_unmount
# Mount the filesystem in degraded mode using the new device and verify that the
# mount succeeds and our file exists, with a size of 10Mb and all its bytes have
# a value of 0xab.
$WIPEFS_PROG -a $dev1 $dev2 >> $seqres.full 2>&1
_mount -o degraded $SPARE_DEV $SCRATCH_MNT
echo "File foo data:"
od -A d -t x1 $SCRATCH_MNT/foo
_spare_dev_put
_scratch_dev_pool_put
status=0
exit
|