Skip to content

Commit

Permalink
tests/bcachefs: new contributed tests
Browse files Browse the repository at this point in the history
Signed-off-by: Kent Overstreet <[email protected]>
  • Loading branch information
Kent Overstreet committed Feb 17, 2024
1 parent 91c9a63 commit fc29daf
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/bcachefs/single_device.ktest
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"
20 changes: 20 additions & 0 deletions tests/bcachefs/subvol.ktest
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"

0 comments on commit fc29daf

Please sign in to comment.