1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/patches/hotplug-fix Fri Jun 18 19:11:31 2010 -0700
1.3 @@ -0,0 +1,440 @@
1.4 +diff -r af89d08633ea usr/src/cmd/fm/modules/common/Makefile
1.5 +--- a/usr/src/cmd/fm/modules/common/Makefile Fri May 28 13:36:41 2010 -0600
1.6 ++++ b/usr/src/cmd/fm/modules/common/Makefile Fri Jun 18 17:41:38 2010 -0700
1.7 +@@ -37,6 +37,7 @@
1.8 + sp-monitor \
1.9 + syslog-msgs \
1.10 + zfs-diagnosis \
1.11 ++ zfs-monitor \
1.12 + zfs-retire
1.13 +
1.14 + include ../../Makefile.subdirs
1.15 +diff -r af89d08633ea usr/src/cmd/fm/modules/common/zfs-monitor/Makefile
1.16 +--- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.17 ++++ b/usr/src/cmd/fm/modules/common/zfs-monitor/Makefile Fri Jun 18 17:41:38 2010 -0700
1.18 +@@ -0,0 +1,33 @@
1.19 ++#
1.20 ++# CDDL HEADER START
1.21 ++#
1.22 ++# The contents of this file are subject to the terms of the
1.23 ++# Common Development and Distribution License (the "License").
1.24 ++# You may not use this file except in compliance with the License.
1.25 ++#
1.26 ++# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1.27 ++# or http://www.opensolaris.org/os/licensing.
1.28 ++# See the License for the specific language governing permissions
1.29 ++# and limitations under the License.
1.30 ++#
1.31 ++# When distributing Covered Code, include this CDDL HEADER in each
1.32 ++# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1.33 ++# If applicable, add the following below this CDDL HEADER, with the
1.34 ++# fields enclosed by brackets "[]" replaced with your own identifying
1.35 ++# information: Portions Copyright [yyyy] [name of copyright owner]
1.36 ++#
1.37 ++# CDDL HEADER END
1.38 ++#
1.39 ++#
1.40 ++# Copyright 2010 Nexenta Systems, Inc. All rights reserved.
1.41 ++# Use is subject to license terms.
1.42 ++#
1.43 ++
1.44 ++MODULE = zfs-monitor
1.45 ++CLASS = common
1.46 ++SRCS = zfs_monitor.c
1.47 ++
1.48 ++include ../../Makefile.plugin
1.49 ++
1.50 ++LDLIBS += -L$(ROOTLIB)/fm -luutil -lzfs -ltopo
1.51 ++LDFLAGS += -R/usr/lib/fm
1.52 +diff -r af89d08633ea usr/src/cmd/fm/modules/common/zfs-monitor/zfs-monitor.conf
1.53 +--- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.54 ++++ b/usr/src/cmd/fm/modules/common/zfs-monitor/zfs-monitor.conf Fri Jun 18 17:41:38 2010 -0700
1.55 +@@ -0,0 +1,24 @@
1.56 ++#
1.57 ++# CDDL HEADER START
1.58 ++#
1.59 ++# The contents of this file are subject to the terms of the
1.60 ++# Common Development and Distribution License (the "License").
1.61 ++# You may not use this file except in compliance with the License.
1.62 ++#
1.63 ++# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1.64 ++# or http://www.opensolaris.org/os/licensing.
1.65 ++# See the License for the specific language governing permissions
1.66 ++# and limitations under the License.
1.67 ++#
1.68 ++# When distributing Covered Code, include this CDDL HEADER in each
1.69 ++# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1.70 ++# If applicable, add the following below this CDDL HEADER, with the
1.71 ++# fields enclosed by brackets "[]" replaced with your own identifying
1.72 ++# information: Portions Copyright [yyyy] [name of copyright owner]
1.73 ++#
1.74 ++# CDDL HEADER END
1.75 ++#
1.76 ++#
1.77 ++# Copyright 2010 Nexenta Systems, Inc. All rights reserved.
1.78 ++# Use is subject to license terms.
1.79 ++#
1.80 +diff -r af89d08633ea usr/src/cmd/fm/modules/common/zfs-monitor/zfs_monitor.c
1.81 +--- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.82 ++++ b/usr/src/cmd/fm/modules/common/zfs-monitor/zfs_monitor.c Fri Jun 18 17:41:38 2010 -0700
1.83 +@@ -0,0 +1,296 @@
1.84 ++/*
1.85 ++ * CDDL HEADER START
1.86 ++ *
1.87 ++ * The contents of this file are subject to the terms of the
1.88 ++ * Common Development and Distribution License (the "License").
1.89 ++ * You may not use this file except in compliance with the License.
1.90 ++ *
1.91 ++ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1.92 ++ * or http://www.opensolaris.org/os/licensing.
1.93 ++ * See the License for the specific language governing permissions
1.94 ++ * and limitations under the License.
1.95 ++ *
1.96 ++ * When distributing Covered Code, include this CDDL HEADER in each
1.97 ++ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1.98 ++ * If applicable, add the following below this CDDL HEADER, with the
1.99 ++ * fields enclosed by brackets "[]" replaced with your own identifying
1.100 ++ * information: Portions Copyright [yyyy] [name of copyright owner]
1.101 ++ *
1.102 ++ * CDDL HEADER END
1.103 ++ */
1.104 ++/*
1.105 ++ * Copyright 2010 Nexenta Systems, Inc. All rights reserved.
1.106 ++ * Use is subject to license terms.
1.107 ++ */
1.108 ++
1.109 ++#include <stdio.h>
1.110 ++#include <stdlib.h>
1.111 ++#include <string.h>
1.112 ++#include <libzfs.h>
1.113 ++#include <fcntl.h>
1.114 ++#include <unistd.h>
1.115 ++#include <fm/fmd_api.h>
1.116 ++#include <fm/libtopo.h>
1.117 ++#include <sys/fs/zfs.h>
1.118 ++#include <sys/fm/protocol.h>
1.119 ++#include <sys/fm/fs/zfs.h>
1.120 ++#include <sys/dkio.h>
1.121 ++
1.122 ++typedef struct zm {
1.123 ++ fmd_hdl_t *fhdl;
1.124 ++ libzfs_handle_t *zhdl;
1.125 ++ fmd_xprt_t *xprt;
1.126 ++ id_t tid;
1.127 ++ hrtime_t interval;
1.128 ++ boolean_t exit;
1.129 ++} zm_t;
1.130 ++
1.131 ++static void
1.132 ++zm_process_tree(zm_t *zm, zpool_handle_t *zph, nvlist_t *vd)
1.133 ++{
1.134 ++ nvlist_t **child;
1.135 ++ uint_t nchild, c;
1.136 ++ vdev_stat_t *vs;
1.137 ++ uint64_t pguid, vguid;
1.138 ++ int ret;
1.139 ++ boolean_t leaf = B_TRUE;
1.140 ++ nvlist_t *er; /* ereport */
1.141 ++ nvlist_t *dt; /* detector */
1.142 ++ uint64_t ena;
1.143 ++ char *class;
1.144 ++ char *path;
1.145 ++ char *vtype;
1.146 ++ int fd;
1.147 ++ char rpath[MAXPATHLEN];
1.148 ++
1.149 ++ /*
1.150 ++ * If we have children devices, then we're not a physical
1.151 ++ * vdev. We only really want to be monitoring real physical
1.152 ++ * devices, but we do recurse down to find all the real
1.153 ++ * devices.
1.154 ++ */
1.155 ++
1.156 ++ /*
1.157 ++ * NB: ZIL devices (LOG devices) are in the CHILDREN array,
1.158 ++ * but are distinguished by a special nvpair "is_log". We
1.159 ++ * don't bother to distinguish the two.
1.160 ++ */
1.161 ++ if (nvlist_lookup_nvlist_array(vd, ZPOOL_CONFIG_CHILDREN, &child,
1.162 ++ &nchild) == 0) {
1.163 ++ for (c = 0; c < nchild; c++) {
1.164 ++ zm_process_tree(zm, zph, child[c]);
1.165 ++ }
1.166 ++ leaf = B_FALSE;
1.167 ++ }
1.168 ++ if (nvlist_lookup_nvlist_array(vd, ZPOOL_CONFIG_L2CACHE, &child,
1.169 ++ &nchild) == 0) {
1.170 ++ for (c = 0; c < nchild; c++) {
1.171 ++ zm_process_tree(zm, zph, child[c]);
1.172 ++ }
1.173 ++ leaf = B_FALSE;
1.174 ++ }
1.175 ++ if (nvlist_lookup_nvlist_array(vd, ZPOOL_CONFIG_SPARES, &child,
1.176 ++ &nchild) == 0) {
1.177 ++ for (c = 0; c < nchild; c++) {
1.178 ++ zm_process_tree(zm, zph, child[c]);
1.179 ++ }
1.180 ++ leaf = B_FALSE;
1.181 ++ }
1.182 ++
1.183 ++ /*
1.184 ++ * Only process physical disk devices.
1.185 ++ */
1.186 ++ if ((!leaf) ||
1.187 ++ (nvlist_lookup_string(vd, ZPOOL_CONFIG_TYPE, &vtype) != 0) ||
1.188 ++ (strcmp(vtype, VDEV_TYPE_DISK) != 0) ||
1.189 ++ (nvlist_lookup_string(vd, ZPOOL_CONFIG_PATH, &path) != 0) ||
1.190 ++ (strncmp(path, "/dev/dsk/", 9) != 0)) {
1.191 ++ return;
1.192 ++ }
1.193 ++
1.194 ++ ret = nvlist_lookup_uint64_array(vd, ZPOOL_CONFIG_VDEV_STATS,
1.195 ++ (uint64_t **)&vs, &c);
1.196 ++ assert(ret == 0);
1.197 ++
1.198 ++ switch (vs->vs_state) {
1.199 ++ case VDEV_STATE_HEALTHY:
1.200 ++ case VDEV_STATE_DEGRADED:
1.201 ++ /*
1.202 ++ * We only care to look at states where ZFS thinks
1.203 ++ * that the device is ready to go. Its unclear what
1.204 ++ * DEGRADED would mean in the presence of a real disk,
1.205 ++ * but lets try to handle it too.
1.206 ++ */
1.207 ++ break;
1.208 ++ default:
1.209 ++ /*
1.210 ++ * For devices that are already in some kind of
1.211 ++ * offline state, we have nothing to do, ZFS already
1.212 ++ * should have brought in a spare, or whatever.
1.213 ++ */
1.214 ++ fmd_hdl_debug(zm->fhdl, "device state %d not healthy\n",
1.215 ++ vs->vs_state);
1.216 ++ return;
1.217 ++ }
1.218 ++ (void) snprintf(rpath, sizeof (rpath), "/dev/rdsk/%s", path + 9);
1.219 ++
1.220 ++ fd = open(rpath, O_RDONLY | O_NDELAY);
1.221 ++ if (fd >= 0) {
1.222 ++ struct dk_minfo minfo;
1.223 ++ char block[DEV_BSIZE];
1.224 ++
1.225 ++ if (read(fd, block, DEV_BSIZE) == DEV_BSIZE) {
1.226 ++ (void) close(fd);
1.227 ++ return;
1.228 ++ }
1.229 ++ fmd_hdl_debug(zm->fhdl, "device read failed: %s\n",
1.230 ++ strerror(errno));
1.231 ++ (void) close(fd);
1.232 ++ }
1.233 ++ if (fd < 0) {
1.234 ++ fmd_hdl_debug(zm->fhdl, "can't open %s: %s\n", rpath,
1.235 ++ strerror(errno));
1.236 ++ }
1.237 ++
1.238 ++ /*
1.239 ++ * From this point on, we know that the vdev is failed or
1.240 ++ * non-responsive, but ZFS doesn't realize it yet. Lets
1.241 ++ * trigger an FMA ereport, which the ZFS diagnostic engine will
1.242 ++ * recognize.
1.243 ++ *
1.244 ++ * Note that because of the way zfs_de.c works, we need to put the
1.245 ++ * VDEV into faulted state first, otherwise the diagnosis engine
1.246 ++ * won't do anything with it.
1.247 ++ */
1.248 ++
1.249 ++ class = FM_EREPORT_CLASS "." ZFS_ERROR_CLASS "."
1.250 ++ FM_EREPORT_ZFS_DEVICE_OPEN_FAILED;
1.251 ++ ena = fmd_event_ena_create(zm->fhdl);
1.252 ++ pguid = zpool_get_prop_int(zph, ZPOOL_PROP_GUID, NULL);
1.253 ++ ret = nvlist_lookup_uint64(vd, ZPOOL_CONFIG_GUID, &vguid);
1.254 ++ assert(ret == 0);
1.255 ++
1.256 ++ ret = zpool_vdev_fault(zph, vguid, VDEV_AUX_OPEN_FAILED);
1.257 ++ if (ret != 0) {
1.258 ++ fmd_hdl_debug(zm->fhdl, "can't fault vdev %llx: %d, %d, %s\n",
1.259 ++ (unsigned long long)vguid, ret, errno, strerror(errno));
1.260 ++ }
1.261 ++
1.262 ++ dt = fmd_nvl_alloc(zm->fhdl, FMD_SLEEP);
1.263 ++ (void) nvlist_add_uint8(dt, FM_VERSION, ZFS_SCHEME_VERSION0);
1.264 ++ (void) nvlist_add_string(dt, FM_FMRI_SCHEME, FM_FMRI_SCHEME_ZFS);
1.265 ++ (void) nvlist_add_uint64(dt, FM_FMRI_ZFS_POOL, pguid);
1.266 ++ (void) nvlist_add_uint64(dt, FM_FMRI_ZFS_VDEV, vguid);
1.267 ++
1.268 ++ er = fmd_nvl_alloc(zm->fhdl, FMD_SLEEP);
1.269 ++ (void) nvlist_add_string(er, FM_CLASS, class);
1.270 ++ (void) nvlist_add_uint8(er, FM_VERSION, FM_EREPORT_VERSION);
1.271 ++ (void) nvlist_add_uint64(er, FM_EREPORT_ENA, ena);
1.272 ++ (void) nvlist_add_nvlist(er, FM_EREPORT_DETECTOR, dt);
1.273 ++ (void) nvlist_add_string(er, FM_EREPORT_PAYLOAD_ZFS_POOL,
1.274 ++ zpool_get_name(zph));
1.275 ++ (void) nvlist_add_uint64(er, FM_EREPORT_PAYLOAD_ZFS_POOL_GUID, pguid);
1.276 ++ (void) nvlist_add_uint64(er, FM_EREPORT_PAYLOAD_ZFS_VDEV_GUID, vguid);
1.277 ++ (void) nvlist_add_uint64(er, FM_EREPORT_PAYLOAD_ZFS_POOL_CONTEXT,
1.278 ++ SPA_LOAD_NONE);
1.279 ++ (void) nvlist_add_string(er, FM_EREPORT_PAYLOAD_ZFS_VDEV_TYPE, vtype);
1.280 ++
1.281 ++ /*
1.282 ++ * Note that it would appear that kernel events include other
1.283 ++ * payload items, but for vdev ereports, the diagnosis engine
1.284 ++ * doesn't need them. Arguably, we could have skipped the
1.285 ++ * entire zfs diagnosis engine, but this way we keep the same
1.286 ++ * code paths as other ereports.
1.287 ++ */
1.288 ++ fmd_xprt_post(zm->fhdl, zm->xprt, er, 0);
1.289 ++ fmd_hdl_debug(zm->fhdl, "posted ereport: %s for %s\n", class, path);
1.290 ++}
1.291 ++
1.292 ++static int
1.293 ++zm_pool_iter(zpool_handle_t *zph, void *arg)
1.294 ++{
1.295 ++ zm_t *zm = arg;
1.296 ++ nvlist_t *cfg;
1.297 ++ nvlist_t *vd;
1.298 ++
1.299 ++ cfg = zpool_get_config(zph, NULL);
1.300 ++ if (nvlist_lookup_nvlist(cfg, ZPOOL_CONFIG_VDEV_TREE, &vd) == 0) {
1.301 ++ zm_process_tree(zm, zph, vd);
1.302 ++ } else {
1.303 ++ fmd_hdl_debug(zm->fhdl, "missing vdev tree?!?\n");
1.304 ++ }
1.305 ++ return (0);
1.306 ++}
1.307 ++
1.308 ++static void
1.309 ++zm_timeout(fmd_hdl_t *hdl, id_t id, void *arg)
1.310 ++{
1.311 ++ zm_t *zm = arg;
1.312 ++ _NOTE(ARGUNUSED(hdl));
1.313 ++ _NOTE(ARGUNUSED(id));
1.314 ++
1.315 ++ if (zm->exit)
1.316 ++ return;
1.317 ++ (void) zpool_iter(zm->zhdl, zm_pool_iter, zm);
1.318 ++ zm->tid = fmd_timer_install(hdl, zm, NULL, zm->interval);
1.319 ++}
1.320 ++
1.321 ++static const fmd_hdl_ops_t fmd_ops = {
1.322 ++ NULL, /* fmdo_recv */
1.323 ++ zm_timeout, /* fmdo_timeout */
1.324 ++ NULL, /* fmdo_close */
1.325 ++ NULL, /* fmdo_stats */
1.326 ++ NULL, /* fmdo_gc */
1.327 ++ NULL, /* fmdo_send */
1.328 ++ NULL, /* fmdo_topo_change */
1.329 ++};
1.330 ++
1.331 ++static const fmd_prop_t fmd_props[] = {
1.332 ++ { "interval", FMD_TYPE_TIME, "10sec" },
1.333 ++ { NULL, 0, NULL }
1.334 ++};
1.335 ++
1.336 ++static const fmd_hdl_info_t fmd_info = {
1.337 ++ "ZFS Disk Monitor", "1.0", &fmd_ops, fmd_props
1.338 ++};
1.339 ++
1.340 ++void
1.341 ++_fmd_init(fmd_hdl_t *fhdl)
1.342 ++{
1.343 ++ zm_t *zm;
1.344 ++
1.345 ++ if (fmd_hdl_register(fhdl, FMD_API_VERSION, &fmd_info) != 0) {
1.346 ++ return;
1.347 ++ }
1.348 ++
1.349 ++ zm = fmd_hdl_alloc(fhdl, sizeof (*zm), FMD_SLEEP);
1.350 ++
1.351 ++ zm->fhdl = fhdl;
1.352 ++
1.353 ++ if ((zm->zhdl = libzfs_init()) == NULL)
1.354 ++ return;
1.355 ++
1.356 ++ fmd_hdl_setspecific(fhdl, zm);
1.357 ++ zm->interval = fmd_prop_get_int64(fhdl, "interval");
1.358 ++ zm->xprt = fmd_xprt_open(fhdl, FMD_XPRT_RDONLY, NULL, NULL);
1.359 ++ zm->exit = B_FALSE;
1.360 ++ fmd_hdl_debug(fhdl, "interval: %llu\n",
1.361 ++ (unsigned long long)zm->interval);
1.362 ++ zm->tid = fmd_timer_install(fhdl, zm, NULL, zm->interval);
1.363 ++}
1.364 ++
1.365 ++void
1.366 ++_fmd_fini(fmd_hdl_t *fhdl)
1.367 ++{
1.368 ++ zm_t *zm;
1.369 ++
1.370 ++ zm = fmd_hdl_getspecific(fhdl);
1.371 ++ zm->exit = B_TRUE;
1.372 ++
1.373 ++ (void) fmd_timer_remove(fhdl, zm->tid);
1.374 ++ fmd_xprt_close(fhdl, zm->xprt);
1.375 ++
1.376 ++ libzfs_fini(zm->zhdl);
1.377 ++
1.378 ++ fmd_hdl_free(fhdl, zm, sizeof (*zm));
1.379 ++}
1.380 +diff -r af89d08633ea usr/src/cmd/fm/schemes/zfs/scheme.c
1.381 +--- a/usr/src/cmd/fm/schemes/zfs/scheme.c Fri May 28 13:36:41 2010 -0600
1.382 ++++ b/usr/src/cmd/fm/schemes/zfs/scheme.c Fri Jun 18 17:41:38 2010 -0700
1.383 +@@ -99,20 +99,28 @@
1.384 + return (nv);
1.385 +
1.386 + if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_CHILDREN,
1.387 +- &child, &children) != 0)
1.388 +- return (NULL);
1.389 ++ &child, &children) == 0) {
1.390 +
1.391 +- for (c = 0; c < children; c++)
1.392 +- if ((ret = find_vdev_iter(child[c], search)) != 0)
1.393 +- return (ret);
1.394 ++ for (c = 0; c < children; c++)
1.395 ++ if ((ret = find_vdev_iter(child[c], search)) != 0)
1.396 ++ return (ret);
1.397 ++ }
1.398 +
1.399 + if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_L2CACHE,
1.400 +- &child, &children) != 0)
1.401 +- return (NULL);
1.402 ++ &child, &children) == 0) {
1.403 +
1.404 +- for (c = 0; c < children; c++)
1.405 +- if ((ret = find_vdev_iter(child[c], search)) != 0)
1.406 +- return (ret);
1.407 ++ for (c = 0; c < children; c++)
1.408 ++ if ((ret = find_vdev_iter(child[c], search)) != 0)
1.409 ++ return (ret);
1.410 ++ }
1.411 ++
1.412 ++ if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_SPARES,
1.413 ++ &child, &children) == 0) {
1.414 ++
1.415 ++ for (c = 0; c < children; c++)
1.416 ++ if ((ret = find_vdev_iter(child[c], search)) != 0)
1.417 ++ return (ret);
1.418 ++ }
1.419 +
1.420 + return (NULL);
1.421 + }
1.422 +diff -r af89d08633ea usr/src/pkgdefs/SUNWfmd/prototype_com
1.423 +--- a/usr/src/pkgdefs/SUNWfmd/prototype_com Fri May 28 13:36:41 2010 -0600
1.424 ++++ b/usr/src/pkgdefs/SUNWfmd/prototype_com Fri Jun 18 17:41:38 2010 -0700
1.425 +@@ -23,6 +23,9 @@
1.426 + # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
1.427 + # Use is subject to license terms.
1.428 + #
1.429 ++# Copyright 2010 Nexenta Systems, Inc. All rights reserved.
1.430 ++# Use is subject to license terms.
1.431 ++#
1.432 +
1.433 + i pkginfo
1.434 + i copyright
1.435 +@@ -100,6 +103,8 @@
1.436 + f none usr/lib/fm/fmd/plugins/syslog-msgs.so 555 root bin
1.437 + f none usr/lib/fm/fmd/plugins/zfs-diagnosis.conf 644 root bin
1.438 + f none usr/lib/fm/fmd/plugins/zfs-diagnosis.so 555 root bin
1.439 ++f none usr/lib/fm/fmd/plugins/zfs-monitor.conf 644 root bin
1.440 ++f none usr/lib/fm/fmd/plugins/zfs-monitor.so 555 root bin
1.441 + f none usr/lib/fm/fmd/plugins/zfs-retire.conf 644 root bin
1.442 + f none usr/lib/fm/fmd/plugins/zfs-retire.so 555 root bin
1.443 + d none usr/lib/fm/fmd/schemes 755 root bin
2.1 --- a/patches/series Thu Jun 10 22:07:19 2010 -0700
2.2 +++ b/patches/series Fri Jun 18 19:11:31 2010 -0700
2.3 @@ -369,3 +369,4 @@
2.4 bkport-bb02b9cd2b96-zfs-mutex-fix.patch
2.5 bkport-16aef3d16470-ddt-deadlock-panic-fix.patch
2.6 bkport-3c3a4d3d1dda-zfs-delete-share-fix.patch
2.7 +hotplug-fix