1#! /bin/ksh -p
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License (the "License").
7# You may not use this file except in compliance with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or https://opensource.org/licenses/CDDL-1.0.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22
23#
24# Copyright (c) 2018 by Lawrence Livermore National Security, LLC.
25#
26
27. $STF_SUITE/include/libtest.shlib
28. $STF_SUITE/tests/functional/io/io.cfg
29
30#
31# DESCRIPTION:
32#	Verify Linux io_uring.
33#
34# STRATEGY:
35#	1. Use fio(1) in verify mode to perform write, read,
36#	   random read, and random write workloads.
37#	2. Repeat the test with additional fio(1) options.
38#
39
40verify_runnable "global"
41
42
43if ! $(grep -q "CONFIG_IO_URING=y" /boot/config-$(uname -r)); then
44	log_unsupported "Requires io_uring support"
45fi
46
47if [ -e /etc/os-release ] ; then
48	source /etc/os-release
49	if [ -n "$REDHAT_SUPPORT_PRODUCT_VERSION" ] && ((floor($REDHAT_SUPPORT_PRODUCT_VERSION) == 9)) ; then
50		log_unsupported "Disabled on CentOS 9, fails with 'Operation not permitted'"
51	fi
52fi
53
54fio --ioengine=io_uring --parse-only || log_unsupported "fio io_uring support required"
55
56function cleanup
57{
58	log_must rm -f "$mntpnt/rw*"
59}
60
61log_assert "Verify Linux io_uring"
62
63log_onexit cleanup
64
65ioengine="--ioengine=io_uring"
66mntpnt=$(get_prop mountpoint $TESTPOOL/$TESTFS)
67dir="--directory=$mntpnt"
68
69set -A fio_arg -- "--sync=0" "--sync=1" "--direct=0" "--direct=1"
70
71for arg in "${fio_arg[@]}"; do
72	log_must fio $dir $ioengine $arg $FIO_WRITE_ARGS
73	log_must fio $dir $ioengine $arg $FIO_READ_ARGS
74	log_must fio $dir $ioengine $arg $FIO_RANDWRITE_ARGS
75	log_must fio $dir $ioengine $arg $FIO_RANDREAD_ARGS
76	log_must rm -f "$mntpnt/rw*"
77done
78
79log_pass "Verified Linux io_uring"
80