2018-01-10 04:56:48 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# Test if "-m single" or "--mixed" can cause dev extent to use the reserved 1M
|
|
|
|
# range
|
|
|
|
#
|
|
|
|
# Other profiles will cause mkfs.btrfs to allocate new meta/sys chunks
|
|
|
|
# using btrfs_alloc_chunk() which won't use the 0~1M range, so other profiles
|
2018-01-23 15:57:57 +00:00
|
|
|
# are safe, but we test them nevertheless.
|
2018-01-10 04:56:48 +00:00
|
|
|
|
2023-04-19 15:08:41 +00:00
|
|
|
source "$TEST_TOP/common" || exit
|
2018-01-10 04:56:48 +00:00
|
|
|
|
|
|
|
check_prereq mkfs.btrfs
|
|
|
|
check_prereq btrfs
|
|
|
|
|
|
|
|
prepare_test_dev
|
|
|
|
|
|
|
|
do_one_test ()
|
|
|
|
{
|
2019-06-05 17:09:38 +00:00
|
|
|
run_check_mkfs_test_dev "$@"
|
2018-01-10 04:56:48 +00:00
|
|
|
|
|
|
|
# Use dev-extent tree to find first device extent
|
|
|
|
first_dev_extent=$(run_check_stdout "$TOP/btrfs" inspect-internal \
|
|
|
|
dump-tree -t device "$TEST_DEV" | \
|
|
|
|
grep -oP '(?<=DEV_EXTENT )[[:digit:]]*' | head -n1)
|
|
|
|
|
2018-03-23 15:34:30 +00:00
|
|
|
if [ -z "$first_dev_extent" ]; then
|
2018-01-10 04:56:48 +00:00
|
|
|
_fail "failed to get first device extent"
|
|
|
|
fi
|
|
|
|
|
2019-07-24 13:53:18 +00:00
|
|
|
_log "first dev extent starts at $first_dev_extent"
|
|
|
|
_log "reserved range is [0, $(( 1024 * 1024)))"
|
2018-01-10 04:56:48 +00:00
|
|
|
# First device extent should not start below 1M
|
2018-03-23 15:34:30 +00:00
|
|
|
if [ "$first_dev_extent" -lt $(( 1024 * 1024 )) ]; then
|
2018-01-10 04:56:48 +00:00
|
|
|
_fail "first device extent occupies reserved 0~1M range"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
do_one_test --mixed
|
|
|
|
do_one_test -m single
|
2018-01-23 15:57:57 +00:00
|
|
|
|
|
|
|
do_one_test
|
|
|
|
do_one_test -m dup
|
|
|
|
do_one_test -d dup
|
|
|
|
do_one_test -m dup -d dup
|
|
|
|
do_one_test --mixed -m dup -d dup
|