summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-06-23 00:16:14 -0400
committerKent Overstreet <kent.overstreet@gmail.com>2022-06-23 00:16:14 -0400
commit3cbb28191eafb06c4ad64bf5efb047f4d8277d67 (patch)
treeee83c32bcae3569e19500a7ef70375da954e68d9
parent3eed383f06e4ea61eb8b1954c579beca641e33b5 (diff)
bcachefs test updates
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
-rw-r--r--tests/bcachefs/bcachefs-test-libs.sh18
-rw-r--r--tests/bcachefs/ec.ktest85
-rw-r--r--tests/bcachefs/quota.ktest36
-rw-r--r--tests/bcachefs/replication.ktest100
-rw-r--r--tests/bcachefs/single_device.ktest542
-rw-r--r--tests/bcachefs/subvol.ktest221
-rw-r--r--tests/bcachefs/tier.ktest47
-rw-r--r--tests/bcachefs/units.ktest1
8 files changed, 737 insertions, 313 deletions
diff --git a/tests/bcachefs/bcachefs-test-libs.sh b/tests/bcachefs/bcachefs-test-libs.sh
index d8f4b5c..4eda9b6 100644
--- a/tests/bcachefs/bcachefs-test-libs.sh
+++ b/tests/bcachefs/bcachefs-test-libs.sh
@@ -98,14 +98,20 @@ antagonist_switch_crc()
bcachefs_antagonist()
{
- setup_tracing 'bcachefs:*'
+ #setup_tracing
+ #setup_tracing 'bcachefs:*'
#echo 1 > /sys/module/bcachefs/parameters/expensive_debug_checks
#echo 1 > /sys/module/bcachefs/parameters/debug_check_iterators
#echo 1 > /sys/module/bcachefs/parameters/debug_check_bkeys
+ #echo 1 > /sys/module/bcachefs/parameters/debug_check_btree_accounting
#echo 1 > /sys/module/bcachefs/parameters/test_alloc_startup
+ #echo 1 > /sys/module/bcachefs/parameters/test_restart_gc
+ #echo 1 > /sys/module/bcachefs/parameters/test_reconstruct_alloc
#echo 1 > /sys/module/bcachefs/parameters/verify_btree_ondisk
+ #echo 1 > /sys/module/bcachefs/parameters/verify_all_btree_replicas
#echo 1 > /sys/module/bcachefs/parameters/btree_gc_coalesce_disabled
#echo 1 > /sys/module/bcachefs/parameters/key_merging_disabled
+ #echo 1 > /sys/module/bcachefs/parameters/journal_seq_verify
#enable_race_faults
@@ -113,7 +119,7 @@ bcachefs_antagonist()
antagonist_shrink &
antagonist_sync &
antagonist_trigger_gc &
- antagonist_switch_str_hash &
+ #antagonist_switch_str_hash &
}
fill_device()
@@ -185,7 +191,7 @@ run_basic_fio_test()
bcachefs_antagonist
- run_quiet "" bcachefs format -f --errors=panic "$@"
+ run_quiet "" bcachefs format -f --discard --no_initialize "$@"
mount -t bcachefs -o fsck $(join_by : "${devs[@]}") /mnt
@@ -197,10 +203,10 @@ run_basic_fio_test()
umount /mnt
# test remount:
- mount -t bcachefs -o fsck $(join_by : "${devs[@]}") /mnt
- umount /mnt
+ #mount -t bcachefs -o fsck $(join_by : "${devs[@]}") /mnt
+ #umount /mnt
- #bcachefs fsck "${devs[@]}"
+ bcachefs fsck -n "${devs[@]}"
}
require-kernel-config DEBUG_FS
diff --git a/tests/bcachefs/ec.ktest b/tests/bcachefs/ec.ktest
index cfa99c4..0de6f1c 100644
--- a/tests/bcachefs/ec.ktest
+++ b/tests/bcachefs/ec.ktest
@@ -16,8 +16,7 @@ config-timeout $(stress_timeout)
test_ec_small()
{
- #echo 1 > /sys/module/bcachefs/parameters/force_reconstruct_read
- #echo 1 > /sys/module/bcachefs/parameters/debug_check_bkeys
+ bcachefs_antagonist
run_quiet "" bcachefs format -f \
--errors=panic \
@@ -29,7 +28,7 @@ test_ec_small()
mount -t bcachefs $devs /mnt
#enable_memory_faults
- dd if=/dev/zero of=/mnt/foo bs=8M count=2 oflag=sync
+ dd if=/dev/zero of=/mnt/foo bs=1M count=1 oflag=sync
#disable_memory_faults
mount -o remount,ro /mnt
@@ -44,7 +43,7 @@ test_ec_small()
mount -t bcachefs -o fsck $devs /mnt
umount /mnt
- #bcachefs fsck /dev/sd[bcdef]
+ bcachefs fsck /dev/sd[bcdef]
}
test_ec_umount()
@@ -64,14 +63,14 @@ test_ec_umount()
done
}
-test_ec()
+do_ec_test()
{
- #echo 1 > /sys/module/bcachefs/parameters/force_reconstruct_read
- #echo 1 > /sys/module/bcachefs/parameters/debug_check_bkeys
+ bcachefs_antagonist
run_quiet "" bcachefs format -f \
--errors=panic \
--erasure_code \
+ "$@" \
--replicas=2 \
/dev/sd[bcdef]
devs=/dev/sdb:/dev/sdc:/dev/sdd:/dev/sde:/dev/sdf
@@ -79,55 +78,44 @@ test_ec()
mount -t bcachefs $devs /mnt
#enable_memory_faults
+
run_fio_randrw
+
#disable_memory_faults
- #bcachefs fs usage -h /mnt
+ bcachefs fs usage -h /mnt
umount /mnt
+ bcachefs fsck -n /dev/sd[bcdef]
# test remount:
echo "Testing remount"
mount -t bcachefs -o fsck $devs /mnt
+ cat /mnt/fiotest > /dev/null
umount /mnt
+}
- #bcachefs fsck /dev/sd[bcdef]
+test_ec()
+{
+ do_ec_test
}
test_ec_lz4()
{
- #echo 1 > /sys/module/bcachefs/parameters/force_reconstruct_read
- #echo 1 > /sys/module/bcachefs/parameters/debug_check_bkeys
-
- run_quiet "" bcachefs format -f \
- --errors=panic \
- --erasure_code \
- --compression=lz4 \
- --replicas=2 \
- /dev/sd[bcdef]
- devs=/dev/sdb:/dev/sdc:/dev/sdd:/dev/sde:/dev/sdf
-
- mount -t bcachefs $devs /mnt
-
- #enable_memory_faults
- run_fio_randrw
- #dd if=/dev/zero of=/mnt/foo bs=1M count=10 oflag=direct
- #disable_memory_faults
-
- #bcachefs fs usage -h /mnt
- umount /mnt
+ do_ec_test --compression=lz4
+}
- # test remount:
- echo "Testing remount"
- mount -t bcachefs -o fsck $devs /mnt
- umount /mnt
+test_ec_crypto()
+{
+ do_ec_test --encrypted --no_passphrase
+}
- #bcachefs fsck /dev/sd[bcdef]
+test_ec_crypto_lz4()
+{
+ do_ec_test --encrypted --no_passphrase --compression=lz4
}
test_ec_mixed_tiers()
{
- #echo 1 > /sys/module/bcachefs/parameters/force_reconstruct_read
- #echo 1 > /sys/module/bcachefs/parameters/debug_check_bkeys
run_quiet "" bcachefs format -f \
--errors=panic \
@@ -145,10 +133,10 @@ test_ec_mixed_tiers()
#enable_memory_faults
run_fio_randrw
- #dd if=/dev/zero of=/mnt/foo bs=1M count=10 oflag=direct
+ #dd if=/dev/zero of=/mnt/foo bs=1M count=100 oflag=direct
#disable_memory_faults
- #bcachefs fs usage -h /mnt
+ bcachefs fs usage -h /mnt
umount /mnt
# test remount:
@@ -156,15 +144,12 @@ test_ec_mixed_tiers()
mount -t bcachefs -o fsck $devs /mnt
umount /mnt
- #bcachefs fsck /dev/sd[bcdef]
+ bcachefs fsck /dev/sd[bcdef]
}
test_ec_gc()
{
- #echo 1 > /sys/module/bcachefs/parameters/force_reconstruct_read
- echo 1 > /sys/module/bcachefs/parameters/debug_check_bkeys
- #echo 1 > /sys/module/bcachefs/parameters/expensive_debug_checks
- #echo 1 > /sys/module/bcachefs/parameters/debug_check_iterators
+ bcachefs_antagonist
run_quiet "" bcachefs format -f \
--errors=continue \
@@ -198,14 +183,14 @@ test_ec_gc()
echo unmounting
exit
- #bcachefs fs usage -h /mnt
+ bcachefs fs usage -h /mnt
umount /mnt
# test remount:
mount -t bcachefs -o fix_errors,erasure_code $devs /mnt
umount /mnt
- #bcachefs fsck /dev/sd[bcdef]
+ bcachefs fsck /dev/sd[bcdef]
}
do_remove_test()
@@ -221,7 +206,7 @@ do_remove_test()
mount -t bcachefs /dev/sdb:/dev/sdc:/dev/sdd:/dev/sde:/dev/sdf /mnt
- local fioout="$ktest_tmp/fioout"
+ local fioout="$ktest_out/fio-out"
run_fio_randrw >"$fioout" 2>&1 &
local fiopid=$!
@@ -258,22 +243,22 @@ do_remove_test()
umount /mnt
}
-test_device_remove_offline()
+d_test_device_remove_offline()
{
do_remove_test 1 0
}
-test_device_remove_online()
+d_test_device_remove_online()
{
do_remove_test 0 0
}
-test_device_evacuate_offline()
+d_test_device_evacuate_offline()
{
do_remove_test 1 1
}
-test_device_evacuate_online()
+d_test_device_evacuate_online()
{
do_remove_test 0 1
}
diff --git a/tests/bcachefs/quota.ktest b/tests/bcachefs/quota.ktest
index 4022cbb..9433ec8 100644
--- a/tests/bcachefs/quota.ktest
+++ b/tests/bcachefs/quota.ktest
@@ -9,7 +9,9 @@ config-scratch-devs 4G
config-scratch-devs 4G
config-timeout $(stress_timeout)
-require-make linuxquota-code
+
+require-git http://evilpiepirate.org/git/linuxquota.git
+require-make linuxquota
test_usrquota_twodevices()
{
@@ -101,10 +103,9 @@ test_grpquota()
test_prjquota()
{
-# bcachefs format \
-# --errors=panic \
-# /dev/sdb >/dev/null
- mkfs.xfs /dev/sdb
+ bcachefs format \
+ --errors=panic \
+ /dev/sdb >/dev/null
mount -o usrquota,grpquota,prjquota /dev/sdb /mnt
@@ -115,7 +116,7 @@ test_prjquota()
touch /mnt/q1/foo
setproject -c -P q1 /mnt/q1
- setproject -c -P q2 /mnt/q2
+ setproject -c -P q2_averylongprojectquotanamefooooooooooooooooooooooooooooooooooooooooobar /mnt/q2
getfattr -R -d -m - /mnt/
@@ -131,7 +132,7 @@ test_prjquota()
#mv /mnt/q1/foo /mnt/q2
repquota -P -s /mnt
-# umount /mnt
+ umount /mnt
}
test_prjquota_multidevices()
@@ -165,24 +166,3 @@ test_prjquota_multidevices()
umount /mnt
}
-
-test_xfs_prjquota()
-{
- mkfs.xfs /dev/sdb
-
- mount -o usrquota,grpquota,prjquota /dev/sdb /mnt
-
- repquota -P -s /mnt
-
- touch /mnt/foo
- setproject -c -P foo /mnt
-
- #setquota -t 60 60 /mnt
- setquota -P foo 256M 512M 64 128 /mnt
-
- echo "testing direct writes"
- ! dd if=/dev/zero of=/mnt/foo bs=1M oflag=direct
- repquota -P -s /mnt
-
- umount /mnt
-}
diff --git a/tests/bcachefs/replication.ktest b/tests/bcachefs/replication.ktest
index a3d8e61..31ea161 100644
--- a/tests/bcachefs/replication.ktest
+++ b/tests/bcachefs/replication.ktest
@@ -12,27 +12,15 @@ config-scratch-devs 4G
config-scratch-devs 4G
config-scratch-devs 4G
-config-timeout $(stress_timeout)
-
-test_mount()
-{
- run_quiet "" bcachefs format /dev/sd[bcdef]
-}
+config-mem 4G
-test_foo()
-{
- run_quiet "" bcachefs format --data_checksum=none --bucket=8M /dev/sdb
- mount /dev/sdb /mnt
- bcachefs device add /mnt /dev/sdd
- bcachefs device add /mnt /dev/sde
- dd if=/dev/zero of=/mnt/foo bs=8M count=1024 oflag=direct
-}
+config-timeout $(stress_timeout)
test_recovery()
{
run_quiet "" bcachefs format \
--discard \
- --bucket=16k \
+ --bucket=64k \
--block_size=4k \
/dev/sd[bcd]
@@ -113,7 +101,8 @@ test_largebuckets()
run_quiet "" bcachefs format -f --bucket=8M /dev/sd[bcd]
mount -t bcachefs /dev/sdb:/dev/sdc:/dev/sdd /mnt
- dd if=/dev/zero of=/mnt/foo bs=16M count=1024 oflag=direct
+ dd if=/dev/zero of=/mnt/foo bs=8M count=1024 oflag=direct
+ umount /mnt
}
test_replicas()
@@ -125,14 +114,21 @@ test_replicas()
test_replicas_variable_buckets()
{
- run_basic_fio_test \
- --replicas=2 \
- --bucket=32k /dev/sdb \
- --bucket=64k /dev/sdc \
- --bucket=128k /dev/sdd
+ run_quiet "" bcachefs format -f --errors=panic \
+ --replicas=2 \
+ --bucket=32k /dev/sdb \
+ --bucket=64k /dev/sdc \
+ --bucket=128k /dev/sdd \
+ --bucket=128k /dev/sde \
+ --bucket=128k /dev/sdf
+
+ mount -t bcachefs /dev/sdb:/dev/sdc:/dev/sdd:/dev/sde:/dev/sdf /mnt
+ fs_mark -v -n 20000 -s 4096 -k -S 0 -D 1000 -N 100000 -d /mnt -t 60
+ df -h /mnt
+ umount /mnt
}
-test_copygc_torture()
+d_test_copygc_torture()
{
loops=$((($ktest_priority + 1) * 4))
@@ -188,13 +184,12 @@ do_remove_test()
evacuate=$2
run_quiet "" bcachefs format \
- --errors=panic \
--replicas=2 \
/dev/sd[bcd]
mount -t bcachefs /dev/sdb:/dev/sdc:/dev/sdd /mnt
- local fioout="$ktest_tmp/fioout"
+ local fioout="$ktest_out/fio-out"
run_fio_randrw >"$fioout" 2>&1 &
local fiopid=$!
@@ -212,11 +207,15 @@ do_remove_test()
echo "done"
fi
+ bcachefs fs usage -h /mnt
+
echo -n "removing /dev/sdb... "
if [[ $evacuate = 1 ]]; then
- bcachefs device remove /dev/sdb
+ #bcachefs device remove /dev/sdb
+ bcachefs device remove 0 /mnt
else
- bcachefs device remove --force /dev/sdb
+ #bcachefs device remove --force /dev/sdb
+ bcachefs device remove --force 0 /mnt
fi
echo "done"
@@ -225,6 +224,7 @@ do_remove_test()
return 1
fi
+ bcachefs fs usage -h /mnt
umount /mnt
mount -t bcachefs /dev/sdb:/dev/sdc:/dev/sdd /mnt
@@ -253,17 +253,17 @@ test_device_evacuate_online()
test_device_add()
{
- setup_tracing 'bcachefs:*'
+ #setup_tracing 'bcachefs:*'
run_quiet "" bcachefs format \
--block_size=4k \
--errors=panic \
+ --no_initialize \
/dev/sdb
mount /dev/sdb /mnt
- local fioout="$ktest_tmp/fioout"
- run_fio_randrw >"$fioout" 2>&1 &
+ run_fio_randrw >"$ktest_out/fio-out" 2>&1 &
local fiopid=$!
sleep 1
@@ -278,6 +278,8 @@ test_device_add()
fi
umount /mnt
+ bcachefs fsck -n /dev/sdb /dev/sdc
+
mount -t bcachefs /dev/sdb:/dev/sdc /mnt
umount /mnt
}
@@ -291,15 +293,18 @@ test_device_set_state()
mount -t bcachefs /dev/sdb:/dev/sdc:/dev/sdd /mnt
- local fioout="$ktest_tmp/fioout"
- run_fio_randrw >"$fioout" 2>&1 &
+ run_fio_randrw >"$ktest_out/fio-out" 2>&1 &
local fiopid=$!
sleep 1
- for state in readonly failed spare; do
- bcachefs device set-state --force /dev/sdc $state
- bcachefs device set-state /dev/sdc readwrite
+ for state in ro failed spare; do
+ echo "setting state $state"
+ bcachefs device set-state --force $state /dev/sdc
+
+ echo "setting state rw"
+ #bcachefs device set-state rw /dev/sdc
+ bcachefs device set-state rw 1 /mnt
done
if ! wait $fiopid; then
@@ -319,14 +324,13 @@ test_device_ro()
mount -t bcachefs /dev/sdb:/dev/sdc:/dev/sdd /mnt
- local fioout="$ktest_tmp/fioout"
+ local fioout="$ktest_out/fio-out"
run_fio_randrw >"$fioout" 2>&1 &
local fiopid=$!
sleep 4
- bcachefs device remove /dev/sdc || true
- #bcachefs device set-state /dev/sdc readonly
+ bcachefs device set-state ro /dev/sdc
if ! wait $fiopid; then
cat "$fioout"
@@ -348,13 +352,13 @@ test_device_set_state_offline()
mount -t bcachefs /dev/sdb:/dev/sdc:/dev/sdd /mnt
- local fioout="$ktest_tmp/fioout"
+ local fioout="$ktest_out/fio-out"
run_fio_randrw >"$fioout" 2>&1 &
local fiopid=$!
sleep 1
- bcachefs device set-state --force /dev/sdc readonly
+ bcachefs device set-state --force ro /dev/sdc
if ! wait $fiopid; then
cat "$fioout"
@@ -363,10 +367,11 @@ test_device_set_state_offline()
umount /mnt
- bcachefs device set-state --offline /dev/sdc readwrite
+ bcachefs device set-state --offline rw /dev/sdc
mount -t bcachefs /dev/sdb:/dev/sdc:/dev/sdd /mnt
cat /sys/block/sdc/bcachefs/state
+ umount /mnt
}
test_device_readd()
@@ -378,7 +383,7 @@ test_device_readd()
mount -t bcachefs /dev/sdb:/dev/sdc /mnt
- local fioout="$ktest_tmp/fioout"
+ local fioout="$ktest_out/fio-out"
run_fio_randrw >"$fioout" 2>&1 &
local fiopid=$!
@@ -407,6 +412,7 @@ do_replicas_errors_test()
{
error_type=$1
+ echo 1 > /sys/module/bcachefs/parameters/verify_all_btree_replicas
#bcachefs_antagonist
mdadm -B /dev/md0 -lfaulty -n1 /dev/sdc
@@ -421,8 +427,18 @@ do_replicas_errors_test()
mdadm -G /dev/md0 -p$error_type
run_fio_randrw
+
+ # Check the read retry path for indirect extents:
+ cp --reflink /mnt/fiotest /mnt/fiotest.reflinked
+ dd if=/mnt/fiotest of=/dev/null bs=4k iflag=direct
+
umount /mnt
mdadm --stop /dev/md0
+
+ #bcachefs fsck -n /dev/sdb /dev/sdc
+
+ mount -t bcachefs -o fsck /dev/sdb:/dev/sdc /mnt
+ umount /mnt
}
test_replicas_write_errors()
@@ -653,7 +669,7 @@ test_key_type_error()
mount -t bcachefs /dev/sdb:/dev/sdc /mnt
bcachefs setattr --data_replicas=1 /mnt
- bcachefs setattr --foreground_target=/dev/sdc /mnt
+ bcachefs setattr --foreground_target=sdc /mnt
dd if=/dev/zero of=/mnt/foo bs=64k count=8 oflag=direct
diff --git a/tests/bcachefs/single_device.ktest b/tests/bcachefs/single_device.ktest
index 5b54638..a6a9a52 100644
--- a/tests/bcachefs/single_device.ktest
+++ b/tests/bcachefs/single_device.ktest
@@ -2,11 +2,272 @@
require-lib bcachefs-test-libs.sh
+require-kernel-config BCACHEFS_TESTS
+
+require-kernel-config MD
+require-kernel-config BLK_DEV_MD
+require-kernel-config MD_FAULTY
+
config-scratch-devs 4G
config-scratch-devs 4G
config-timeout $(stress_timeout)
+test_stress_ng()
+{
+ apt install -y stress-ng
+ setup_tracing 'bcachefs:*'
+
+ run_quiet "" bcachefs format --no_initialize --version=11 -f /dev/sdb
+ mount -t bcachefs /dev/sdb /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
+}
+
+test_page_owner_thing()
+{
+ run_quiet "" bcachefs format -f --no_initialize /dev/sdb
+ mount -t bcachefs /dev/sdb /mnt
+ dd if=/dev/zero of=/mnt/foo bs=8M count=1 oflag=direct
+ dd if=/mnt/foo of=/dev/null bs=8M count=1 iflag=direct
+ umount /mnt
+
+ cat /sys/kernel/debug/page_owner > /root/page_owner
+ /host/home/kent/linux/tools/vm/page_owner_sort /root/page_owner /ktest-out/page_owner
+}
+
+test_punch()
+{
+ run_quiet "" bcachefs format -f --errors=panic /dev/sdb
+ mount -t bcachefs /dev/sdb /mnt
+
+ xfs_io -f /mnt/foo -c "pwrite -S 0x55 0 16384"
+ xfs_io -f /mnt/foo -c "fsync"
+ xfs_io -f /mnt/foo -c "fpunch 4095 4097"
+
+ md5sum /mnt/foo
+ umount /mnt
+
+ mount -t bcachefs /dev/sdb /mnt
+ md5sum /mnt/foo
+ umount /mnt
+}
+
+test_remount_ro_rw()
+{
+ run_quiet "" bcachefs format -f --errors=panic /dev/sdb
+ mount -t bcachefs /dev/sdb /mnt
+
+ mount -o remount,ro /mnt
+ mount -o remount,rw /mnt
+ touch /mnt/foo
+ umount /mnt
+}
+
+test_extent_merge2()
+{
+ echo 1 > /sys/module/bcachefs/parameters/debug_check_iterators
+
+ run_quiet "" bcachefs format -f --errors=panic /dev/sdb
+ mount -t bcachefs /dev/sdb /mnt
+
+ fallocate -o 0 -l 4096 /mnt/foo
+ fallocate -o 4096 -l 4096 /mnt/foo
+
+ umount /mnt
+ bcachefs fsck -n /dev/sdb
+}
+
+test_reflink2()
+{
+ bcachefs_antagonist
+ run_quiet "" bcachefs format /dev/sdb
+
+ mount -t bcachefs /dev/sdb /mnt
+
+ dd if=/dev/urandom of=/mnt/foo bs=16k count=1 oflag=direct
+ cp --reflink /mnt/foo /mnt/foo2
+ cp --reflink /mnt/foo /mnt/foo3
+ cp --reflink /mnt/foo /mnt/foo4
+ cp --reflink /mnt/foo /mnt/foo5
+ cp --reflink /mnt/foo /mnt/foo6
+
+ cat /sys/kernel/debug/bcachefs/*/reflink
+
+ dd if=/dev/urandom of=/mnt/foo2 bs=4k oflag=direct conv=notrunc count=1
+ dd if=/dev/urandom of=/mnt/foo3 bs=4k oflag=direct conv=notrunc count=1 seek=1
+ dd if=/dev/urandom of=/mnt/foo4 bs=4k oflag=direct conv=notrunc count=1 seek=3
+
+ dd if=/dev/urandom of=/mnt/foo5 bs=4k oflag=direct conv=notrunc count=2
+ dd if=/dev/urandom of=/mnt/foo6 bs=4k oflag=direct conv=notrunc count=1 seek=3
+ dd if=/dev/urandom of=/mnt/foo6 bs=4k oflag=direct conv=notrunc count=1 seek=2
+
+ cat /sys/kernel/debug/bcachefs/*/reflink
+
+ cat /sys/kernel/debug/bcachefs/*/reflink|wc -l
+ rm /mnt/foo*
+ cat /sys/kernel/debug/bcachefs/*/reflink|wc -l
+}
+
+test_reflink()
+{
+ run_quiet "" bcachefs format -f --errors=panic /dev/sdb
+ mount -t bcachefs /dev/sdb /mnt
+
+ run_fio_randrw --filesize=1000M &
+
+ for i in `seq 0 10`; do
+ sleep 0.5
+ cp --reflink /mnt/fiotest /mnt/fiotest2
+ rm /mnt/fiotest2
+ done
+
+ wait
+
+ cat /sys/kernel/debug/bcachefs/*/reflink|wc -l
+ rm /mnt/fiotest*
+ nr_left=`cat /sys/kernel/debug/bcachefs/*/reflink|wc -l`
+ echo "nr_left: $nr_left"
+
+ [[ $nr_left = 0 ]]
+
+ umount /mnt
+}
+
+test_fio_raw()
+{
+ fio --eta=always \
+ --exitall_on_error=1 \
+ --randrepeat=0 \
+ --ioengine=libaio \
+ --iodepth=64 \
+ --iodepth_batch=16 \
+ --direct=1 \
+ --numjobs=1 \
+ --filename=/dev/sdb \
+ --name=randread \
+ --rw=randread \
+ --size=40G \
+ --bs=4k
+}
+
+test_rewrite_old_nodes()
+{
+ run_quiet "" bcachefs format -f --no_initialize --version=10 /dev/sdb
+
+ bcachefs show-super /dev/sdb
+
+ mount -t bcachefs /dev/sdb /mnt
+ dd if=/dev/zero of=/mnt/foo bs=4k count=65536 oflag=direct
+
+ echo 1 > /sys/fs/bcachefs/*/internal/trigger_gc
+ exit
+
+ umount /mnt
+
+ bcachefs show-super /dev/sdb
+
+ bcachefs fsck /dev/sdb
+
+ bcachefs show-super /dev/sdb
+
+ mount -t bcachefs -o version_upgrade /dev/sdb /mnt
+ bcachefs data job rewrite_old_nodes /mnt
+ umount /mnt
+
+ bcachefs fsck /dev/sdb
+
+ bcachefs show-super /dev/sdb
+}
+
+test_merge_torture_flakey()
+{
+ local loops=$((($ktest_priority + 1) * 3))
+ local n=40M
+
+ mdadm -B /dev/md0 -lfaulty -n1 /dev/sdb
+
+ run_quiet "" bcachefs format -f --btree_node_size=32k --errors=panic /dev/md0
+
+ for i in `seq 0 $loops`; do
+ echo "loop: $i"
+
+ mount -t bcachefs -o fsck /dev/md0 /mnt
+
+ echo seq_delete $n 1 > /sys/fs/bcachefs/*/perf_test
+ echo -n "nodes: "
+ grep "^l " /sys/kernel/debug/bcachefs/*/xattrs-formats|wc -l
+ df -h /mnt
+
+ echo seq_insert $n 1 > /sys/fs/bcachefs/*/perf_test &
+ sleep 10
+ mdadm -G /dev/md0 -pwrite-all
+ wait
+
+ umount /mnt
+ mdadm -G /dev/md0 -pnone
+
+ mount -t bcachefs -o fsck /dev/md0 /mnt
+
+ echo seq_delete $n 1 > /sys/fs/bcachefs/*/perf_test &
+ sleep 2
+ mdadm -G /dev/md0 -pwrite-all
+ wait
+
+ umount /mnt
+ mdadm -G /dev/md0 -pnone
+ done
+
+ mdadm --stop /dev/md0
+}
+
+# Disabled, because currently OOMs
+d_test_merge_torture()
+{
+ setup_tracing
+
+ local loops=$((($ktest_priority + 1) * 3))
+ local n=10M
+
+ run_quiet "" bcachefs format -f --errors=panic --btree_node_size=8k --no_initialize /dev/sdb
+
+ for i in `seq 0 $loops`; do
+ mount -t bcachefs -o fsck /dev/sdb /mnt
+
+ echo "loop: $i"
+ echo rand_insert $n 1 > /sys/fs/bcachefs/*/perf_test
+ df -h /mnt
+ echo rand_delete $n 1 > /sys/fs/bcachefs/*/perf_test
+
+ echo -n "nodes: "
+ grep "^l " /sys/kernel/debug/bcachefs/*/xattrs-formats|wc -l
+ df -h /mnt
+
+ umount /mnt
+ done
+}
+
+test_make_files()
+{
+ run_quiet "" bcachefs format -f /dev/sdb
+ mount -t bcachefs /dev/sdb /mnt
+
+ echo 3 > /proc/sys/vm/drop_caches
+ free -m
+
+ for i in `seq 0 1`; do
+ echo -n > /mnt/$i
+ done
+
+ free -m
+ echo 3 > /proc/sys/vm/drop_caches
+ free -m
+ umount /mnt
+}
+
test_journal_resize()
{
run_quiet "" bcachefs format -f /dev/sdb
@@ -21,6 +282,20 @@ test_journal_resize()
umount /mnt
}
+test_drop_alloc()
+{
+ run_quiet "" bcachefs format -f /dev/sdb
+ mount -t bcachefs /dev/sdb /mnt
+
+ run_fio_randrw --filesize=2G
+ umount /mnt
+
+ mount -t bcachefs -o reconstruct_alloc,fsck,fix_errors /dev/sdb /mnt
+ umount /mnt
+
+ bcachefs fsck -n /dev/sdb
+}
+
test_reflink_inline_data()
{
run_quiet "" bcachefs format -f /dev/sdb
@@ -46,27 +321,28 @@ test_split_compressed()
umount /mnt
}
-test_remount_loop()
+test_fcollapse()
{
- run_quiet "" bcachefs format /dev/sdb
+ run_quiet "" bcachefs format -f \
+ --errors=panic \
+ /dev/sdb
+ mount /dev/sdb /mnt
- while true; do
- mount -t bcachefs -o fsck /dev/sdb /mnt
- run_fio_randrw
- umount /mnt
- done
-}
+ dd if=/dev/zero of=/mnt/foo bs=4k count=4 oflag=direct
-test_fcollapse()
-{
- run_quiet "" bcachefs format /dev/sdb
- mount -t bcachefs -o fsck /dev/sdb /mnt
+ echo "before fcollapse"
+ cat /sys/kernel/debug/bcachefs/*/btrees/extents
+ ls -l /mnt/foo
+ echo
- dd if=/dev/zero of=/mnt/foo bs=64k count=1 oflag=direct
+ xfs_io -c "fcollapse 4k 2k" /mnt/foo
- cat /sys/kernel/debug/bcachefs/*/extents
+ echo "after fcollapse"
+ cat /sys/kernel/debug/bcachefs/*/btrees/extents
+ ls -l /mnt/foo
+ echo
- xfs_io -c "fcollapse 0 1024" /mnt/foo
+ umount /mnt
}
test_finsert()
@@ -76,9 +352,10 @@ test_finsert()
dd if=/dev/zero of=/mnt/foo bs=64k count=1 oflag=direct
- cat /sys/kernel/debug/bcachefs/*/extents
+ cat /sys/kernel/debug/bcachefs/*/btrees/extents
xfs_io -c "finsert 1024 1024" /mnt/foo
+ umount /mnt
}
test_key_merge()
@@ -89,7 +366,7 @@ test_key_merge()
dd if=/dev/zero of=/mnt/foo bs=8k count=128 oflag=direct
- NR=$(cat /sys/kernel/debug/bcachefs/*/extents|wc -l)
+ NR=$(cat /sys/kernel/debug/bcachefs/*/btrees/extents|wc -l)
[[ $NR -eq 4 ]]
@@ -106,32 +383,13 @@ test_key_merge_csum()
cat /mnt/foo > /dev/null
- NR=$(cat /sys/kernel/debug/bcachefs/*/extents|wc -l)
+ NR=$(cat /sys/kernel/debug/bcachefs/*/btrees/extents|wc -l)
[[ $NR -le 16 ]]
umount /mnt
}
-test_reflink()
-{
- bcachefs_antagonist
- run_quiet "" bcachefs format /dev/sdb
-
- mount -t bcachefs /dev/sdb /mnt
-
- dd if=/dev/urandom of=/mnt/foo bs=8k count=1 oflag=direct
- md5sum /mnt/foo
-
- cp --reflink /mnt/foo /mnt/bar
- md5sum /mnt/foo
- md5sum /mnt/bar
-
- #dd if=/dev/urandom of=/mnt/foo bs=8k count=1 oflag=sync
- #dd if=/dev/urandom of=/mnt/bar bs=8k count=1 oflag=sync
- #umount /mnt
-}
-
test_reconstruct_alloc()
{
run_quiet "" bcachefs format --btree_node_size=16k /dev/sdb
@@ -145,6 +403,8 @@ test_reconstruct_alloc()
run_fio_randrw
umount /mnt
+ fsck.bcachefs -n --reconstruct_alloc /dev/sdb
+
mount -t bcachefs -o reconstruct_alloc,fix_errors,fsck /dev/sdb /mnt
umount /mnt
@@ -156,6 +416,7 @@ test_reconstruct_alloc()
test_recovery()
{
run_quiet "" bcachefs format \
+ --errors=panic \
--encrypted --no_passphrase \
--bucket=8k \
/dev/sdb
@@ -189,6 +450,24 @@ test_recovery()
done
}
+test_lz4_zeros()
+{
+ run_quiet "" bcachefs format -f --errors=panic --compression=lz4 --data_checksum=none --bucket=2M /dev/sdb
+ mount -t bcachefs /dev/sdb /mnt
+
+ dd if=/dev/zero of=/mnt/foo || true
+ umount /mnt
+}
+
+test_lz4_incompressible()
+{
+ run_quiet "" bcachefs format -f --errors=panic --compression=lz4 --data_checksum=none --bucket=2M /dev/sdb
+ mount -t bcachefs /dev/sdb /mnt
+
+ dd if=/dev/urandom of=/mnt/foo || true
+ umount /mnt
+}
+
test_lz4()
{
run_basic_fio_test \
@@ -199,8 +478,6 @@ test_lz4()
test_lz4_buffered()
{
#bcachefs_antagonist
- antagonist_trigger_gc &
- echo 1 > /sys/module/bcachefs/parameters/debug_check_bkeys
run_quiet "" bcachefs format -f \
--errors=panic \
@@ -208,19 +485,17 @@ test_lz4_buffered()
/dev/sdb
mount /dev/sdb /mnt
- while true; do
- echo starting copy
- cp -rx / /mnt
+ echo starting copy
+ cp -rx / /mnt
- echo starting sync
- sync
+ echo starting sync
+ sync
- #echo starting gc
- #echo 1 | tee /sys/fs/bcachefs/*/internal/trigger_gc >& /dev/null || true
+ #echo starting gc
+ #echo 1 | tee /sys/fs/bcachefs/*/internal/trigger_gc >& /dev/null || true
- echo starting rm
- rm -rf /mnt/*
- done
+ echo starting rm
+ rm -rf /mnt/*
umount /mnt
}
@@ -286,10 +561,10 @@ test_crc64()
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
umount /mnt
- bcachefs fsck \
- /dev/sdb
+ bcachefs fsck /dev/sdb
}
test_crypto()
@@ -319,10 +594,12 @@ run_copygc_torture()
run_quiet "" bcachefs format -f \
--errors=panic \
+ --no_initialize --version=14 \
+ --btree_node_size=8k \
+ --data_checksum=none \
"$@" /dev/sdb
mount /dev/sdb /mnt
- #enable_memory_faults
fill_device /mnt/fiotest
@@ -334,7 +611,7 @@ run_copygc_torture()
--stonewall \
--rw=randwrite \
--loops=$loops \
- --bsrange=4k-4k
+ --bsrange=4k-128k
cur_size=$(stat -c '%s' /mnt/fiotest)
new_size=$(($cur_size - 1048576))
@@ -350,8 +627,8 @@ run_copygc_torture()
expect_sysfs cache cached_buckets 0
expect_sysfs cache cached_data 0
- #disable_memory_faults
umount /mnt
+ bcachefs fsck -n /dev/sdb
}
test_copygc_torture()
@@ -377,6 +654,15 @@ test_small_buckets()
/dev/sdb
}
+# Gets stuck due to only having 512 buckets
+test_large_buckets()
+{
+ run_basic_fio_test \
+ --bucket=8M \
+ --data_checksum=none \
+ /dev/sdb
+}
+
test_small_nodes()
{
run_basic_fio_test \
@@ -385,7 +671,7 @@ test_small_nodes()
/dev/sdb
}
-test_crypto_passphrase()
+d_test_crypto_passphrase()
{
bcachefs_antagonist
@@ -469,7 +755,6 @@ test_quota()
# test nfs exports:
require-kernel-config NFSD
-require-kernel-config NFSD_V3
require-kernel-config NFSD_V4
test_nfs()
@@ -567,7 +852,7 @@ test_journal_torture()
mount -t bcachefs /dev/sdb /mnt
#enable_memory_faults
- echo 0 > /sys/fs/bcachefs/*/journal_write_delay_ms
+ echo 1 > /sys/fs/bcachefs/*/options/journal_flush_delay
run_fio_randrw
@@ -694,6 +979,24 @@ test_debugfs()
umount /mnt
}
+test_set_option()
+{
+ run_quiet "" bcachefs format -f \
+ --errors=panic \
+ /dev/sdb
+
+ mount -t bcachefs /dev/sdb /mnt
+ bcachefs set-option --compression=zstd /dev/sdb
+ cat /sys/fs/bcachefs/*/options/compression
+ umount /mnt
+
+ bcachefs set-option --compression=lz4 /dev/sdb
+
+ mount -t bcachefs /dev/sdb /mnt
+ cat /sys/fs/bcachefs/*/options/compression
+ umount /mnt
+}
+
disabled_test_swapfile()
{
run_quiet "" bcachefs format -f \
@@ -713,7 +1016,7 @@ disabled_test_swapfile()
migrate_from_fs()
{
- fstype=$1
+ local fstype=$1
if [[ $fstype = ext4 ]]; then
run_quiet "" mkfs.$fstype -F /dev/sdb
@@ -734,7 +1037,9 @@ migrate_from_fs()
--encrypted \
--no_passphrase \
-F -f /mnt | tee /root/migratelog
- offset=$(grep -oE 'sb=[[:digit:]]+' /root/migratelog|sed -e 's/sb=//')
+ offset=$(grep -w mount /root/migratelog|grep -oE 'sb=[[:digit:]]+'|sed -e 's/sb=//')
+
+ echo "Attempting to mount bcachefs filesystem with superblock offset $offset"
if true; then
mkdir -p /mnt2
@@ -747,7 +1052,7 @@ migrate_from_fs()
--exclude=/bcachefs \
--dry-run \
--itemize-changes \
- /mnt/ /mnt2/ |tee /root/rsynclog
+ /mnt/ /mnt2/ > /root/rsynclog
umount /mnt2
echo "rsync passed"
@@ -756,8 +1061,6 @@ migrate_from_fs()
umount /mnt
fsck.$fstype -n /dev/sdb
- echo "Attempting to mount bcachefs filesystem with superblock offset"
-
mount -t bcachefs -o sb=$offset /dev/sdb /mnt
rm /mnt/old_migrated_filesystem
umount /mnt
@@ -786,14 +1089,13 @@ test_migrate_from_btrfs()
migrate_from_fs btrfs
}
-test_migrate_from_bcachefs()
+d_test_migrate_from_bcachefs()
{
migrate_from_fs bcachefs
}
-# fault injection:
-
-test_init_faults()
+# we don't currently have fault injection:
+d_test_init_faults()
{
setup_tracing 'bcachefs:*'
@@ -821,7 +1123,8 @@ test_init_faults()
run_fault_injection_test bcachefs:meta:read init_fault_fn
}
-test_meta_write_faults()
+# we don't currently have fault injection:
+d_test_meta_write_faults()
{
setup_tracing 'bcachefs:*'
@@ -844,54 +1147,6 @@ test_meta_write_faults()
run_fault_injection_test bcachefs:meta::write meta_write_fault_fn
}
-test_make_test_image()
-{
- run_quiet "" bcachefs format -f \
- --errors=panic \
- --encrypted --no_passphrase \
- /dev/sdb
-
- mount -t bcachefs /dev/sdb /mnt
-
- for compress in none lz4 gzip zstd; do
- for crc in none crc32c crc64; do
- setfattr -n bcachefs.compression -v $compress /mnt
- setfattr -n bcachefs.data_checksum -v $crc /mnt
-
- filename=/mnt/$compress-$crc
- fio --name=write --rw=write \
- --blocksize=1M --size=1M \
- --buffer_compress_percentage=20 \
- --filename=$filename
-
- md5sum $filename > $filename.md5sum
- done
- done
-
- umount /mnt
-}
-
-test_read_test_image()
-{
- mount -t bcachefs /dev/sdb /mnt
-
- for sum in /mnt/*.md5sum; do
- f=${sum%.md5sum}
-
- sum1=$(md5sum $f)
- sum2=$(cat $sum)
-
- if [[ $sum1 = $sum2 ]]; then
- echo $f: checksum matches
- else
- echo $f: checksum mismatch
- return 1
- fi
- done
-
- umount /mnt
-}
-
test_long_name()
{
run_quiet "" bcachefs format -f \
@@ -948,30 +1203,6 @@ disabled_test_invalid_keys()
echo 0 > /sys/module/bcachefs/parameters/inject_invalid_keys
}
-test_fcollapse()
-{
- run_quiet "" bcachefs format -f \
- --errors=panic \
- /dev/sdb
- mount /dev/sdb /mnt
-
- dd if=/dev/zero of=/mnt/foo bs=4k count=4 oflag=direct
-
- echo "before fcollapse"
- cat /sys/kernel/debug/bcachefs/*/extents
- ls -l /mnt/foo
- echo
-
- xfs_io -c "fcollapse 4k 2k" /mnt/foo
-
- echo "after fcollapse"
- cat /sys/kernel/debug/bcachefs/*/extents
- ls -l /mnt/foo
- echo
-
- umount /mnt
-}
-
test_buffered_reads()
{
run_quiet "" bcachefs format -f \
@@ -1034,9 +1265,6 @@ test_gc()
antagonist_trigger_gc &
run_fio_randrw
- #dd if=/dev/zero of=/mnt/foo bs=1M count=16 oflag=direct
- #echo 1 > /sys/fs/bcachefs/*/internal/trigger_gc
-
umount /mnt
mount -t bcachefs /dev/sdb /mnt
@@ -1086,6 +1314,7 @@ test_setattr()
touch /mnt/foo/bar
bcachefs setattr --compression lz4 /mnt/foo
+ bcachefs setattr --foreground_target= /mnt/foo
getfattr -R -d -m - /mnt
umount /mnt
@@ -1115,3 +1344,32 @@ test_dump()
umount /mnt
bcachefs dump -o /tmp/sdb.qcow2 /dev/sdb
}
+
+test_kill_btree_node()
+{
+ run_quiet "" bcachefs format --errors=panic /dev/sdb
+
+ mount -t bcachefs /dev/sdb /mnt
+ cp -a /usr /mnt
+ umount /mnt
+
+ # Doesn't yet work with the alloc btree:
+ for btree in extents backpointers freespace; do
+ echo "Killing a btree node in btree $btree "
+ local index=1
+
+ [[ $btree = freespace ]] && index=0
+
+ bcachefs kill_btree_node -b $btree -i $index /dev/sdb
+
+ 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
+ umount /mnt
+ #bcachefs fsck -y /dev/sdb || true
+
+ echo
+ echo "Running fsck again; should be clean"
+ bcachefs fsck -y /dev/sdb || true
+ done
+}
diff --git a/tests/bcachefs/subvol.ktest b/tests/bcachefs/subvol.ktest
index feb76d9..76d2cc1 100644
--- a/tests/bcachefs/subvol.ktest
+++ b/tests/bcachefs/subvol.ktest
@@ -9,7 +9,7 @@ config-timeout $(stress_timeout)
test_snapshots_simple()
{
- NR_SNAPS=20
+ NR_SNAPS=1
bcachefs_antagonist
@@ -23,6 +23,11 @@ test_snapshots_simple()
done
popd
+ umount /mnt
+ sleep 0.2
+ bcachefs fsck -n /dev/sdb
+ exit
+
for i in `seq 0 $NR_SNAPS|sort -r`; do
umount /mnt
sleep 0.2
@@ -40,7 +45,44 @@ test_snapshots_simple()
umount /mnt
}
-test_snapshots_dbench()
+test_files_many()
+{
+ #bcachefs_antagonist
+
+ run_quiet "" bcachefs format -f --errors=panic /dev/sdb
+ mount -t bcachefs /dev/sdb /mnt
+
+ for i in $(seq 0 1000001); do
+ echo $i > /mnt/$i
+ done
+
+ umount /mnt
+ sleep 0.2
+ time mount -t bcachefs -o fsck /dev/sdb /mnt
+ umount /mnt
+}
+
+d_test_snapshots_many()
+{
+ #bcachefs_antagonist
+
+ run_quiet "" bcachefs format -f --errors=panic /dev/sdb
+ mount -t bcachefs /dev/sdb /mnt
+
+ cd /mnt
+
+ for i in $(seq 0 1000001); do
+ bcachefs subvolume snapshot "snap_$(date -u +%F-%H%M%_S%N)"
+ echo $i > snap_number
+ done
+
+ umount /mnt
+ sleep 0.2
+ mount -t bcachefs -o fsck /dev/sdb /mnt
+ umount /mnt
+}
+
+test_dbench()
{
# so wait doesn't hang
[[ $(jobs -p) != "" ]] && kill $(jobs -p)
@@ -64,11 +106,6 @@ test_snapshots_dbench()
df -h /mnt
for i in `seq 0 $NR_SNAPS|sort -r`; do
- umount /mnt
- sleep 0.2
- #bcachefs fsck -n /dev/sdb
- mount -t bcachefs -o fsck /dev/sdb /mnt
-
echo "deleting snap-$i"
bcachefs subvolume delete /mnt/snap-$i
df -h /mnt
@@ -76,13 +113,41 @@ test_snapshots_dbench()
umount /mnt
sleep 0.2
- bcachefs fsck -n /dev/sdb
- mount /dev/sdb /mnt
+ #bcachefs fsck -n /dev/sdb
+ mount -t bcachefs -o fsck /dev/sdb /mnt
df -h /mnt
umount /mnt
}
-test_snapshots_fio()
+test_reflink()
+{
+ run_quiet "" bcachefs format -f --errors=panic /dev/sdb
+ mount -t bcachefs /dev/sdb /mnt
+
+ pushd /mnt
+ cp -a /usr .
+ bcachefs subvolume snapshot snap-$i
+ cp -r --reflink usr usr2
+ popd
+
+ umount /mnt
+}
+
+d_test_finsert()
+{
+ run_quiet "" bcachefs format -f --errors=panic /dev/sdb
+ mount -t bcachefs /dev/sdb /mnt
+
+ pushd /mnt
+ dd if=/dev/zero of=foo bs=1M count=8 oflag=direct
+ bcachefs subvolume snapshot snap-$i
+ xfs_io -c "finsert 1024 1024" foo
+ popd
+
+ umount /mnt
+}
+
+d_test_snapshots_fio()
{
# so wait doesn't hang
[[ $(jobs -p) != "" ]] && kill $(jobs -p)
@@ -174,6 +239,8 @@ test_subvol_create()
mv /mnt/foo /mnt/subvolume_1
umount /mnt
+
+ bcachefs fsck -n /dev/sdb
}
test_subvol_delete()
@@ -184,6 +251,8 @@ test_subvol_delete()
rm -rf /mnt/subvolume_1
umount /mnt
+
+ bcachefs fsck -n /dev/sdb
}
test_subvol_snapshot_create()
@@ -194,6 +263,22 @@ test_subvol_snapshot_create()
bcachefs subvolume snapshot /mnt/subvolume_1 /mnt/snapshot_1
umount /mnt
+
+ bcachefs fsck -n /dev/sdb
+}
+
+test_subvol_snapshot_create_ro()
+{
+ run_quiet "" bcachefs format -f --errors=panic /dev/sdb
+ mount -t bcachefs /dev/sdb /mnt
+ bcachefs subvolume create /mnt/subvolume_1
+ bcachefs subvolume snapshot -r /mnt/subvolume_1 /mnt/snapshot_1
+
+ ! touch /mnt/snapshot_1/foo
+
+ umount /mnt
+
+ bcachefs fsck -n /dev/sdb
}
test_subvol_snapshot_delete()
@@ -205,24 +290,90 @@ test_subvol_snapshot_delete()
bcachefs subvolume delete /mnt/snapshot_1
umount /mnt
+
+ bcachefs fsck -n /dev/sdb
}
-# Fails
-test_subvol_snapshot_reuse_snapshot_name()
+test_subvol_snapshot_delete_create()
{
run_quiet "" bcachefs format -f --errors=panic /dev/sdb
mount -t bcachefs /dev/sdb /mnt
bcachefs subvolume create /mnt/subvolume_1
bcachefs subvolume snapshot /mnt/subvolume_1 /mnt/snapshot_1
bcachefs subvolume delete /mnt/snapshot_1
+ bcachefs subvolume snapshot /mnt/subvolume_1 /mnt/snapshot_1
+
+ umount /mnt
- # Next line fails
+ bcachefs fsck -n /dev/sdb
+}
+
+d_test_subvol_snapshot_rm()
+{
+ run_quiet "" bcachefs format -f --errors=panic /dev/sdb
+ mount -t bcachefs /dev/sdb /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
+}
+
+# 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
+ mkdir /mnt/dir1
+ bcachefs subvolume snapshot /mnt/ /mnt/snap1
+ mv /mnt/dir1 /mnt/dir2
+ umount /mnt
+
+ bcachefs fsck -n /dev/sdb
+}
+
+test_subvol_mv_snapshot()
+{
+ run_quiet "" bcachefs format -f --errors=panic /dev/sdb
+ mount -t bcachefs /dev/sdb /mnt
+ bcachefs subvolume create /mnt/sub1
+ bcachefs subvolume snapshot /mnt/ /mnt/snap1
+ mv /mnt/sub1 /mnt/sub2
+ umount /mnt
+
+ bcachefs fsck -n /dev/sdb
+}
+
+# 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
+ bcachefs subvolume create /mnt/sub1
+ bcachefs subvolume create /mnt/sub2
+ mv /mnt/sub1 /mnt/sub2
+ umount /mnt
+
+ bcachefs fsck -n /dev/sdb
+}
+
+test_subvol_snapshot_reuse_snapshot_name()
+{
+ run_quiet "" bcachefs format -f --errors=panic /dev/sdb
+ mount -t bcachefs /dev/sdb /mnt
+ bcachefs subvolume create /mnt/subvolume_1
+ bcachefs subvolume snapshot /mnt/subvolume_1 /mnt/snapshot_1
+ bcachefs subvolume delete /mnt/snapshot_1
bcachefs subvolume snapshot /mnt/subvolume_1 /mnt/snapshot_1
umount /mnt
+
+ bcachefs fsck -n /dev/sdb
}
-# Fails
test_subvol_delete_snapshot_of_deleted_subvol()
{
run_quiet "" bcachefs format -f --errors=panic /dev/sdb
@@ -230,14 +381,13 @@ test_subvol_delete_snapshot_of_deleted_subvol()
bcachefs subvolume create /mnt/subvolume_1
bcachefs subvolume snapshot /mnt/subvolume_1 /mnt/snapshot_1
rm -rf /mnt/subvolume_1
-
- # Next line fails
bcachefs subvolume delete /mnt/snapshot_1
umount /mnt
+
+ bcachefs fsck -n /dev/sdb
}
-# Fails
test_subvol_snapshot_delete_repeat()
{
run_quiet "" bcachefs format -f --errors=panic /dev/sdb
@@ -247,4 +397,41 @@ test_subvol_snapshot_delete_repeat()
bcachefs subvolume delete /mnt/$i
done
umount /mnt
+
+ bcachefs fsck -n /dev/sdb
+}
+
+test_subvol_snapshot_delete_fio()
+{
+ run_quiet "" bcachefs format -f --errors=panic /dev/sdb
+ mount -t bcachefs /dev/sdb /mnt
+
+ for i in $(seq 1 10); do
+ #run_fio_randrw --filesize=500M --bs=4k
+ dd if=/dev/zero of=/mnt/test bs=4k count=1024 oflag=direct
+ bcachefs subvolume snapshot /mnt/$i
+ done
+
+ for i in $(seq 1 10); do
+ umount /mnt
+ bcachefs fsck -n /dev/sdb
+ mount -t bcachefs -o fsck /dev/sdb /mnt
+ done
+
+ umount /mnt
+ bcachefs fsck -n /dev/sdb
+}
+
+test_snapshot_copygc()
+{
+ run_quiet "" bcachefs format -f --errors=panic /dev/sdb
+ mount -t bcachefs /dev/sdb /mnt
+
+ for i in $(seq 1 4); do
+ run_fio_randrw --filesize=1000M --loops=4 --bs=4k
+ bcachefs subvolume snapshot /mnt/$i
+ done
+
+ bcachefs fs usage -h /mnt
+ umount /mnt
}
diff --git a/tests/bcachefs/tier.ktest b/tests/bcachefs/tier.ktest
index 87cca64..0ff6e97 100644
--- a/tests/bcachefs/tier.ktest
+++ b/tests/bcachefs/tier.ktest
@@ -9,25 +9,6 @@ config-scratch-devs 16G
config-timeout $(stress_timeout)
-test_labels()
-{
- run_quiet "" bcachefs format /dev/sd[bcde]
-
- mount -t bcachefs /dev/sdb:/dev/sdc:/dev/sdd:/dev/sde /mnt
-
- cd /sys/fs/bcachefs/*
- echo zstd > options/background_compression
- echo lz4 > options/compression
- echo ssd | tee dev-[01]/label
- echo hdd | tee dev-[23]/label
- echo ssd > options/foreground_target
- echo ssd > options/promote_target
- echo hdd > options/background_target
-
- run_fio_randrw
- umount /mnt
-}
-
run_basic_tiering_test()
{
run_basic_fio_test "$@" \
@@ -62,6 +43,7 @@ test_tiering_torture()
run_fio_randrw --loops=50
mount -o remount,ro /mnt
+ umount /mnt
}
test_tiering()
@@ -69,6 +51,19 @@ test_tiering()
run_basic_tiering_test
}
+test_tiering_drop_alloc()
+{
+ run_basic_tiering_test
+ # mount dropping all alloc info
+
+ echo "dropping alloc:"
+ mount -t bcachefs -o reconstruct_alloc,fsck,fix_errors /dev/sdb:/dev/sdc:/dev/sdd:/dev/sde /mnt
+ umount /mnt
+
+ echo "final fsck:"
+ bcachefs fsck -n /dev/sd[bcde]
+}
+
test_tiering_buffered()
{
run_quiet "" bcachefs format \
@@ -148,7 +143,7 @@ test_setattr()
touch /mnt/foo
touch /mnt/bar
- bcachefs setattr --foreground_target /dev/sdb /mnt/
+ bcachefs setattr --foreground_target sdb /mnt/
bcachefs setattr --promote_target ssd /mnt/
umount /mnt
@@ -212,7 +207,6 @@ test_tiering_variable_buckets_replicas()
test_device_add()
{
run_quiet "" bcachefs format \
- --errors=panic \
--label=ssd /dev/sdb \
--label=hdd /dev/sd[de]
@@ -221,6 +215,9 @@ test_device_add()
run_fio_randrw|tail -n200 &
bcachefs device add --label=hdd /mnt /dev/sdc
+
+ wait
+ umount /mnt
}
test_mount_umount_torture()
@@ -239,15 +236,9 @@ test_mount_umount_torture()
done
}
-test_dm_log_writes()
-{
- exit 1
-}
-
-disabled_test_change_replicas()
+test_change_replicas()
{
run_quiet "" bcachefs format \
- --errors=panic \
--label=ssd /dev/sd[bc] \
--label=hdd /dev/sd[de] \
--foreground_target=ssd \
diff --git a/tests/bcachefs/units.ktest b/tests/bcachefs/units.ktest
index c0e29cd..872c340 100644
--- a/tests/bcachefs/units.ktest
+++ b/tests/bcachefs/units.ktest
@@ -52,4 +52,5 @@ list_tests()
echo extent_overwrite_back
echo extent_overwrite_middle
echo extent_overwrite_all
+ echo snapshots
}