btrfs-progs: mkfs-tests: Add test case to verify the --rootdir size limit

Add a test case to ensure we can create a 350M fs with 128M rootdir.

Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Qu Wenruo 2020-06-16 14:32:30 +08:00 committed by David Sterba
parent 0ae7840775
commit 5de63ab1c9
1 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,22 @@
#!/bin/bash
# Regression test for mkfs.btrfs --rootdir with DUP data profile and rootdir
# size near the limit of the device.
#
# There is a bug that makes mkfs.btrfs always to create unnecessary SINGLE
# chunks, which eats up a lot of space and leads to unexpected ENOSPC bugs.
source "$TEST_TOP/common"
check_prereq mkfs.btrfs
prepare_test_dev
tmp=$(mktemp -d --tmpdir btrfs-progs-mkfs.rootdirXXXXXXX)
fallocate -l 128M $tmp/large_file
# We should be able to create the fs with size limit to 2 * (128 + 32 + 8)
# which is 336M. Here we round it up to 350M.
run_check "$TOP/mkfs.btrfs" -f --rootdir "$tmp" -d dup -b 350M "$TEST_DEV"
run_check "$TOP/btrfs" check "$TEST_DEV"
rm -rf -- "$tmp"