mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
Rescan enclosure sysfs path on import
When you create a pool, zfs writes vd->vdev_enc_sysfs_path with the
enclosure sysfs path to the fault LEDs, like:
vdev_enc_sysfs_path = /sys/class/enclosure/0:0:1:0/SLOT8
However, this enclosure path doesn't get updated on successive imports
even if enclosure path to the disk changes. This patch fixes the issue.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Closes #11950
Closes #12095
This commit is contained in:
@@ -26,7 +26,8 @@ zpool_LDADD = \
|
||||
$(abs_top_builddir)/lib/libzfs/libzfs.la \
|
||||
$(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \
|
||||
$(abs_top_builddir)/lib/libnvpair/libnvpair.la \
|
||||
$(abs_top_builddir)/lib/libuutil/libuutil.la
|
||||
$(abs_top_builddir)/lib/libuutil/libuutil.la \
|
||||
$(abs_top_builddir)/lib/libzutil/libzutil.la
|
||||
|
||||
zpool_LDADD += $(LTLIBINTL)
|
||||
|
||||
|
||||
+3
-47
@@ -264,51 +264,6 @@ for_each_pool(int argc, char **argv, boolean_t unavail,
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int
|
||||
for_each_vdev_cb(zpool_handle_t *zhp, nvlist_t *nv, pool_vdev_iter_f func,
|
||||
void *data)
|
||||
{
|
||||
nvlist_t **child;
|
||||
uint_t c, children;
|
||||
int ret = 0;
|
||||
int i;
|
||||
char *type;
|
||||
|
||||
const char *list[] = {
|
||||
ZPOOL_CONFIG_SPARES,
|
||||
ZPOOL_CONFIG_L2CACHE,
|
||||
ZPOOL_CONFIG_CHILDREN
|
||||
};
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(list); i++) {
|
||||
if (nvlist_lookup_nvlist_array(nv, list[i], &child,
|
||||
&children) == 0) {
|
||||
for (c = 0; c < children; c++) {
|
||||
uint64_t ishole = 0;
|
||||
|
||||
(void) nvlist_lookup_uint64(child[c],
|
||||
ZPOOL_CONFIG_IS_HOLE, &ishole);
|
||||
|
||||
if (ishole)
|
||||
continue;
|
||||
|
||||
ret |= for_each_vdev_cb(zhp, child[c], func,
|
||||
data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nvlist_lookup_string(nv, ZPOOL_CONFIG_TYPE, &type) != 0)
|
||||
return (ret);
|
||||
|
||||
/* Don't run our function on root vdevs */
|
||||
if (strcmp(type, VDEV_TYPE_ROOT) != 0) {
|
||||
ret |= func(zhp, nv, data);
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*
|
||||
* This is the equivalent of for_each_pool() for vdevs. It iterates thorough
|
||||
* all vdevs in the pool, ignoring root vdevs and holes, calling func() on
|
||||
@@ -327,7 +282,7 @@ for_each_vdev(zpool_handle_t *zhp, pool_vdev_iter_f func, void *data)
|
||||
verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE,
|
||||
&nvroot) == 0);
|
||||
}
|
||||
return (for_each_vdev_cb(zhp, nvroot, func, data));
|
||||
return (for_each_vdev_cb((void *) zhp, nvroot, func, data));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -603,7 +558,7 @@ vdev_run_cmd_thread(void *cb_cmd_data)
|
||||
|
||||
/* For each vdev in the pool run a command */
|
||||
static int
|
||||
for_each_vdev_run_cb(zpool_handle_t *zhp, nvlist_t *nv, void *cb_vcdl)
|
||||
for_each_vdev_run_cb(void *zhp_data, nvlist_t *nv, void *cb_vcdl)
|
||||
{
|
||||
vdev_cmd_data_list_t *vcdl = cb_vcdl;
|
||||
vdev_cmd_data_t *data;
|
||||
@@ -611,6 +566,7 @@ for_each_vdev_run_cb(zpool_handle_t *zhp, nvlist_t *nv, void *cb_vcdl)
|
||||
char *vname = NULL;
|
||||
char *vdev_enc_sysfs_path = NULL;
|
||||
int i, match = 0;
|
||||
zpool_handle_t *zhp = zhp_data;
|
||||
|
||||
if (nvlist_lookup_string(nv, ZPOOL_CONFIG_PATH, &path) != 0)
|
||||
return (1);
|
||||
|
||||
@@ -5156,11 +5156,12 @@ get_stat_flags(zpool_list_t *list)
|
||||
* Return 1 if cb_data->cb_vdev_names[0] is this vdev's name, 0 otherwise.
|
||||
*/
|
||||
static int
|
||||
is_vdev_cb(zpool_handle_t *zhp, nvlist_t *nv, void *cb_data)
|
||||
is_vdev_cb(void *zhp_data, nvlist_t *nv, void *cb_data)
|
||||
{
|
||||
iostat_cbdata_t *cb = cb_data;
|
||||
char *name = NULL;
|
||||
int ret = 0;
|
||||
zpool_handle_t *zhp = zhp_data;
|
||||
|
||||
name = zpool_vdev_name(g_zfs, zhp, nv, cb->cb_name_flags);
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
#include <libnvpair.h>
|
||||
#include <libzfs.h>
|
||||
#include <libzutil.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -68,7 +69,6 @@ int for_each_pool(int, char **, boolean_t unavail, zprop_list_t **,
|
||||
boolean_t, zpool_iter_f, void *);
|
||||
|
||||
/* Vdev list functions */
|
||||
typedef int (*pool_vdev_iter_f)(zpool_handle_t *, nvlist_t *, void *);
|
||||
int for_each_vdev(zpool_handle_t *zhp, pool_vdev_iter_f func, void *data);
|
||||
|
||||
typedef struct zpool_list zpool_list_t;
|
||||
|
||||
Reference in New Issue
Block a user