diff options
author | Sydney Vanda <[email protected]> | 2017-03-02 09:47:26 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2017-04-05 16:18:19 -0700 |
commit | 7a4500a10102c00a67442628df2ac2395484757e (patch) | |
tree | 39eed4a62156f55f1e7911dd0df78d149e805a5b /cmd/zed | |
parent | 6ba1ce9ee9741b1ce65f4a71549099d94392012e (diff) |
Added auto-replace FMA test for the ZFS Test Suite
Also included are updates to auto-online test
Automated auto-replace test to go along with ZED FMA integration
(PR 4673) auto-replace_001.pos works using a scsi_debug device
(the only usable virtual device currently due to whole_disk var
needing to be set)
Functionality for automated FMA auto-replace test to work with
scsi_debug devs: Some functionality/exceptions needed to be
added for automation of auto-replace to work correctly.
In the test an alias vdev_id rule is added for any scsi_debug
device which sets the phys_path="scsidebug" after a udevadm
trigger command.
A symlink is created for the vdev_id.conf file (in /etc/zfs/ by
default) to be used in-tree for the test suite
(/var/tmp/zfs/vdev_id.conf). "./scripts/zfs-helpers.sh -i" needs
to be run before fault tests in the ZTS (to use udev rules in-tree)
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Don Brady <[email protected]>
Reviewed-by: David Quigley <[email protected]>
Signed-off-by: Sydney Vanda <[email protected]>
Closes #5944
Diffstat (limited to 'cmd/zed')
-rw-r--r-- | cmd/zed/agents/zfs_mod.c | 20 | ||||
-rw-r--r-- | cmd/zed/zed_disk_event.c | 27 |
2 files changed, 42 insertions, 5 deletions
diff --git a/cmd/zed/agents/zfs_mod.c b/cmd/zed/agents/zfs_mod.c index d297ab294..7ebf708ae 100644 --- a/cmd/zed/agents/zfs_mod.c +++ b/cmd/zed/agents/zfs_mod.c @@ -22,7 +22,7 @@ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012 by Delphix. All rights reserved. * Copyright 2014 Nexenta Systems, Inc. All rights reserved. - * Copyright (c) 2016, Intel Corporation. + * Copyright (c) 2016, 2017, Intel Corporation. */ /* @@ -89,6 +89,7 @@ #define DEV_BYID_PATH "/dev/disk/by-id/" #define DEV_BYPATH_PATH "/dev/disk/by-path/" +#define DEV_BYVDEV_PATH "/dev/disk/by-vdev/" typedef void (*zfs_process_func_t)(zpool_handle_t *, nvlist_t *, boolean_t); @@ -190,6 +191,7 @@ zfs_process_add(zpool_handle_t *zhp, nvlist_t *vdev, boolean_t labeled) char devpath[PATH_MAX]; int ret; int is_dm = 0; + int is_sd = 0; uint_t c; vdev_stat_t *vs; @@ -259,6 +261,13 @@ zfs_process_add(zpool_handle_t *zhp, nvlist_t *vdev, boolean_t labeled) } /* + * vdev_id alias rule for using scsi_debug devices (FMA automated + * testing) + */ + if (strcmp("scsidebug", physpath) == 0) + is_sd = 1; + + /* * If the pool doesn't have the autoreplace property set, then use * vdev online to trigger a FMA fault by posting an ereport. */ @@ -272,10 +281,13 @@ zfs_process_add(zpool_handle_t *zhp, nvlist_t *vdev, boolean_t labeled) } /* - * convert physical path into its current device node + * Convert physical path into its current device node. Rawpath + * needs to be /dev/disk/by-vdev for a scsi_debug device since + * /dev/disk/by-path will not be present. */ - (void) snprintf(rawpath, sizeof (rawpath), "%s%s", DEV_BYPATH_PATH, - physpath); + (void) snprintf(rawpath, sizeof (rawpath), "%s%s", + is_sd ? DEV_BYVDEV_PATH : DEV_BYPATH_PATH, physpath); + if (realpath(rawpath, devpath) == NULL && !is_dm) { zed_log_msg(LOG_INFO, " realpath: %s failed (%s)", rawpath, strerror(errno)); diff --git a/cmd/zed/zed_disk_event.c b/cmd/zed/zed_disk_event.c index ae39bd6a9..32eefb2f3 100644 --- a/cmd/zed/zed_disk_event.c +++ b/cmd/zed/zed_disk_event.c @@ -11,7 +11,7 @@ */ /* - * Copyright (c) 2016, Intel Corporation. + * Copyright (c) 2016, 2017, Intel Corporation. */ #ifdef HAVE_LIBUDEV @@ -312,6 +312,31 @@ zed_udev_monitor(void *arg) free(tmp2); } + /* + * Special case an EC_DEV_ADD for scsi_debug devices + * + * These devices require a udevadm trigger command after + * creation in order to register the vdev_id scsidebug alias + * rule (adds a persistent path (phys_path) used for fault + * management automated tests in the ZFS test suite. + * + * After udevadm trigger command, event registers as a "change" + * event but needs to instead be handled as another "add" event + * to allow for disk labeling and partitioning to occur. + */ + if (strcmp(class, EC_DEV_STATUS) == 0 && + udev_device_get_property_value(dev, "ID_VDEV") && + udev_device_get_property_value(dev, "ID_MODEL")) { + const char *id_model, *id_model_sd = "scsi_debug"; + + id_model = udev_device_get_property_value(dev, + "ID_MODEL"); + if (strcmp(id_model, id_model_sd) == 0) { + class = EC_DEV_ADD; + subclass = ESC_DISK; + } + } + if ((nvl = dev_event_nvlist(dev)) != NULL) { zed_udev_event(class, subclass, nvl); nvlist_free(nvl); |