]>
git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/procfs/procfs_list_basic.ksh
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 # Test that we can read from and write to a file in procfs whose contents is
32 # backed by a linked list.
35 # 1. Take some snapshots of a filesystem, which will cause some messages to be
36 # written to the zfs dbgmsgs.
37 # 2. Read the dbgmsgs via procfs and verify that the expected messages are
39 # 3. Write to the dbgmsgs file to clear the messages.
40 # 4. Read the dbgmsgs again, and make sure the messages are no longer present.
45 datasetexists
$FS && log_must zfs destroy
-r $FS
48 function count_snap_cmds
50 typeset expected_count
=$1
51 count
=$
(grep "command: zfs snapshot $FS@testsnapshot" |
wc -l)
52 log_must
eval "[[ $count -eq $expected_count ]]"
55 typeset
-r ZFS_DBGMSG
=/proc
/spl
/kstat
/zfs
/dbgmsg
56 typeset
-r FS
=$TESTPOOL/fs
61 # Clear out old messages
62 echo 0 >$ZFS_DBGMSG || log_fail
"failed to write to $ZFS_DBGMSG"
64 log_must zfs create
$FS
66 log_must zfs snapshot
"$FS@testsnapshot$i"
68 log_must zpool sync
$TESTPOOL
71 # Read the debug message file in small chunks to make sure that the read is
72 # split up into multiple syscalls. This tests that when a syscall begins we
73 # correctly pick up in the list of messages where the previous syscall left
74 # off. The size of the read can affect how many bytes the seq_file code has
75 # left in its internal buffer, which in turn can affect the relative pos that
76 # the seq_file code picks up at when the next read starts. Try a few
77 # different size reads to make sure we can handle each case.
79 # Check that the file has the right contents by grepping for some of the
80 # messages that we expect to be present.
82 for chunk_sz
in {1,64,256,1024,4096}; do
83 dd if=$ZFS_DBGMSG bs
=$chunk_sz | count_snap_cmds
20
86 # Clear out old messages and check that they really are gone
87 echo 0 >$ZFS_DBGMSG || log_fail
"failed to write to $ZFS_DBGMSG"
88 cat $ZFS_DBGMSG | count_snap_cmds
0
90 # Even though we don't expect any messages in the file, reading should still
93 log_must
cat $ZFS_DBGMSG
95 log_pass
"Basic reading/writing of procfs file backed by linked list successful"