2017-11-29 08:58:43 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# Test if mkfs.btrfs --rootdir will skip shrinking correctly
|
|
|
|
|
2023-04-19 15:08:41 +00:00
|
|
|
source "$TEST_TOP/common" || exit
|
2017-11-29 08:58:43 +00:00
|
|
|
|
|
|
|
check_prereq mkfs.btrfs
|
|
|
|
|
|
|
|
setup_root_helper
|
|
|
|
|
|
|
|
fs_size=$((512 * 1024 * 1024))
|
|
|
|
bs=$((1024 * 1024))
|
2021-10-11 13:56:58 +00:00
|
|
|
tmp=$(_mktemp_dir mkfs-rootdir)
|
2017-11-29 08:58:43 +00:00
|
|
|
|
2018-03-23 15:34:30 +00:00
|
|
|
prepare_test_dev "$fs_size"
|
2017-11-29 08:58:43 +00:00
|
|
|
|
|
|
|
# No shrink case
|
|
|
|
|
2019-06-05 17:09:38 +00:00
|
|
|
run_check_mkfs_test_dev --rootdir "$tmp"
|
2017-11-29 08:58:43 +00:00
|
|
|
run_check_mount_test_dev
|
|
|
|
|
|
|
|
# We should be able to write at least half of the fs size data since the fs is
|
|
|
|
# not shrunk
|
2018-03-23 15:34:30 +00:00
|
|
|
run_check $SUDO_HELPER dd if=/dev/zero bs="$bs" count=$(($fs_size / $bs / 2)) \
|
2017-11-29 08:58:43 +00:00
|
|
|
of="$TEST_MNT/file"
|
|
|
|
|
|
|
|
run_check_umount_test_dev
|
|
|
|
|
|
|
|
# Shrink case
|
|
|
|
|
2019-06-05 17:09:38 +00:00
|
|
|
run_check_mkfs_test_dev --rootdir "$tmp" --shrink
|
2017-11-29 08:58:43 +00:00
|
|
|
run_check_mount_test_dev
|
|
|
|
|
|
|
|
run_mustfail "mkfs.btrfs for shrink rootdir" \
|
2018-03-23 15:34:30 +00:00
|
|
|
$SUDO_HELPER dd if=/dev/zero bs="$bs" count=$(($fs_size / $bs / 2)) \
|
2017-11-29 08:58:43 +00:00
|
|
|
of="$TEST_MNT/file"
|
|
|
|
|
|
|
|
run_check_umount_test_dev
|
|
|
|
|
|
|
|
rm -rf -- "$tmp"
|