summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDon Brady <[email protected]>2016-08-31 15:46:58 -0600
committerBrian Behlendorf <[email protected]>2016-09-01 11:39:45 -0700
commitd02ca379795a37b8541da5a1b37528f7130de1e6 (patch)
tree67167cfd23f15abeccefe553400bf37dd1032399 /lib
parent0b284702b75aa712a7d1353b93e19d5b2c783f27 (diff)
Bring over illumos ZFS FMA logic -- phase 1
This first phase brings over the ZFS SLM module, zfs_mod.c, to handle auto operations in response to disk events. Disk event monitoring is provided from libudev and generates the expected payload schema for zfs_mod. This work leverages the recently added devid and phys_path strings in the vdev label. Signed-off-by: Brian Behlendorf <[email protected]> Signed-off-by: Don Brady <[email protected]> Signed-off-by: Tony Hutter <[email protected]> Closes #4673
Diffstat (limited to 'lib')
-rw-r--r--lib/libzfs/libzfs_import.c16
-rw-r--r--lib/libzfs/libzfs_pool.c10
2 files changed, 14 insertions, 12 deletions
diff --git a/lib/libzfs/libzfs_import.c b/lib/libzfs/libzfs_import.c
index edc0adcee..edd4e5d58 100644
--- a/lib/libzfs/libzfs_import.c
+++ b/lib/libzfs/libzfs_import.c
@@ -116,10 +116,10 @@ typedef struct vdev_dev_strs {
/*
* Obtain the persistent device id string (describes what)
*
- * used by ZED auto-{online,expand,replace}
+ * used by ZED vdev matching for auto-{online,expand,replace}
*/
-static int
-udev_device_get_devid(struct udev_device *dev, char *bufptr, size_t buflen)
+int
+zfs_device_get_devid(struct udev_device *dev, char *bufptr, size_t buflen)
{
struct udev_list_entry *entry;
const char *bus;
@@ -167,10 +167,10 @@ udev_device_get_devid(struct udev_device *dev, char *bufptr, size_t buflen)
/*
* Obtain the persistent physical location string (describes where)
*
- * used by ZED auto-{online,expand,replace}
+ * used by ZED vdev matching for auto-{online,expand,replace}
*/
-static int
-udev_device_get_physical(struct udev_device *dev, char *bufptr, size_t buflen)
+int
+zfs_device_get_physical(struct udev_device *dev, char *bufptr, size_t buflen)
{
const char *physpath, *value;
@@ -394,12 +394,12 @@ encode_device_strings(const char *path, vdev_dev_strs_t *ds,
if (!wholedisk && !udev_mpath_whole_disk(dev))
goto no_dev;
- ret = udev_device_get_devid(dev, ds->vds_devid, sizeof (ds->vds_devid));
+ ret = zfs_device_get_devid(dev, ds->vds_devid, sizeof (ds->vds_devid));
if (ret != 0)
goto no_dev_ref;
/* physical location string (optional) */
- if (udev_device_get_physical(dev, ds->vds_devphys,
+ if (zfs_device_get_physical(dev, ds->vds_devphys,
sizeof (ds->vds_devphys)) != 0) {
ds->vds_devphys[0] = '\0'; /* empty string --> not available */
}
diff --git a/lib/libzfs/libzfs_pool.c b/lib/libzfs/libzfs_pool.c
index 2484ddc12..a37ea7913 100644
--- a/lib/libzfs/libzfs_pool.c
+++ b/lib/libzfs/libzfs_pool.c
@@ -3397,9 +3397,11 @@ set_path(zpool_handle_t *zhp, nvlist_t *nv, const char *path)
* case only occurs when the suffix is preceded by a digit, i.e. "md0p0" The
* third case only occurs when preceded by a string matching the regular
* expression "^([hsv]|xv)d[a-z]+", i.e. a scsi, ide, virtio or xen disk.
+ *
+ * caller must free the returned string
*/
-static char *
-strip_partition(libzfs_handle_t *hdl, char *path)
+char *
+zfs_strip_partition(libzfs_handle_t *hdl, char *path)
{
char *tmp = zfs_strdup(hdl, path);
char *part = NULL, *d = NULL;
@@ -3542,7 +3544,7 @@ zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv,
*/
if (nvlist_lookup_uint64(nv, ZPOOL_CONFIG_WHOLE_DISK, &value)
== 0 && value && !(name_flags & VDEV_NAME_PATH)) {
- return (strip_partition(hdl, path));
+ return (zfs_strip_partition(hdl, path));
}
} else {
verify(nvlist_lookup_string(nv, ZPOOL_CONFIG_TYPE, &path) == 0);
@@ -4216,7 +4218,7 @@ zpool_label_disk(libzfs_handle_t *hdl, zpool_handle_t *zhp, char *name)
(void) snprintf(path, sizeof (path), "%s/%s", DISK_ROOT, name);
- if ((fd = open(path, O_RDWR|O_DIRECT)) < 0) {
+ if ((fd = open(path, O_RDWR|O_DIRECT|O_EXCL)) < 0) {
/*
* This shouldn't happen. We've long since verified that this
* is a valid device.