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.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
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]
24 # Copyright (c) 2022 by Lawrence Livermore National Security, LLC.
27 . $STF_SUITE/include/libtest.shlib
28 . $STF_SUITE/tests/functional/zvol/zvol_common.shlib
32 # Verify that a zvol Force Unit Access (FUA) write works.
35 # 1. dd write 5MB of data with "oflag=dsync,direct" to a zvol. Those flags
36 # together do a FUA write.
37 # 3. Verify the data is correct.
38 # 3. Repeat 1-2 for both the blk-mq and non-blk-mq cases.
40 verify_runnable "global"
42 if ! is_physical_device $DISKS; then
43 log_unsupported "This directory cannot be run on raw files."
47 log_unsupported "Only linux supports dd with oflag=dsync for FUA writes"
50 typeset datafile1="$(mktemp zvol_misc_fua1.XXXXXX)"
51 typeset datafile2="$(mktemp zvol_misc_fua2.XXXXXX)"
52 typeset zvolpath=${ZVOL_DEVDIR}/$TESTPOOL/$TESTVOL
56 rm "$datafile1" "$datafile2"
60 # Wait for udev to create symlinks to our zvol
61 block_device_wait $zvolpath
64 log_must dd if=/dev/urandom of="$datafile1" bs=1M count=5
66 # Write the data to our zvol using FUA
67 log_must dd if=$datafile1 of=$zvolpath oflag=dsync,direct bs=1M count=5
69 # Extract data from our zvol
70 log_must dd if=$zvolpath of="$datafile2" bs=1M count=5
72 # Compare the data we expect with what's on our zvol. diff will return
73 # non-zero if they differ.
74 log_must diff $datafile1 $datafile2
76 log_must rm $datafile1 $datafile2
79 log_assert "Verify that a ZFS volume can do Force Unit Access (FUA)"
82 log_must zfs set compression=off $TESTPOOL/$TESTVOL
84 log_note "Testing without blk-mq"
87 log_must zpool export $TESTPOOL
88 log_must zpool import $TESTPOOL
92 log_must zpool export $TESTPOOL
93 log_must zpool import $TESTPOOL
96 log_pass "ZFS volume FUA works"