5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License Version 1.0 (CDDL-1.0).
7 # You can obtain a copy of the license from the top-level file
8 # "OPENSOLARIS.LICENSE" or at <http://opensource.org/licenses/CDDL-1.0>.
9 # You may not use this file except in compliance with the license.
15 # Copyright (c) 2018, Intel Corporation.
19 # Adjust lustre service degrade state in response to a statechange
21 # ZEVENT_SUBCLASS: 'statechange'
22 # POOL HEALTH: status from "zpool list health" (either ONLINE or DEGRADED)
31 # 4: Pool status neither "ONLINE" nor "DEGRADED
33 # This script is also symlinked as vdev_attach-lustre.sh, vdev_remove-lustre.sh
34 # and vdev_clear-lustre.sh, since it needs to take the same action on those
37 [ -f "${ZED_ZEDLET_DIR}/zed.rc" ] && . "${ZED_ZEDLET_DIR}/zed.rc"
38 . "${ZED_ZEDLET_DIR}/zed-functions.sh"
40 LCTL=${LCTL:-/usr/sbin/lctl}
41 ZPOOL=${ZPOOL:-/usr/sbin/zpool}
42 ZFS=${ZFS:-/usr/sbin/zfs}
44 zed_check_cmd "$LCTL" || exit 1
45 zed_check_cmd "$ZPOOL" || exit 2
46 zed_check_cmd "$ZFS" || exit 3
49 # sync_degrade_state (dataset, state)
55 local service=$($ZFS list -H -o lustre:svname ${dataset})
57 zed_log_msg "Lustre:sync_degrade_state pool:${dataset} degraded:${state}"
59 if [ -n "${service}" ] && [ "${service}" != "-" ] ; then
60 local current=$($LCTL get_param -n obdfilter.${service}.degraded)
62 if [ "${current}" != "${state}" ] ; then
63 $LCTL set_param obdfilter.${service}.degraded=${state}
69 # use pool state as deciding factor
71 POOL_STATE=$($ZPOOL list -H -o health ${ZEVENT_POOL})
73 if [ "${POOL_STATE}" == "ONLINE" ] ; then
75 elif [ "${POOL_STATE}" == "DEGRADED" ] ; then
82 # visit target pool's datasets and adjust lustre service degrade mode
84 read -r -a DATASETS <<< \
85 $($ZFS get -rH -s local -t filesystem -o name lustre:svname ${ZEVENT_POOL})
87 for dataset in "${DATASETS[@]}" ; do
88 sync_degrade_state "${dataset}" "${MODE}"