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 <behlendorf1@llnl.gov>
Reviewed-by: Don Brady <don.brady@intel.com>
Reviewed-by: David Quigley <david.quigley@intel.com>
Signed-off-by: Sydney Vanda <sydney.m.vanda@intel.com>
Closes #5944
This commit is contained in:
Sydney Vanda
2017-03-02 09:47:26 -07:00
committed by Brian Behlendorf
parent 6ba1ce9ee9
commit 7a4500a101
11 changed files with 374 additions and 117 deletions
+16 -4
View File
@@ -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;
@@ -258,6 +260,13 @@ zfs_process_add(zpool_handle_t *zhp, nvlist_t *vdev, boolean_t labeled)
return;
}
/*
* 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));
+26 -1
View File
@@ -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);