]> git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/slog/slog_015_neg.ksh
Update ZTS to work on FreeBSD
[mirror_zfs.git] / tests / zfs-tests / tests / functional / slog / slog_015_neg.ksh
1 #!/bin/ksh -p
2 #
3 # This file and its contents are supplied under the terms of the
4 # Common Development and Distribution License ("CDDL"), version 1.0.
5 # You may only use this file in accordance with the terms of version
6 # 1.0 of the CDDL.
7 #
8 # A full copy of the text of the CDDL should have accompanied this
9 # source. A copy of the CDDL is also available via the Internet at
10 # http://www.illumos.org/license/CDDL.
11 #
12
13 #
14 # Copyright (c) 2017 by Delphix. All rights reserved.
15 #
16
17 . $STF_SUITE/tests/functional/slog/slog.kshlib
18
19 #
20 # DESCRIPTION:
21 # Concurrent sync writes with log offline/online works.
22 #
23 # STRATEGY:
24 # 1. Configure "zfs_commit_timeout_pct"
25 # 2. Create pool with a log device.
26 # 3. Concurrently do the following:
27 # 3.1. Perform 8K sync writes
28 # 3.2. Perform log offline/online commands
29 # 4. Loop to test with growing "zfs_commit_timeout_pct" values.
30 #
31
32 verify_runnable "global"
33
34 function cleanup
35 {
36 #
37 # Wait for any of the writes and/or zpool commands that were
38 # kicked off in the background to complete. On failure, we may
39 # enter this function without previously waiting for them.
40 #
41 wait
42
43 set_tunable64 $COMMIT_TIMEOUT_PCT $ORIG_TIMEOUT
44
45 poolexists $TESTPOOL && zpool destroy -f $TESTPOOL
46 }
47
48 if is_freebsd; then
49 typeset COMMIT_TIMEOUT_PCT=commit_timeout_pct
50 else
51 typeset COMMIT_TIMEOUT_PCT=zfs_commit_timeout_pct
52 fi
53 typeset ORIG_TIMEOUT=$(get_tunable $COMMIT_TIMEOUT_PCT)
54 log_onexit cleanup
55 log_must setup
56
57 for PCT in 0 1 2 4 8 16 32 64 128 256 512 1024; do
58 log_must set_tunable64 $COMMIT_TIMEOUT_PCT $PCT
59
60 log_must zpool create $TESTPOOL $VDEV log $SDEV
61
62 for i in {1..10}; do
63 log_must fio --rw write --sync 1 --directory "/$TESTPOOL" \
64 --bs 8K --size 8K --name slog-test
65 done &
66
67 for i in {1..10}; do
68 log_must zpool offline $TESTPOOL $SDEV
69 log_must verify_slog_device $TESTPOOL $SDEV 'OFFLINE'
70 log_must zpool online $TESTPOOL $SDEV
71 log_must verify_slog_device $TESTPOOL $SDEV 'ONLINE'
72 done &
73
74 wait
75
76 log_must zpool destroy -f $TESTPOOL
77 done
78
79 log_pass "Concurrent writes with slog offline/online works."