Skip to content

Commit

Permalink
2683: turbo/issue-2562 - Add a vdev_size payload to the ereport if vd…
Browse files Browse the repository at this point in the history
…ev_path is set.

Signed-off-by: Turbo Fredriksson <[email protected]>

Closes: openzfs#2562
  • Loading branch information
FransUrbo committed Nov 5, 2014
1 parent fb46909 commit 0b7e39e
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 2 deletions.
24 changes: 22 additions & 2 deletions cmd/zed/zed.d/io-spare.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# Replace a device with a hot spare in response to IO or checksum errors.
# The following actions will be performed automatically when the number
Expand Down Expand Up @@ -62,6 +62,17 @@ vdev_status() {
return 0
}

# Given a <device>, return the size
vdev_size() {
local VDEV=`basename $1`

for dir in /dev /dev/disk/by-*; do
if [[ -L $dir/$VDEV ]]; then
blockdev --getsize64 $dir/$VDEV
fi
done
}

# Fault devices after N I/O errors.
if [ "${ZEVENT_CLASS}" = "ereport.fs.zfs.io" ]; then
ERRORS=`expr ${ZEVENT_VDEV_READ_ERRORS} + ${ZEVENT_VDEV_WRITE_ERRORS}`
Expand All @@ -70,6 +81,7 @@ if [ "${ZEVENT_CLASS}" = "ereport.fs.zfs.io" ]; then
${ERRORS} -ge ${ZED_SPARE_ON_IO_ERRORS} ]; then
ACTION="fault"
fi

# Degrade devices after N checksum errors.
elif [ "${ZEVENT_CLASS}" = "ereport.fs.zfs.checksum" ]; then
ERRORS=${ZEVENT_VDEV_CKSUM_ERRORS}
Expand All @@ -78,12 +90,12 @@ elif [ "${ZEVENT_CLASS}" = "ereport.fs.zfs.checksum" ]; then
${ERRORS} -ge ${ZED_SPARE_ON_CHECKSUM_ERRORS} ]; then
ACTION="degrade"
fi

else
ACTION=
fi

if [ -n "${ACTION}" ]; then

# Device is already FAULTED or DEGRADED
set -- `vdev_status ${ZEVENT_POOL} ${ZEVENT_VDEV_PATH}`
ZEVENT_VDEV_PATH_FOUND=$1
Expand Down Expand Up @@ -111,10 +123,18 @@ if [ -n "${ACTION}" ]; then
# Round robin through the spares selecting those which are available.
#
for SPARE in ${ZEVENT_VDEV_SPARE_PATHS}; do
orig_size=${ZEVENT_VDEV_SIZE}
spare_size=$(vdev_size ${SPARE})
echo "${ZEVENT_POOL}:${ZEVENT_VDEV_GUID} = '$orig_size'" >> /tmp/zed.out
echo "${ZEVENT_POOL}:${SPARE} = '$spare_size'" >> /tmp/zed.out

set -- `vdev_status ${ZEVENT_POOL} ${SPARE}`
SPARE_VDEV_FOUND=$1
STATUS=$2
echo " SPARE_VDEV_FOUND='$SPARE_VDEV_FOUND', STATUS='$STATUS'" >> /tmp/zed.out

if [ "${STATUS}" = "AVAIL" ]; then
echo " ${ZPOOL} replace ${ZEVENT_POOL} ${ZEVENT_VDEV_GUID} ${SPARE_VDEV_FOUND}" >> /tmp/zed.out
${ZPOOL} replace ${ZEVENT_POOL} \
${ZEVENT_VDEV_GUID} ${SPARE_VDEV_FOUND} && exit 0
fi
Expand Down
4 changes: 4 additions & 0 deletions include/sys/fm/fs/zfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ extern "C" {
#define FM_EREPORT_PAYLOAD_ZFS_VDEV_FRU "vdev_fru"
#define FM_EREPORT_PAYLOAD_ZFS_VDEV_STATE "vdev_state"
#define FM_EREPORT_PAYLOAD_ZFS_VDEV_ASHIFT "vdev_ashift"
#define FM_EREPORT_PAYLOAD_ZFS_VDEV_ASIZE "vdev_asize"
#define FM_EREPORT_PAYLOAD_ZFS_VDEV_PSIZE "vdev_psize"
#define FM_EREPORT_PAYLOAD_ZFS_VDEV_MIN_ASIZE "vdev_min_asize"
#define FM_EREPORT_PAYLOAD_ZFS_VDEV_MAX_ASIZE "vdev_max_asize"
#define FM_EREPORT_PAYLOAD_ZFS_VDEV_COMP_TS "vdev_complete_ts"
#define FM_EREPORT_PAYLOAD_ZFS_VDEV_DELTA_TS "vdev_delta_ts"
#define FM_EREPORT_PAYLOAD_ZFS_VDEV_SPARE_PATHS "vdev_spare_paths"
Expand Down
37 changes: 37 additions & 0 deletions man/man5/zfs-events.5
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,43 @@ The GUID of the vdev in question (the vdev failing or operated upon with
\fBzpool clear\fR etc).
.RE

.sp
.ne 2
.na
\fBvdev_asize\fR
.ad
.RS 12n
Allocatable device capacity
.RE

.sp
.ne 2
.na
\fBvdev_min_asize\fR
.ad
.RS 12n
Min acceptable asize
.RE

.sp
.ne 2
.na
\fBvdev_max_asize\fR
.ad
.RS 12n
Max acceptable asize
.RE

.sp
.ne 2
.na
\fBvdev_psize\fR
.ad
.RS 12n
Size of the vdev in question (the vdev failing or operated upon with
\fBzpool clear\fR etc).
.RE

.sp
.ne 2
.na
Expand Down
10 changes: 10 additions & 0 deletions module/zfs/zfs_fm.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,16 @@ zfs_ereport_start(nvlist_t **ereport_out, nvlist_t **detector_out,
FM_EREPORT_PAYLOAD_ZFS_PARENT_TYPE,
DATA_TYPE_STRING, pvd->vdev_ops->vdev_op_type,
NULL);
fm_payload_set(ereport,
FM_EREPORT_PAYLOAD_ZFS_VDEV_ASIZE,
DATA_TYPE_UINT64, pvd->vdev_asize,
FM_EREPORT_PAYLOAD_ZFS_VDEV_PSIZE,
DATA_TYPE_UINT64, pvd->vdev_psize,
FM_EREPORT_PAYLOAD_ZFS_VDEV_MIN_ASIZE,
DATA_TYPE_UINT64, pvd->vdev_min_asize,
FM_EREPORT_PAYLOAD_ZFS_VDEV_MAX_ASIZE,
DATA_TYPE_UINT64, pvd->vdev_max_asize,
NULL);
if (pvd->vdev_path)
fm_payload_set(ereport,
FM_EREPORT_PAYLOAD_ZFS_PARENT_PATH,
Expand Down

0 comments on commit 0b7e39e

Please sign in to comment.