#!/bin/bash . $(dirname $(readlink -e ${BASH_SOURCE[0]}))/bcachefs-test-libs.sh config-scratch-devs 4G config-scratch-devs 4G config-scratch-devs 16G config-scratch-devs 16G run_basic_tiering_test() { run_basic_fio_test "$@" \ --block_size=4k \ --btree_node_size=32k \ --bucket=256k \ --label=ssd.ssd1 /dev/sdb \ --label=ssd.ssd2 /dev/sdc \ --label=hdd.hdd1 /dev/sdd \ --label=hdd.hdd2 /dev/sde \ --foreground_target=ssd \ --promote_target=ssd \ --background_target=hdd } test_tiering_torture() { run_quiet "" bcachefs format \ --block_size=4k \ --bucket=8M \ --label=ssd.ssd1 /dev/sdb \ --label=ssd.ssd2 /dev/sdc \ --label=hdd.hdd1 /dev/sdd \ --label=hdd.hdd2 /dev/sde \ --foreground_target=ssd \ --promote_target=ssd \ --background_target=hdd mount -t bcachefs /dev/sdb:/dev/sdc:/dev/sdd:/dev/sde /mnt run_fio_randrw mv /mnt/fiotest /mnt/fiotest_old run_fio_randrw --loops=50 mount -o remount,ro /mnt umount /mnt } test_tiering() { run_basic_tiering_test } test_tiering_drop_alloc() { run_basic_tiering_test # mount dropping all alloc info echo "dropping alloc:" mount -t bcachefs -o reconstruct_alloc,fsck,fix_errors /dev/sdb:/dev/sdc:/dev/sdd:/dev/sde /mnt umount /mnt echo "final fsck:" bcachefs fsck -n /dev/sd[bcde] } test_tiering_buffered() { set_watchdog 6000 run_quiet "" bcachefs format \ --block_size=4k \ --label=ssd.ssd1 /dev/sdb \ --label=ssd.ssd2 /dev/sdc \ --label=hdd.hdd1 /dev/sdd \ --label=hdd.hdd2 /dev/sde \ --foreground_target=ssd \ --promote_target=ssd \ --background_target=hdd mount -t bcachefs /dev/sdb:/dev/sdc:/dev/sdd:/dev/sde /mnt local loops=$((($ktest_priority + 1) * 4)) fio --eta=always \ --exitall_on_error=1 \ --ioengine=sync \ --numjobs=1 \ --verify=crc32c \ --verify_fatal=1 \ --buffer_compress_percentage=30 \ --filename=/mnt/fiotest \ --filesize=3500M \ --loops=$loops \ --name=randrw \ --rw=randrw \ --bsrange=512-16k umount /mnt } test_writethrough() { run_basic_fio_test "$@" \ --durability=0 --label=ssd /dev/sd[bc] \ --durability=1 --label=hdd /dev/sd[de] \ --foreground_target=ssd \ --promote_target=ssd \ --background_target=hdd } test_promote() { run_basic_fio_test "$@" \ --durability=0 --label=ssd /dev/sdb \ --durability=1 --label=hdd /dev/sdd \ --foreground_target=hdd \ --promote_target=ssd \ --background_target=hdd } test_setattr() { setup_tracing 'bcachefs:*' run_quiet "" bcachefs format \ --durability=0 --label=ssd /dev/sdb \ --durability=1 --label=hdd /dev/sdd \ --background_target=hdd mount -t bcachefs /dev/sdb:/dev/sdd /mnt touch /mnt/foo touch /mnt/bar bcachefs setattr --foreground_target sdb /mnt/ bcachefs setattr --promote_target ssd /mnt/ umount /mnt } test_tiering_no_checksum() { run_basic_tiering_test --data_checksum=none } test_tiering_compression() { run_basic_tiering_test --compression=lz4 } test_tiering_crypto() { run_basic_tiering_test --encrypted --no_passphrase } test_tiering_crypto_lz4() { run_basic_tiering_test --encrypted --no_passphrase --compression=lz4 } test_tiering_crypto_zstd() { run_basic_tiering_test --encrypted --no_passphrase --compression=zstd } test_tiering_replication() { run_basic_tiering_test --replicas=2 } test_tiering_variable_buckets() { run_basic_fio_test \ --label=ssd --bucket=32k /dev/sdb \ --label=ssd --bucket=64k /dev/sdc \ --label=hdd --bucket=128k /dev/sde \ --label=hdd --bucket=256k /dev/sdd \ --foreground_target=ssd \ --promote_target=ssd \ --background_target=hdd } test_tiering_variable_buckets_replicas() { run_basic_fio_test \ --replicas=2 \ --label=ssd --bucket=32k /dev/sdb \ --label=ssd --bucket=64k /dev/sdc \ --label=hdd --bucket=128k /dev/sde \ --label=hdd --bucket=256k /dev/sdd \ --foreground_target=ssd \ --promote_target=ssd \ --background_target=hdd } test_device_add() { set_watchdog 60 run_quiet "" bcachefs format \ --label=ssd /dev/sdb \ --label=hdd /dev/sd[de] mount -t bcachefs /dev/sdb:/dev/sdd:/dev/sde /mnt run_fio_randrw|tail -n200 & bcachefs device add --label=hdd /mnt /dev/sdc wait umount /mnt } test_mount_umount_torture() { set_watchdog 60 run_quiet "" bcachefs format \ --replicas=2 \ --label=ssd /dev/sd[bc] \ --label=hdd /dev/sd[de] \ --foreground_target=ssd \ --promote_target=ssd \ --background_target=hdd for i in {0..10}; do mount -t bcachefs /dev/sdb:/dev/sdc:/dev/sdd:/dev/sde /mnt umount /mnt done } test_change_replicas() { set_watchdog 180 run_quiet "" bcachefs format \ --label=ssd /dev/sd[bc] \ --label=hdd /dev/sd[de] \ --foreground_target=ssd \ --promote_target=ssd \ --background_target=hdd mount -t bcachefs /dev/sdb:/dev/sdc:/dev/sdd:/dev/sde /mnt ( cd /sys/fs/bcachefs/* while true; do echo 1 > options/data_replicas sleep 0.1 echo 2 > options/data_replicas sleep 0.1 done ) & loops=$((($ktest_priority + 1) * 4)) fio --eta=always \ --numjobs=1 \ --buffer_compress_percentage=50 \ --filename=/mnt/fiotest \ --filesize=1500M \ --loops=$loops \ --name=randrw \ --rw=randrw \ --bsrange=4k-1M # while true; do # dd if=/dev/zero of=/mnt/foo bs=1M count=1024 oflag=direct # sync # #rm /mnt/foo # done kill %1 umount /mnt } main $@