diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2025-05-25 13:27:49 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2025-05-25 13:27:49 -0400 |
commit | 207e9688cf2be993cc3ae26e390619972e459a14 (patch) | |
tree | 370b0ac57a2883bd01bcb96596f37ebb440d56b0 | |
parent | 442b7be4c4fcaac21d0545037cb830b07579426b (diff) |
bcachefs: test_recover_super
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rwxr-xr-x | tests/fs/bcachefs/tier.ktest | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/fs/bcachefs/tier.ktest b/tests/fs/bcachefs/tier.ktest index faca29d..daff7cc 100755 --- a/tests/fs/bcachefs/tier.ktest +++ b/tests/fs/bcachefs/tier.ktest @@ -413,4 +413,33 @@ test_metadata_on_wrong_device_after_disk_add_v2() umount /mnt } +test_recover_super() +{ + set_watchdog 60 + run_quiet "" bcachefs format -f \ + --errors=panic \ + ${ktest_scratch_dev[@]} + bcachefs show-super -l ${ktest_scratch_dev[0]} + + mount -t bcachefs ${ktest_scratch_dev[0]} /mnt + cp -rx /usr /mnt/usr + umount /mnt + + echo "Wiping super" + dd if=/dev/zero of=${ktest_scratch_dev[0]} bs=1M count=1 oflag=direct + + echo "Attempting mount, should fail" + ! mount -t bcachefs ${ktest_scratch_dev[0]} /mnt + + echo "Recovering superblock" + bcachefs recover-super --src_device ${ktest_scratch_dev[1]} --dev_idx 0 -y ${ktest_scratch_dev[0]} + + echo "Attempting mount, should succeed" + echo "Fixing errors because recovered device will no longer have a journal" + mount -t bcachefs -o fsck,fix_errors ${ktest_scratch_dev[0]} /mnt + umount /mnt + + check_counters ${ktest_scratch_dev[0]} +} + main $@ |