From fc29dafd7afffe6fbef764495d281ce3041a1c00 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Thu, 4 Jan 2024 21:07:27 -0500 Subject: [PATCH] tests/bcachefs: new contributed tests Signed-off-by: Kent Overstreet --- tests/bcachefs/single_device.ktest | 44 ++++++++++++++++++++++++++++++ tests/bcachefs/subvol.ktest | 20 ++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/tests/bcachefs/single_device.ktest b/tests/bcachefs/single_device.ktest index d036207..8fbd753 100755 --- a/tests/bcachefs/single_device.ktest +++ b/tests/bcachefs/single_device.ktest @@ -1636,4 +1636,48 @@ test_kernel_fsck() check_counters ${ktest_scratch_dev[0]} } +test_nocow_fragmented() +{ + set_watchdog 60 + run_quiet "" bcachefs format -f \ + --errors=panic \ + ${ktest_scratch_dev[0]} + + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt + + run_fio_randrw + echo 1 > /sys/fs/bcachefs/*/options/nocow + dd if=/dev/zero of=/mnt/fiotest bs=1M oflag=direct + umount /mnt + + bcachefs fsck -ny ${ktest_scratch_dev[0]} + check_counters ${ktest_scratch_dev[0]} +} + +config-mem 16G + +test_nocow_fragmented2() +{ + modprobe brd rd_size=536870912 rd_nr=7 + bcachefs format -f --nocow \ + --foreground_target=/dev/ram4 \ + --promote_target=/dev/ram5 \ + /dev/ram1 /dev/ram2 /dev/ram5 /dev/ram0 \ + /dev/ram4 /dev/ram6 /dev/ram3 + mount -t bcachefs /dev/ram1:/dev/ram2:/dev/ram5:/dev/ram0:/dev/ram4:/dev/ram6:/dev/ram3 /mnt + fio --group_reporting \ + --ioengine=io_uring \ + --directory=/mnt --size=16m \ + --time_based --runtime=60s \ + --iodepth=256 --verify_async=8 \ + --bs=4k-64k --norandommap \ + --random_distribution=zipf:0.5 --numjobs=16 --rw=randrw \ + --name=A --direct=1 --name=B --direct=0 >/dev/null & + sleep 10 + bcachefs device offline /dev/ram5 + + wait + umount /mnt +} + main "$@" diff --git a/tests/bcachefs/subvol.ktest b/tests/bcachefs/subvol.ktest index 4a50da2..de9ce7e 100755 --- a/tests/bcachefs/subvol.ktest +++ b/tests/bcachefs/subvol.ktest @@ -736,4 +736,24 @@ test_subvol_rmdir_empty_snapshot() bcachefs fsck ${ktest_scratch_dev[0]} } +test_snapshot_reflink() +{ + run_quiet "" bcachefs format -f ${ktest_scratch_dev[0]} + mount -t bcachefs -o noinline_data ${ktest_scratch_dev[0]} /mnt + + cp /usr/bin/cp /mnt/file + #echo Test > /mnt/file + bcachefs subvolume snapshot /mnt/snapshot + + cp --reflink=always /mnt/snapshot/file /mnt/file1 + rm /mnt/file + cp --reflink=always /mnt/snapshot/file /mnt/file2 + + md5sum /mnt/file* /mnt/snapshot/file /usr/bin/cp + umount /mnt + + mount -t bcachefs -o fsck ${ktest_scratch_dev[0]} /mnt + umount /mnt +} + main "$@"