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();
Records block device layout into the openQA test log as a diagnostic snapshot.
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($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')
start_block_trace($dev, $log);
start_block_trace($dev, $log, $mask);
Start a background blktrace on a block device, piped into blkparse, to record the requests reaching the device while a test runs. Use stop_block_trace to end it and count_block_writes to evaluate the result.
Arguments: $dev - Block device to trace (e.g. '/dev/loop0') $log - Path of the blkparse output file to write $mask - Optional blktrace action mask (default: write)
blktrace needs debugfs, so it gets mounted if it is not available yet.
Returns: the blktrace pid
stop_block_trace();
Stop the trace started by start_block_trace. blktrace is interrupted rather than killed, so that it closes the pipe and blkparse flushes its output.
count_block_writes($log);
Count the write requests in a blkparse output file and return the number. The RWBS field of an event holds W followed by optional modifiers like S for sync or M for metadata, the summary lines at the end of the file spell the direction out and are not counted.