diff options
-rw-r--r-- | lib/libktest.sh | 2 | ||||
-rwxr-xr-x | tests/bcache/init_errors.ktest | 4 | ||||
-rwxr-xr-x | tests/bcachefs/ec.ktest | 69 | ||||
-rwxr-xr-x | tests/bcachefs/nas_apps.ktest | 8 | ||||
-rwxr-xr-x | tests/bcachefs/nfs.ktest | 4 | ||||
-rwxr-xr-x | tests/bcachefs/perf.ktest | 12 | ||||
-rwxr-xr-x | tests/bcachefs/quota.ktest | 42 | ||||
-rwxr-xr-x | tests/bcachefs/replication.ktest | 281 | ||||
-rwxr-xr-x | tests/bcachefs/single_device.ktest | 434 | ||||
-rwxr-xr-x | tests/bcachefs/subvol.ktest | 198 | ||||
-rwxr-xr-x | tests/bcachefs/tier.ktest | 120 | ||||
-rwxr-xr-x | tests/bcachefs/units.ktest | 4 | ||||
-rwxr-xr-x | tests/blkdev.ktest | 6 | ||||
-rwxr-xr-x | tests/blktests.ktest | 2 | ||||
-rwxr-xr-x | tests/block/discard | 2 | ||||
-rwxr-xr-x | tests/fio.ktest | 2 | ||||
-rwxr-xr-x | tests/md.ktest | 4 | ||||
-rw-r--r-- | tests/prelude.sh | 25 | ||||
-rw-r--r-- | tests/xfstests.sh | 19 |
19 files changed, 644 insertions, 594 deletions
diff --git a/lib/libktest.sh b/lib/libktest.sh index 507fb52..7d139a1 100644 --- a/lib/libktest.sh +++ b/lib/libktest.sh @@ -402,7 +402,7 @@ start_vm() qemu_disk file="$file",snapshot=on,cache.no-flush=on,cache.direct=$ktest_dio done - for size in "${ktest_scratch_devs[@]}"; do + for size in "${ktest_scratch_dev_sizes[@]}"; do local file="$ktest_out/vm/dev-$disknr" truncate -s "$size" "$file" diff --git a/tests/bcache/init_errors.ktest b/tests/bcache/init_errors.ktest index 5a8ffc6..dcb3c57 100755 --- a/tests/bcache/init_errors.ktest +++ b/tests/bcache/init_errors.ktest @@ -23,10 +23,10 @@ run_test_faults() echo "TESTING FAULT $id" echo "Registering sdb" - echo /dev/sdb > /sys/fs/bcache/register || true + echo ${ktest_scratch_dev[0]} > /sys/fs/bcache/register || true echo "Registering sdc" - echo /dev/sdc > /sys/fs/bcache/register || true + echo ${ktest_scratch_dev[1]} > /sys/fs/bcache/register || true sleep 2 echo "class $fault disable" > $control diff --git a/tests/bcachefs/ec.ktest b/tests/bcachefs/ec.ktest index 442fd2d..9914284 100755 --- a/tests/bcachefs/ec.ktest +++ b/tests/bcachefs/ec.ktest @@ -22,8 +22,8 @@ test_ec_small() --errors=panic \ --erasure_code \ --replicas=2 \ - /dev/sd[bcdef] - devs=/dev/sdb:/dev/sdc:/dev/sdd:/dev/sde:/dev/sdf + "${ktest_scratch_dev[@]}" + devs="$(join_by : "${ktest_scratch_dev[@]}")" mount -t bcachefs $devs /mnt @@ -36,16 +36,16 @@ test_ec_small() df -h /mnt umount /mnt - bcachefs fsck -n /dev/sd[bcdef] + bcachefs fsck -n "${ktest_scratch_dev[@]}" # test remount: echo "Testing remount" mount -t bcachefs -o fsck $devs /mnt umount /mnt - bcachefs fsck /dev/sd[bcdef] + bcachefs fsck -n "${ktest_scratch_dev[@]}" - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_ec_umount() @@ -56,8 +56,8 @@ test_ec_umount() --errors=panic \ --erasure_code \ --replicas=2 \ - /dev/sd[bcdef] - devs=/dev/sdb:/dev/sdc:/dev/sdd:/dev/sde:/dev/sdf + "${ktest_scratch_dev[@]}" + devs="$(join_by : "${ktest_scratch_dev[@]}")" for i in $(seq 1 10); do mount -t bcachefs $devs /mnt @@ -66,7 +66,7 @@ test_ec_umount() umount /mnt done - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } do_ec_test() @@ -80,8 +80,8 @@ do_ec_test() --erasure_code \ "$@" \ --replicas=2 \ - /dev/sd[bcdef] - devs=/dev/sdb:/dev/sdc:/dev/sdd:/dev/sde:/dev/sdf + "${ktest_scratch_dev[@]}" + devs="$(join_by : "${ktest_scratch_dev[@]}")" mount -t bcachefs $devs /mnt @@ -93,7 +93,7 @@ do_ec_test() bcachefs fs usage -h /mnt umount /mnt - bcachefs fsck -n /dev/sd[bcdef] + bcachefs fsck -n "${ktest_scratch_dev[@]}" # test remount: echo "Testing remount" @@ -101,7 +101,7 @@ do_ec_test() cat /mnt/fiotest > /dev/null umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_ec() @@ -133,13 +133,18 @@ test_ec_mixed_tiers() --erasure_code \ --compression=lz4 \ --replicas=2 \ - --label dup /dev/sd[bc] \ - --label tri /dev/sd[def] \ + --label dup \ + ${ktest_scratch_dev[0]} \ + ${ktest_scratch_dev[1]} \ + --label tri \ + ${ktest_scratch_dev[2]} \ + ${ktest_scratch_dev[3]} \ + ${ktest_scratch_dev[4]} \ --foreground_target=dup \ --promote_target=dup \ --background_target=tri - devs=/dev/sdb:/dev/sdc:/dev/sdd:/dev/sde:/dev/sdf + devs="$(join_by : "${ktest_scratch_dev[@]}")" mount -t bcachefs $devs /mnt #enable_memory_faults @@ -155,9 +160,9 @@ test_ec_mixed_tiers() mount -t bcachefs -o fsck $devs /mnt umount /mnt - bcachefs fsck /dev/sd[bcdef] + bcachefs fsck -n "${ktest_scratch_dev[@]}" - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_ec_gc() @@ -169,9 +174,9 @@ test_ec_gc() run_quiet "" bcachefs format -f \ --errors=continue \ --replicas=2 \ - /dev/sd[bcdef] - devs=/dev/sdb:/dev/sdc:/dev/sdd:/dev/sde:/dev/sdf + "${ktest_scratch_dev[@]}" + devs="$(join_by : "${ktest_scratch_dev[@]}")" mount -t bcachefs -o erasure_code $devs /mnt fill_device /mnt/fiotest @@ -205,9 +210,9 @@ test_ec_gc() mount -t bcachefs -o fix_errors,erasure_code $devs /mnt umount /mnt - bcachefs fsck /dev/sd[bcdef] + bcachefs fsck "${ktest_scratch_dev[@]}" - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } do_remove_test() @@ -221,9 +226,9 @@ do_remove_test() --errors=panic \ --erasure_code \ --replicas=2 \ - /dev/sd[bcdef] + "${ktest_scratch_dev[@]}" - mount -t bcachefs /dev/sdb:/dev/sdc:/dev/sdd:/dev/sde:/dev/sdf /mnt + mount -t bcachefs "$(join_by : "${ktest_scratch_dev[@]}")" /mnt local fioout="$ktest_out/fio-out" run_fio_randrw >"$fioout" 2>&1 & @@ -232,22 +237,22 @@ do_remove_test() sleep 1 if [[ $offline = 1 ]]; then - echo -n "offlining /dev/sdb... " - bcachefs device offline --force /dev/sdb + echo -n "offlining ${ktest_scratch_dev[0]}... " + bcachefs device offline --force ${ktest_scratch_dev[0]} echo "done" fi if [[ $evacuate = 1 ]]; then - echo -n "evacuating /dev/sdb... " - bcachefs device evacuate /dev/sdb + echo -n "evacuating ${ktest_scratch_dev[0]}... " + bcachefs device evacuate ${ktest_scratch_dev[0]} echo "done" fi - echo -n "removing /dev/sdb... " + echo -n "removing ${ktest_scratch_dev[0]}... " if [[ $evacuate = 1 ]]; then - bcachefs device remove /dev/sdb + bcachefs device remove ${ktest_scratch_dev[0]} else - bcachefs device remove --force /dev/sdb + bcachefs device remove --force ${ktest_scratch_dev[0]} fi echo "done" @@ -258,10 +263,10 @@ do_remove_test() umount /mnt - mount -t bcachefs /dev/sdb:/dev/sdc:/dev/sdd:/dev/sde:/dev/sdf /mnt + mount -t bcachefs "$(join_by : "${ktest_scratch_dev[@]}")" /mnt umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } d_test_device_remove_offline() diff --git a/tests/bcachefs/nas_apps.ktest b/tests/bcachefs/nas_apps.ktest index b567a77..97b0a3a 100755 --- a/tests/bcachefs/nas_apps.ktest +++ b/tests/bcachefs/nas_apps.ktest @@ -40,9 +40,9 @@ array_setup() --errors=panic \ --erasure_code \ --replicas=3 \ - /dev/sd[bcdefghijk] - devs=/dev/sdb:/dev/sdc:/dev/sdd:/dev/sde:/dev/sdf:/dev/sdg:/dev/sdh:/dev/sdi:/dev/sdj:/dev/sdk - mount -t bcachefs $devs /mnt + ${ktest_scratch_dev[@]} + + mount -t bcachefs "$(join_by : "${ktest_scratch_dev[@]}")" /mnt } array_teardown() @@ -67,7 +67,7 @@ test_iscsi() run_quiet "" iscsiadm -m discovery -t sendtargets -p 127.0.0.1 run_quiet "" iscsiadm -m node --login - run_fio_randrw --filename=/dev/sdl + run_fio_randrw --filename=${ktest_scratch_dev[10]} run_quiet "" iscsiadm -m node --logout run_quiet "" targetcli /iscsi delete iqn.2018-05.world.srv:dlp.target01 diff --git a/tests/bcachefs/nfs.ktest b/tests/bcachefs/nfs.ktest index 234d227..411debd 100755 --- a/tests/bcachefs/nfs.ktest +++ b/tests/bcachefs/nfs.ktest @@ -18,8 +18,8 @@ test_nfs() run_quiet "" bcachefs format -f \ --errors=panic \ - /dev/sdb - mount -t bcachefs /dev/sdb /export2 + ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /export2 echo "/export1 *(rw,insecure,no_root_squash,no_subtree_check)" >> /etc/exports echo "/export2 *(rw,insecure,no_root_squash,no_subtree_check)" >> /etc/exports diff --git a/tests/bcachefs/perf.ktest b/tests/bcachefs/perf.ktest index da775cf..4f0f0d1 100755 --- a/tests/bcachefs/perf.ktest +++ b/tests/bcachefs/perf.ktest @@ -28,15 +28,15 @@ perf_mkfs() --btree_node_size=$btree_node_size \ --no_initialize \ --version=11 \ - /dev/sdb - mount -t bcachefs -o version_upgrade /dev/sdb /mnt - bcachefs device resize-journal /dev/sdb 1G + ${ktest_scratch_dev[0]} + mount -t bcachefs -o version_upgrade ${ktest_scratch_dev[0]} /mnt + bcachefs device resize-journal ${ktest_scratch_dev[0]} 1G sleep 1 - bcachefs device resize-journal /dev/sdb 2G + bcachefs device resize-journal ${ktest_scratch_dev[0]} 2G sleep 1 - bcachefs device resize-journal /dev/sdb 3G + bcachefs device resize-journal ${ktest_scratch_dev[0]} 3G sleep 1 - bcachefs device resize-journal /dev/sdb 4G + bcachefs device resize-journal ${ktest_scratch_dev[0]} 4G ln -sf /sys/fs/bcachefs/*/perf_test p } diff --git a/tests/bcachefs/quota.ktest b/tests/bcachefs/quota.ktest index e6535c2..3704822 100755 --- a/tests/bcachefs/quota.ktest +++ b/tests/bcachefs/quota.ktest @@ -13,11 +13,11 @@ require-make linuxquota test_usrquota_twodevices() { - bcachefs format \ - --errors=panic \ - /dev/sd[bc] >/dev/null + run_quiet "" bcachefs format \ + --errors=panic \ + ${ktest_scratch_dev[@]} - mount -t bcachefs -o usrquota,grpquota,prjquota /dev/sdc:/dev/sdb /mnt + mount -t bcachefs -o usrquota,grpquota,prjquota ${ktest_scratch_dev[0]}:${ktest_scratch_dev[1]} /mnt repquota -s /mnt @@ -44,14 +44,14 @@ test_usrquota_twodevices() test_usrquota() { if false; then - mkfs.xfs /dev/sdb + mkfs.xfs ${ktest_scratch_dev[0]} else bcachefs format \ - --errors=panic \ - /dev/sdb >/dev/null + --errors=panic \ + ${ktest_scratch_dev[0]} >/dev/null fi - mount -t bcachefs -o usrquota,grpquota,prjquota /dev/sdb /mnt + mount -t bcachefs -o usrquota,grpquota,prjquota ${ktest_scratch_dev[0]} /mnt repquota -s /mnt @@ -78,14 +78,14 @@ test_usrquota() test_grpquota() { if false; then - mkfs.xfs /dev/sdb + mkfs.xfs ${ktest_scratch_dev[0]} else - bcachefs format \ - --errors=panic \ - /dev/sdb /dev/sdc >/dev/null + run_quiet "" bcachefs format \ + --errors=panic \ + ${ktest_scratch_dev[0]} ${ktest_scratch_dev[1]} >/dev/null fi - mount -t bcachefs -o usrquota,grpquota,prjquota /dev/sdb:/dev/sdc /mnt + mount -t bcachefs -o usrquota,grpquota,prjquota ${ktest_scratch_dev[0]}:${ktest_scratch_dev[1]} /mnt setquota -g root 256M 512M 64 128 /mnt #setquota -t 60 60 /mnt @@ -101,11 +101,11 @@ test_grpquota() test_prjquota() { - bcachefs format \ - --errors=panic \ - /dev/sdb >/dev/null + run_quiet "" bcachefs format \ + --errors=panic \ + ${ktest_scratch_dev[0]} >/dev/null - mount -t bcachefs -o usrquota,grpquota,prjquota /dev/sdb /mnt + mount -t bcachefs -o usrquota,grpquota,prjquota ${ktest_scratch_dev[0]} /mnt repquota -vP /mnt mkdir /mnt/q1 @@ -135,11 +135,11 @@ test_prjquota() test_prjquota_multidevices() { - bcachefs format \ - --errors=panic \ - /dev/sd[bc] >/dev/null + run_quiet "" bcachefs format \ + --errors=panic \ + ${ktest_scratch_dev[@]} - mount -t bcachefs -o usrquota,grpquota,prjquota /dev/sdb:/dev/sdc /mnt + mount -t bcachefs -o usrquota,grpquota,prjquota ${ktest_scratch_dev[0]}:${ktest_scratch_dev[1]} /mnt repquota -vP /mnt mkdir /mnt/q1 diff --git a/tests/bcachefs/replication.ktest b/tests/bcachefs/replication.ktest index 8c54580..47c09da 100755 --- a/tests/bcachefs/replication.ktest +++ b/tests/bcachefs/replication.ktest @@ -22,10 +22,12 @@ test_recovery() --discard \ --bucket=64k \ --block_size=4k \ - /dev/sd[bcd] + ${ktest_scratch_dev[0]} \ + ${ktest_scratch_dev[1]} \ + ${ktest_scratch_dev[2]} for i in `seq 0 20`; do - mount -t bcachefs /dev/sdb:/dev/sdc:/dev/sdd /mnt + mount -t bcachefs ${ktest_scratch_dev[0]}:${ktest_scratch_dev[1]}:${ktest_scratch_dev[2]} /mnt #run_fio_randrw fio --eta=always \ @@ -48,48 +50,53 @@ test_recovery() umount /mnt done - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_multimount() { set_watchdog 10 bcachefs format \ - /dev/sdb + ${ktest_scratch_dev[0]} mkdir -p /mnt/1 /mnt/2 - mount -t bcachefs /dev/sdb /mnt/1 - mount -t bcachefs /dev/sdb /mnt/2 + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt/1 + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt/2 umount /mnt/1 umount /mnt/2 - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_twodevices() { run_basic_fio_test \ - /dev/sdb /dev/sdc /dev/sdd + ${ktest_scratch_dev[0]} ${ktest_scratch_dev[1]} ${ktest_scratch_dev[2]} } test_largebuckets() { set_watchdog 30 - run_quiet "" bcachefs format -f --bucket=8M /dev/sd[bcd] + run_quiet "" bcachefs format -f --bucket=8M \ + ${ktest_scratch_dev[0]} \ + ${ktest_scratch_dev[1]} \ + ${ktest_scratch_dev[2]} - mount -t bcachefs /dev/sdb:/dev/sdc:/dev/sdd /mnt + mount -t bcachefs ${ktest_scratch_dev[0]}:${ktest_scratch_dev[1]}:${ktest_scratch_dev[2]} /mnt dd if=/dev/zero of=/mnt/foo bs=8M count=1024 oflag=direct umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_replicas() { run_basic_fio_test \ --replicas=2 \ - /dev/sd[bcd] + ${ktest_scratch_dev[0]} \ + ${ktest_scratch_dev[1]} \ + ${ktest_scratch_dev[2]} } test_replicas_variable_buckets() @@ -97,18 +104,18 @@ test_replicas_variable_buckets() set_watchdog 1200 run_quiet "" bcachefs format -f \ --replicas=2 \ - --bucket=32k /dev/sdb \ - --bucket=64k /dev/sdc \ - --bucket=128k /dev/sdd \ - --bucket=128k /dev/sde \ - --bucket=128k /dev/sdf + --bucket=32k ${ktest_scratch_dev[0]} \ + --bucket=64k ${ktest_scratch_dev[1]} \ + --bucket=128k ${ktest_scratch_dev[2]} \ + --bucket=128k ${ktest_scratch_dev[3]} \ + --bucket=128k ${ktest_scratch_dev[4]} - mount -t bcachefs /dev/sdb:/dev/sdc:/dev/sdd:/dev/sde:/dev/sdf /mnt + mount -t bcachefs "$(join_by : "${ktest_scratch_dev[@]}")" /mnt fs_mark -v -n 20000 -s 4096 -k -S 0 -D 1000 -N 100000 -d /mnt -t 60 df -h /mnt umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } d_test_copygc_torture() @@ -118,10 +125,12 @@ d_test_copygc_torture() bcachefs_antagonist set_watchdog 600 - run_quiet "" bcachefs format -f \ - "$@" /dev/sd[bcd] + run_quiet "" bcachefs format -f "$@" \ + ${ktest_scratch_dev[0]} \ + ${ktest_scratch_dev[1]} \ + ${ktest_scratch_dev[2]} - mount -t bcachefs /dev/sdb:/dev/sdc:/dev/sdd /mnt + mount -t bcachefs ${ktest_scratch_dev[0]}:${ktest_scratch_dev[1]}:${ktest_scratch_dev[2]} /mnt #enable_memory_faults fio \ @@ -161,7 +170,7 @@ d_test_copygc_torture() #disable_memory_faults umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } do_remove_test() @@ -172,9 +181,11 @@ do_remove_test() run_quiet "" bcachefs format \ --replicas=2 \ - /dev/sd[bcd] + ${ktest_scratch_dev[0]} \ + ${ktest_scratch_dev[1]} \ + ${ktest_scratch_dev[2]} - mount -t bcachefs /dev/sdb:/dev/sdc:/dev/sdd /mnt + mount -t bcachefs ${ktest_scratch_dev[0]}:${ktest_scratch_dev[1]}:${ktest_scratch_dev[2]} /mnt local fioout="$ktest_out/fio-out" run_fio_randrw >"$fioout" 2>&1 & @@ -183,25 +194,25 @@ do_remove_test() sleep 1 if [[ $offline = 1 ]]; then - echo -n "offlining /dev/sdb... " - bcachefs device offline --force /dev/sdb + echo -n "offlining ${ktest_scratch_dev[0]}... " + bcachefs device offline --force ${ktest_scratch_dev[0]} echo "done" fi if [[ $evacuate = 1 ]]; then - echo -n "evacuating /dev/sdb... " - bcachefs device evacuate /dev/sdb + echo -n "evacuating ${ktest_scratch_dev[0]}... " + bcachefs device evacuate ${ktest_scratch_dev[0]} echo "done" fi bcachefs fs usage -h /mnt - echo -n "removing /dev/sdb... " + echo -n "removing ${ktest_scratch_dev[0]}... " if [[ $evacuate = 1 ]]; then - #bcachefs device remove /dev/sdb + #bcachefs device remove ${ktest_scratch_dev[0]} bcachefs device remove 0 /mnt else - #bcachefs device remove --force /dev/sdb + #bcachefs device remove --force ${ktest_scratch_dev[0]} bcachefs device remove --force 0 /mnt fi echo "done" @@ -214,10 +225,10 @@ do_remove_test() bcachefs fs usage -h /mnt umount /mnt - mount -t bcachefs /dev/sdb:/dev/sdc:/dev/sdd /mnt + mount -t bcachefs ${ktest_scratch_dev[0]}:${ktest_scratch_dev[1]}:${ktest_scratch_dev[2]} /mnt umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_device_remove_offline() @@ -248,17 +259,17 @@ test_device_add() run_quiet "" bcachefs format \ --block_size=4k \ --no_initialize \ - /dev/sdb + ${ktest_scratch_dev[0]} - mount -t bcachefs /dev/sdb /mnt + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt run_fio_randrw >"$ktest_out/fio-out" 2>&1 & local fiopid=$! sleep 1 - echo -n "adding /dev/sdc... " - bcachefs device add /mnt /dev/sdc + echo -n "adding ${ktest_scratch_dev[1]}... " + bcachefs device add /mnt ${ktest_scratch_dev[1]} echo "done" if ! wait $fiopid; then @@ -267,12 +278,12 @@ test_device_add() fi umount /mnt - bcachefs fsck -n /dev/sdb /dev/sdc + bcachefs fsck -n ${ktest_scratch_dev[0]} ${ktest_scratch_dev[1]} - mount -t bcachefs /dev/sdb:/dev/sdc /mnt + mount -t bcachefs ${ktest_scratch_dev[0]}:${ktest_scratch_dev[1]} /mnt umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_device_add_label() @@ -281,13 +292,13 @@ test_device_add_label() # Caught bugs: # - label was not set correctly; set to dev-0 label instead of new one. - bcachefs format -L test_add_label --label=foo /dev/sdb - mount -t bcachefs /dev/sdb /mnt - bcachefs device add --label=bar /mnt /dev/sdc + bcachefs format -L test_add_label --label=foo ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt + bcachefs device add --label=bar /mnt ${ktest_scratch_dev[1]} expect_sysfs dev-1 label bar umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_device_add_label_compound() @@ -299,13 +310,13 @@ test_device_add_label_compound() set_watchdog 30 - bcachefs format -L test_add_compound_label --label=hdd /dev/sdb - mount -t bcachefs /dev/sdb /mnt - bcachefs device add --label=foo.bar /mnt /dev/sdc + bcachefs format -L test_add_compound_label --label=hdd ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt + bcachefs device add --label=foo.bar /mnt ${ktest_scratch_dev[1]} expect_sysfs dev-1 label foo.bar umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_device_set_state() @@ -314,9 +325,11 @@ test_device_set_state() run_quiet "" bcachefs format \ --replicas=2 \ - /dev/sd[bcd] + ${ktest_scratch_dev[0]} \ + ${ktest_scratch_dev[1]} \ + ${ktest_scratch_dev[2]} - mount -t bcachefs /dev/sdb:/dev/sdc:/dev/sdd /mnt + mount -t bcachefs ${ktest_scratch_dev[0]}:${ktest_scratch_dev[1]}:${ktest_scratch_dev[2]} /mnt run_fio_randrw >"$ktest_out/fio-out" 2>&1 & local fiopid=$! @@ -325,10 +338,10 @@ test_device_set_state() for state in ro failed spare; do echo "setting state $state" - bcachefs device set-state --force $state /dev/sdc + bcachefs device set-state --force $state ${ktest_scratch_dev[1]} echo "setting state rw" - #bcachefs device set-state rw /dev/sdc + #bcachefs device set-state rw ${ktest_scratch_dev[1]} bcachefs device set-state rw 1 /mnt done @@ -339,7 +352,7 @@ test_device_set_state() umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_device_ro() @@ -348,9 +361,11 @@ test_device_ro() run_quiet "" bcachefs format \ --btree_node_size=128k \ - /dev/sd[bcd] + ${ktest_scratch_dev[0]} \ + ${ktest_scratch_dev[1]} \ + ${ktest_scratch_dev[2]} - mount -t bcachefs /dev/sdb:/dev/sdc:/dev/sdd /mnt + mount -t bcachefs ${ktest_scratch_dev[0]}:${ktest_scratch_dev[1]}:${ktest_scratch_dev[2]} /mnt local fioout="$ktest_out/fio-out" run_fio_randrw >"$fioout" 2>&1 & @@ -358,7 +373,7 @@ test_device_ro() sleep 4 - bcachefs device set-state ro /dev/sdc + bcachefs device set-state ro ${ktest_scratch_dev[1]} if ! wait $fiopid; then cat "$fioout" @@ -367,10 +382,10 @@ test_device_ro() umount /mnt - mount -t bcachefs /dev/sdb:/dev/sdc:/dev/sdd /mnt + mount -t bcachefs ${ktest_scratch_dev[0]}:${ktest_scratch_dev[1]}:${ktest_scratch_dev[2]} /mnt umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_device_set_state_offline() @@ -378,9 +393,11 @@ test_device_set_state_offline() set_watchdog 120 run_quiet "" bcachefs format \ --replicas=2 \ - /dev/sd[bcd] + ${ktest_scratch_dev[0]} \ + ${ktest_scratch_dev[1]} \ + ${ktest_scratch_dev[2]} - mount -t bcachefs /dev/sdb:/dev/sdc:/dev/sdd /mnt + mount -t bcachefs ${ktest_scratch_dev[0]}:${ktest_scratch_dev[1]}:${ktest_scratch_dev[2]} /mnt local fioout="$ktest_out/fio-out" run_fio_randrw >"$fioout" 2>&1 & @@ -388,7 +405,7 @@ test_device_set_state_offline() sleep 1 - bcachefs device set-state --force ro /dev/sdc + bcachefs device set-state --force ro ${ktest_scratch_dev[1]} if ! wait $fiopid; then cat "$fioout" @@ -397,13 +414,13 @@ test_device_set_state_offline() umount /mnt - bcachefs device set-state --offline rw /dev/sdc + bcachefs device set-state --offline rw ${ktest_scratch_dev[1]} - mount -t bcachefs /dev/sdb:/dev/sdc:/dev/sdd /mnt - cat /sys/block/sdc/bcachefs/state + mount -t bcachefs ${ktest_scratch_dev[0]}:${ktest_scratch_dev[1]}:${ktest_scratch_dev[2]} /mnt + cat /sys/block/[sv]dc/bcachefs/state umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_device_readd() @@ -411,9 +428,10 @@ test_device_readd() set_watchdog 120 run_quiet "" bcachefs format \ --replicas=2 \ - /dev/sd[bc] + ${ktest_scratch_dev[0]} \ + ${ktest_scratch_dev[1]} - mount -t bcachefs /dev/sdb:/dev/sdc /mnt + mount -t bcachefs ${ktest_scratch_dev[0]}:${ktest_scratch_dev[1]} /mnt local fioout="$ktest_out/fio-out" run_fio_randrw >"$fioout" 2>&1 & @@ -421,12 +439,12 @@ test_device_readd() sleep 1 - echo -n "offlining /dev/sdb... " - bcachefs device offline --force /dev/sdb + echo -n "offlining ${ktest_scratch_dev[0]}... " + bcachefs device offline --force ${ktest_scratch_dev[0]} echo "done" - echo -n "onlining /dev/sdb... " - bcachefs device online /dev/sdb + echo -n "onlining ${ktest_scratch_dev[0]}... " + bcachefs device online ${ktest_scratch_dev[0]} echo "done" if ! wait $fiopid; then @@ -436,10 +454,10 @@ test_device_readd() umount /mnt - mount -t bcachefs /dev/sdb:/dev/sdc /mnt + mount -t bcachefs ${ktest_scratch_dev[0]}:${ktest_scratch_dev[1]} /mnt umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_device_repeated_add_remove() @@ -450,22 +468,22 @@ test_device_repeated_add_remove() set_watchdog 120 - bcachefs format -L test_device_repeated_add_remove --label=hdd /dev/sdb - mount -t bcachefs /dev/sdb /mnt + bcachefs format -L test_device_repeated_add_remove --label=hdd ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt for ii in {1..10}; do echo "add-remove run #$ii ----------------------------------------------------" echo "bcachefs device add" - bcachefs device add /mnt /dev/sdc + bcachefs device add /mnt ${ktest_scratch_dev[1]} echo "bcachefs device evacuate" - bcachefs device evacuate /dev/sdc + bcachefs device evacuate ${ktest_scratch_dev[1]} echo "bcachefs device remove" - bcachefs device remove /dev/sdc + bcachefs device remove ${ktest_scratch_dev[1]} done umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } do_replicas_errors_test() @@ -476,13 +494,13 @@ do_replicas_errors_test() echo 1 > /sys/module/bcachefs/parameters/verify_all_btree_replicas #bcachefs_antagonist - mdadm -B /dev/md0 -lfaulty -n1 /dev/sdc + mdadm -B /dev/md0 -lfaulty -n1 ${ktest_scratch_dev[1]} run_quiet "" bcachefs format \ --replicas=2 \ - /dev/md0 /dev/sdb + /dev/md0 ${ktest_scratch_dev[0]} - mount -t bcachefs -o degraded /dev/sdb:/dev/md0 /mnt + mount -t bcachefs -o degraded ${ktest_scratch_dev[0]}:/dev/md0 /mnt mdadm -G /dev/md0 -p$error_type @@ -495,12 +513,12 @@ do_replicas_errors_test() umount /mnt mdadm --stop /dev/md0 - #bcachefs fsck -n /dev/sdb /dev/sdc + #bcachefs fsck -n ${ktest_scratch_dev[0]} ${ktest_scratch_dev[1]} - mount -t bcachefs -o fsck /dev/sdb:/dev/sdc /mnt + mount -t bcachefs -o fsck ${ktest_scratch_dev[0]}:${ktest_scratch_dev[1]} /mnt umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_replicas_write_errors() @@ -520,10 +538,12 @@ test_cmd_fs_usage() run_quiet "" bcachefs format \ --replicas=2 \ --bucket=128k \ - /dev/sd[bcd] + ${ktest_scratch_dev[0]} \ + ${ktest_scratch_dev[1]} \ + ${ktest_scratch_dev[2]} echo -n "mounting... " - mount -t bcachefs -o verbose /dev/sdb:/dev/sdc:/dev/sdd /mnt + mount -t bcachefs -o verbose ${ktest_scratch_dev[0]}:${ktest_scratch_dev[1]}:${ktest_scratch_dev[2]} /mnt echo done echo "Before writing:" @@ -542,20 +562,22 @@ test_cmd_fs_usage() umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_rereplicate() { set_watchdog 60 run_quiet "" bcachefs format \ - /dev/sd[bcd] - mount -t bcachefs /dev/sdb:/dev/sdc:/dev/sdd /mnt + ${ktest_scratch_dev[0]} \ + ${ktest_scratch_dev[1]} \ + ${ktest_scratch_dev[2]} + mount -t bcachefs ${ktest_scratch_dev[0]}:${ktest_scratch_dev[1]}:${ktest_scratch_dev[2]} /mnt dd if=/dev/zero of=/mnt/test bs=1M count=1024 oflag=direct umount /mnt - mount -t bcachefs -o metadata_replicas=2,data_replicas=2 /dev/sdb:/dev/sdc:/dev/sdd /mnt + mount -t bcachefs -o metadata_replicas=2,data_replicas=2 ${ktest_scratch_dev[0]}:${ktest_scratch_dev[1]}:${ktest_scratch_dev[2]} /mnt #echo 2 > /sys/fs/bcachefs/*/options/data_replicas #echo 2 > /sys/fs/bcachefs/*/options/metadata_replicas @@ -565,10 +587,10 @@ test_rereplicate() bcachefs fs usage -h /mnt umount /mnt - mount -t bcachefs -o degraded /dev/sdb:/dev/sdc /mnt + mount -t bcachefs -o degraded ${ktest_scratch_dev[0]}:${ktest_scratch_dev[1]} /mnt umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } disabled_test_device_add_faults() @@ -577,13 +599,13 @@ disabled_test_device_add_faults() run_quiet "" bcachefs format \ --errors=remount-ro \ - /dev/sdb - mount /dev/sdb /mnt + ${ktest_scratch_dev[0]} + mount ${ktest_scratch_dev[0]} /mnt device_add_fault_fn() { set_faults "$1 enable" - ! bcachefs device add /mnt /dev/sdc + ! bcachefs device add /mnt ${ktest_scratch_dev[1]} } run_fault_injection_test bcachefs:add device_add_fault_fn @@ -591,7 +613,7 @@ disabled_test_device_add_faults() run_fault_injection_test bcachefs:bch_fs_init:alloc_start device_add_fault_fn run_fault_injection_test bcachefs:bch_fs_init:read_super device_add_fault_fn - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_striping() @@ -602,14 +624,15 @@ test_striping() if false; then run_quiet "" bcachefs format \ --replicas=2 \ - /dev/sd[bc] + ${ktest_scratch_dev[0]} \ + ${ktest_scratch_dev[1]} - mount -t bcachefs /dev/sdb:/dev/sdc /mnt + mount -t bcachefs ${ktest_scratch_dev[0]}:${ktest_scratch_dev[1]} /mnt dd if=/dev/zero of=/mnt/test0 bs=1M count=1024 oflag=direct bcachefs fs usage -h /mnt - bcachefs device add /mnt /dev/sdd + bcachefs device add /mnt ${ktest_scratch_dev[2]} dd if=/dev/zero of=/mnt/test1 bs=1M count=1024 oflag=direct else @@ -618,15 +641,17 @@ test_striping() --replicas=2 \ --label cache \ --durability=1 \ - --bucket=8M /dev/sd[b] \ + --bucket=8M \ + ${ktest_scratch_dev[0]} \ --label hdd \ --durability=2 \ - --bucket=8M /dev/sd[cd] \ + ${ktest_scratch_dev[1]} \ + ${ktest_scratch_dev[2]} \ --foreground_target=cache \ --background_target=hdd \ --promote_target=cache - mount -t bcachefs /dev/sdb:/dev/sdc:/dev/sdd /mnt + mount -t bcachefs ${ktest_scratch_dev[0]}:${ktest_scratch_dev[1]}:${ktest_scratch_dev[2]} /mnt dd if=/dev/zero of=/mnt/test0 bs=1M count=1024 oflag=direct fi @@ -635,16 +660,17 @@ test_striping() umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } disabled_change_replicas() { run_quiet "" bcachefs format \ --replicas=2 \ - /dev/sd[bc] + ${ktest_scratch_dev[0]} \ + ${ktest_scratch_dev[1]} - mount -t bcachefs /dev/sdb:/dev/sdc /mnt + mount -t bcachefs ${ktest_scratch_dev[0]}:${ktest_scratch_dev[1]} /mnt ( cd /sys/fs/bcachefs/* @@ -667,16 +693,17 @@ disabled_change_replicas() kill %1 umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } disabled_change_replicas2() { run_quiet "" bcachefs format \ --replicas=2 \ - /dev/sd[bc] + ${ktest_scratch_dev[0]} \ + ${ktest_scratch_dev[1]} - mount -t bcachefs /dev/sdb:/dev/sdc /mnt + mount -t bcachefs ${ktest_scratch_dev[0]}:${ktest_scratch_dev[1]} /mnt local opt=/sys/fs/bcachefs/*/options/data_replicas while true; do @@ -689,7 +716,7 @@ disabled_change_replicas2() umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_replicas_gc() @@ -701,8 +728,8 @@ test_replicas_gc() run_quiet "" bcachefs format -f \ --replicas=2 \ - /dev/sd[bcdef] - devs=/dev/sdb:/dev/sdc:/dev/sdd:/dev/sde:/dev/sdf + ${ktest_scratch_dev[@]} + devs="$(join_by : "${ktest_scratch_dev[@]}")" mount -t bcachefs $devs /mnt @@ -716,58 +743,58 @@ test_replicas_gc() mount -t bcachefs -o fix_errors,erasure_code $devs /mnt umount /mnt - bcachefs fsck /dev/sd[bcdef] + bcachefs fsck ${ktest_scratch_dev[@]} - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_replace_replica() { set_watchdog 60 - bcachefs format --replicas=2 /dev/sd[bc] - mount -t bcachefs -o degraded /dev/sdb /mnt + bcachefs format --replicas=2 ${ktest_scratch_dev[0]} ${ktest_scratch_dev[1]} + mount -t bcachefs -o degraded ${ktest_scratch_dev[0]} /mnt - bcachefs device add -f /mnt /dev/sdd + bcachefs device add -f /mnt ${ktest_scratch_dev[2]} - bcachefs device set-state --force failed /dev/sdc + bcachefs device set-state --force failed ${ktest_scratch_dev[1]} bcachefs data rereplicate /mnt umount /mnt - mount -t bcachefs -o degraded /dev/sdd /mnt + mount -t bcachefs -o degraded ${ktest_scratch_dev[2]} /mnt umount /mnt # We expect more btree_path_upgrade_fail events than usual in this test, # due to the way the btree node rewrite path works and the fact that we're # rewriting every btree node - check_counters /dev/sdb 4 + check_counters ${ktest_scratch_dev[0]} 4 } test_key_type_error() { set_watchdog 20 - bcachefs format --replicas=2 /dev/sd[bc] + bcachefs format --replicas=2 ${ktest_scratch_dev[0]} ${ktest_scratch_dev[1]} - mount -t bcachefs /dev/sdb:/dev/sdc /mnt + mount -t bcachefs ${ktest_scratch_dev[0]}:${ktest_scratch_dev[1]} /mnt bcachefs setattr --data_replicas=1 /mnt - bcachefs setattr --foreground_target=sdc /mnt + bcachefs setattr --foreground_target=$(basename ${ktest_scratch_dev[1]}) /mnt dd if=/dev/zero of=/mnt/foo bs=64k count=8 oflag=direct umount /mnt - mount -t bcachefs -o very_degraded /dev/sdb /mnt + mount -t bcachefs -o very_degraded ${ktest_scratch_dev[0]} /mnt - bcachefs device remove --force /dev/sdc + bcachefs device remove --force ${ktest_scratch_dev[1]} # should fail: ! dd if=/mnt/foo of=/dev/null bs=64k count=1 iflag=direct umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } main "$@" diff --git a/tests/bcachefs/single_device.ktest b/tests/bcachefs/single_device.ktest index 113e614..f8aa41b 100755 --- a/tests/bcachefs/single_device.ktest +++ b/tests/bcachefs/single_device.ktest @@ -17,23 +17,23 @@ test_stress_ng() set_watchdog 300 setup_tracing 'bcachefs:*' - run_quiet "" bcachefs format --no_initialize --version=11 -f /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format --no_initialize --version=11 -f ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt cd /mnt stress-ng -v -t 60 --class filesystem --all 1 || true stress-ng -v -t 60 --class filesystem --all 2 || true cd /root umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_punch() { set_watchdog 10 - run_quiet "" bcachefs format -f --errors=panic /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt xfs_io -f /mnt/foo -c "pwrite -S 0x55 0 16384" xfs_io -f /mnt/foo -c "fsync" @@ -42,26 +42,26 @@ test_punch() md5sum /mnt/foo umount /mnt - mount -t bcachefs /dev/sdb /mnt + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt md5sum /mnt/foo umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_remount_ro_rw() { set_watchdog 10 - run_quiet "" bcachefs format -f --errors=panic /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt mount -o remount,ro /mnt mount -o remount,rw /mnt touch /mnt/foo umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_extent_merge2() @@ -69,25 +69,25 @@ test_extent_merge2() set_watchdog 10 echo 1 > /sys/module/bcachefs/parameters/debug_check_iterators - run_quiet "" bcachefs format -f --errors=panic /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt fallocate -o 0 -l 4096 /mnt/foo fallocate -o 4096 -l 4096 /mnt/foo umount /mnt - bcachefs fsck -n /dev/sdb + bcachefs fsck -n ${ktest_scratch_dev[0]} - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_reflink2() { set_watchdog 10 bcachefs_antagonist - run_quiet "" bcachefs format /dev/sdb + run_quiet "" bcachefs format ${ktest_scratch_dev[0]} - mount -t bcachefs /dev/sdb /mnt + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt dd if=/dev/urandom of=/mnt/foo bs=16k count=1 oflag=direct cp --reflink /mnt/foo /mnt/foo2 @@ -114,14 +114,14 @@ test_reflink2() umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_reflink() { set_watchdog 10 - run_quiet "" bcachefs format -f --errors=panic /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt run_fio_randrw --filesize=1000M & @@ -146,7 +146,7 @@ test_reflink() umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_fio_raw() @@ -160,7 +160,7 @@ test_fio_raw() --iodepth_batch=16 \ --direct=1 \ --numjobs=1 \ - --filename=/dev/sdb \ + --filename=${ktest_scratch_dev[0]} \ --name=randread \ --rw=randread \ --size=40G \ @@ -170,29 +170,29 @@ test_fio_raw() test_rewrite_old_nodes() { set_watchdog 60 - run_quiet "" bcachefs format -f --no_initialize --version=10 /dev/sdb + run_quiet "" bcachefs format -f --no_initialize --version=10 ${ktest_scratch_dev[0]} - bcachefs show-super /dev/sdb + bcachefs show-super ${ktest_scratch_dev[0]} - mount -t bcachefs /dev/sdb /mnt + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt dd if=/dev/zero of=/mnt/foo bs=4k count=65536 oflag=direct umount /mnt - bcachefs show-super /dev/sdb + bcachefs show-super ${ktest_scratch_dev[0]} - bcachefs fsck /dev/sdb + bcachefs fsck ${ktest_scratch_dev[0]} - bcachefs show-super /dev/sdb + bcachefs show-super ${ktest_scratch_dev[0]} - mount -t bcachefs -o version_upgrade /dev/sdb /mnt + mount -t bcachefs -o version_upgrade ${ktest_scratch_dev[0]} /mnt bcachefs data job rewrite_old_nodes /mnt umount /mnt - bcachefs fsck /dev/sdb + bcachefs fsck ${ktest_scratch_dev[0]} - bcachefs show-super /dev/sdb + bcachefs show-super ${ktest_scratch_dev[0]} - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_merge_torture_flakey() @@ -201,7 +201,7 @@ test_merge_torture_flakey() local loops=$((($ktest_priority + 1) * 3)) local n=40M - mdadm -B /dev/md0 -lfaulty -n1 /dev/sdb + mdadm -B /dev/md0 -lfaulty -n1 ${ktest_scratch_dev[0]} run_quiet "" bcachefs format -f --btree_node_size=32k --errors=panic /dev/md0 @@ -236,7 +236,7 @@ test_merge_torture_flakey() mdadm --stop /dev/md0 - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } # Disabled, because currently OOMs @@ -247,10 +247,10 @@ d_test_merge_torture() local loops=$((($ktest_priority + 1) * 3)) local n=10M - run_quiet "" bcachefs format -f --errors=panic --btree_node_size=8k --no_initialize /dev/sdb + run_quiet "" bcachefs format -f --errors=panic --btree_node_size=8k --no_initialize ${ktest_scratch_dev[0]} for i in `seq 0 $loops`; do - mount -t bcachefs -o fsck /dev/sdb /mnt + mount -t bcachefs -o fsck ${ktest_scratch_dev[0]} /mnt echo "loop: $i" echo rand_insert $n 1 > /sys/fs/bcachefs/*/perf_test @@ -268,8 +268,8 @@ d_test_merge_torture() test_make_files() { set_watchdog 30 - run_quiet "" bcachefs format -f /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format -f ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt echo 3 > /proc/sys/vm/drop_caches free -m @@ -283,48 +283,48 @@ test_make_files() free -m umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_journal_resize() { set_watchdog 30 - run_quiet "" bcachefs format -f /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format -f ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt run_fio_randrw --filesize=2G & sleep 4 - bcachefs device resize-journal /dev/sdb 1G + bcachefs device resize-journal ${ktest_scratch_dev[0]} 1G wait umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_drop_alloc() { set_watchdog 120 - run_quiet "" bcachefs format -f /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format -f ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt run_fio_randrw --filesize=2G umount /mnt - mount -t bcachefs -o reconstruct_alloc,fsck,fix_errors /dev/sdb /mnt + mount -t bcachefs -o reconstruct_alloc,fsck,fix_errors ${ktest_scratch_dev[0]} /mnt umount /mnt - bcachefs fsck -n /dev/sdb + bcachefs fsck -n ${ktest_scratch_dev[0]} - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_reflink_inline_data() { set_watchdog 30 - run_quiet "" bcachefs format -f /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format -f ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt dd if=/dev/urandom of=/root/foo bs=256 count=1 cp /root/foo /mnt/foo1 @@ -334,21 +334,21 @@ test_reflink_inline_data() umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_split_compressed() { set_watchdog 30 - run_quiet "" bcachefs format --compression=zstd /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format --compression=zstd ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt # Test that splitting of compressed extents is working correctly: dd if=/dev/zero of=/mnt/foo bs=128k count=1 oflag=direct dd if=/dev/urandom of=/mnt/foo bs=4k count=1 seek=1 oflag=direct conv=notrunc umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_fcollapse() @@ -356,8 +356,8 @@ test_fcollapse() set_watchdog 30 run_quiet "" bcachefs format -f \ --errors=panic \ - /dev/sdb - mount -t bcachefs /dev/sdb /mnt + ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt dd if=/dev/zero of=/mnt/foo bs=4k count=4 oflag=direct @@ -375,14 +375,14 @@ test_fcollapse() umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_finsert() { set_watchdog 30 - run_quiet "" bcachefs format /dev/sdb - mount -t bcachefs -o fsck /dev/sdb /mnt + run_quiet "" bcachefs format ${ktest_scratch_dev[0]} + mount -t bcachefs -o fsck ${ktest_scratch_dev[0]} /mnt dd if=/dev/zero of=/mnt/foo bs=64k count=1 oflag=direct @@ -391,15 +391,15 @@ test_finsert() xfs_io -c "finsert 1024 1024" /mnt/foo umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_key_merge() { set_watchdog 30 - run_quiet "" bcachefs format --data_checksum=none /dev/sdb + run_quiet "" bcachefs format --data_checksum=none ${ktest_scratch_dev[0]} - mount -t bcachefs /dev/sdb /mnt + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt dd if=/dev/zero of=/mnt/foo bs=8k count=128 oflag=direct @@ -409,15 +409,15 @@ test_key_merge() umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_key_merge_csum() { set_watchdog 30 - run_quiet "" bcachefs format --data_checksum=crc32c /dev/sdb + run_quiet "" bcachefs format --data_checksum=crc32c ${ktest_scratch_dev[0]} - mount -t bcachefs /dev/sdb /mnt + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt dd if=/dev/urandom of=/mnt/foo bs=8k count=128 oflag=direct @@ -429,39 +429,39 @@ test_key_merge_csum() umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_reconstruct_alloc() { set_watchdog 120 - run_quiet "" bcachefs format --btree_node_size=16k /dev/sdb + run_quiet "" bcachefs format --btree_node_size=16k ${ktest_scratch_dev[0]} - mount -t bcachefs -o reconstruct_alloc,fix_errors,fsck /dev/sdb /mnt + mount -t bcachefs -o reconstruct_alloc,fix_errors,fsck ${ktest_scratch_dev[0]} /mnt umount /mnt - bcachefs fsck -n /dev/sdb + bcachefs fsck -n ${ktest_scratch_dev[0]} - mount -t bcachefs /dev/sdb /mnt + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt run_fio_randrw umount /mnt echo "Running fsck --reconstruct_alloc" - fsck.bcachefs -ny --reconstruct_alloc /dev/sdb && rc=$? || rc=$? + fsck.bcachefs -ny --reconstruct_alloc ${ktest_scratch_dev[0]} && rc=$? || rc=$? if (( $rc != 0 && $rc != 1 )); then echo "Bad exit status from fsck: $rc" exit 1 fi echo "Mounting with -o reconstruct_alloc" - mount -t bcachefs -o reconstruct_alloc,fix_errors,fsck /dev/sdb /mnt + mount -t bcachefs -o reconstruct_alloc,fix_errors,fsck ${ktest_scratch_dev[0]} /mnt umount /mnt - bcachefs fsck -n /dev/sdb - mount -t bcachefs -o fsck /dev/sdb /mnt + bcachefs fsck -n ${ktest_scratch_dev[0]} + mount -t bcachefs -o fsck ${ktest_scratch_dev[0]} /mnt umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_recovery() @@ -471,10 +471,10 @@ test_recovery() --errors=panic \ --encrypted --no_passphrase \ --bucket=8k \ - /dev/sdb + ${ktest_scratch_dev[0]} for i in `seq 0 1`; do - mount -t bcachefs /dev/sdb /mnt + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt dd if=/dev/zero of=/mnt/foo bs=4k count=8 oflag=direct @@ -501,39 +501,39 @@ test_recovery() umount /mnt done - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_lz4_zeros() { set_watchdog 30 - run_quiet "" bcachefs format -f --errors=panic --compression=lz4 --data_checksum=none --bucket=2M /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format -f --errors=panic --compression=lz4 --data_checksum=none --bucket=2M ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt dd if=/dev/zero of=/mnt/foo bs=1M count=10 # XXX check disk space used umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_lz4_incompressible() { set_watchdog 120 - run_quiet "" bcachefs format -f --errors=panic --compression=lz4 --data_checksum=none --bucket=2M /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format -f --errors=panic --compression=lz4 --data_checksum=none --bucket=2M ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt dd if=/dev/urandom of=/mnt/foo || true umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_lz4() { run_basic_fio_test \ --compression=lz4 \ - /dev/sdb + ${ktest_scratch_dev[0]} } test_lz4_buffered() @@ -544,8 +544,8 @@ test_lz4_buffered() run_quiet "" bcachefs format -f \ --errors=panic \ --compression=lz4 \ - /dev/sdb - mount -t bcachefs /dev/sdb /mnt + ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt echo starting copy cp -rx / /mnt/foo @@ -558,21 +558,21 @@ test_lz4_buffered() umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_gzip() { run_basic_fio_test \ --compression=gzip \ - /dev/sdb + ${ktest_scratch_dev[0]} } test_zstd() { run_basic_fio_test \ --compression=zstd \ - /dev/sdb + ${ktest_scratch_dev[0]} } disabled_test_background_compression() @@ -580,12 +580,12 @@ disabled_test_background_compression() run_quiet "" bcachefs format -f \ --errors=panic \ --background_compression=zstd \ - /dev/sdb - mount -t bcachefs /dev/sdb /mnt + ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt echo zstd > /sys/fs/bcachefs/*/options/background_compression run_fio_randrw - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_compress_no_checksum() @@ -594,7 +594,7 @@ test_compress_no_checksum() --compression=lz4 \ --metadata_checksum=none \ --data_checksum=none \ - /dev/sdb + ${ktest_scratch_dev[0]} } test_no_checksum() @@ -602,7 +602,7 @@ test_no_checksum() run_basic_fio_test \ --metadata_checksum=none \ --data_checksum=none \ - /dev/sdb + ${ktest_scratch_dev[0]} } test_crc32c() @@ -610,7 +610,7 @@ test_crc32c() run_basic_fio_test \ --metadata_checksum=crc32c \ --data_checksum=crc32c \ - /dev/sdb + ${ktest_scratch_dev[0]} } test_crc64() @@ -618,31 +618,31 @@ test_crc64() run_basic_fio_test \ --metadata_checksum=crc64 \ --data_checksum=crc64 \ - /dev/sdb + ${ktest_scratch_dev[0]} } test_crypto_locked_mnt() { - echo foo|bcachefs format --encrypted /dev/sdb - echo foo|bcachefs unlock -k session /dev/sdb - mount -t bcachefs -o verbose /dev/sdb /mnt + echo foo|bcachefs format --encrypted ${ktest_scratch_dev[0]} + echo foo|bcachefs unlock -k session ${ktest_scratch_dev[0]} + mount -t bcachefs -o verbose ${ktest_scratch_dev[0]} /mnt umount /mnt - bcachefs fsck /dev/sdb + bcachefs fsck ${ktest_scratch_dev[0]} - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_crypto() { run_basic_fio_test \ --encrypted --no_passphrase \ - /dev/sdb - mount -t bcachefs -o fsck /dev/sdb /mnt + ${ktest_scratch_dev[0]} + mount -t bcachefs -o fsck ${ktest_scratch_dev[0]} /mnt umount /mnt bcachefs fsck \ - /dev/sdb + ${ktest_scratch_dev[0]} - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_crypto_lz4() @@ -650,7 +650,7 @@ test_crypto_lz4() run_basic_fio_test \ --encrypted --no_passphrase \ --compression=lz4 \ - /dev/sdb + ${ktest_scratch_dev[0]} } run_copygc_torture() @@ -664,9 +664,9 @@ run_copygc_torture() run_quiet "" bcachefs format -f \ --errors=panic \ --data_checksum=none \ - "$@" /dev/sdb + "$@" ${ktest_scratch_dev[0]} - mount -t bcachefs /dev/sdb /mnt + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt fill_device /mnt/fiotest @@ -695,9 +695,9 @@ run_copygc_torture() expect_sysfs cache cached_data 0 umount /mnt - bcachefs fsck -n /dev/sdb + bcachefs fsck -n ${ktest_scratch_dev[0]} - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_copygc_torture() @@ -720,7 +720,7 @@ test_small_buckets() { run_basic_fio_test \ --bucket=32k \ - /dev/sdb + ${ktest_scratch_dev[0]} } # Gets stuck due to only having 512 buckets @@ -729,7 +729,7 @@ test_large_buckets() run_basic_fio_test \ --bucket=8M \ --data_checksum=none \ - /dev/sdb + ${ktest_scratch_dev[0]} } test_small_nodes() @@ -737,19 +737,19 @@ test_small_nodes() run_basic_fio_test \ --bucket=256k \ --btree_node_size=4k \ - /dev/sdb + ${ktest_scratch_dev[0]} } d_test_crypto_passphrase() { bcachefs_antagonist - echo ""|bcachefs format -f --encrypted /dev/sdb - echo ""|bcachefs unlock /dev/sdb + echo ""|bcachefs format -f --encrypted ${ktest_scratch_dev[0]} + echo ""|bcachefs unlock ${ktest_scratch_dev[0]} - mount -t bcachefs /dev/sdb /mnt + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt umount /mnt - bcachefs fsck /dev/sdb + bcachefs fsck ${ktest_scratch_dev[0]} } test_partial_overwritten_extents() @@ -759,8 +759,8 @@ test_partial_overwritten_extents() run_quiet "" bcachefs format -f \ --errors=panic \ --encrypted --no_passphrase \ - /dev/sdb - mount -t bcachefs /dev/sdb /mnt + ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt dd if=/dev/urandom of=/mnt/foo bs=32k count=1 skip=0 oflag=direct dd if=/mnt/foo of=/dev/null bs=4k count=8 skip=0 iflag=direct @@ -779,7 +779,7 @@ test_partial_overwritten_extents() dd if=/mnt/baz of=/dev/null bs=4k count=8 skip=0 iflag=direct > /dev/null umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } # test the xattr interface for per-inode IO options: @@ -788,8 +788,8 @@ test_xattr() set_watchdog 10 run_quiet "" bcachefs format -f \ --errors=panic \ - /dev/sdb - mount -t bcachefs /dev/sdb /mnt + ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt mkdir /mnt/foo setfattr -n bcachefs.compression -v lz4 /mnt/foo @@ -809,7 +809,7 @@ test_xattr() umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_quota() @@ -819,8 +819,8 @@ test_quota() run_quiet "" bcachefs format -f \ --errors=panic \ - /dev/sdb - mount -t bcachefs -o usrquota,grpquota,prjquota /dev/sdb /mnt + ${ktest_scratch_dev[0]} + mount -t bcachefs -o usrquota,grpquota,prjquota ${ktest_scratch_dev[0]} /mnt loops=$((($ktest_priority + 1) * 4)) @@ -829,7 +829,7 @@ test_quota() rm /mnt/fiotest umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } # test nfs exports: @@ -843,8 +843,8 @@ test_nfs() run_quiet "" bcachefs format -f \ --errors=panic \ - /dev/sdb - mount -t bcachefs /dev/sdb /export2 + ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /export2 echo "/export1 *(ro,insecure,all_squash,no_subtree_check)" >> /etc/exports echo "/export2 *(ro,insecure,all_squash,no_subtree_check)" >> /etc/exports @@ -853,7 +853,7 @@ test_nfs() umount /export2 - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } # We should get this working at some point: @@ -876,8 +876,8 @@ d_test_suspend() run_quiet "" bcachefs format -f \ --errors=panic \ - /dev/sdb - mount -t bcachefs /dev/sdb /mnt + ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt if false; then run_dbench @@ -886,7 +886,7 @@ d_test_suspend() run_stress fi - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_journal_torture() @@ -896,9 +896,9 @@ test_journal_torture() run_quiet "" bcachefs format -f \ --errors=panic \ - /dev/sdb + ${ktest_scratch_dev[0]} - mount -t bcachefs /dev/sdb /mnt + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt #enable_memory_faults echo 1 > /sys/fs/bcachefs/*/options/journal_flush_delay @@ -908,7 +908,7 @@ test_journal_torture() #disable_memory_faults umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_online_resize() @@ -919,17 +919,17 @@ test_online_resize() run_quiet "" bcachefs format -f \ --errors=panic \ --fs_size=1G \ - /dev/sdb + ${ktest_scratch_dev[0]} - mount -t bcachefs /dev/sdb /mnt + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt df -h /mnt - bcachefs device resize /dev/sdb + bcachefs device resize ${ktest_scratch_dev[0]} df -h /mnt umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_offline_resize() @@ -940,21 +940,21 @@ test_offline_resize() run_quiet "" bcachefs format -f \ --errors=panic \ --fs_size=1G \ - /dev/sdb + ${ktest_scratch_dev[0]} - mount -t bcachefs /dev/sdb /mnt + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt df -h /mnt cat /proc/mounts umount /mnt - bcachefs device resize /dev/sdb + bcachefs device resize ${ktest_scratch_dev[0]} - mount -t bcachefs /dev/sdb /mnt + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt df -h /mnt umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } require-kernel-config BLK_DEV_DM @@ -962,8 +962,8 @@ require-kernel-config BLK_DEV_DM test_offline_resize_lv() { set_watchdog 60 - pvcreate /dev/sdb - vgcreate vg /dev/sdb + pvcreate ${ktest_scratch_dev[0]} + vgcreate vg ${ktest_scratch_dev[0]} lvcreate -L 1G -n foo vg dev=/dev/vg/foo @@ -992,14 +992,14 @@ test_sysfs() set_watchdog 10 run_quiet "" bcachefs format -f \ --errors=panic \ - /dev/sdb - mount -t bcachefs /dev/sdb /mnt + ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt find -H /sys/fs/bcachefs/ -type f -perm -0400 -exec cat {} \; > /dev/null umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_debugfs() @@ -1007,8 +1007,8 @@ test_debugfs() set_watchdog 30 run_quiet "" bcachefs format -f \ --errors=panic \ - /dev/sdb - mount -t bcachefs /dev/sdb /mnt + ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt dd if=/dev/zero of=/mnt/test1 bs=1k count=10240 oflag=direct dd if=/dev/zero of=/mnt/test2 bs=1k count=10240 oflag=direct @@ -1017,7 +1017,7 @@ test_debugfs() umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_set_option() @@ -1025,28 +1025,28 @@ test_set_option() set_watchdog 10 run_quiet "" bcachefs format -f \ --errors=panic \ - /dev/sdb + ${ktest_scratch_dev[0]} - mount -t bcachefs /dev/sdb /mnt - bcachefs set-option --compression=zstd /dev/sdb + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt + bcachefs set-option --compression=zstd ${ktest_scratch_dev[0]} cat /sys/fs/bcachefs/*/options/compression umount /mnt - bcachefs set-option --compression=lz4 /dev/sdb + bcachefs set-option --compression=lz4 ${ktest_scratch_dev[0]} - mount -t bcachefs /dev/sdb /mnt + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt cat /sys/fs/bcachefs/*/options/compression umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } disabled_test_swapfile() { run_quiet "" bcachefs format -f \ --errors=panic \ - /dev/sdb - mount -t bcachefs /dev/sdb /mnt + ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt fallocate -l 1G /mnt/swapfile mkswap /mnt/swapfile @@ -1064,11 +1064,11 @@ migrate_from_fs() local fstype=$1 if [[ $fstype = ext4 ]]; then - run_quiet "" mkfs.$fstype -F /dev/sdb - mount -t $fstype -o user_xattr /dev/sdb /mnt + run_quiet "" mkfs.$fstype -F ${ktest_scratch_dev[0]} + mount -t $fstype -o user_xattr ${ktest_scratch_dev[0]} /mnt else - run_quiet "" mkfs.$fstype -f /dev/sdb - mount -t $fstype /dev/sdb /mnt + run_quiet "" mkfs.$fstype -f ${ktest_scratch_dev[0]} + mount -t $fstype ${ktest_scratch_dev[0]} /mnt fi cp -a /usr /mnt @@ -1088,7 +1088,7 @@ migrate_from_fs() if true; then mkdir -p /mnt2 - mount -t bcachefs -o noexcl,nochanges,sb=$offset /dev/sdb /mnt2 + mount -t bcachefs -o noexcl,nochanges,sb=$offset ${ktest_scratch_dev[0]} /mnt2 rsync --archive \ --acls \ @@ -1104,19 +1104,19 @@ migrate_from_fs() fi umount /mnt - fsck.$fstype -n /dev/sdb + fsck.$fstype -n ${ktest_scratch_dev[0]} - mount -t bcachefs -o sb=$offset /dev/sdb /mnt + mount -t bcachefs -o sb=$offset ${ktest_scratch_dev[0]} /mnt umount /mnt echo "Creating default superblock" - bcachefs migrate-superblock -d /dev/sdb -o $offset + bcachefs migrate-superblock -d ${ktest_scratch_dev[0]} -o $offset - mount -t bcachefs /dev/sdb /mnt + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt rm /mnt/old_migrated_filesystem umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_migrate_from_ext4() @@ -1148,10 +1148,10 @@ d_test_init_faults() run_quiet "" bcachefs format -f \ --errors=remount-ro \ - /dev/sdb + ${ktest_scratch_dev[0]} # put some data on the filesystem - mount -t bcachefs /dev/sdb /mnt + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt run_fio_randrw # dbench would be better, create a directory structure @@ -1163,7 +1163,7 @@ d_test_init_faults() { set_faults "$1 enable" # should fail: - ! mount -t bcachefs -o verbose /dev/sdb /mnt + ! mount -t bcachefs -o verbose ${ktest_scratch_dev[0]} /mnt } run_fault_injection_test bcachefs:bch_fs_init init_fault_fn @@ -1177,11 +1177,11 @@ d_test_meta_write_faults() run_quiet "" bcachefs format -f \ --errors=remount-ro \ - /dev/sdb + ${ktest_scratch_dev[0]} meta_write_fault_fn() { - mount -t bcachefs /dev/sdb /mnt + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt (sleep 2; set_faults "$1 enable") & # Should fail due to read only cache set @@ -1199,8 +1199,8 @@ test_long_name() set_watchdog 20 run_quiet "" bcachefs format -f \ --errors=panic \ - /dev/sdb - mount -t bcachefs /dev/sdb /mnt + ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt local i=1 local n="1" @@ -1212,7 +1212,7 @@ test_long_name() umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_many_files() @@ -1220,8 +1220,8 @@ test_many_files() set_watchdog 60 run_quiet "" bcachefs format -f \ --errors=panic \ - /dev/sdb - mount -t bcachefs /dev/sdb /mnt + ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt for i in {1..1000}; do touch /mnt/$i @@ -1229,10 +1229,10 @@ test_many_files() umount /mnt - mount -t bcachefs /dev/sdb /mnt + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } disabled_test_invalid_keys() @@ -1241,8 +1241,8 @@ disabled_test_invalid_keys() run_quiet "" bcachefs format -f \ --errors=continue \ - /dev/sdb - mount -t bcachefs /dev/sdb /mnt + ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt for i in {1..1000}; do touch /mnt/$i @@ -1250,7 +1250,7 @@ disabled_test_invalid_keys() umount /mnt - mount -t bcachefs -o fix_errors /dev/sdb /mnt + mount -t bcachefs -o fix_errors ${ktest_scratch_dev[0]} /mnt umount /mnt echo 0 > /sys/module/bcachefs/parameters/inject_invalid_keys @@ -1263,16 +1263,16 @@ test_buffered_reads() --errors=panic \ --bucket=8M \ --data_checksum=none \ - /dev/sdb + ${ktest_scratch_dev[0]} - mount -t bcachefs /dev/sdb /mnt + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt dd if=/dev/zero of=/mnt/foo bs=1M oflag=direct 2>/dev/null || true time dd if=/mnt/foo of=/dev/null bs=1M count=1024 umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_small_fs() @@ -1282,9 +1282,9 @@ test_small_fs() --errors=panic \ --bucket=4k \ --fs_size=512k \ - /dev/sdb + ${ktest_scratch_dev[0]} - mount -t bcachefs /dev/sdb /mnt + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt df -h /mnt dd if=/dev/zero of=/mnt/foo bs=4k oflag=direct 2>/dev/null || true @@ -1292,7 +1292,7 @@ test_small_fs() df -h /mnt umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_small_torture() @@ -1306,10 +1306,10 @@ test_small_fsck() run_quiet "" bcachefs format -f \ --errors=panic \ --fs_size=1M \ - /dev/sdb + ${ktest_scratch_dev[0]} for i in {1..100}; do - bcachefs fsck /dev/sdb + bcachefs fsck ${ktest_scratch_dev[0]} done } @@ -1319,19 +1319,19 @@ test_gc() run_quiet "" bcachefs format -f \ --errors=panic \ --compression=lz4 \ - /dev/sdb + ${ktest_scratch_dev[0]} - mount -t bcachefs /dev/sdb /mnt + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt antagonist_trigger_gc & run_fio_randrw umount /mnt - mount -t bcachefs /dev/sdb /mnt + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_attr_inherit() @@ -1339,9 +1339,9 @@ test_attr_inherit() set_watchdog 60 run_quiet "" bcachefs format -f \ --errors=panic \ - /dev/sdb + ${ktest_scratch_dev[0]} - mount -t bcachefs /dev/sdb /mnt + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt mkdir /mnt/foo mkdir /mnt/bar @@ -1365,7 +1365,7 @@ test_attr_inherit() umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_setattr() @@ -1373,9 +1373,9 @@ test_setattr() set_watchdog 60 run_quiet "" bcachefs format -f \ --errors=panic \ - /dev/sdb + ${ktest_scratch_dev[0]} - mount -t bcachefs /dev/sdb /mnt + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt mkdir /mnt/foo touch /mnt/foo/bar @@ -1386,17 +1386,17 @@ test_setattr() umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_mount_twice() { set_watchdog 60 mkdir -p /mnt/1 /mnt/2 - #run_quiet "" bcachefs format -f /dev/sdb - mkfs.ext2 /dev/sdb - mount -t ext2 /dev/sdb /mnt/1 - mount -t ext2 /dev/sdb /mnt/2 + #run_quiet "" bcachefs format -f ${ktest_scratch_dev[0]} + mkfs.ext2 ${ktest_scratch_dev[0]} + mount -t ext2 ${ktest_scratch_dev[0]} /mnt/1 + mount -t ext2 ${ktest_scratch_dev[0]} /mnt/2 umount /mnt/1 umount /mnt/2 @@ -1405,22 +1405,22 @@ test_mount_twice() test_dump() { set_watchdog 60 - run_quiet "" bcachefs format /dev/sdb + run_quiet "" bcachefs format ${ktest_scratch_dev[0]} - mount -t bcachefs /dev/sdb /mnt + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt touch /mnt/a touch /mnt/b umount /mnt - bcachefs dump -o /tmp/sdb.qcow2 /dev/sdb + bcachefs dump -o /tmp/sdb.qcow2 ${ktest_scratch_dev[0]} } test_kill_btree_node() { set_watchdog 240 - run_quiet "" bcachefs format --errors=panic /dev/sdb + run_quiet "" bcachefs format --errors=panic ${ktest_scratch_dev[0]} - mount -t bcachefs /dev/sdb /mnt + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt cp -a /usr /mnt umount /mnt @@ -1431,20 +1431,20 @@ test_kill_btree_node() [[ $btree = freespace ]] && index=0 - bcachefs kill_btree_node -b $btree -i $index /dev/sdb + bcachefs kill_btree_node -b $btree -i $index ${ktest_scratch_dev[0]} echo "Running fsck" # How to assert exit status equals something specific with -o errexit? - mount -t bcachefs -o fsck,fix_errors,verbose /dev/sdb /mnt + mount -t bcachefs -o fsck,fix_errors,verbose ${ktest_scratch_dev[0]} /mnt umount /mnt - #bcachefs fsck -y /dev/sdb || true + #bcachefs fsck -y ${ktest_scratch_dev[0]} || true echo echo "Running fsck again; should be clean" - bcachefs fsck -y /dev/sdb || true + bcachefs fsck -y ${ktest_scratch_dev[0]} || true done - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } main "$@" diff --git a/tests/bcachefs/subvol.ktest b/tests/bcachefs/subvol.ktest index e3f3d05..18f734c 100755 --- a/tests/bcachefs/subvol.ktest +++ b/tests/bcachefs/subvol.ktest @@ -11,8 +11,8 @@ test_snapshots_simple() bcachefs_antagonist - run_quiet "" bcachefs format -f --errors=panic /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt pushd /mnt for i in `seq 0 $NR_SNAPS`; do @@ -23,14 +23,14 @@ test_snapshots_simple() umount /mnt sleep 0.2 - bcachefs fsck -n /dev/sdb + bcachefs fsck -n ${ktest_scratch_dev[0]} exit for i in `seq 0 $NR_SNAPS|sort -r`; do umount /mnt sleep 0.2 - bcachefs fsck -n /dev/sdb - mount -t bcachefs /dev/sdb /mnt + bcachefs fsck -n ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt echo "deleting snap-$i" bcachefs subvolume delete /mnt/snap-$i @@ -39,18 +39,18 @@ test_snapshots_simple() umount /mnt sleep 0.2 - mount -t bcachefs -o fsck /dev/sdb /mnt + mount -t bcachefs -o fsck ${ktest_scratch_dev[0]} /mnt umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_files_many() { #bcachefs_antagonist - run_quiet "" bcachefs format -f --errors=panic /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt for i in $(seq 0 1000001); do echo $i > /mnt/$i @@ -58,18 +58,18 @@ test_files_many() umount /mnt sleep 0.2 - time mount -t bcachefs -o fsck /dev/sdb /mnt + time mount -t bcachefs -o fsck ${ktest_scratch_dev[0]} /mnt umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } d_test_snapshots_many() { #bcachefs_antagonist - run_quiet "" bcachefs format -f --errors=panic /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt cd /mnt @@ -80,10 +80,10 @@ d_test_snapshots_many() umount /mnt sleep 0.2 - mount -t bcachefs -o fsck /dev/sdb /mnt + mount -t bcachefs -o fsck ${ktest_scratch_dev[0]} /mnt umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_dbench() @@ -93,8 +93,8 @@ test_dbench() NR_SNAPS=10 - run_quiet "" bcachefs format -f --errors=panic /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt ( cd /mnt @@ -117,18 +117,18 @@ test_dbench() umount /mnt sleep 0.2 - #bcachefs fsck -n /dev/sdb - mount -t bcachefs -o fsck /dev/sdb /mnt + #bcachefs fsck -n ${ktest_scratch_dev[0]} + mount -t bcachefs -o fsck ${ktest_scratch_dev[0]} /mnt df -h /mnt umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_reflink() { - run_quiet "" bcachefs format -f --errors=panic /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt pushd /mnt cp -a /usr . @@ -138,13 +138,13 @@ test_reflink() umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } d_test_finsert() { - run_quiet "" bcachefs format -f --errors=panic /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt pushd /mnt dd if=/dev/zero of=foo bs=1M count=8 oflag=direct @@ -154,7 +154,7 @@ d_test_finsert() umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } d_test_snapshots_fio() @@ -162,8 +162,8 @@ d_test_snapshots_fio() # so wait doesn't hang [[ $(jobs -p) != "" ]] && kill $(jobs -p) - run_quiet "" bcachefs format -f --errors=panic /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt fallocate -l500M /mnt/fiotest @@ -222,7 +222,7 @@ d_test_snapshots_fio() for i in `seq 0 10|sort -r`; do umount /mnt sleep 0.1 - mount -t bcachefs -o fsck /dev/sdb /mnt + mount -t bcachefs -o fsck ${ktest_scratch_dev[0]} /mnt echo "deleting snap-$i" cd /mnt @@ -234,17 +234,17 @@ d_test_snapshots_fio() umount /mnt sleep 0.1 - mount -t bcachefs -o fsck /dev/sdb /mnt + mount -t bcachefs -o fsck ${ktest_scratch_dev[0]} /mnt df -h /mnt umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_subvol_create() { - run_quiet "" bcachefs format -f --errors=panic /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt bcachefs subvolume create /mnt/subvolume_1 touch /mnt/foo @@ -252,43 +252,43 @@ test_subvol_create() umount /mnt - bcachefs fsck -n /dev/sdb + bcachefs fsck -n ${ktest_scratch_dev[0]} - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_subvol_delete() { - run_quiet "" bcachefs format -f --errors=panic /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt bcachefs subvolume create /mnt/subvolume_1 rm -rf /mnt/subvolume_1 umount /mnt - bcachefs fsck -n /dev/sdb + bcachefs fsck -n ${ktest_scratch_dev[0]} - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_subvol_snapshot_create() { - run_quiet "" bcachefs format -f --errors=panic /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt bcachefs subvolume create /mnt/subvolume_1 bcachefs subvolume snapshot /mnt/subvolume_1 /mnt/snapshot_1 umount /mnt - bcachefs fsck -n /dev/sdb + bcachefs fsck -n ${ktest_scratch_dev[0]} - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_subvol_snapshot_create_ro() { - run_quiet "" bcachefs format -f --errors=panic /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt bcachefs subvolume create /mnt/subvolume_1 bcachefs subvolume snapshot -r /mnt/subvolume_1 /mnt/snapshot_1 @@ -296,30 +296,30 @@ test_subvol_snapshot_create_ro() umount /mnt - bcachefs fsck -n /dev/sdb + bcachefs fsck -n ${ktest_scratch_dev[0]} - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_subvol_snapshot_delete() { - run_quiet "" bcachefs format -f --errors=panic /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt bcachefs subvolume create /mnt/subvolume_1 bcachefs subvolume snapshot /mnt/subvolume_1 /mnt/snapshot_1 bcachefs subvolume delete /mnt/snapshot_1 umount /mnt - bcachefs fsck -n /dev/sdb + bcachefs fsck -n ${ktest_scratch_dev[0]} - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_subvol_snapshot_delete_create() { - run_quiet "" bcachefs format -f --errors=panic /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt bcachefs subvolume create /mnt/subvolume_1 bcachefs subvolume snapshot /mnt/subvolume_1 /mnt/snapshot_1 bcachefs subvolume delete /mnt/snapshot_1 @@ -327,75 +327,75 @@ test_subvol_snapshot_delete_create() umount /mnt - bcachefs fsck -n /dev/sdb + bcachefs fsck -n ${ktest_scratch_dev[0]} - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } d_test_subvol_snapshot_rm() { - run_quiet "" bcachefs format -f --errors=panic /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt bcachefs subvolume create /mnt/subvolume_1 bcachefs subvolume snapshot /mnt/subvolume_1 /mnt/snapshot_1 rm -r /mnt/snapshot_1 umount /mnt - bcachefs fsck -n /dev/sdb + bcachefs fsck -n ${ktest_scratch_dev[0]} - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } # Create a subvolume, then snapshot the parent subvolume, then move the child # subvolume: test_mkdir_mv_snapshot() { - run_quiet "" bcachefs format -f --errors=panic /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt mkdir /mnt/dir1 bcachefs subvolume snapshot /mnt/ /mnt/snap1 mv /mnt/dir1 /mnt/dir2 umount /mnt - bcachefs fsck -n /dev/sdb + bcachefs fsck -n ${ktest_scratch_dev[0]} - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_subvol_mv_snapshot() { - run_quiet "" bcachefs format -f --errors=panic /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt bcachefs subvolume create /mnt/sub1 bcachefs subvolume snapshot /mnt/ /mnt/snap1 mv /mnt/sub1 /mnt/sub2 umount /mnt - bcachefs fsck -n /dev/sdb + bcachefs fsck -n ${ktest_scratch_dev[0]} - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } # Test moving a subvol to another subvol test_subvol_mv_subvol() { - run_quiet "" bcachefs format -f --errors=panic /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt bcachefs subvolume create /mnt/sub1 bcachefs subvolume create /mnt/sub2 mv /mnt/sub1 /mnt/sub2 umount /mnt - bcachefs fsck -n /dev/sdb + bcachefs fsck -n ${ktest_scratch_dev[0]} - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_subvol_snapshot_reuse_snapshot_name() { - run_quiet "" bcachefs format -f --errors=panic /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt bcachefs subvolume create /mnt/subvolume_1 bcachefs subvolume snapshot /mnt/subvolume_1 /mnt/snapshot_1 bcachefs subvolume delete /mnt/snapshot_1 @@ -403,15 +403,15 @@ test_subvol_snapshot_reuse_snapshot_name() umount /mnt - bcachefs fsck -n /dev/sdb + bcachefs fsck -n ${ktest_scratch_dev[0]} - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_subvol_delete_snapshot_of_deleted_subvol() { - run_quiet "" bcachefs format -f --errors=panic /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt bcachefs subvolume create /mnt/subvolume_1 bcachefs subvolume snapshot /mnt/subvolume_1 /mnt/snapshot_1 rm -rf /mnt/subvolume_1 @@ -419,30 +419,30 @@ test_subvol_delete_snapshot_of_deleted_subvol() umount /mnt - bcachefs fsck -n /dev/sdb + bcachefs fsck -n ${ktest_scratch_dev[0]} - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_subvol_snapshot_delete_repeat() { - run_quiet "" bcachefs format -f --errors=panic /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt for i in $(seq 1 64); do bcachefs subvolume snapshot /mnt/$i bcachefs subvolume delete /mnt/$i done umount /mnt - bcachefs fsck -n /dev/sdb + bcachefs fsck -n ${ktest_scratch_dev[0]} - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_subvol_snapshot_delete_fio() { - run_quiet "" bcachefs format -f --errors=panic /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt for i in $(seq 1 10); do #run_fio_randrw --filesize=500M --bs=4k @@ -452,20 +452,20 @@ test_subvol_snapshot_delete_fio() for i in $(seq 1 10); do umount /mnt - bcachefs fsck -n /dev/sdb - mount -t bcachefs -o fsck /dev/sdb /mnt + bcachefs fsck -n ${ktest_scratch_dev[0]} + mount -t bcachefs -o fsck ${ktest_scratch_dev[0]} /mnt done umount /mnt - bcachefs fsck -n /dev/sdb + bcachefs fsck -n ${ktest_scratch_dev[0]} - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_snapshot_copygc() { - run_quiet "" bcachefs format -f --errors=panic /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt for i in $(seq 1 4); do run_fio_randrw --filesize=1000M --loops=4 --bs=4k @@ -475,13 +475,13 @@ test_snapshot_copygc() bcachefs fs usage -h /mnt umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_snapshot_many_overwrite() { - run_quiet "" bcachefs format -f --errors=panic /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt for i in $(seq 1 100); do echo foo > /mnt/test @@ -491,13 +491,13 @@ test_snapshot_many_overwrite() bcachefs fs usage -h /mnt umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_snapshot_prjquota() { - run_quiet "" bcachefs format -f --errors=panic --prjquota /dev/sdb - mount -t bcachefs /dev/sdb /mnt + run_quiet "" bcachefs format -f --errors=panic --prjquota ${ktest_scratch_dev[0]} + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt echo foo > /mnt/test bcachefs subvolume snapshot /mnt/snap.$i @@ -505,10 +505,10 @@ test_snapshot_prjquota() bcachefs fs usage -h /mnt umount /mnt - mount -t bcachefs /dev/sdb /mnt + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } main "$@" diff --git a/tests/bcachefs/tier.ktest b/tests/bcachefs/tier.ktest index 9f5bcb2..8aa0db4 100755 --- a/tests/bcachefs/tier.ktest +++ b/tests/bcachefs/tier.ktest @@ -13,10 +13,10 @@ run_basic_tiering_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 \ + --label=ssd.ssd1 ${ktest_scratch_dev[0]} \ + --label=ssd.ssd2 ${ktest_scratch_dev[1]} \ + --label=hdd.hdd1 ${ktest_scratch_dev[2]} \ + --label=hdd.hdd2 ${ktest_scratch_dev[3]} \ --foreground_target=ssd \ --promote_target=ssd \ --background_target=hdd @@ -27,15 +27,15 @@ 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 \ + --label=ssd.ssd1 ${ktest_scratch_dev[0]} \ + --label=ssd.ssd2 ${ktest_scratch_dev[1]} \ + --label=hdd.hdd1 ${ktest_scratch_dev[2]} \ + --label=hdd.hdd2 ${ktest_scratch_dev[3]} \ --foreground_target=ssd \ --promote_target=ssd \ --background_target=hdd - mount -t bcachefs /dev/sdb:/dev/sdc:/dev/sdd:/dev/sde /mnt + mount -t bcachefs ${ktest_scratch_dev[0]}:${ktest_scratch_dev[1]}:${ktest_scratch_dev[2]}:${ktest_scratch_dev[3]} /mnt run_fio_randrw mv /mnt/fiotest /mnt/fiotest_old run_fio_randrw --loops=50 @@ -43,7 +43,7 @@ test_tiering_torture() mount -o remount,ro /mnt umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_tiering() @@ -57,13 +57,13 @@ test_tiering_drop_alloc() # 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 + mount -t bcachefs -o reconstruct_alloc,fsck,fix_errors "$(join_by : "${ktest_scratch_dev[@]}")" /mnt umount /mnt echo "final fsck:" - bcachefs fsck -n /dev/sd[bcde] + bcachefs fsck -n "${ktest_scratch_dev[@]}" - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_tiering_buffered() @@ -72,15 +72,15 @@ test_tiering_buffered() 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 \ + --label=ssd.ssd1 ${ktest_scratch_dev[0]} \ + --label=ssd.ssd2 ${ktest_scratch_dev[1]} \ + --label=hdd.hdd1 ${ktest_scratch_dev[2]} \ + --label=hdd.hdd2 ${ktest_scratch_dev[3]} \ --foreground_target=ssd \ --promote_target=ssd \ --background_target=hdd - mount -t bcachefs /dev/sdb:/dev/sdc:/dev/sdd:/dev/sde /mnt + mount -t bcachefs "$(join_by : "${ktest_scratch_dev[@]}")" /mnt local loops=$((($ktest_priority + 1) * 4)) @@ -99,24 +99,24 @@ test_tiering_buffered() --bsrange=512-16k umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } 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 \ + run_basic_fio_test "$@" \ + --durability=0 --label=ssd ${ktest_scratch_dev[0]} ${ktest_scratch_dev[1]} \ + --durability=1 --label=hdd ${ktest_scratch_dev[2]} ${ktest_scratch_dev[3]} \ + --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 \ + --durability=0 --label=ssd ${ktest_scratch_dev[0]} \ + --durability=1 --label=hdd ${ktest_scratch_dev[2]} \ --foreground_target=hdd \ --promote_target=ssd \ --background_target=hdd @@ -127,21 +127,21 @@ test_setattr() setup_tracing 'bcachefs:*' run_quiet "" bcachefs format \ - --durability=0 --label=ssd /dev/sdb \ - --durability=1 --label=hdd /dev/sdd \ + --durability=0 --label=ssd ${ktest_scratch_dev[0]} \ + --durability=1 --label=hdd ${ktest_scratch_dev[2]} \ --background_target=hdd - mount -t bcachefs /dev/sdb:/dev/sdd /mnt + mount -t bcachefs ${ktest_scratch_dev[0]}:${ktest_scratch_dev[2]} /mnt touch /mnt/foo touch /mnt/bar - bcachefs setattr --foreground_target sdb /mnt/ + bcachefs setattr --foreground_target $(basename ${ktest_scratch_dev[0]}) /mnt/ bcachefs setattr --promote_target ssd /mnt/ umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } test_tiering_no_checksum() @@ -177,10 +177,10 @@ test_tiering_replication() 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 \ + --label=ssd --bucket=32k ${ktest_scratch_dev[0]} \ + --label=ssd --bucket=64k ${ktest_scratch_dev[1]} \ + --label=hdd --bucket=128k ${ktest_scratch_dev[3]} \ + --label=hdd --bucket=256k ${ktest_scratch_dev[2]} \ --foreground_target=ssd \ --promote_target=ssd \ --background_target=hdd @@ -190,10 +190,10 @@ 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 \ + --label=ssd --bucket=32k ${ktest_scratch_dev[0]} \ + --label=ssd --bucket=64k ${ktest_scratch_dev[1]} \ + --label=hdd --bucket=128k ${ktest_scratch_dev[3]} \ + --label=hdd --bucket=256k ${ktest_scratch_dev[2]} \ --foreground_target=ssd \ --promote_target=ssd \ --background_target=hdd @@ -202,52 +202,52 @@ test_tiering_variable_buckets_replicas() test_device_add() { set_watchdog 60 - run_quiet "" bcachefs format \ - --label=ssd /dev/sdb \ - --label=hdd /dev/sd[de] + run_quiet "" bcachefs format \ + --label=ssd ${ktest_scratch_dev[0]} \ + --label=hdd ${ktest_scratch_dev[2]} ${ktest_scratch_dev[3]} - mount -t bcachefs /dev/sdb:/dev/sdd:/dev/sde /mnt + mount -t bcachefs ${ktest_scratch_dev[0]}:${ktest_scratch_dev[2]}:${ktest_scratch_dev[3]} /mnt run_fio_randrw|tail -n200 & - bcachefs device add --label=hdd /mnt /dev/sdc + bcachefs device add --label=hdd /mnt ${ktest_scratch_dev[1]} wait umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } 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 \ + run_quiet "" bcachefs format \ + --replicas=2 \ + --label=ssd ${ktest_scratch_dev[0]} ${ktest_scratch_dev[1]} \ + --label=hdd ${ktest_scratch_dev[2]} ${ktest_scratch_dev[3]} \ + --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 + mount -t bcachefs "$(join_by : "${ktest_scratch_dev[@]}")" /mnt umount /mnt done - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } 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 \ + run_quiet "" bcachefs format \ + --label=ssd ${ktest_scratch_dev[0]} ${ktest_scratch_dev[1]} \ + --label=hdd ${ktest_scratch_dev[2]} ${ktest_scratch_dev[3]} \ + --foreground_target=ssd \ + --promote_target=ssd \ --background_target=hdd - mount -t bcachefs /dev/sdb:/dev/sdc:/dev/sdd:/dev/sde /mnt + mount -t bcachefs "$(join_by : "${ktest_scratch_dev[@]}")" /mnt ( cd /sys/fs/bcachefs/* @@ -280,7 +280,7 @@ test_change_replicas() kill %1 umount /mnt - check_counters /dev/sdb + check_counters ${ktest_scratch_dev[0]} } main $@ diff --git a/tests/bcachefs/units.ktest b/tests/bcachefs/units.ktest index df5a2e4..b19f2b0 100755 --- a/tests/bcachefs/units.ktest +++ b/tests/bcachefs/units.ktest @@ -24,10 +24,10 @@ run_test() bcachefs format \ --errors=panic \ - /dev/sdb >/dev/null + ${ktest_scratch_dev[0]} >/dev/null #--bucket=$btree_node_size \ #--btree_node_size=$btree_node_size \ - mount -t bcachefs /dev/sdb /mnt + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt ln -sf /sys/fs/bcachefs/*/perf_test p for i in $@; do diff --git a/tests/blkdev.ktest b/tests/blkdev.ktest index 4f7e166..75eba78 100755 --- a/tests/blkdev.ktest +++ b/tests/blkdev.ktest @@ -29,10 +29,10 @@ run_fio() test_block_simple() { - #run_fio /dev/sdb + #run_fio ${ktest_scratch_dev[0]} - mkfs.ext4 /dev/sdb - mount /dev/sdb /mnt + mkfs.ext4 ${ktest_scratch_dev[0]} + mount ${ktest_scratch_dev[0]} /mnt run_fio /mnt/foo --size=1G umount /mnt } diff --git a/tests/blktests.ktest b/tests/blktests.ktest index 56e5ff8..6af7e07 100755 --- a/tests/blktests.ktest +++ b/tests/blktests.ktest @@ -34,6 +34,6 @@ run_test() { dmesg -n 4 cd "$ktest_dir/tests/blktests" - echo 'TEST_DEVS=(/dev/sdb)' > config + echo 'TEST_DEVS=(${ktest_scratch_dev[0]})' > config ./check "$@" } diff --git a/tests/block/discard b/tests/block/discard index 82717e0..f1d9669 100755 --- a/tests/block/discard +++ b/tests/block/discard @@ -16,7 +16,7 @@ modprobe scsi_debug dev_size_mb=1024 stride=8192 for i in `seq 0 $stride 4194304`; do - hdparm --please-destroy-my-drive --trim-sector-ranges $i:$stride /dev/sdb > /dev/null 2> /dev/null + hdparm --please-destroy-my-drive --trim-sector-ranges $i:$stride ${ktest_scratch_dev[0]} > /dev/null 2> /dev/null done echo "TEST SUCCESSFUL" diff --git a/tests/fio.ktest b/tests/fio.ktest index fb6a674..c9ca01d 100755 --- a/tests/fio.ktest +++ b/tests/fio.ktest @@ -8,7 +8,7 @@ config-timeout 7200 test_buffered_reads() { - blockdev --setra 0 /dev/sdb + blockdev --setra 0 ${ktest_scratch_dev[0]} fio --eta=always \ --exitall_on_error=1 \ --randrepeat=0 \ diff --git a/tests/md.ktest b/tests/md.ktest index 20617c7..5589b6b 100755 --- a/tests/md.ktest +++ b/tests/md.ktest @@ -41,8 +41,8 @@ run_fio() run_mdtest() { - wipefs -a /dev/sd[bcde] - mdadm --create --force -n4 -l$1 /dev/md0 /dev/sd[bcde] + wipefs -a "${ktest_scratch_dev[@]}" + mdadm --create --force -n4 -l$1 /dev/md0 "${ktest_scratch_dev[@]}" run_fio /dev/md0 diff --git a/tests/prelude.sh b/tests/prelude.sh index a10152e..0bacb65 100644 --- a/tests/prelude.sh +++ b/tests/prelude.sh @@ -17,15 +17,27 @@ if [[ ! -v ktest_verbose ]]; then ktest_storage_bus=ahci ktest_images=() - ktest_scratch_devs=() + + ktest_scratch_dev=() + ktest_scratch_dev_sizes=() + ktest_scratch_dev_count=0 + ktest_make_install=() ktest_kernel_config_require=() ktest_qemu_append=() - NEXT_SCRATCH_DEV="b" BUILD_ON_HOST="" fi +case $ktest_storage_bus in + virtio-blk) + ktest_dev_prefix="vd" + ;; + *) + ktest_dev_prefix="sd" + ;; +esac + require-git() { local req="$1" @@ -118,7 +130,12 @@ require-kernel-append() config-scratch-devs() { - ktest_scratch_devs+=("$1") + local chars=( {b..z} ) + + ktest_scratch_dev+=("/dev/${ktest_dev_prefix}${chars[$ktest_scratch_dev_count]}") + ktest_scratch_dev_count=$((ktest_scratch_dev_count + 1)) + + ktest_scratch_dev_sizes+=("$1") } config-pmem-devs() @@ -251,7 +268,7 @@ main() echo "ktest_kernel_append=(${ktest_kernel_append[@]})" echo "ktest_storage_bus=$ktest_storage_bus" echo "ktest_images=(${ktest_images[@]})" - echo "ktest_scratch_devs=(${ktest_scratch_devs[@]})" + echo "ktest_scratch_dev_sizes=(${ktest_scratch_dev_sizes[@]})" echo "ktest_make_install=(${ktest_make_install[@]})" echo "ktest_kernel_config_require=(${ktest_kernel_config_require[@]})" echo "ktest_qemu_append=(${ktest_qemu_append[@]})" diff --git a/tests/xfstests.sh b/tests/xfstests.sh index 1cc1fa4..6b39986 100644 --- a/tests/xfstests.sh +++ b/tests/xfstests.sh @@ -1,3 +1,4 @@ +#!/bin/bash # xfstests wrapper: . $(dirname $(readlink -e "${BASH_SOURCE[0]}"))/test-libs.sh @@ -32,8 +33,8 @@ run_xfstests() shift if [[ ! -f /xfstests-init-done ]]; then - mkswap /dev/sde - swapon /dev/sde + mkswap ${ktest_scratch_dev[3]} + swapon ${ktest_scratch_dev[3]} useradd -m fsgqa useradd fsgqa2 @@ -45,28 +46,28 @@ run_xfstests() rm -rf /ktest-out/xfstests - wipefs -af /dev/sdb - mkfs.$FSTYP $MKFS_OPTIONS -q /dev/sdb + wipefs -af ${ktest_scratch_dev[0]} + mkfs.$FSTYP $MKFS_OPTIONS -q ${ktest_scratch_dev[0]} touch /xfstests-init-done fi # mkfs.xfs 5.19 requires these variables to be exported into its # environment to allow sub-300MB filesystems for fstests. - export TEST_DEV=/dev/sdb + export TEST_DEV=${ktest_scratch_dev[0]} export TEST_DIR=/mnt/test cat << EOF > /ktest/tests/xfstests/local.config -TEST_DEV=$TEST_DEV +TEST_DEV=${ktest_scratch_dev[0]} TEST_DIR=$TEST_DIR -SCRATCH_DEV=/dev/sdc +SCRATCH_DEV=${ktest_scratch_dev[1]} SCRATCH_MNT=/mnt/scratch -LOGWRITES_DEV=/dev/sdd +LOGWRITES_DEV=${ktest_scratch_dev[2]} RESULT_BASE=/ktest-out/xfstests LOGGER_PROG=true EOF export MKFS_OPTIONS - mount -t $FSTYP /dev/sdb /mnt/test + mount -t $FSTYP ${ktest_scratch_dev[0]} /mnt/test cd "$ktest_dir/tests/xfstests" ./check "$@" |