ext4: add KUnit regression tests for inode migration fixes

Add KUnit regression tests in fs/ext4/migrate-test.c covering the
ext4_ext_migrate() bug fixes in the tree:

- test_ext_migrate_caps_long_run_at_init_max_len(): verify that a
  contiguous run longer than EXT_INIT_MAX_LEN is split into multiple
  initialized extents, covering commit b0a3f2c102e8 ("ext4: cap
  migration extent length at EXT_INIT_MAX_LEN").
- test_ext_migrate_survives_handle_restart(): verify that a handle
  restart during extent insertion does not abort migration, covering
  commit 3b6aee59883c ("ext4: clear journal restart indication after
  inserting extent").
- test_ext_migrate_reports_concurrent_allocation() and an -EIO check in
  test_ext_migrate_error_rollback_frees_tmp_extent_blocks(): verify that
  migration errors are returned to the caller instead of being
  overwritten, covering commit 82e2a5743b6a ("ext4: don't clobber the
  migration error in ext4_ext_migrate()").
- test_ext_migrate_credit_or_dirty_failure_keeps_live_blocks(): verify
  that post-swap ext4_journal_ensure_credits() or ext4_mark_inode_dirty()
  failures leave tmp_inode empty on eviction and do not free the
  migrated inode's extent blocks, covering commit 047061e6a6da ("ext4:
  don't free the tmp_inode tree after a partial migration swap"),
  commit ed8c07b7692c ("ext4: drop tmp inode ownership before migration
  cleanup"), and commit 7c1f0eea4a9b ("ext4: fix failed migrate freeing
  extent tree blocks").

Add KUNIT_STATIC_STUB_REDIRECT() hooks and EXPORT_SYMBOL_FOR_EXT4_TEST()
exports for ext4_datasem_ensure_credits() in fs/ext4/extents.c and
__ext4_journal_ensure_credits() in fs/ext4/ext4_jbd2.c so the KUnit
tests can emulate transaction restarts, concurrent block allocations,
and post-swap credit failures without a journal.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 files changed