2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2020 Oracle. All Rights Reserved.
7 # Test for seed device-delete on a sprouted FS.
8 # Requires kernel patch
9 # b5ddcffa3777 btrfs: fix put of uninitialized kobject after seed device delete
12 # Create a seed FS. Add a RW device to make it sprout FS and then delete
16 seqres=$RESULT_DIR/$seq
17 echo "QA output created by $seq"
21 status=1 # failure is the default!
22 trap "_cleanup; exit \$status" 0 1 2 3 15
30 # get standard environment, filters and checks
34 # remove previous $seqres.full before test
37 # real QA test starts here
39 # Modify as appropriate.
42 _require_scratch_dev_pool 2
44 _scratch_dev_pool_get 2
46 seed=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $1}')
47 sprout=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}')
50 _mount $seed $SCRATCH_MNT
52 $XFS_IO_PROG -f -c "pwrite -S 0xab 0 1M" $SCRATCH_MNT/foo > /dev/null
54 $BTRFS_TUNE_PROG -S 1 $seed
56 # Mount the seed device and add the rw device
57 _mount -o ro $seed $SCRATCH_MNT
58 $BTRFS_UTIL_PROG device add -f $sprout $SCRATCH_MNT
62 _mount $sprout $SCRATCH_MNT
63 $XFS_IO_PROG -f -c "pwrite -S 0xcd 0 1M" $SCRATCH_MNT/bar > /dev/null
65 echo --- before delete ----
66 od -x $SCRATCH_MNT/foo
67 od -x $SCRATCH_MNT/bar
69 $BTRFS_UTIL_PROG device delete $seed $SCRATCH_MNT
71 _btrfs_forget_or_module_reload
72 _mount $sprout $SCRATCH_MNT
74 echo --- after delete ----
75 od -x $SCRATCH_MNT/foo
76 od -x $SCRATCH_MNT/bar