summaryrefslogtreecommitdiff
path: root/tests/btrfs/218
blob: 83ec785ee2a06938fa2c94a3bd0e4d308743b67a (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
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2020 Facebook.  All Rights Reserved.
#
# FS QA Test 218
#
# Regression test for the problem fixed by the patch
#
#  btrfs: init device stats for seed devices
#
# Make a seed device, add a sprout to it, and then make sure we can still read
# the device stats for both devices after we remount with the new sprout device.
#
. ./common/preamble
_begin_fstest auto quick volume

# Import common functions.
. ./common/filter
. ./common/filter.btrfs

# real QA test starts here

# Modify as appropriate.
_supported_fs btrfs
_require_test
_require_scratch_dev_pool 2

_scratch_dev_pool_get 2

dev_seed=$(echo $SCRATCH_DEV_POOL | awk '{print $1}')
dev_sprout=$(echo $SCRATCH_DEV_POOL | awk '{print $2}')

# Create the seed device
_mkfs_dev $dev_seed
_mount $dev_seed $SCRATCH_MNT
$XFS_IO_PROG -f -d -c "pwrite -S 0xab 0 1M" $SCRATCH_MNT/foo > /dev/null
$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | \
	_filter_btrfs_filesystem_show
_scratch_unmount
$BTRFS_TUNE_PROG -S 1 $dev_seed

# Mount the seed device and add the rw device
_mount -o ro $dev_seed $SCRATCH_MNT
_run_btrfs_util_prog device add -f $dev_sprout $SCRATCH_MNT >> $seqres.full
$BTRFS_UTIL_PROG device stats $SCRATCH_MNT | _filter_scratch_pool
_scratch_unmount

# Now remount, validate the device stats do not fail
_mount $dev_sprout $SCRATCH_MNT
$BTRFS_UTIL_PROG device stats $SCRATCH_MNT | _filter_scratch_pool

_scratch_dev_pool_put

# success, all done
status=0
exit