libzfs_pool.c (228103) | libzfs_pool.c (236155) |
---|---|
1/* 2 * CDDL HEADER START 3 * 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 --- 8 unchanged lines hidden (view full) --- 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. | 1/* 2 * CDDL HEADER START 3 * 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 --- 8 unchanged lines hidden (view full) --- 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. | 25 * Copyright (c) 2012 by Delphix. All rights reserved. |
26 */ 27 28#include <sys/types.h> 29#include <sys/stat.h> 30#include <ctype.h> 31#include <errno.h> 32#include <devid.h> 33#include <fcntl.h> --- 262 unchanged lines hidden (view full) --- 296 297 case PROP_TYPE_NUMBER: 298 intval = zpool_get_prop_int(zhp, prop, &src); 299 300 switch (prop) { 301 case ZPOOL_PROP_SIZE: 302 case ZPOOL_PROP_ALLOCATED: 303 case ZPOOL_PROP_FREE: | 26 */ 27 28#include <sys/types.h> 29#include <sys/stat.h> 30#include <ctype.h> 31#include <errno.h> 32#include <devid.h> 33#include <fcntl.h> --- 262 unchanged lines hidden (view full) --- 296 297 case PROP_TYPE_NUMBER: 298 intval = zpool_get_prop_int(zhp, prop, &src); 299 300 switch (prop) { 301 case ZPOOL_PROP_SIZE: 302 case ZPOOL_PROP_ALLOCATED: 303 case ZPOOL_PROP_FREE: |
304 case ZPOOL_PROP_EXPANDSZ: |
|
304 (void) zfs_nicenum(intval, buf, len); 305 break; 306 307 case ZPOOL_PROP_CAPACITY: 308 (void) snprintf(buf, len, "%llu%%", 309 (u_longlong_t)intval); 310 break; 311 --- 73 unchanged lines hidden (view full) --- 385 for (c = 0; c < children; c++) { 386 if (pool_uses_efi(child[c])) 387 return (B_TRUE); 388 } 389#endif /* sun */ 390 return (B_FALSE); 391} 392 | 305 (void) zfs_nicenum(intval, buf, len); 306 break; 307 308 case ZPOOL_PROP_CAPACITY: 309 (void) snprintf(buf, len, "%llu%%", 310 (u_longlong_t)intval); 311 break; 312 --- 73 unchanged lines hidden (view full) --- 386 for (c = 0; c < children; c++) { 387 if (pool_uses_efi(child[c])) 388 return (B_TRUE); 389 } 390#endif /* sun */ 391 return (B_FALSE); 392} 393 |
393static boolean_t 394pool_is_bootable(zpool_handle_t *zhp) | 394boolean_t 395zpool_is_bootable(zpool_handle_t *zhp) |
395{ 396 char bootfs[ZPOOL_MAXNAMELEN]; 397 398 return (zpool_get_prop(zhp, ZPOOL_PROP_BOOTFS, bootfs, 399 sizeof (bootfs), NULL) == 0 && strncmp(bootfs, "-", 400 sizeof (bootfs)) != 0); 401} 402 --- 718 unchanged lines hidden (view full) --- 1121 SPA_VERSION_SPARES && 1122 nvlist_lookup_nvlist_array(nvroot, ZPOOL_CONFIG_SPARES, 1123 &spares, &nspares) == 0) { 1124 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "pool must be " 1125 "upgraded to add hot spares")); 1126 return (zfs_error(hdl, EZFS_BADVERSION, msg)); 1127 } 1128 | 396{ 397 char bootfs[ZPOOL_MAXNAMELEN]; 398 399 return (zpool_get_prop(zhp, ZPOOL_PROP_BOOTFS, bootfs, 400 sizeof (bootfs), NULL) == 0 && strncmp(bootfs, "-", 401 sizeof (bootfs)) != 0); 402} 403 --- 718 unchanged lines hidden (view full) --- 1122 SPA_VERSION_SPARES && 1123 nvlist_lookup_nvlist_array(nvroot, ZPOOL_CONFIG_SPARES, 1124 &spares, &nspares) == 0) { 1125 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "pool must be " 1126 "upgraded to add hot spares")); 1127 return (zfs_error(hdl, EZFS_BADVERSION, msg)); 1128 } 1129 |
1129 if (pool_is_bootable(zhp) && nvlist_lookup_nvlist_array(nvroot, | 1130 if (zpool_is_bootable(zhp) && nvlist_lookup_nvlist_array(nvroot, |
1130 ZPOOL_CONFIG_SPARES, &spares, &nspares) == 0) { 1131 uint64_t s; 1132 1133 for (s = 0; s < nspares; s++) { 1134 char *path; 1135 1136 if (nvlist_lookup_string(spares[s], ZPOOL_CONFIG_PATH, 1137 &path) == 0 && pool_uses_efi(spares[s])) { --- 1269 unchanged lines hidden (view full) --- 2407 nvlist_t *tgt; 2408 boolean_t avail_spare, l2cache, islog; 2409 uint64_t val; 2410 char *newname; 2411 nvlist_t **child; 2412 uint_t children; 2413 nvlist_t *config_root; 2414 libzfs_handle_t *hdl = zhp->zpool_hdl; | 1131 ZPOOL_CONFIG_SPARES, &spares, &nspares) == 0) { 1132 uint64_t s; 1133 1134 for (s = 0; s < nspares; s++) { 1135 char *path; 1136 1137 if (nvlist_lookup_string(spares[s], ZPOOL_CONFIG_PATH, 1138 &path) == 0 && pool_uses_efi(spares[s])) { --- 1269 unchanged lines hidden (view full) --- 2408 nvlist_t *tgt; 2409 boolean_t avail_spare, l2cache, islog; 2410 uint64_t val; 2411 char *newname; 2412 nvlist_t **child; 2413 uint_t children; 2414 nvlist_t *config_root; 2415 libzfs_handle_t *hdl = zhp->zpool_hdl; |
2415 boolean_t rootpool = pool_is_bootable(zhp); | 2416 boolean_t rootpool = zpool_is_bootable(zhp); |
2416 2417 if (replacing) 2418 (void) snprintf(msg, sizeof (msg), dgettext(TEXT_DOMAIN, 2419 "cannot replace %s with %s"), old_disk, new_disk); 2420 else 2421 (void) snprintf(msg, sizeof (msg), dgettext(TEXT_DOMAIN, 2422 "cannot attach %s to %s"), new_disk, old_disk); 2423 --- 625 unchanged lines hidden (view full) --- 3049 (void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name)); 3050 if (zfs_ioctl(hdl, ZFS_IOC_POOL_REGUID, &zc) == 0) 3051 return (0); 3052 3053 return (zpool_standard_error(hdl, errno, msg)); 3054} 3055 3056/* | 2417 2418 if (replacing) 2419 (void) snprintf(msg, sizeof (msg), dgettext(TEXT_DOMAIN, 2420 "cannot replace %s with %s"), old_disk, new_disk); 2421 else 2422 (void) snprintf(msg, sizeof (msg), dgettext(TEXT_DOMAIN, 2423 "cannot attach %s to %s"), new_disk, old_disk); 2424 --- 625 unchanged lines hidden (view full) --- 3050 (void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name)); 3051 if (zfs_ioctl(hdl, ZFS_IOC_POOL_REGUID, &zc) == 0) 3052 return (0); 3053 3054 return (zpool_standard_error(hdl, errno, msg)); 3055} 3056 3057/* |
3058 * Reopen the pool. 3059 */ 3060int 3061zpool_reopen(zpool_handle_t *zhp) 3062{ 3063 zfs_cmd_t zc = { 0 }; 3064 char msg[1024]; 3065 libzfs_handle_t *hdl = zhp->zpool_hdl; 3066 3067 (void) snprintf(msg, sizeof (msg), 3068 dgettext(TEXT_DOMAIN, "cannot reopen '%s'"), 3069 zhp->zpool_name); 3070 3071 (void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name)); 3072 if (zfs_ioctl(hdl, ZFS_IOC_POOL_REOPEN, &zc) == 0) 3073 return (0); 3074 return (zpool_standard_error(hdl, errno, msg)); 3075} 3076 3077/* |
|
3057 * Convert from a devid string to a path. 3058 */ 3059static char * 3060devid_to_path(char *devid_str) 3061{ 3062 ddi_devid_t devid; 3063 char *minor; 3064 char *path; --- 633 unchanged lines hidden (view full) --- 3698 3699 /* prepare an error message just in case */ 3700 (void) snprintf(errbuf, sizeof (errbuf), 3701 dgettext(TEXT_DOMAIN, "cannot label '%s'"), name); 3702 3703 if (zhp) { 3704 nvlist_t *nvroot; 3705 | 3078 * Convert from a devid string to a path. 3079 */ 3080static char * 3081devid_to_path(char *devid_str) 3082{ 3083 ddi_devid_t devid; 3084 char *minor; 3085 char *path; --- 633 unchanged lines hidden (view full) --- 3719 3720 /* prepare an error message just in case */ 3721 (void) snprintf(errbuf, sizeof (errbuf), 3722 dgettext(TEXT_DOMAIN, "cannot label '%s'"), name); 3723 3724 if (zhp) { 3725 nvlist_t *nvroot; 3726 |
3706 if (pool_is_bootable(zhp)) { | 3727 if (zpool_is_bootable(zhp)) { |
3707 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, 3708 "EFI labeled devices are not supported on root " 3709 "pools.")); 3710 return (zfs_error(hdl, EZFS_POOL_NOTSUP, errbuf)); 3711 } 3712 3713 verify(nvlist_lookup_nvlist(zhp->zpool_config, 3714 ZPOOL_CONFIG_VDEV_TREE, &nvroot) == 0); --- 194 unchanged lines hidden --- | 3728 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, 3729 "EFI labeled devices are not supported on root " 3730 "pools.")); 3731 return (zfs_error(hdl, EZFS_POOL_NOTSUP, errbuf)); 3732 } 3733 3734 verify(nvlist_lookup_nvlist(zhp->zpool_config, 3735 ZPOOL_CONFIG_VDEV_TREE, &nvroot) == 0); --- 194 unchanged lines hidden --- |