btrfs: selftests: add delayed ref self test cases
authorJosef Bacik <josef@toxicpanda.com>
Thu, 14 Nov 2024 15:03:34 +0000 (10:03 -0500)
committerDavid Sterba <dsterba@suse.com>
Mon, 13 Jan 2025 13:53:13 +0000 (14:53 +0100)
commit2b34879d97e27b74e8e933463f5e9073d9d39821
treec1ea600c28c96ea8411e5f4be3e52ea8642e0f89
parent5473aeedffa49e036d9d313148e3fa96af85c0a6
btrfs: selftests: add delayed ref self test cases

The recent fix for a stupid mistake I made uncovered the fact that we
don't have adequate testing in the delayed refs code, as it took a
pretty extensive and long running stress test to uncover something that
a unit test would have uncovered right away.

Fix this by adding a delayed refs self test suite.  This will validate
that the btrfs_ref transformation does the correct thing, that we do the
correct thing when merging delayed refs, and that we get the delayed
refs in the order that we expect.  These are all crucial to how the
delayed refs operate.

I introduced various bugs (including the original bug) into the delayed
refs code to validate that these tests caught all of the shenanigans
that I could think of.

Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/Makefile
fs/btrfs/delayed-ref.c
fs/btrfs/tests/btrfs-tests.c
fs/btrfs/tests/btrfs-tests.h
fs/btrfs/tests/delayed-refs-tests.c [new file with mode: 0644]