4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
24 */
25
26 #include <sys/spa.h>
27 #include <sys/spa_impl.h>
28 #include <sys/nvpair.h>
29 #include <sys/uio.h>
30 #include <sys/fs/zfs.h>
31 #include <sys/vdev_impl.h>
32 #include <sys/zfs_ioctl.h>
33 #include <sys/utsname.h>
34 #include <sys/systeminfo.h>
35 #include <sys/sunddi.h>
36 #ifdef _KERNEL
37 #include <sys/kobj.h>
38 #include <sys/zone.h>
39 #endif
40
41 /*
42 * Pool configuration repository.
43 *
328 (SCL_CONFIG | SCL_STATE));
329
330 /*
331 * If txg is -1, report the current value of spa->spa_config_txg.
332 */
333 if (txg == -1ULL)
334 txg = spa->spa_config_txg;
335
336 VERIFY(nvlist_alloc(&config, NV_UNIQUE_NAME, KM_SLEEP) == 0);
337
338 VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_VERSION,
339 spa_version(spa)) == 0);
340 VERIFY(nvlist_add_string(config, ZPOOL_CONFIG_POOL_NAME,
341 spa_name(spa)) == 0);
342 VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_POOL_STATE,
343 spa_state(spa)) == 0);
344 VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_POOL_TXG,
345 txg) == 0);
346 VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_POOL_GUID,
347 spa_guid(spa)) == 0);
348 #ifdef _KERNEL
349 hostid = zone_get_hostid(NULL);
350 #else /* _KERNEL */
351 /*
352 * We're emulating the system's hostid in userland, so we can't use
353 * zone_get_hostid().
354 */
355 (void) ddi_strtoul(hw_serial, NULL, 10, &hostid);
356 #endif /* _KERNEL */
357 if (hostid != 0) {
358 VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_HOSTID,
359 hostid) == 0);
360 }
361 VERIFY(nvlist_add_string(config, ZPOOL_CONFIG_HOSTNAME,
362 utsname.nodename) == 0);
363
364 if (vd != rvd) {
365 VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_TOP_GUID,
366 vd->vdev_top->vdev_guid) == 0);
367 VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_GUID,
|
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
25 * Copyright (c) 2011 by Delphix. All rights reserved.
26 */
27
28 #include <sys/spa.h>
29 #include <sys/spa_impl.h>
30 #include <sys/nvpair.h>
31 #include <sys/uio.h>
32 #include <sys/fs/zfs.h>
33 #include <sys/vdev_impl.h>
34 #include <sys/zfs_ioctl.h>
35 #include <sys/utsname.h>
36 #include <sys/systeminfo.h>
37 #include <sys/sunddi.h>
38 #ifdef _KERNEL
39 #include <sys/kobj.h>
40 #include <sys/zone.h>
41 #endif
42
43 /*
44 * Pool configuration repository.
45 *
330 (SCL_CONFIG | SCL_STATE));
331
332 /*
333 * If txg is -1, report the current value of spa->spa_config_txg.
334 */
335 if (txg == -1ULL)
336 txg = spa->spa_config_txg;
337
338 VERIFY(nvlist_alloc(&config, NV_UNIQUE_NAME, KM_SLEEP) == 0);
339
340 VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_VERSION,
341 spa_version(spa)) == 0);
342 VERIFY(nvlist_add_string(config, ZPOOL_CONFIG_POOL_NAME,
343 spa_name(spa)) == 0);
344 VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_POOL_STATE,
345 spa_state(spa)) == 0);
346 VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_POOL_TXG,
347 txg) == 0);
348 VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_POOL_GUID,
349 spa_guid(spa)) == 0);
350 VERIFY(spa->spa_comment == NULL || nvlist_add_string(config,
351 ZPOOL_CONFIG_COMMENT, spa->spa_comment) == 0);
352
353
354 #ifdef _KERNEL
355 hostid = zone_get_hostid(NULL);
356 #else /* _KERNEL */
357 /*
358 * We're emulating the system's hostid in userland, so we can't use
359 * zone_get_hostid().
360 */
361 (void) ddi_strtoul(hw_serial, NULL, 10, &hostid);
362 #endif /* _KERNEL */
363 if (hostid != 0) {
364 VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_HOSTID,
365 hostid) == 0);
366 }
367 VERIFY(nvlist_add_string(config, ZPOOL_CONFIG_HOSTNAME,
368 utsname.nodename) == 0);
369
370 if (vd != rvd) {
371 VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_TOP_GUID,
372 vd->vdev_top->vdev_guid) == 0);
373 VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_GUID,
|