mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2025-06-26 11:08:01 +03:00

Before, make shellcheck checked scripts/{commitcheck,make_gitrev,man-dates,paxcheck,zfs-helpers,zfs, zfs-tests,zimport,zloop}.sh cmd/zed/zed.d/{{all-debug,all-syslog,data-notify,generic-notify, resilver_finish-start-scrub,scrub_finish-notify, statechange-led,statechange-notify,trim_finish-notify, zed-functions}.sh,history_event-zfs-list-cacher.sh.in} cmd/zpool/zpool.d/{dm-deps,iostat,lsblk,media,ses,smart,upath} now it also checks contrib/dracut/{02zfsexpandknowledge/module-setup, 90zfs/{export-zfs,parse-zfs,zfs-needshutdown, zfs-load-key,zfs-lib,module-setup, mount-zfs,zfs-generator}}.sh.in cmd/zed/zed.d/{pool_import-led,vdev_attach-led, resilver_finish-notify,vdev_clear-led}.sh contrib/initramfs/{zfsunlock,hooks/zfs.in,scripts/local-top/zfs} tests/zfs-tests/tests/perf/scripts/prefetch_io.sh scripts/common.sh.in contrib/bpftrace/zfs-trace.sh autogen.sh Reviewed-by: John Kennedy <john.kennedy@delphix.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes #12042
83 lines
2.2 KiB
Bash
Executable File
83 lines
2.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# shellcheck disable=SC1004
|
|
|
|
#
|
|
# This file and its contents are supplied under the terms of the
|
|
# Common Development and Distribution License ("CDDL"), version 1.0.
|
|
# You may only use this file in accordance with the terms of version
|
|
# 1.0 of the CDDL.
|
|
#
|
|
# A full copy of the text of the CDDL should have accompanied this
|
|
# source. A copy of the CDDL is also available via the Internet at
|
|
# http://www.illumos.org/license/CDDL.
|
|
#
|
|
|
|
#
|
|
# Copyright (c) 2016 by Intel, Corp.
|
|
#
|
|
|
|
#
|
|
# Linux platform placeholder for collecting prefetch I/O stats
|
|
# TBD if we can add additional kstats to achieve the desired results
|
|
#
|
|
|
|
zfs_kstats="/proc/spl/kstat/zfs"
|
|
|
|
function get_prefetch_ios
|
|
{
|
|
typeset -l data_misses="$(awk '$1 == "prefetch_data_misses" \
|
|
{ print $3; exit }' "$zfs_kstats/arcstats")"
|
|
typeset -l metadata_misses="$(awk '$1 == "prefetch_metadata_misses" \
|
|
{ print $3; exit }' "$zfs_kstats/arcstats")"
|
|
typeset -l total_misses=$(( data_misses + metadata_misses ))
|
|
|
|
echo "$total_misses"
|
|
}
|
|
|
|
function get_prefetched_demand_reads
|
|
{
|
|
typeset -l demand_reads="$(awk '$1 == "demand_hit_predictive_prefetch" \
|
|
{ print $3; exit }' "$zfs_kstats/arcstats")"
|
|
|
|
echo "$demand_reads"
|
|
}
|
|
|
|
function get_async_upgrade_sync
|
|
{
|
|
typeset -l sync_wait="$(awk '$1 == "async_upgrade_sync" \
|
|
{ print $3; exit }' "$zfs_kstats/arcstats")"
|
|
|
|
echo "$sync_wait"
|
|
}
|
|
|
|
if [ $# -ne 2 ]
|
|
then
|
|
echo "Usage: ${0##*/} poolname interval" >&2
|
|
exit 1
|
|
fi
|
|
|
|
interval=$2
|
|
prefetch_ios=$(get_prefetch_ios)
|
|
prefetched_demand_reads=$(get_prefetched_demand_reads)
|
|
async_upgrade_sync=$(get_async_upgrade_sync)
|
|
|
|
while true
|
|
do
|
|
new_prefetch_ios=$(get_prefetch_ios)
|
|
printf "%u\n%-24s\t%u\n" "$(date +%s)" "prefetch_ios" \
|
|
$(( new_prefetch_ios - prefetch_ios ))
|
|
prefetch_ios=$new_prefetch_ios
|
|
|
|
new_prefetched_demand_reads=$(get_prefetched_demand_reads)
|
|
printf "%-24s\t%u\n" "prefetched_demand_reads" \
|
|
$(( new_prefetched_demand_reads - prefetched_demand_reads ))
|
|
prefetched_demand_reads=$new_prefetched_demand_reads
|
|
|
|
new_async_upgrade_sync=$(get_async_upgrade_sync)
|
|
printf "%-24s\t%u\n" "async_upgrade_sync" \
|
|
$(( new_async_upgrade_sync - async_upgrade_sync ))
|
|
async_upgrade_sync=$new_async_upgrade_sync
|
|
|
|
sleep "$interval"
|
|
done
|