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 errors caused by messages being dropped from the list backing the
32 # procfs file are handled gracefully.
35 # 1. Make sure a few entries have been logged.
36 # 2. Open the procfs file and start reading from it.
37 # 3. Write to the file to cause its contents to be dropped.
38 # 4. Resume reading from the first instance, and check that the expected
40 # 5. Repeat steps 1-4, except instead of dropping all the messages by writing
41 # to the file, cause enough new messages to be written that the old messages
47 echo $default_max_entries >$MAX_ENTRIES_PARAM || log_fail
53 log_must zpool sync
$TESTPOOL
62 # Clear out old entries
63 echo 0 >$TXG_HIST || log_fail
65 # Add some new entries
68 # Confirm that there actually is something in the file.
69 [[ $
(wc -l <$TXG_HIST) -ge 20 ]] || log_fail
"expected more entries"
72 # Start reading file, pause and run a command that will cause the
73 # current offset into the file to become invalid, and then try to
77 log_must
dd bs
=512 count
=4 >/dev
/null
79 cat 2>&1 >/dev
/null | log_must
grep "Input/output error"
83 typeset
-r TXG_HIST
=/proc
/spl
/kstat
/zfs
/$TESTPOOL/txgs
84 typeset MAX_ENTRIES_PARAM
=/sys
/module
/zfs
/parameters
/zfs_txg_history
85 typeset default_max_entries
89 default_max_entries
=$
(cat $MAX_ENTRIES_PARAM) || log_fail
90 echo 50 >$MAX_ENTRIES_PARAM || log_fail
92 # Clear all of the existing entries.
93 do_test
"echo 0 >$TXG_HIST"
95 # Add enough new entries to the list that all of the old ones are dropped.
98 log_pass
"Attempting to read dropped message returns expected error"