diff options
author | koverstreet <kent.overstreet@gmail.com> | 2025-07-24 11:28:34 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-24 11:28:34 -0500 |
commit | 9cab12c0553609beb0a7d7ef71f55e360a7465e1 (patch) | |
tree | f6037e0fe90af36287d3c221a0bd869f1a12f9b4 /tests/fs/bcachefs/subvol.ktest | |
parent | 07ffdcd8f45249a862d5309b47837c6e9eb478bc (diff) | |
parent | bcac7e8344c55bd5e134b533b9cd3f381f8a23ae (diff) |
tests/fs/bcachfs/subvol: add snapshots_while_stressed test
Diffstat (limited to 'tests/fs/bcachefs/subvol.ktest')
-rwxr-xr-x | tests/fs/bcachefs/subvol.ktest | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/fs/bcachefs/subvol.ktest b/tests/fs/bcachefs/subvol.ktest index c76f36a..3582ef7 100755 --- a/tests/fs/bcachefs/subvol.ktest +++ b/tests/fs/bcachefs/subvol.ktest @@ -241,6 +241,58 @@ d_test_snapshots_fio() bcachefs_test_end_checks ${ktest_scratch_dev[0]} } +test_snapshots_while_stressed() +{ + set_watchdog 300 + + run_quiet "" bcachefs format -f \ + --compression=zstd \ + ${ktest_scratch_dev[0]} + + mount -t bcachefs -o verbose ${ktest_scratch_dev[0]} /mnt + + echo ":: start background job writing to lots of small files" + local fioout="$ktest_out/fio-out" + mkdir /mnt/fio + fio --eta=always \ + --name=snapshot_stress \ + --directory=/mnt/fio \ + --numjobs=3 \ + --nrfiles=1000 \ + --size=16M \ + --file_service_type=random \ + --rw=randwrite \ + --time_based \ + --runtime=60 \ + >"$fioout" 2>&1 \ + & + local fiopid=$! + + local snapshots_dir=/mnt/snapshots + mkdir $snapshots_dir + + echo ":: take frequent snapshots under load with interspersed removal of old snapshots" + local n=1 + while [[ -d "/proc/$fiopid" ]]; do + echo -n ":: taking snapshot #$n... " + bcachefs subvolume snapshot --read-only "$snapshots_dir/$n" + echo "done" + + if (( n % 3 == 0 )); then + bcachefs fs usage -h /mnt + local random_n=$(ls $snapshots_dir | shuf | head -n1) + echo -n ":: deleting snapshot #$random_n... " + bcachefs subvolume delete "$snapshots_dir/$random_n" + echo "done" + fi + + sleep 1 + ((n++)) + done + + umount /mnt +} + test_subvol_create() { run_quiet "" bcachefs format -f --errors=panic ${ktest_scratch_dev[0]} |