mirror of
https://github.com/kdave/btrfs-progs
synced 2025-01-03 12:12:05 +00:00
btrfs-progs: tests: check that convert does not create extents beyond device boundary
Add a test case to check if the converted fs has device extent beyond boundary. The disk layout of source ext4 fs needs some extents to make them allocated at the very end of the fs. The script is from the original reporter. Also, since the existing convert tests always uses 512M as device size, which is not suitable for this test case, make it to grab the existing device size to co-operate with this test case. Reported-by: Jiachen YANG <farseerfc@gmail.com> Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
0ff7a9b521
commit
761add2622
@ -61,14 +61,20 @@ convert_test_prep_fs() {
|
||||
local fstype
|
||||
local force
|
||||
local mountopts
|
||||
local oldsize
|
||||
|
||||
fstype="$1"
|
||||
shift
|
||||
# Use device size that was set before, or the default 512M
|
||||
oldsize=$(stat --format=%s "$TEST_DEV")
|
||||
if [ -z "$oldsize" ]; then
|
||||
oldssize=512M
|
||||
fi
|
||||
# TEST_DEV not removed as the file might have special permissions, eg.
|
||||
# when test image is on NFS and would not be writable for root
|
||||
run_check truncate -s 0 "$TEST_DEV"
|
||||
# 256MB is the smallest acceptable btrfs image.
|
||||
run_check truncate -s 512M "$TEST_DEV"
|
||||
run_check truncate -s "$oldsize" "$TEST_DEV"
|
||||
force=
|
||||
mountopts=
|
||||
case "$fstype" in
|
||||
|
31
tests/convert-tests/017-fs-near-full/test.sh
Executable file
31
tests/convert-tests/017-fs-near-full/test.sh
Executable file
@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
# Check if btrfs-convert creates filesystem with device extents beyond the
|
||||
# device boundary
|
||||
|
||||
source "$TEST_TOP/common"
|
||||
source "$TEST_TOP/common.convert"
|
||||
|
||||
setup_root_helper
|
||||
prepare_test_dev 1G
|
||||
check_prereq btrfs-convert
|
||||
check_global_prereq mke2fs
|
||||
check_global_prereq fallocate
|
||||
|
||||
convert_test_prep_fs ext4 mke2fs -t ext4 -b 4096
|
||||
|
||||
# Use up 800MiB first
|
||||
for i in $(seq 1 4); do
|
||||
run_check $SUDO_HELPER fallocate -l 200M "$TEST_MNT/file$i"
|
||||
done
|
||||
|
||||
# Then add 5MiB for above files. These 5 MiB will be allocated near the very
|
||||
# end of the fs, to confuse btrfs-convert
|
||||
for i in $(seq 1 4); do
|
||||
run_check $SUDO_HELPER fallocate -l 205M "$TEST_MNT/file$i"
|
||||
done
|
||||
|
||||
run_check_umount_test_dev
|
||||
|
||||
# convert_test_do_convert() will call btrfs check, which should expose any
|
||||
# invalid inline extent with too large size
|
||||
convert_test_do_convert
|
Loading…
Reference in New Issue
Block a user