summaryrefslogtreecommitdiff
path: root/tests/fs/bcachefs/subvol.ktest
diff options
context:
space:
mode:
authorkoverstreet <kent.overstreet@gmail.com>2025-07-24 11:28:34 -0500
committerGitHub <noreply@github.com>2025-07-24 11:28:34 -0500
commit9cab12c0553609beb0a7d7ef71f55e360a7465e1 (patch)
treef6037e0fe90af36287d3c221a0bd869f1a12f9b4 /tests/fs/bcachefs/subvol.ktest
parent07ffdcd8f45249a862d5309b47837c6e9eb478bc (diff)
parentbcac7e8344c55bd5e134b533b9cd3f381f8a23ae (diff)
Merge pull request #44 from samhug/snapshotsHEADmaster
tests/fs/bcachfs/subvol: add snapshots_while_stressed test
Diffstat (limited to 'tests/fs/bcachefs/subvol.ktest')
-rwxr-xr-xtests/fs/bcachefs/subvol.ktest52
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]}