lib/Kernel/block_dev.pm

is_block_device

is_block_device(@devices);

Asserts that each device in the list exists as a block device. Dies if any device is not found, allowing the test to fail if a block device is not detected on the SUT.

record_storage_info

record_storage_info();

Records block device layout into the openQA test log as a diagnostic snapshot.

create_loop_backing_file

create_loop_backing_file($path, $size, %opts);

Creates a loop device backing file with proper Btrfs host handling.

Arguments: $path - Full path to the backing file (e.g., '/opt/xfstests/test_dev') $size - Size specification (e.g., '5G', '1024M') %opts - Optional parameters: timeout => timeout in seconds (default: 300)

This function creates an empty file, applies chattr +C to disable CoW and compression on Btrfs hosts (no-op on other filesystems), then uses fallocate to allocate the requested space.

The chattr +C flag must be set on an empty file before data is written to prevent Btrfs host filesystem issues: - CoW disabled: prevents physical space explosion during overwrites - Compression disabled: ensures full physical space allocation - Safe for all test filesystems (xfs, btrfs, ext4, overlay, nfs)

Returns: nothing (dies on error via assert_script_run)

attach_loop_device

attach_loop_device($backing_file, %opts);

Attaches a loop device to a backing file and returns the loop device path.

Arguments: $backing_file - Path to the backing file %opts - Optional parameters: loop_dev => specific loop device path (e.g., '/dev/loop100') If not provided, uses 'losetup -f' to find next free device timeout => timeout in seconds (default: 300)

Returns: the loop device path (e.g., '/dev/loop0')