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 http://www.opensolaris.org/os/licensing.
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 2017, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
25#
26
27. $STF_SUITE/include/libtest.shlib
28. $STF_SUITE/tests/functional/zvol/zvol_common.shlib
29. $STF_SUITE/tests/functional/zvol/zvol_misc/zvol_misc_common.kshlib
30
31#
32# DESCRIPTION:
33# Verify ZIL functionality on ZVOLs
34#
35# STRATEGY:
36# 1. Create a ZVOLs with various combination of "logbias" and "sync" values
37# 2. Write data to ZVOL device node
38# 3. Verify we don't trigger any issue like the one reported in #6238
39#
40
41verify_runnable "global"
42
43function cleanup
44{
45	datasetexists $ZVOL && destroy_dataset $ZVOL
46	block_device_wait
47}
48
49log_assert "Verify ZIL functionality on ZVOLs"
50log_onexit cleanup
51
52ZVOL="$TESTPOOL/vol"
53ZDEV="$ZVOL_DEVDIR/$ZVOL"
54typeset -a logbias_prop_vals=('latency' 'throughput')
55typeset -a sync_prop_vals=('standard' 'always' 'disabled')
56
57for logbias in ${logbias_prop_vals[@]}; do
58	for sync in ${sync_prop_vals[@]}; do
59		# 1. Create a ZVOL with logbias=throughput and sync=always
60		log_must zfs create -V $VOLSIZE -b 128K -o sync=$sync \
61		    -o logbias=$logbias $ZVOL
62
63		# 2. Write data to its device node
64		for i in {1..50}; do
65			dd if=/dev/zero of=$ZDEV bs=8k count=1 &
66		done
67
68		# 3. Verify we don't trigger any issue
69		log_must wait
70		log_must_busy zfs destroy $ZVOL
71	done
72done
73
74log_pass "ZIL functionality works on ZVOLs"
75