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
31 # get standard environment, filters and checks
35 # remove previous $seqres.full before test
38 # real QA test starts here
40 # Modify as appropriate.
43 _require_scratch_dev_pool 2
44 _require_btrfs_forget_or_module_loadable
46 _scratch_dev_pool_get 2
48 seed=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $1}')
49 sprout=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}')
52 _mount $seed $SCRATCH_MNT
54 $XFS_IO_PROG -f -c "pwrite -S 0xab 0 1M" $SCRATCH_MNT/foo > /dev/null
56 $BTRFS_TUNE_PROG -S 1 $seed
58 # Mount the seed device and add the rw device
59 _mount -o ro $seed $SCRATCH_MNT
60 $BTRFS_UTIL_PROG device add -f $sprout $SCRATCH_MNT
64 _mount $sprout $SCRATCH_MNT
65 $XFS_IO_PROG -f -c "pwrite -S 0xcd 0 1M" $SCRATCH_MNT/bar > /dev/null
67 echo --- before delete ----
68 od -x $SCRATCH_MNT/foo
69 od -x $SCRATCH_MNT/bar
71 $BTRFS_UTIL_PROG device delete $seed $SCRATCH_MNT
73 _btrfs_forget_or_module_reload
74 _mount $sprout $SCRATCH_MNT
76 echo --- after delete ----
77 od -x $SCRATCH_MNT/foo
78 od -x $SCRATCH_MNT/bar