summaryrefslogtreecommitdiff
path: root/tests/btrfs/184
blob: ad95745780d26088366c080c1c42322f16d722a3 (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
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2019 SUSE LLC. All Rights Reserved.
#
# FS QA Test 184
#
# Verify that when a device is removed from a multi-device
# filesystem its superblock copies are correctly deleted
#
. ./common/preamble
_begin_fstest auto quick volume

. ./common/filter

_supported_fs btrfs
_require_scratch
_require_scratch_dev_pool 2
_require_btrfs_command inspect-internal dump-super

_scratch_dev_pool_get 2

# Explicitly use raid0 mode to ensure at least one of the devices can be
# removed.
_scratch_pool_mkfs "-d raid0 -m raid0" >> $seqres.full 2>&1 || _fail "mkfs failed"
_scratch_mount

# pick last dev in the list
dev_del=`echo ${SCRATCH_DEV_POOL} | $AWK_PROG '{print $NF}'`
$BTRFS_UTIL_PROG device delete $dev_del $SCRATCH_MNT || _fail "btrfs device delete failed"
for i in {0..2}; do
	output=$($BTRFS_UTIL_PROG inspect-internal dump-super -s $i $dev_del 2>&1)
	$BTRFS_UTIL_PROG inspect-internal dump-super -s $i $dev_del 2>&1 | grep -q "bad magic"
	ret=$?
	if [[ "$output" != "" && $ret -eq 1 ]]; then
		_fail "Deleted dev superblocks not scratched"
	fi
done
_scratch_unmount

_scratch_dev_pool_put

# success, all done
echo "Silence is golden"
status=0
exit