2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2021 Anand Jain. All Rights Reserved.
4 # Copyright (c) 2021 Oracle. All Rights Reserved.
8 # Validate if the command 'btrfs filesystem usage' works with missing seed
11 # Create a degraded raid1 seed device
12 # Create a sprout filesystem (an rw device on top of a seed device)
13 # Dump 'btrfs filesystem usage', check it didn't fail
15 # Tests btrfs-progs bug fixed by the kernel patch and a btrfs-prog patch
16 # btrfs: sysfs add devinfo/fsid to retrieve fsid from the device
17 # btrfs-progs: read fsid from the sysfs in device_is_seed
20 _begin_fstest auto quick seed volume
22 # Import common functions.
25 # real QA test starts here
27 # Modify as appropriate.
29 _require_scratch_dev_pool 3
30 _require_command "$WIPEFS_PROG" wipefs
31 _require_btrfs_forget_or_module_loadable
33 _scratch_dev_pool_get 2
34 # use the scratch devices as seed devices
35 seed_dev1=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{ print $1 }')
36 seed_dev2=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{ print $2 }')
38 # use the spare device as a sprout device
42 # create raid1 seed filesystem
43 _scratch_pool_mkfs "-draid1 -mraid1" >> $seqres.full 2>&1
44 $BTRFS_TUNE_PROG -S 1 $seed_dev1
45 $WIPEFS_PROG -a $seed_dev1 >> $seqres.full 2>&1
46 _btrfs_forget_or_module_reload
47 _mount -o degraded $seed_dev2 $SCRATCH_MNT >> $seqres.full 2>&1
49 # create a sprout device
50 $BTRFS_UTIL_PROG device add -f $SPARE_DEV $SCRATCH_MNT >> $seqres.full 2>&1
52 # dump filesystem usage if it fails error goes to the bad.out file
53 $BTRFS_UTIL_PROG filesystem usage $SCRATCH_MNT >> $seqres.full
54 # also check for the error code
56 if [ $ret != 0 ]; then
57 _fail "FAILED: btrfs filesystem usage, ret $ret. Check btrfs.ko and btrfs-progs version."
64 echo "Silence is golden"