usr/src/cmd/syseventd/modules/zfs_mod/zfs_mod.c
author Eric Taylor <Eric.Taylor@Sun.COM>
Thu, 20 May 2010 16:14:49 -0600
changeset 12456 318640f559d8
parent 12318 a036286976a0
child 12710 66c9c36f2046
permissions -rw-r--r--
6952269 several memory leaks in zfs_mod
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
     1
/*
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
     2
 * CDDL HEADER START
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
     3
 *
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
     4
 * The contents of this file are subject to the terms of the
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
     5
 * Common Development and Distribution License (the "License").
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
     6
 * You may not use this file except in compliance with the License.
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
     7
 *
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
     8
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
     9
 * or http://www.opensolaris.org/os/licensing.
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    10
 * See the License for the specific language governing permissions
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    11
 * and limitations under the License.
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    12
 *
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    13
 * When distributing Covered Code, include this CDDL HEADER in each
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    14
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    15
 * If applicable, add the following below this CDDL HEADER, with the
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    16
 * fields enclosed by brackets "[]" replaced with your own identifying
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    17
 * information: Portions Copyright [yyyy] [name of copyright owner]
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    18
 *
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    19
 * CDDL HEADER END
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    20
 */
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    21
/*
12318
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
    22
 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
4451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    23
 */
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    24
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    25
/*
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    26
 * ZFS syseventd module.
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    27
 *
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    28
 * The purpose of this module is to identify when devices are added to the
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    29
 * system, and appropriately online or replace the affected vdevs.
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    30
 *
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    31
 * When a device is added to the system:
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    32
 *
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    33
 * 	1. Search for any vdevs whose devid matches that of the newly added
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    34
 *	   device.
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    35
 *
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    36
 * 	2. If no vdevs are found, then search for any vdevs whose devfs path
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    37
 *	   matches that of the new device.
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    38
 *
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    39
 *	3. If no vdevs match by either method, then ignore the event.
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    40
 *
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    41
 * 	4. Attempt to online the device with a flag to indicate that it should
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    42
 *	   be unspared when resilvering completes.  If this succeeds, then the
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    43
 *	   same device was inserted and we should continue normally.
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    44
 *
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    45
 *	5. If the pool does not have the 'autoreplace' property set, attempt to
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    46
 *	   online the device again without the unspare flag, which will
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    47
 *	   generate a FMA fault.
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    48
 *
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    49
 *	6. If the pool has the 'autoreplace' property set, and the matching vdev
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    50
 *	   is a whole disk, then label the new disk and attempt a 'zpool
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    51
 *	   replace'.
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    52
 *
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    53
 * The module responds to EC_DEV_ADD events for both disks and lofi devices,
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    54
 * with the latter used for testing.  The special ESC_ZFS_VDEV_CHECK event
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    55
 * indicates that a device failed to open during pool load, but the autoreplace
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    56
 * property was set.  In this case, we deferred the associated FMA fault until
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    57
 * our module had a chance to process the autoreplace logic.  If the device
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    58
 * could not be replaced, then the second online attempt will trigger the FMA
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    59
 * fault that we skipped earlier.
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    60
 */
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    61
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    62
#include <alloca.h>
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    63
#include <devid.h>
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    64
#include <fcntl.h>
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    65
#include <libnvpair.h>
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    66
#include <libsysevent.h>
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    67
#include <libzfs.h>
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    68
#include <limits.h>
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    69
#include <stdlib.h>
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    70
#include <string.h>
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    71
#include <syslog.h>
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    72
#include <sys/sunddi.h>
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    73
#include <sys/sysevent/eventdefs.h>
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    74
#include <sys/sysevent/dev.h>
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    75
#include <unistd.h>
12318
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
    76
