2023-12-08 15:45:28 +00:00
|
|
|
#!/bin/bash
|
2023-12-08 22:17:17 +00:00
|
|
|
# Read and set scrub limits on a filesystem
|
2023-12-08 15:45:28 +00:00
|
|
|
|
|
|
|
source "$TEST_TOP/common" || exit
|
|
|
|
|
|
|
|
setup_root_helper
|
|
|
|
setup_loopdevs 4
|
|
|
|
prepare_loopdevs
|
|
|
|
TEST_DEV=${loopdevs[1]}
|
2023-12-08 22:17:17 +00:00
|
|
|
support=true
|
2023-12-08 15:45:28 +00:00
|
|
|
|
|
|
|
fsid="13411a59-ccea-4296-a6f8-1446ccf8c9be"
|
|
|
|
sysfs="/sys/fs/btrfs/13411a59-ccea-4296-a6f8-1446ccf8c9be"
|
|
|
|
|
|
|
|
run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f --uuid "$fsid" -d raid1 -m raid1 "${loopdevs[@]}"
|
|
|
|
run_check_mount_test_dev
|
2023-12-08 22:17:17 +00:00
|
|
|
|
|
|
|
# Set the limits directly
|
2023-12-08 15:45:28 +00:00
|
|
|
for i in "$sysfs"/devinfo/*/scrub_speed_max; do
|
|
|
|
if ! [ -f "$i" ]; then
|
|
|
|
_log "sysfs file scrub_speed_max not available, skip setting limits"
|
2023-12-08 22:17:17 +00:00
|
|
|
support=false
|
2023-12-08 15:45:28 +00:00
|
|
|
break;
|
|
|
|
fi
|
|
|
|
run_check cat "$i"
|
|
|
|
echo "10m" | run_check $SUDO_HELPER tee "$i" >/dev/null
|
|
|
|
done
|
|
|
|
# This works even if scrub_speed_max files don't exist, this is equivalent to unlimited
|
|
|
|
run_check "$TOP/btrfs" scrub limit "$TEST_MNT"
|
2023-12-08 22:17:17 +00:00
|
|
|
|
|
|
|
# The rest of the test would fail
|
|
|
|
if ! $support; then
|
|
|
|
run_check_umount_test_dev
|
|
|
|
cleanup_loopdevs
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Set the limits by command
|
|
|
|
here=`pwd`
|
|
|
|
cd "$sysfs/devinfo"
|
|
|
|
for i in *; do
|
|
|
|
run_check $SUDO_HELPER "$TOP/btrfs" scrub limit -d "$i" -l 20m "$TEST_MNT"
|
|
|
|
done
|
|
|
|
cd "$here"
|
|
|
|
run_check "$TOP/btrfs" scrub limit "$TEST_MNT"
|
|
|
|
|
2023-12-08 15:45:28 +00:00
|
|
|
run_check_umount_test_dev
|
|
|
|
|
|
|
|
cleanup_loopdevs
|