summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLOLi <[email protected]>2017-08-21 17:59:48 +0200
committerTony Hutter <[email protected]>2017-08-21 16:46:54 -0700
commitae5b4a05fff84cfb4facab1037bdb725f1b30bc6 (patch)
treebc2e30d73b44de8d7d729e0767a0833177b6b244 /tests
parent3468fdbd347c39db5c3c73a6bcaea69871a66fe9 (diff)
Fix range locking in ZIL commit codepath
Since OpenZFS 7578 (1b7c1e5) if we have a ZVOL with logbias=throughput we will force WR_INDIRECT itxs in zvol_log_write() setting itx->itx_lr offset and length to the offset and length of the BIO from zvol_write()->zvol_log_write(): these offset and length are later used to take a range lock in zillog->zl_get_data function: zvol_get_data(). Now suppose we have a ZVOL with blocksize=8K and push 4K writes to offset 0: we will only be range-locking 0-4096. This means the ASSERTion we make in dbuf_unoverride() is no longer valid because now dmu_sync() is called from zilog's get_data functions holding a partial lock on the dbuf. Fix this by taking a range lock on the whole block in zvol_get_data(). Reviewed-by: Chunwei Chen <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: loli10K <[email protected]> Closes #6238 Closes #6315 Closes #6356 Closes #6477
Diffstat (limited to 'tests')
-rw-r--r--tests/runfiles/linux.run2
-rw-r--r--tests/zfs-tests/tests/functional/zvol/zvol_misc/Makefile.am3
-rwxr-xr-xtests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_zil.ksh74
3 files changed, 77 insertions, 2 deletions
diff --git a/tests/runfiles/linux.run b/tests/runfiles/linux.run
index 820e56048..2b99f22e5 100644
--- a/tests/runfiles/linux.run
+++ b/tests/runfiles/linux.run
@@ -575,7 +575,7 @@ tests = ['zvol_cli_001_pos', 'zvol_cli_002_pos', 'zvol_cli_003_neg']
[tests/functional/zvol/zvol_misc]
tests = ['zvol_misc_001_neg', 'zvol_misc_002_pos', 'zvol_misc_003_neg',
'zvol_misc_004_pos', 'zvol_misc_005_neg', 'zvol_misc_006_pos',
- 'zvol_misc_snapdev', 'zvol_misc_volmode']
+ 'zvol_misc_snapdev', 'zvol_misc_volmode', 'zvol_misc_zil']
[tests/functional/zvol/zvol_swap]
tests = ['zvol_swap_001_pos', 'zvol_swap_002_pos', 'zvol_swap_003_pos',
diff --git a/tests/zfs-tests/tests/functional/zvol/zvol_misc/Makefile.am b/tests/zfs-tests/tests/functional/zvol/zvol_misc/Makefile.am
index 30ef9acbd..8859ff359 100644
--- a/tests/zfs-tests/tests/functional/zvol/zvol_misc/Makefile.am
+++ b/tests/zfs-tests/tests/functional/zvol/zvol_misc/Makefile.am
@@ -10,4 +10,5 @@ dist_pkgdata_SCRIPTS = \
zvol_misc_005_neg.ksh \
zvol_misc_006_pos.ksh \
zvol_misc_snapdev.ksh \
- zvol_misc_volmode.ksh
+ zvol_misc_volmode.ksh \
+ zvol_misc_zil.ksh
diff --git a/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_zil.ksh b/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_zil.ksh
new file mode 100755
index 000000000..b8989f478
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_zil.ksh
@@ -0,0 +1,74 @@
+#!/bin/ksh -p
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2017, loli10K <[email protected]>. All rights reserved.
+#
+
+. $STF_SUITE/include/libtest.shlib
+. $STF_SUITE/tests/functional/zvol/zvol_common.shlib
+. $STF_SUITE/tests/functional/zvol/zvol_misc/zvol_misc_common.kshlib
+
+#
+# DESCRIPTION:
+# Verify ZIL functionality on ZVOLs
+#
+# STRATEGY:
+# 1. Create a ZVOLs with various combination of "logbias" and "sync" values
+# 2. Write data to ZVOL device node
+# 3. Verify we don't trigger any issue like the one reported in #6238
+#
+
+verify_runnable "global"
+
+function cleanup
+{
+ datasetexists $ZVOL && log_must_busy zfs destroy $ZVOL
+ udev_wait
+}
+
+log_assert "Verify ZIL functionality on ZVOLs"
+log_onexit cleanup
+
+ZVOL="$TESTPOOL/vol"
+ZDEV="$ZVOL_DEVDIR/$ZVOL"
+typeset -a logbias_prop_vals=('latency' 'throughput')
+typeset -a sync_prop_vals=('standard' 'always' 'disabled')
+
+for logbias in ${logbias_prop_vals[@]}; do
+ for sync in ${sync_prop_vals[@]}; do
+ # 1. Create a ZVOL with logbias=throughput and sync=always
+ log_must zfs create -V $VOLSIZE -b 128K -o sync=$sync \
+ -o logbias=$logbias $ZVOL
+
+ # 2. Write data to its device node
+ for i in {1..50}; do
+ dd if=/dev/zero of=$ZDEV bs=8k count=1 &
+ done
+
+ # 3. Verify we don't trigger any issue
+ log_must wait
+ log_must_busy zfs destroy $ZVOL
+ done
+done
+
+log_pass "ZIL functionality works on ZVOLs"