Skip to content

Commit

Permalink
Add support for devid and phys_path keys in vdev disk labels
Browse files Browse the repository at this point in the history
This is foundational work for ZED.

Updates a leaf vdev's persistent device strings on Linux platform

* only applies for a dedicated leaf vdev (aka whole disk)
* updated during pool create|add|attach|import
* used for matching device matching during auto-{online,expand,replace}
* stored in a leaf disk config label (i.e. alongside 'path' NVP)
* can opt-out using env var ZFS_VDEV_DEVID_OPT_OUT=YES

Some examples:

    path: '/dev/sdb1'
    devid: 'scsi-350000394a8ca4fbc-part1'
    phys_path: 'pci-0000:04:00.0-sas-0x50000394a8ca4fbf-lun-0'

    path: '/dev/mapper/mpatha'
    devid: 'dm-uuid-mpath-35000c5006304de3f'

Signed-off-by: Don Brady <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #2856
Closes #3978
Closes #4416
  • Loading branch information
Don Brady authored and behlendorf committed Mar 31, 2016
1 parent bebd73f commit 39fc0cb
Show file tree
Hide file tree
Showing 11 changed files with 476 additions and 163 deletions.
15 changes: 14 additions & 1 deletion cmd/zpool/zpool_vdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013 by Delphix. All rights reserved.
* Copyright (c) 2016 Intel Corporation.
*/

/*
Expand Down Expand Up @@ -447,7 +448,7 @@ check_disk(const char *path, blkid_cache cache, int force,
(void) close(fd);

if (force) {
/* Partitions will no be created using the backup */
/* Partitions will now be created using the backup */
return (0);
} else {
vdev_error(gettext("%s contains a corrupt primary "
Expand Down Expand Up @@ -1178,6 +1179,12 @@ make_disks(zpool_handle_t *zhp, nvlist_t *nv)
&wholedisk));

if (!wholedisk) {
/*
* Update device id string for mpath nodes (Linux only)
*/
if (is_mpath_whole_disk(path))
update_vdev_config_dev_strs(nv);

(void) zero_label(path);
return (0);
}
Expand Down Expand Up @@ -1249,6 +1256,12 @@ make_disks(zpool_handle_t *zhp, nvlist_t *nv)
*/
verify(nvlist_add_string(nv, ZPOOL_CONFIG_PATH, udevpath) == 0);

/*
* Update device id strings for whole disks (Linux only)
*/
if (wholedisk)
update_vdev_config_dev_strs(nv);

return (0);
}

Expand Down
13 changes: 13 additions & 0 deletions config/user-libudev.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
dnl #
dnl # Check for libudev - needed for vdev auto-online and auto-replace
dnl #
AC_DEFUN([ZFS_AC_CONFIG_USER_LIBUDEV], [
LIBUDEV=
AC_CHECK_HEADER([libudev.h], [AC_SUBST([LIBUDEV], ["-ludev"])
AC_DEFINE([HAVE_LIBUDEV], 1, [Define if you have libudev])], [])
AC_SEARCH_LIBS(i[udev_device_get_is_initialized], [udev], [
AC_DEFINE([HAVE_LIBUDEV_UDEV_DEVICE_GET_IS_INITIALIZED], 1, [
Define if udev_device_get_is_initialized is available])], [])
])
1 change: 1 addition & 0 deletions config/user.m4
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ AC_DEFUN([ZFS_AC_CONFIG_USER], [
ZFS_AC_CONFIG_USER_LIBUUID
ZFS_AC_CONFIG_USER_LIBBLKID
ZFS_AC_CONFIG_USER_LIBATTR
ZFS_AC_CONFIG_USER_LIBUDEV
ZFS_AC_CONFIG_USER_FRAME_LARGER_THAN
ZFS_AC_CONFIG_USER_RUNSTATEDIR
Expand Down
7 changes: 7 additions & 0 deletions include/libzfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
* Copyright 2013 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2016, Intel Corporation.
*/

#ifndef _LIBZFS_H
Expand Down Expand Up @@ -801,6 +802,12 @@ extern boolean_t libzfs_fru_compare(libzfs_handle_t *, const char *,
extern boolean_t libzfs_fru_notself(libzfs_handle_t *, const char *);
extern int zpool_fru_set(zpool_handle_t *, uint64_t, const char *);

/*
* Support for Linux libudev derived persistent device strings
*/
extern boolean_t is_mpath_whole_disk(const char *);
extern void update_vdev_config_dev_strs(nvlist_t *);

#ifdef __cplusplus
}
#endif
Expand Down
77 changes: 0 additions & 77 deletions lib/libspl/include/devid.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,82 +28,5 @@
#define _LIBSPL_DEVID_H

#include <sys/types.h>
#include <stdlib.h>

typedef int ddi_devid_t;

typedef struct devid_nmlist {
char *devname;
dev_t dev;
} devid_nmlist_t;

static inline
int
devid_str_decode(
char *devidstr,
ddi_devid_t *retdevid,
char **retminor_name)
{
abort();
}

static inline
int
devid_deviceid_to_nmlist(
char *search_path,
ddi_devid_t devid,
char *minor_name,
devid_nmlist_t **retlist)
{
abort();
}

static inline
void
devid_str_free(char *str)
{
abort();
}

static inline
void
devid_free(ddi_devid_t devid)
{
abort();
}

static inline
void
devid_free_nmlist(devid_nmlist_t *list)
{
abort();
}

static inline
int
devid_get(
int fd,
ddi_devid_t *retdevid)
{
return (-1);
}

static inline
int
devid_get_minor_name(
int fd,
char **retminor_name)
{
abort();
}

static inline
char *
devid_str_encode(
ddi_devid_t devid,
char *minor_name)
{
abort();
}

#endif
2 changes: 1 addition & 1 deletion lib/libzfs/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ libzfs_la_LIBADD = \
$(top_builddir)/lib/libnvpair/libnvpair.la \
$(top_builddir)/lib/libzpool/libzpool.la

libzfs_la_LIBADD += -lm $(LIBBLKID)
libzfs_la_LIBADD += -lm $(LIBBLKID) $(LIBUDEV)
libzfs_la_LDFLAGS = -version-info 2:0:0

EXTRA_DIST = $(libzfs_pc_DATA) $(USER_C)
Loading

0 comments on commit 39fc0cb

Please sign in to comment.