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) 2018 by Delphix. All rights reserved.
27 . $STF_SUITE/include/libtest.shlib
31 # Make sure that interleaving reads from different readers does not affect the
32 # results that are returned.
35 # 1. Make sure a few debug messages have been logged.
36 # 2. Open the procfs file and start reading from it.
37 # 3. Open the file again, and read its entire contents.
38 # 4. Resume reading from the first instance.
39 # 5. Check that the contents read by the two instances are identical.
44 [[ -z $msgs1 ]] || log_must rm $msgs1
45 [[ -z $msgs2 ]] || log_must rm $msgs2
46 datasetexists $FS && log_must zfs destroy -r $FS
49 typeset -r ZFS_DBGMSG=/proc/spl/kstat/zfs/dbgmsg
50 typeset -r FS=$TESTPOOL/fs
55 # Clear out old messages
56 echo 0 >$ZFS_DBGMSG || log_fail "failed to write to $ZFS_DBGMSG"
58 # Add some new messages
59 log_must zfs create $FS
61 log_must zfs snapshot "$FS@testsnapshot$i"
63 log_must zpool sync $TESTPOOL
65 msgs1=$(mktemp) || log_fail
66 msgs2=$(mktemp) || log_fail
69 # Start reading file, pause and read it from another process, and then finish
72 { dd bs=512 count=4; cat $ZFS_DBGMSG >$msgs1; cat; } <$ZFS_DBGMSG >$msgs2
75 # Truncate the result of the read that completed second in case it picked up an
76 # extra message that was logged after the first read completed.
78 log_must truncate -s $(stat_size $msgs1) $msgs2
80 log_must diff $msgs1 $msgs2
82 log_pass "Concurrent readers receive identical results"