1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3
4. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
5
6TID="generic_02"
7ERR_CODE=0
8
9if ! _have_program bpftrace; then
10	exit "$UBLK_SKIP_CODE"
11fi
12
13_prep_test "null" "sequential io order for MQ"
14
15dev_id=$(_add_ublk_dev -t null -q 2)
16_check_add_dev $TID $?
17
18dev_t=$(_get_disk_dev_t "$dev_id")
19bpftrace trace/seq_io.bt "$dev_t" "W" 1 > "$UBLK_TMP" 2>&1 &
20btrace_pid=$!
21sleep 2
22
23if ! kill -0 "$btrace_pid" > /dev/null 2>&1; then
24	_cleanup_test "null"
25	exit "$UBLK_SKIP_CODE"
26fi
27
28# run fio over this ublk disk
29fio --name=write_seq \
30    --filename=/dev/ublkb"${dev_id}" \
31    --ioengine=libaio --iodepth=16 \
32    --rw=write \
33    --size=512M \
34    --direct=1 \
35    --bs=4k > /dev/null 2>&1
36ERR_CODE=$?
37kill "$btrace_pid"
38wait
39if grep -q "io_out_of_order" "$UBLK_TMP"; then
40	cat "$UBLK_TMP"
41	ERR_CODE=255
42fi
43_cleanup_test "null"
44_show_result $TID $ERR_CODE
45