mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-23 02:44:41 +03:00
Add dbuf hash and dbuf cache kstats
Introduce kstats about the dbuf hash and dbuf cache to make it easier to inspect state. This should help with debugging and understanding of these portions of the codebase. Correct format of dbuf kstat file. Introduce a dbc column to dbufs kstat to indicate if a dbuf is in the dbuf cache. Introduce field filtering in the dbufstat python script. Introduce a no header option to the dbufstat python script. Introduce a test case to test basic mru->mfu list movement in the ARC. Reviewed-by: Tony Hutter <hutter2@llnl.gov> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Giuseppe Di Natale <dinatale2@llnl.gov> Closes #6906
This commit is contained in:
committed by
Brian Behlendorf
parent
0735ecb334
commit
5e021f56d3
@@ -27,6 +27,10 @@ tags = ['functional']
|
||||
tests = ['posix_003_pos']
|
||||
tags = ['functional', 'acl', 'posix']
|
||||
|
||||
[tests/functional/arc]
|
||||
tests = ['dbufstats_001_pos', 'dbufstats_002_pos']
|
||||
tags = ['functional', 'arc']
|
||||
|
||||
[tests/functional/atime]
|
||||
tests = ['atime_001_pos', 'atime_002_neg', 'atime_003_pos']
|
||||
tags = ['functional', 'atime']
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
SUBDIRS = \
|
||||
acl \
|
||||
arc \
|
||||
atime \
|
||||
bootfs \
|
||||
cache \
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/arc
|
||||
dist_pkgdata_SCRIPTS = \
|
||||
cleanup.ksh \
|
||||
setup.ksh \
|
||||
dbufstats_001_pos.ksh \
|
||||
dbufstats_002_pos.ksh
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
#!/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 (c) 2017, Lawrence Livermore National Security, LLC.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
default_cleanup
|
||||
@@ -0,0 +1,83 @@
|
||||
#!/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 (c) 2017, Lawrence Livermore National Security, LLC.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
. $STF_SUITE/include/math.shlib
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# Ensure stats presented in /proc/spl/kstat/zfs/dbufstats are correct
|
||||
# based on /proc/spl/kstat/zfs/dbufs.
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Generate a file with random data in it
|
||||
# 2. Store output from dbufs kstat
|
||||
# 3. Store output from dbufstats kstat
|
||||
# 4. Compare stats presented in dbufstats with stat generated using
|
||||
# dbufstat.py and the dbufs kstat output
|
||||
#
|
||||
|
||||
DBUFSTATS_FILE=$(mktemp $TEST_BASE_DIR/dbufstats.out.XXXXXX)
|
||||
DBUFS_FILE=$(mktemp $TEST_BASE_DIR/dbufs.out.XXXXXX)
|
||||
|
||||
function cleanup
|
||||
{
|
||||
log_must rm -f $TESTDIR/file $DBUFS_FILE $DBUFSTATS_FILE
|
||||
}
|
||||
|
||||
function testdbufstat # stat_name dbufstat_filter
|
||||
{
|
||||
name=$1
|
||||
filter=""
|
||||
|
||||
[[ -n "$2" ]] && filter="-F $2"
|
||||
|
||||
verify_eq \
|
||||
$(grep -w "$name" "$DBUFSTATS_FILE" | awk '{ print $3 }') \
|
||||
$(dbufstat.py -bxn -i "$DBUFS_FILE" "$filter" | wc -l) \
|
||||
"$name"
|
||||
}
|
||||
|
||||
verify_runnable "both"
|
||||
|
||||
log_assert "dbufstats produces correct statistics"
|
||||
|
||||
log_onexit cleanup
|
||||
|
||||
log_must file_write -o create -f "$TESTDIR/file" -b 1048576 -c 20 -d R
|
||||
log_must zpool sync
|
||||
|
||||
log_must eval "cat /proc/spl/kstat/zfs/dbufs > $DBUFS_FILE"
|
||||
log_must eval "cat /proc/spl/kstat/zfs/dbufstats > $DBUFSTATS_FILE"
|
||||
|
||||
for level in {0..11}; do
|
||||
testdbufstat "cache_level_$level" "dbc=1,level=$level"
|
||||
done
|
||||
|
||||
testdbufstat "cache_count" "dbc=1"
|
||||
testdbufstat "hash_elements" ""
|
||||
|
||||
log_pass "dbufstats produces correct statistics passed"
|
||||
@@ -0,0 +1,80 @@
|
||||
#!/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 (c) 2017, Lawrence Livermore National Security, LLC.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
. $STF_SUITE/include/math.shlib
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# Ensure that dbufs move from mru to mfu as expected.
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Set dbuf cache size to a small size (10M for this test)
|
||||
# 2. Generate a file with random data (small enough to fit in cache)
|
||||
# 3. zpool sync to remove dbufs from anon list in ARC
|
||||
# 4. Obtain the object ID using linux stat command
|
||||
# 5. Ensure that all dbufs are on the mru list in the ARC
|
||||
# 6. Generate another random file large enough to flush dbuf cache
|
||||
# 7. cat the first generated file
|
||||
# 8. Ensure that at least some dbufs moved to the mfu list in the ARC
|
||||
#
|
||||
|
||||
DBUFS_FILE=$(mktemp $TEST_BASE_DIR/dbufs.out.XXXXXX)
|
||||
|
||||
function cleanup
|
||||
{
|
||||
log_must rm -f $TESTDIR/file $TESTDIR/file2 $DBUFS_FILE
|
||||
}
|
||||
|
||||
verify_runnable "both"
|
||||
|
||||
log_assert "dbufs move from mru to mfu list"
|
||||
|
||||
log_onexit cleanup
|
||||
|
||||
log_must file_write -o create -f "$TESTDIR/file" -b 1048576 -c 1 -d R
|
||||
log_must zpool sync
|
||||
|
||||
objid=$(stat --format="%i" "$TESTDIR/file")
|
||||
log_note "Object ID for $TESTDIR/file is $objid"
|
||||
|
||||
log_must eval "cat /proc/spl/kstat/zfs/dbufs > $DBUFS_FILE"
|
||||
dbuf=$(dbufstat.py -bxn -i "$DBUFS_FILE" -F "object=$objid" | wc -l)
|
||||
mru=$(dbufstat.py -bxn -i "$DBUFS_FILE" -F "object=$objid,list=1" | wc -l)
|
||||
mfu=$(dbufstat.py -bxn -i "$DBUFS_FILE" -F "object=$objid,list=3" | wc -l)
|
||||
log_note "dbuf count is $dbuf, mru count is $mru, mfu count is $mfu"
|
||||
verify_ne "0" "$mru" "mru count"
|
||||
verify_eq "0" "$mfu" "mfu count"
|
||||
|
||||
log_must eval "cat $TESTDIR/file > /dev/null"
|
||||
log_must eval "cat /proc/spl/kstat/zfs/dbufs > $DBUFS_FILE"
|
||||
dbuf=$(dbufstat.py -bxn -i "$DBUFS_FILE" -F "object=$objid" | wc -l)
|
||||
mru=$(dbufstat.py -bxn -i "$DBUFS_FILE" -F "object=$objid,list=1" | wc -l)
|
||||
mfu=$(dbufstat.py -bxn -i "$DBUFS_FILE" -F "object=$objid,list=3" | wc -l)
|
||||
log_note "dbuf count is $dbuf, mru count is $mru, mfu count is $mfu"
|
||||
verify_ne "0" "$mfu" "mfu count"
|
||||
|
||||
log_pass "dbufs move from mru to mfu list passed"
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
#!/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 (c) 2017, Lawrence Livermore National Security, LLC.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
DISK=${DISKS%% *}
|
||||
default_setup $DISK
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
set -A args "" "-b" "-d" "-r" "-v" "-s \",\"" "-x"
|
||||
set -A args "" "-b" "-d" "-r" "-v" "-s \",\"" "-x" "-n"
|
||||
|
||||
log_assert "dbufstat.py generates output and doesn't return an error code"
|
||||
|
||||
@@ -37,4 +37,7 @@ while [[ $i -lt ${#args[*]} ]]; do
|
||||
((i = i + 1))
|
||||
done
|
||||
|
||||
# A simple test of dbufstat.py filter functionality
|
||||
log_must eval "dbufstat.py -F object=10,dbc=1,pool=$TESTPOOL > /dev/null"
|
||||
|
||||
log_pass "dbufstat.py generates output and doesn't return an error code"
|
||||
|
||||
Reference in New Issue
Block a user