Skip to content

Commit

Permalink
Add a vdev_size payload to the ereport if vdev_path is set.
Browse files Browse the repository at this point in the history
Signed-off-by: Turbo Fredriksson <turbo@bayour.com>

Closes: openzfs#2562
  • Loading branch information
FransUrbo committed May 3, 2015
1 parent 6186e29 commit 134ebc2
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 1 deletion.
15 changes: 14 additions & 1 deletion 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 @@ -110,6 +110,17 @@ notify()
return "${rv}"
}

# 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
}


# main
#
Expand Down Expand Up @@ -210,6 +221,8 @@ main()
# Round-robin through the spares trying those that are available.
#
for spare in ${ZEVENT_VDEV_SPARE_PATHS}; do
orig_size=${ZEVENT_VDEV_SIZE}
spare_size=$(vdev_size ${SPARE})

# shellcheck disable=SC2046
set -- $(query_vdev_status "${ZEVENT_POOL}" "${spare}")
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 134ebc2

Please sign in to comment.