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.
10 # Create a seed FS. Add a RW device to make it sprout FS and then delete
14 _begin_fstest auto quick volume seed
16 # Override the default cleanup function.
24 # Import common functions.
27 # real QA test starts here
29 # Modify as appropriate.
31 _fixed_by_kernel_commit b5ddcffa3777 \
32 "btrfs: fix put of uninitialized kobject after seed device delete"
34 _require_scratch_dev_pool 2
35 _require_btrfs_forget_or_module_loadable
37 _scratch_dev_pool_get 2
39 seed=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $1}')
40 sprout=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}')
43 _mount $seed $SCRATCH_MNT
45 $XFS_IO_PROG -f -c "pwrite -S 0xab 0 1M" $SCRATCH_MNT/foo > /dev/null
47 $BTRFS_TUNE_PROG -S 1 $seed
49 # Mount the seed device and add the rw device
50 _mount -o ro $seed $SCRATCH_MNT
51 $BTRFS_UTIL_PROG device add -f $sprout $SCRATCH_MNT >> $seqres.full
55 _mount $sprout $SCRATCH_MNT
56 $XFS_IO_PROG -f -c "pwrite -S 0xcd 0 1M" $SCRATCH_MNT/bar > /dev/null
58 echo --- before delete ----
59 od -x $SCRATCH_MNT/foo
60 od -x $SCRATCH_MNT/bar
62 $BTRFS_UTIL_PROG device delete $seed $SCRATCH_MNT
64 _btrfs_forget_or_module_reload
65 _mount $sprout $SCRATCH_MNT
67 echo --- after delete ----
68 od -x $SCRATCH_MNT/foo
69 od -x $SCRATCH_MNT/bar