Skip to content

Commit

Permalink
Add zettacache support to zfs-object-agent.service (openzfs#428)
Browse files Browse the repository at this point in the history
  • Loading branch information
manoj-joseph authored Sep 3, 2021
1 parent 5b56f9d commit 36f05f1
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 3 deletions.
4 changes: 3 additions & 1 deletion cmd/zfs_object_agent/scripts/Makefile.am
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
dist_bin_SCRIPTS = zoa_chaos_monkey
dist_bin_SCRIPTS = \
zoa_chaos_monkey \
start_zoa
46 changes: 46 additions & 0 deletions cmd/zfs_object_agent/scripts/start_zoa
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/sh

#
# This script starts the ZFS Object Agent process.
# It uses the following environment variables, typically set by zfs-object-agent.service
# to determine which command line parameters to pass to the ZFS Object Agent process.
# - ZOA_LOG: File to log output to
# - ZOA_CONFIG: Configuration file to set tunables (toml/json/yaml"
# - ZETTACACHE_DEVICE: File/device to use for ZettaCache
# - ZOA_LOG_LEVEL : Sets the level of logging verbosity.
# Values can be TRACE, DEBUG, INFO, WARN.
#

error() {
echo "$@" 1>&2
}

ZOA_LOG="${ZOA_LOG:-/var/log/zoa.log}"
PARAMS="-o ${ZOA_LOG}"
echo "Logging to: ${ZOA_LOG}"

if [ ! -z $ZOA_CONFIG ]; then
echo "Config file: ${ZOA_CONFIG}"
PARAMS="${PARAMS} -t ${ZOA_CONFIG}"
fi

if [ ! -z $ZETTACACHE_DEVICE ]; then
echo "ZettaCache: ${ZETTACACHE_DEVICE}"
PARAMS="$PARAMS -c ${ZETTACACHE_DEVICE}"
fi

if [ ! -z $ZOA_LOG_LEVEL ]; then
if [ $ZOA_LOG_LEVEL = 'WARN' ]; then
: # WARN is the default log level.
elif [ $ZOA_LOG_LEVEL = 'INFO' ]; then
PARAMS="${PARAMS} -v"
elif [ $ZOA_LOG_LEVEL = 'DEBUG' ]; then
PARAMS="${PARAMS} -vv"
elif [ $ZOA_LOG_LEVEL = 'TRACE' ]; then
PARAMS="${PARAMS} -vvv"
else
error "Invalid log level setting: $ZOA_LOG_LEVEL; ignoring."
fi
fi

/sbin/zfs_object_agent ${PARAMS}
3 changes: 3 additions & 0 deletions debian/zfsutils-linux.install
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ lib/udev/
debian/tmp/etc/default/zfs etc/default/
debian/tmp/etc/zfs/zfs-functions etc/zfs/
etc/zfs/zpool.d/
debian/tmp/etc/zfs/zoa_config.toml etc/zfs/
debian/tmp/etc/zfs/zoa.conf etc/zfs/
usr/lib/*/zfs/zpool.d/
usr/lib/*/zfs/zpool_influxdb
sbin/fsck.zfs
Expand All @@ -38,6 +40,7 @@ sbin/zoa_test
cmd/zfs_object_agent/libzoa.so lib/
usr/bin/zvol_wait
usr/bin/zoa_chaos_monkey
usr/bin/start_zoa
usr/sbin/arc_summary
usr/sbin/arcstat
usr/sbin/dbufstat
Expand Down
3 changes: 2 additions & 1 deletion etc/systemd/system/zfs-object-agent.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Before=zfs-import-cache.service
Environment="RUST_BACKTRACE=1"
Environment="AWS_SECRET_ACCESS_KEY="
Environment="AWS_ACCESS_KEY_ID="
ExecStart=/sbin/zfs_object_agent -vv
EnvironmentFile=-/etc/zfs/zoa.conf
ExecStart=/usr/bin/start_zoa
Restart=always

[Install]
Expand Down
4 changes: 3 additions & 1 deletion etc/zfs/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ dist_pkgsysconf_DATA = \
vdev_id.conf.sas_direct.example \
vdev_id.conf.sas_switch.example \
vdev_id.conf.multipath.example \
vdev_id.conf.scsi.example
vdev_id.conf.scsi.example \
zoa.conf \
zoa_config.toml

pkgsysconf_SCRIPTS = \
zfs-functions
Expand Down
4 changes: 4 additions & 0 deletions etc/zfs/zoa.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ZOA_LOG=/var/log/zoa.log
ZOA_LOG_LEVEL=DEBUG
ZOA_CONFIG=/etc/zfs/zoa_config.toml
ZETTACACHE_DEVICE=
4 changes: 4 additions & 0 deletions etc/zfs/zoa_config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#
# This config file overrides default values for tunable parameters in
# the ZFS Object Agent.
#
3 changes: 3 additions & 0 deletions rpm/generic/zfs.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ systemctl --system daemon-reload >/dev/null || true
%{_bindir}/zvol_wait
# Optional zfs_object_agent script
%{_bindir}/zoa_chaos_monkey
%{_bindir}/start_zoa
# Optional Python 2/3 scripts
%{_bindir}/arc_summary
%{_bindir}/arcstat
Expand Down Expand Up @@ -512,6 +513,8 @@ systemctl --system daemon-reload >/dev/null || true
%endif
%config(noreplace) %{_sysconfdir}/%{name}/zed.d/*
%config(noreplace) %{_sysconfdir}/%{name}/zpool.d/*
%config(noreplace) %{_sysconfdir}/%{name}/zoa_config.toml
%config(noreplace) %{_sysconfdir}/%{name}/zoa.conf
%config(noreplace) %{_sysconfdir}/%{name}/vdev_id.conf.*.example
%attr(440, root, root) %config(noreplace) %{_sysconfdir}/sudoers.d/*
%if %{with pam}
Expand Down

0 comments on commit 36f05f1

Please sign in to comment.