#include "syseventd.h"
4451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    77
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    78
#if defined(__i386) || defined(__amd64)
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    79
#define	PHYS_PATH	":q"
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    80
#define	RAW_SLICE	"p0"
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    81
#elif defined(__sparc)
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    82
#define	PHYS_PATH	":c"
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    83
#define	RAW_SLICE	"s2"
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    84
#else
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    85
#error Unknown architecture
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    86
#endif
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    87
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    88
typedef void (*zfs_process_func_t)(zpool_handle_t *, nvlist_t *, boolean_t);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    89
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    90
libzfs_handle_t *g_zfshdl;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    91
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    92
/*
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    93
 * The device associated with the given vdev (either by devid or physical path)
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    94
 * has been added to the system.  If 'isdisk' is set, then we only attempt a
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    95
 * replacement if it's a whole disk.  This also implies that we should label the
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    96
 * disk first.
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    97
 *
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    98
 * First, we attempt to online the device (making sure to undo any spare
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
    99
 * operation when finished).  If this succeeds, then we're done.  If it fails,
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   100
 * and the new state is VDEV_CANT_OPEN, it indicates that the device was opened,
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   101
 * but that the label was not what we expected.  If the 'autoreplace' property
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   102
 * is not set, then we relabel the disk (if specified), and attempt a 'zpool
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   103
 * replace'.  If the online is successful, but the new state is something else
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   104
 * (REMOVED or FAULTED), it indicates that we're out of sync or in some sort of
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   105
 * race, and we should avoid attempting to relabel the disk.
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   106
 */
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   107
static void
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   108
zfs_process_add(zpool_handle_t *zhp, nvlist_t *vdev, boolean_t isdisk)
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   109
{
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   110
	char *path;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   111
	vdev_state_t newstate;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   112
	nvlist_t *nvroot, *newvd;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   113
	uint64_t wholedisk = 0ULL;
6673
be079d6124af 6697301 deadlock between ZFS and devfs can hang system
eschrock
parents: 6643
diff changeset
   114
	char *physpath = NULL;
4451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   115
	char rawpath[PATH_MAX], fullpath[PATH_MAX];
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   116
	size_t len;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   117
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   118
	if (nvlist_lookup_string(vdev, ZPOOL_CONFIG_PATH, &path) != 0)
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   119
		return;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   120
6673
be079d6124af 6697301 deadlock between ZFS and devfs can hang system
eschrock
parents: 6643
diff changeset
   121
	(void) nvlist_lookup_string(vdev, ZPOOL_CONFIG_PHYS_PATH, &physpath);
4451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   122
	(void) nvlist_lookup_uint64(vdev, ZPOOL_CONFIG_WHOLE_DISK, &wholedisk);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   123
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   124
	/*
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   125
	 * We should have a way to online a device by guid.  With the current
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   126
	 * interface, we are forced to chop off the 's0' for whole disks.
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   127
	 */
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   128
	(void) strlcpy(fullpath, path, sizeof (fullpath));
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   129
	if (wholedisk)
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   130
		fullpath[strlen(fullpath) - 2] = '\0';
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   131
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   132
	/*
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   133
	 * Attempt to online the device.  It would be nice to online this by
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   134
	 * GUID, but the current interface only supports lookup by path.
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   135
	 */
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   136
	if (zpool_vdev_online(zhp, fullpath,
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   137
	    ZFS_ONLINE_CHECKREMOVE | ZFS_ONLINE_UNSPARE, &newstate) == 0 &&
6673
be079d6124af 6697301 deadlock between ZFS and devfs can hang system
eschrock
parents: 6643
diff changeset
   138
	    (newstate == VDEV_STATE_HEALTHY || newstate == VDEV_STATE_DEGRADED))
4451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   139
		return;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   140
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   141
	/*
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   142
	 * If the pool doesn't have the autoreplace property set, then attempt a
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   143
	 * true online (without the unspare flag), which will trigger a FMA
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   144
	 * fault.
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   145
	 */
5094
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4451
diff changeset
   146
	if (!zpool_get_prop_int(zhp, ZPOOL_PROP_AUTOREPLACE, NULL) ||
4451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   147
	    (isdisk && !wholedisk)) {
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   148
		(void) zpool_vdev_online(zhp, fullpath, ZFS_ONLINE_FORCEFAULT,
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   149
		    &newstate);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   150
		return;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   151
	}
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   152
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   153
	if (isdisk) {
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   154
		/*
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   155
		 * If this is a request to label a whole disk, then attempt to
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   156
		 * write out the label.  Before we can label the disk, we need
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   157
		 * access to a raw node.  Ideally, we'd like to walk the devinfo
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   158
		 * tree and find a raw node from the corresponding parent node.
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   159
		 * This is overly complicated, and since we know how we labeled
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   160
		 * this device in the first place, we know it's save to switch
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   161
		 * from /dev/dsk to /dev/rdsk and append the backup slice.
6643
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 5756
diff changeset
   162
		 *
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 5756
diff changeset
   163
		 * If any part of this process fails, then do a force online to
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 5756
diff changeset
   164
		 * trigger a ZFS fault for the device (and any hot spare
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 5756
diff changeset
   165
		 * replacement).
4451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   166
		 */
6643
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 5756
diff changeset
   167
		if (strncmp(path, "/dev/dsk/", 9) != 0) {
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 5756
diff changeset
   168
			(void) zpool_vdev_online(zhp, fullpath,
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 5756
diff changeset
   169
			    ZFS_ONLINE_FORCEFAULT, &newstate);
4451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   170
			return;
6643
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 5756
diff changeset
   171
		}
4451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   172
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   173
		(void) strlcpy(rawpath, path + 9, sizeof (rawpath));
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   174
		len = strlen(rawpath);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   175
		rawpath[len - 2] = '\0';
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   176
6643
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 5756
diff changeset
   177
		if (zpool_label_disk(g_zfshdl, zhp, rawpath) != 0) {
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 5756
diff changeset
   178
			(void) zpool_vdev_online(zhp, fullpath,
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 5756
diff changeset
   179
			    ZFS_ONLINE_FORCEFAULT, &newstate);
4451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   180
			return;
6643
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 5756
diff changeset
   181
		}
4451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   182
	}
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   183
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   184
	/*
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   185
	 * Cosntruct the root vdev to pass to zpool_vdev_attach().  While adding
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   186
	 * the entire vdev structure is harmless, we construct a reduced set of
6673
be079d6124af 6697301 deadlock between ZFS and devfs can hang system
eschrock
parents: 6643
diff changeset
   187
	 * path/physpath/wholedisk to keep it simple.
4451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   188
	 */
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   189
	if (nvlist_alloc(&nvroot, NV_UNIQUE_NAME, 0) != 0)
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   190
		return;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   191
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   192
	if (nvlist_alloc(&newvd, NV_UNIQUE_NAME, 0) != 0) {
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   193
		nvlist_free(nvroot);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   194
		return;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   195
	}
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   196
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   197
	if (nvlist_add_string(newvd, ZPOOL_CONFIG_TYPE, VDEV_TYPE_DISK) != 0 ||
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   198
	    nvlist_add_string(newvd, ZPOOL_CONFIG_PATH, path) != 0 ||
6673
be079d6124af 6697301 deadlock between ZFS and devfs can hang system
eschrock
parents: 6643
diff changeset
   199
	    (physpath != NULL && nvlist_add_string(newvd,
be079d6124af 6697301 deadlock between ZFS and devfs can hang system
eschrock
parents: 6643
diff changeset
   200
	    ZPOOL_CONFIG_PHYS_PATH, physpath) != 0) ||
4451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   201
	    nvlist_add_uint64(newvd, ZPOOL_CONFIG_WHOLE_DISK, wholedisk) != 0 ||
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   202
	    nvlist_add_string(nvroot, ZPOOL_CONFIG_TYPE, VDEV_TYPE_ROOT) != 0 ||
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   203
	    nvlist_add_nvlist_array(nvroot, ZPOOL_CONFIG_CHILDREN, &newvd,
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   204
	    1) != 0) {
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   205
		nvlist_free(newvd);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   206
		nvlist_free(nvroot);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   207
		return;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   208
	}
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   209
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   210
	nvlist_free(newvd);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   211
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   212
	(void) zpool_vdev_attach(zhp, fullpath, path, nvroot, B_TRUE);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   213
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   214
	nvlist_free(nvroot);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   215
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   216
}
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   217
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   218
/*
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   219
 * Utility functions to find a vdev matching given criteria.
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   220
 */
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   221
typedef struct dev_data {
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   222
	const char		*dd_compare;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   223
	const char		*dd_prop;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   224
	zfs_process_func_t	dd_func;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   225
	boolean_t		dd_found;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   226
	boolean_t		dd_isdisk;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   227
	uint64_t		dd_pool_guid;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   228
	uint64_t		dd_vdev_guid;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   229
} dev_data_t;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   230
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   231
static void
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   232
zfs_iter_vdev(zpool_handle_t *zhp, nvlist_t *nvl, void *data)
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   233
{
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   234
	dev_data_t *dp = data;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   235
	char *path;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   236
	uint_t c, children;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   237
	nvlist_t **child;
5756
05eb4c1ff492 6585441 spa_event_notify() doesn't pass its attributes
eschrock
parents: 5094
diff changeset
   238
	size_t len;
4451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   239
	uint64_t guid;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   240
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   241
	/*
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   242
	 * First iterate over any children.
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   243
	 */
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   244
	if (nvlist_lookup_nvlist_array(nvl, ZPOOL_CONFIG_CHILDREN,
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   245
	    &child, &children) == 0) {
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   246
		for (c = 0; c < children; c++)
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   247
			zfs_iter_vdev(zhp, child[c], data);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   248
		return;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   249
	}
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   250
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   251
	if (dp->dd_vdev_guid != 0) {
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   252
		if (nvlist_lookup_uint64(nvl, ZPOOL_CONFIG_GUID,
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   253
		    &guid) != 0 || guid != dp->dd_vdev_guid)
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   254
			return;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   255
	} else {
5756
05eb4c1ff492 6585441 spa_event_notify() doesn't pass its attributes
eschrock
parents: 5094
diff changeset
   256
		len = strlen(dp->dd_compare);
05eb4c1ff492 6585441 spa_event_notify() doesn't pass its attributes
eschrock
parents: 5094
diff changeset
   257
4451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   258
		if (nvlist_lookup_string(nvl, dp->dd_prop, &path) != 0 ||
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   259
		    strncmp(dp->dd_compare, path, len) != 0)
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   260
			return;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   261
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   262
		/*
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   263
		 * Normally, we want to have an exact match for the comparison
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   264
		 * string.  However, we allow substring matches in the following
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   265
		 * cases:
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   266
		 *
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   267
		 * 	<path>:		This is a devpath, and the target is one
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   268
		 * 			of its children.
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   269
		 *
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   270
		 * 	<path/>		This is a devid for a whole disk, and
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   271
		 * 			the target is one of its children.
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   272
		 */
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   273
		if (path[len] != '\0' && path[len] != ':' &&
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   274
		    path[len - 1] != '/')
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   275
			return;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   276
	}
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   277
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   278
	(dp->dd_func)(zhp, nvl, dp->dd_isdisk);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   279
}
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   280
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   281
static int
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   282
zfs_iter_pool(zpool_handle_t *zhp, void *data)
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   283
{
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   284
	nvlist_t *config, *nvl;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   285
	dev_data_t *dp = data;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   286
	uint64_t pool_guid;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   287
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   288
	if ((config = zpool_get_config(zhp, NULL)) != NULL) {
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   289
		if (dp->dd_pool_guid == 0 ||
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   290
		    (nvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_GUID,
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   291
		    &pool_guid) == 0 && pool_guid == dp->dd_pool_guid)) {
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   292
			(void) nvlist_lookup_nvlist(config,
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   293
			    ZPOOL_CONFIG_VDEV_TREE, &nvl);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   294
			zfs_iter_vdev(zhp, nvl, data);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   295
		}
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   296
	}
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   297
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   298
	zpool_close(zhp);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   299
	return (0);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   300
}
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   301
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   302
/*
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   303
 * Given a physical device path, iterate over all (pool, vdev) pairs which
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   304
 * correspond to the given path.
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   305
 */
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   306
static boolean_t
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   307
devpath_iter(const char *devpath, zfs_process_func_t func, boolean_t wholedisk)
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   308
{
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   309
	dev_data_t data = { 0 };
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   310
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   311
	data.dd_compare = devpath;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   312
	data.dd_func = func;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   313
	data.dd_prop = ZPOOL_CONFIG_PHYS_PATH;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   314
	data.dd_found = B_FALSE;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   315
	data.dd_isdisk = wholedisk;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   316
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   317
	(void) zpool_iter(g_zfshdl, zfs_iter_pool, &data);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   318
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   319
	return (data.dd_found);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   320
}
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   321
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   322
/*
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   323
 * Given a /devices path, lookup the corresponding devid for each minor node,
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   324
 * and find any vdevs with matching devids.  Doing this straight up would be
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   325
 * rather inefficient, O(minor nodes * vdevs in system), so we take advantage of
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   326
 * the fact that each devid ends with "/<minornode>".  Once we find any valid
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   327
 * minor node, we chop off the portion after the last slash, and then search for
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   328
 * matching vdevs, which is O(vdevs in system).
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   329
 */
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   330
static boolean_t
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   331
devid_iter(const char *devpath, zfs_process_func_t func, boolean_t wholedisk)
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   332
{
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   333
	size_t len = strlen(devpath) + sizeof ("/devices") +
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   334
	    sizeof (PHYS_PATH) - 1;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   335
	char *fullpath;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   336
	int fd;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   337
	ddi_devid_t devid;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   338
	char *devidstr, *fulldevid;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   339
	dev_data_t data = { 0 };
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   340
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   341
	/*
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   342
	 * Try to open a known minor node.
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   343
	 */
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   344
	fullpath = alloca(len);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   345
	(void) snprintf(fullpath, len, "/devices%s%s", devpath, PHYS_PATH);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   346
	if ((fd = open(fullpath, O_RDONLY)) < 0)
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   347
		return (B_FALSE);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   348
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   349
	/*
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   350
	 * Determine the devid as a string, with no trailing slash for the minor
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   351
	 * node.
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   352
	 */
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   353
	if (devid_get(fd, &devid) != 0) {
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   354
		(void) close(fd);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   355
		return (B_FALSE);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   356
	}
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   357
	(void) close(fd);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   358
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   359
	if ((devidstr = devid_str_encode(devid, NULL)) == NULL) {
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   360
		devid_free(devid);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   361
		return (B_FALSE);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   362
	}
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   363
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   364
	len = strlen(devidstr) + 2;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   365
	fulldevid = alloca(len);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   366
	(void) snprintf(fulldevid, len, "%s/", devidstr);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   367
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   368
	data.dd_compare = fulldevid;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   369
	data.dd_func = func;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   370
	data.dd_prop = ZPOOL_CONFIG_DEVID;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   371
	data.dd_found = B_FALSE;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   372
	data.dd_isdisk = wholedisk;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   373
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   374
	(void) zpool_iter(g_zfshdl, zfs_iter_pool, &data);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   375
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   376
	devid_str_free(devidstr);
12456
318640f559d8 6952269 several memory leaks in zfs_mod
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 12318
diff changeset
   377
	devid_free(devid);
4451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   378
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   379
	return (data.dd_found);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   380
}
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   381
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   382
/*
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   383
 * This function is called when we receive a devfs add event.  This can be
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   384
 * either a disk event or a lofi event, and the behavior is slightly different
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   385
 * depending on which it is.
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   386
 */
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   387
static int
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   388
zfs_deliver_add(nvlist_t *nvl, boolean_t is_lofi)
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   389
{
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   390
	char *devpath, *devname;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   391
	char path[PATH_MAX], realpath[PATH_MAX];
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   392
	char *colon, *raw;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   393
	int ret;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   394
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   395
	/*
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   396
	 * The main unit of operation is the physical device path.  For disks,
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   397
	 * this is the device node, as all minor nodes are affected.  For lofi
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   398
	 * devices, this includes the minor path.  Unfortunately, this isn't
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   399
	 * represented in the DEV_PHYS_PATH for various reasons.
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   400
	 */
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   401
	if (nvlist_lookup_string(nvl, DEV_PHYS_PATH, &devpath) != 0)
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   402
		return (-1);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   403
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   404
	/*
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   405
	 * If this is a lofi device, then also get the minor instance name.
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   406
	 * Unfortunately, the current payload doesn't include an easy way to get
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   407
	 * this information.  So we cheat by resolving the 'dev_name' (which
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   408
	 * refers to the raw device) and taking the portion between ':(*),raw'.
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   409
	 */
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   410
	(void) strlcpy(realpath, devpath, sizeof (realpath));
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   411
	if (is_lofi) {
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   412
		if (nvlist_lookup_string(nvl, DEV_NAME,
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   413
		    &devname) == 0 &&
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   414
		    (ret = resolvepath(devname, path,
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   415
		    sizeof (path))) > 0) {
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   416
			path[ret] = '\0';
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   417
			colon = strchr(path, ':');
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   418
			if (colon != NULL)
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   419
				raw = strstr(colon + 1, ",raw");
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   420
			if (colon != NULL && raw != NULL) {
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   421
				*raw = '\0';
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   422
				(void) snprintf(realpath,
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   423
				    sizeof (realpath), "%s%s",
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   424
				    devpath, colon);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   425
				*raw = ',';
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   426
			}
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   427
		}
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   428
	}
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   429
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   430
	/*
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   431
	 * Iterate over all vdevs with a matching devid, and then those with a
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   432
	 * matching /devices path.  For disks, we only want to pay attention to
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   433
	 * vdevs marked as whole disks.  For lofi, we don't care (because we're
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   434
	 * matching an exact minor name).
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   435
	 */
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   436
	if (!devid_iter(realpath, zfs_process_add, !is_lofi))
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   437
		(void) devpath_iter(realpath, zfs_process_add, !is_lofi);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   438
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   439
	return (0);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   440
}
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   441
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   442
/*
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   443
 * Called when we receive a VDEV_CHECK event, which indicates a device could not
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   444
 * be opened during initial pool open, but the autoreplace property was set on
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   445
 * the pool.  In this case, we treat it as if it were an add event.
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   446
 */
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   447
static int
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   448
zfs_deliver_check(nvlist_t *nvl)
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   449
{
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   450
	dev_data_t data = { 0 };
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   452
	if (nvlist_lookup_uint64(nvl, ZFS_EV_POOL_GUID,
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   453
	    &data.dd_pool_guid) != 0 ||
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   454
	    nvlist_lookup_uint64(nvl, ZFS_EV_VDEV_GUID,
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   455
	    &data.dd_vdev_guid) != 0)
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   456
		return (0);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   457
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   458
	data.dd_isdisk = B_TRUE;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   459
	data.dd_func = zfs_process_add;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   460
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   461
	(void) zpool_iter(g_zfshdl, zfs_iter_pool, &data);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   462
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   463
	return (0);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   464
}
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   465
12318
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   466
#define	DEVICE_PREFIX	"/devices"
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   467
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   468
static int
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   469
zfsdle_vdev_online(zpool_handle_t *zhp, void *data)
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   470
{
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   471
	char *devname = data;
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   472
	boolean_t avail_spare, l2cache;
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   473
	vdev_state_t newstate;
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   474
	nvlist_t *tgt;
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   475
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   476
	syseventd_print(9, "zfsdle_vdev_online: searching for %s in pool %s\n",
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   477
	    devname, zpool_get_name(zhp));
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   478
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   479
	if ((tgt = zpool_find_vdev_by_physpath(zhp, devname,
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   480
	    &avail_spare, &l2cache, NULL)) != NULL) {
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   481
		char *path, fullpath[MAXPATHLEN];
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   482
		uint64_t wholedisk = 0ULL;
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   483
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   484
		verify(nvlist_lookup_string(tgt, ZPOOL_CONFIG_PATH,
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   485
		    &path) == 0);
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   486
		verify(nvlist_lookup_uint64(tgt, ZPOOL_CONFIG_WHOLE_DISK,
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   487
		    &wholedisk) == 0);
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   488
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   489
		(void) strlcpy(fullpath, path, sizeof (fullpath));
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   490
		if (wholedisk)
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   491
			fullpath[strlen(fullpath) - 2] = '\0';
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   492
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   493
		if (zpool_get_prop_int(zhp, ZPOOL_PROP_AUTOEXPAND, NULL)) {
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   494
			syseventd_print(9, "zfsdle_vdev_online: setting device"
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   495
			    " device %s to ONLINE state in pool %s.\n",
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   496
			    fullpath, zpool_get_name(zhp));
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   497
			if (zpool_get_state(zhp) != POOL_STATE_UNAVAIL)
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   498
				(void) zpool_vdev_online(zhp, fullpath, 0,
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   499
				    &newstate);
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   500
		}
12456
318640f559d8 6952269 several memory leaks in zfs_mod
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 12318
diff changeset
   501
		zpool_close(zhp);
12318
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   502
		return (1);
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   503
	}
12456
318640f559d8 6952269 several memory leaks in zfs_mod
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 12318
diff changeset
   504
	zpool_close(zhp);
12318
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   505
	return (0);
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   506
}
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   507
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   508
int
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   509
zfs_deliver_dle(nvlist_t *nvl)
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   510
{
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   511
	char *devname;
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   512
	if (nvlist_lookup_string(nvl, DEV_PHYS_PATH, &devname) != 0) {
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   513
		syseventd_print(9, "zfs_deliver_event: no physpath\n");
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   514
		return (-1);
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   515
	}
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   516
	if (strncmp(devname, DEVICE_PREFIX, strlen(DEVICE_PREFIX)) != 0) {
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   517
		syseventd_print(9, "zfs_deliver_event: invalid "
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   518
		    "device '%s'", devname);
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   519
		return (-1);
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   520
	}
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   521
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   522
	/*
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   523
	 * We try to find the device using the physical
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   524
	 * path that has been supplied. We need to strip off
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   525
	 * the /devices prefix before starting our search.
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   526
	 */
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   527
	devname += strlen(DEVICE_PREFIX);
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   528
	if (zpool_iter(g_zfshdl, zfsdle_vdev_online, devname) != 1) {
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   529
		syseventd_print(9, "zfs_deliver_event: device '%s' not"
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   530
		    " found\n", devname);
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   531
		return (1);
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   532
	}
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   533
	nvlist_free(nvl);
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   534
	return (0);
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   535
}
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   536
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   537
4451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   538
/*ARGSUSED*/
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   539
static int
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   540
zfs_deliver_event(sysevent_t *ev, int unused)
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   541
{
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   542
	const char *class = sysevent_get_class_name(ev);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   543
	const char *subclass = sysevent_get_subclass_name(ev);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   544
	nvlist_t *nvl;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   545
	int ret;
12318
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   546
	boolean_t is_lofi, is_check, is_dle = B_FALSE;
4451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   547
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   548
	if (strcmp(class, EC_DEV_ADD) == 0) {
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   549
		/*
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   550
		 * We're mainly interested in disk additions, but we also listen
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   551
		 * for new lofi devices, to allow for simplified testing.
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   552
		 */
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   553
		if (strcmp(subclass, ESC_DISK) == 0)
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   554
			is_lofi = B_FALSE;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   555
		else if (strcmp(subclass, ESC_LOFI) == 0)
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   556
			is_lofi = B_TRUE;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   557
		else
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   558
			return (0);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   559
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   560
		is_check = B_FALSE;
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   561
	} else if (strcmp(class, EC_ZFS) == 0 &&
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   562
	    strcmp(subclass, ESC_ZFS_VDEV_CHECK) == 0) {
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   563
		/*
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   564
		 * This event signifies that a device failed to open during pool
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   565
		 * load, but the 'autoreplace' property was set, so we should
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   566
		 * pretend it's just been added.
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   567
		 */
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   568
		is_check = B_TRUE;
12318
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   569
	} else if (strcmp(class, EC_DEV_STATUS) == 0 &&
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   570
	    strcmp(subclass, ESC_DEV_DLE) == 0) {
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   571
		is_dle = B_TRUE;
4451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   572
	} else {
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   573
		return (0);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   574
	}
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   575
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   576
	if (sysevent_get_attr_list(ev, &nvl) != 0)
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   577
		return (-1);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   578
12318
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   579
	if (is_dle)
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   580
		ret = zfs_deliver_dle(nvl);
a036286976a0 6907687 zfs pool is not automatically fixed when disk are brought back online or after boot
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 6673
diff changeset
   581
	else if (is_check)
4451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   582
		ret = zfs_deliver_check(nvl);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   583
	else
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   584
		ret = zfs_deliver_add(nvl, is_lofi);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   585
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   586
	nvlist_free(nvl);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   587
	return (ret);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   588
}
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   589
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   590
static struct slm_mod_ops zfs_mod_ops = {
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   591
	SE_MAJOR_VERSION, SE_MINOR_VERSION, 10, zfs_deliver_event
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   592
};
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   593
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   594
struct slm_mod_ops *
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   595
slm_init()
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   596
{
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   597
	if ((g_zfshdl = libzfs_init()) == NULL)
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   598
		return (NULL);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   599
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   600
	return (&zfs_mod_ops);
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   601
}
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   602
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   603
void
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   604
slm_fini()
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   605
{
12456
318640f559d8 6952269 several memory leaks in zfs_mod
Eric Taylor <Eric.Taylor@Sun.COM>
parents: 12318
diff changeset
   606
	libzfs_fini(g_zfshdl);
4451
24fbf2d7a5d7 PSARC 2007/197 ZFS hotplug
eschrock
parents:
diff changeset
   607
}