Skip to content

Commit

Permalink
DOSE-836 zoa.conf multiple disk zettacache support (openzfs#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
grwilson authored Dec 14, 2021
1 parent 014b145 commit 808f37e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
27 changes: 14 additions & 13 deletions cmd/zfs_object_agent/scripts/start_zoa
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
#!/bin/sh
#!/bin/bash

#
# 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_CONFIG: Configuration file to set tunables (toml/json/yaml)
# - ZOA_LOG_CONFIG : log4rs configuration
# - ZETTACACHE_DEVICE: File/device to use for ZettaCache
# - ZETTACACHE_DEVICES: File[s]/device[s] to use for ZettaCache
#

DEV_WAIT=300

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

wait_for_device() {
function wait_for_device() {
local DEVICE=$1

# Wait for udev to settle and for the device to show up.
udevadm settle
for i in $(seq 1 $DEV_WAIT); do
if [ -b "$DEVICE" ]; then
return
fi
[[ -b "$DEVICE" ]] && return

echo "Waiting for $DEVICE to show up..."
sleep 1
done
Expand All @@ -36,16 +35,18 @@ ZOA_LOG_CONFIG="${ZOA_LOG_CONFIG:-/etc/zfs/zoa_log4rs.yml}"
PARAMS="-l ${ZOA_LOG_CONFIG}"
echo "Logging config: ${ZOA_LOG_CONFIG}"

if [ ! -z $ZOA_CONFIG ]; then
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}"

wait_for_device ${ZETTACACHE_DEVICE}
if [[ ! -z $ZETTACACHE_DEVICES ]]; then
echo "ZettaCache: ${ZETTACACHE_DEVICES}"
ZETTACACHE_DEVICES=(${ZETTACACHE_DEVICES//,/\ })
for dev in "${ZETTACACHE_DEVICES[@]}"; do
wait_for_device "${dev}"
PARAMS="$PARAMS -c ${dev}"
done
fi

/sbin/zfs_object_agent ${PARAMS}
2 changes: 1 addition & 1 deletion etc/zfs/zoa.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ZOA_CONFIG=/etc/zfs/zoa_config.toml
ZOA_LOG_CONFIG=/etc/zfs/zoa_log4rs.yml
ZETTACACHE_DEVICE=
ZETTACACHE_DEVICES=

0 comments on commit 808f37e

Please sign in to comment.