libzfs_pool.c (078266a5) | libzfs_pool.c (1a902ef8) |
---|---|
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 --- 359 unchanged lines hidden (view full) --- 368 369 if (strncmp(pool, bootfs, len) == 0 && 370 (bootfs[len] == '/' || bootfs[len] == '\0')) 371 return (B_TRUE); 372 373 return (B_FALSE); 374} 375 | 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 --- 359 unchanged lines hidden (view full) --- 368 369 if (strncmp(pool, bootfs, len) == 0 && 370 (bootfs[len] == '/' || bootfs[len] == '\0')) 371 return (B_TRUE); 372 373 return (B_FALSE); 374} 375 |
376/* 377 * Inspect the configuration to determine if any of the devices contain 378 * an EFI label. 379 */ 380static boolean_t 381pool_uses_efi(nvlist_t *config) 382{ 383 nvlist_t **child; 384 uint_t c, children; 385 386 if (nvlist_lookup_nvlist_array(config, ZPOOL_CONFIG_CHILDREN, 387 &child, &children) != 0) 388 return (read_efi_label(config, NULL) >= 0); 389 390 for (c = 0; c < children; c++) { 391 if (pool_uses_efi(child[c])) 392 return (B_TRUE); 393 } 394 return (B_FALSE); 395} 396 | |
397boolean_t 398zpool_is_bootable(zpool_handle_t *zhp) 399{ 400 char bootfs[ZPOOL_MAXNAMELEN]; 401 402 return (zpool_get_prop(zhp, ZPOOL_PROP_BOOTFS, bootfs, 403 sizeof (bootfs), NULL, B_FALSE) == 0 && strncmp(bootfs, "-", 404 sizeof (bootfs)) != 0); --- 12 unchanged lines hidden (view full) --- 417 nvpair_t *elem; 418 nvlist_t *retprops; 419 zpool_prop_t prop; 420 char *strval; 421 uint64_t intval; 422 char *slash, *check; 423 struct stat64 statbuf; 424 zpool_handle_t *zhp; | 376boolean_t 377zpool_is_bootable(zpool_handle_t *zhp) 378{ 379 char bootfs[ZPOOL_MAXNAMELEN]; 380 381 return (zpool_get_prop(zhp, ZPOOL_PROP_BOOTFS, bootfs, 382 sizeof (bootfs), NULL, B_FALSE) == 0 && strncmp(bootfs, "-", 383 sizeof (bootfs)) != 0); --- 12 unchanged lines hidden (view full) --- 396 nvpair_t *elem; 397 nvlist_t *retprops; 398 zpool_prop_t prop; 399 char *strval; 400 uint64_t intval; 401 char *slash, *check; 402 struct stat64 statbuf; 403 zpool_handle_t *zhp; |
425 nvlist_t *nvroot; | |
426 427 if (nvlist_alloc(&retprops, NV_UNIQUE_NAME, 0) != 0) { 428 (void) no_memory(hdl); 429 return (NULL); 430 } 431 432 elem = NULL; 433 while ((elem = nvlist_next_nvpair(props, elem)) != NULL) { --- 102 unchanged lines hidden (view full) --- 536 } 537 538 if ((zhp = zpool_open_canfail(hdl, poolname)) == NULL) { 539 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, 540 "could not open pool '%s'"), poolname); 541 (void) zfs_error(hdl, EZFS_OPENFAILED, errbuf); 542 goto error; 543 } | 404 405 if (nvlist_alloc(&retprops, NV_UNIQUE_NAME, 0) != 0) { 406 (void) no_memory(hdl); 407 return (NULL); 408 } 409 410 elem = NULL; 411 while ((elem = nvlist_next_nvpair(props, elem)) != NULL) { --- 102 unchanged lines hidden (view full) --- 514 } 515 516 if ((zhp = zpool_open_canfail(hdl, poolname)) == NULL) { 517 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, 518 "could not open pool '%s'"), poolname); 519 (void) zfs_error(hdl, EZFS_OPENFAILED, errbuf); 520 goto error; 521 } |
544 verify(nvlist_lookup_nvlist(zpool_get_config(zhp, NULL), 545 ZPOOL_CONFIG_VDEV_TREE, &nvroot) == 0); 546 547 /* 548 * bootfs property cannot be set on a disk which has 549 * been EFI labeled. 550 */ 551 if (pool_uses_efi(nvroot)) { 552 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, 553 "property '%s' not supported on " 554 "EFI labeled devices"), propname); 555 (void) zfs_error(hdl, EZFS_POOL_NOTSUP, errbuf); 556 zpool_close(zhp); 557 goto error; 558 } | |
559 zpool_close(zhp); 560 break; 561 562 case ZPOOL_PROP_ALTROOT: 563 if (!flags.create && !flags.import) { 564 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, 565 "property '%s' can only be set during pool " 566 "creation or import"), propname); --- 706 unchanged lines hidden (view full) --- 1273 SPA_VERSION_SPARES && 1274 nvlist_lookup_nvlist_array(nvroot, ZPOOL_CONFIG_SPARES, 1275 &spares, &nspares) == 0) { 1276 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "pool must be " 1277 "upgraded to add hot spares")); 1278 return (zfs_error(hdl, EZFS_BADVERSION, msg)); 1279 } 1280 | 522 zpool_close(zhp); 523 break; 524 525 case ZPOOL_PROP_ALTROOT: 526 if (!flags.create && !flags.import) { 527 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, 528 "property '%s' can only be set during pool " 529 "creation or import"), propname); --- 706 unchanged lines hidden (view full) --- 1236 SPA_VERSION_SPARES && 1237 nvlist_lookup_nvlist_array(nvroot, ZPOOL_CONFIG_SPARES, 1238 &spares, &nspares) == 0) { 1239 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "pool must be " 1240 "upgraded to add hot spares")); 1241 return (zfs_error(hdl, EZFS_BADVERSION, msg)); 1242 } 1243 |
1281 if (zpool_is_bootable(zhp) && nvlist_lookup_nvlist_array(nvroot, 1282 ZPOOL_CONFIG_SPARES, &spares, &nspares) == 0) { 1283 uint64_t s; 1284 1285 for (s = 0; s < nspares; s++) { 1286 char *path; 1287 1288 if (nvlist_lookup_string(spares[s], ZPOOL_CONFIG_PATH, 1289 &path) == 0 && pool_uses_efi(spares[s])) { 1290 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, 1291 "device '%s' contains an EFI label and " 1292 "cannot be used on root pools."), 1293 zpool_vdev_name(hdl, NULL, spares[s], 1294 B_FALSE)); 1295 return (zfs_error(hdl, EZFS_POOL_NOTSUP, msg)); 1296 } 1297 } 1298 } 1299 | |
1300 if (zpool_get_prop_int(zhp, ZPOOL_PROP_VERSION, NULL) < 1301 SPA_VERSION_L2CACHE && 1302 nvlist_lookup_nvlist_array(nvroot, ZPOOL_CONFIG_L2CACHE, 1303 &l2cache, &nl2cache) == 0) { 1304 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "pool must be " 1305 "upgraded to add cache devices")); 1306 return (zfs_error(hdl, EZFS_BADVERSION, msg)); 1307 } --- 998 unchanged lines hidden (view full) --- 2306 return (EZFS_INVALCONFIG); 2307 2308 if (nvlist_lookup_string(vdev_root, ZPOOL_CONFIG_TYPE, &type) != 0 || 2309 nvlist_lookup_nvlist_array(vdev_root, ZPOOL_CONFIG_CHILDREN, 2310 &child, &count) != 0) 2311 return (EZFS_INVALCONFIG); 2312 2313 /* | 1244 if (zpool_get_prop_int(zhp, ZPOOL_PROP_VERSION, NULL) < 1245 SPA_VERSION_L2CACHE && 1246 nvlist_lookup_nvlist_array(nvroot, ZPOOL_CONFIG_L2CACHE, 1247 &l2cache, &nl2cache) == 0) { 1248 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "pool must be " 1249 "upgraded to add cache devices")); 1250 return (zfs_error(hdl, EZFS_BADVERSION, msg)); 1251 } --- 998 unchanged lines hidden (view full) --- 2250 return (EZFS_INVALCONFIG); 2251 2252 if (nvlist_lookup_string(vdev_root, ZPOOL_CONFIG_TYPE, &type) != 0 || 2253 nvlist_lookup_nvlist_array(vdev_root, ZPOOL_CONFIG_CHILDREN, 2254 &child, &count) != 0) 2255 return (EZFS_INVALCONFIG); 2256 2257 /* |
2314 * root pool can not have EFI labeled disks and can only have 2315 * a single top-level vdev. | 2258 * root pool can only have a single top-level vdev. |
2316 */ | 2259 */ |
2317 if (strcmp(type, VDEV_TYPE_ROOT) != 0 || count != 1 || 2318 pool_uses_efi(vdev_root)) | 2260 if (strcmp(type, VDEV_TYPE_ROOT) != 0 || count != 1) |
2319 return (EZFS_POOL_INVALARG); 2320 2321 (void) vdev_get_physpaths(child[0], physpath, phypath_size, &rsz, 2322 B_FALSE); 2323 2324 /* No online devices */ 2325 if (rsz == 0) 2326 return (EZFS_NODEVICE); --- 285 unchanged lines hidden (view full) --- 2612 2613 if (replacing) 2614 (void) snprintf(msg, sizeof (msg), dgettext(TEXT_DOMAIN, 2615 "cannot replace %s with %s"), old_disk, new_disk); 2616 else 2617 (void) snprintf(msg, sizeof (msg), dgettext(TEXT_DOMAIN, 2618 "cannot attach %s to %s"), new_disk, old_disk); 2619 | 2261 return (EZFS_POOL_INVALARG); 2262 2263 (void) vdev_get_physpaths(child[0], physpath, phypath_size, &rsz, 2264 B_FALSE); 2265 2266 /* No online devices */ 2267 if (rsz == 0) 2268 return (EZFS_NODEVICE); --- 285 unchanged lines hidden (view full) --- 2554 2555 if (replacing) 2556 (void) snprintf(msg, sizeof (msg), dgettext(TEXT_DOMAIN, 2557 "cannot replace %s with %s"), old_disk, new_disk); 2558 else 2559 (void) snprintf(msg, sizeof (msg), dgettext(TEXT_DOMAIN, 2560 "cannot attach %s to %s"), new_disk, old_disk); 2561 |
2620 /* 2621 * If this is a root pool, make sure that we're not attaching an 2622 * EFI labeled device. 2623 */ 2624 if (rootpool && pool_uses_efi(nvroot)) { 2625 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, 2626 "EFI labeled devices are not supported on root pools.")); 2627 return (zfs_error(hdl, EZFS_POOL_NOTSUP, msg)); 2628 } 2629 | |
2630 (void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name)); 2631 if ((tgt = zpool_find_vdev(zhp, old_disk, &avail_spare, &l2cache, 2632 &islog)) == 0) 2633 return (zfs_error(hdl, EZFS_NODEVICE, msg)); 2634 2635 if (avail_spare) 2636 return (zfs_error(hdl, EZFS_ISSPARE, msg)); 2637 --- 1259 unchanged lines hidden (view full) --- 3897 3898 /* prepare an error message just in case */ 3899 (void) snprintf(errbuf, sizeof (errbuf), 3900 dgettext(TEXT_DOMAIN, "cannot label '%s'"), name); 3901 3902 if (zhp) { 3903 nvlist_t *nvroot; 3904 | 2562 (void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name)); 2563 if ((tgt = zpool_find_vdev(zhp, old_disk, &avail_spare, &l2cache, 2564 &islog)) == 0) 2565 return (zfs_error(hdl, EZFS_NODEVICE, msg)); 2566 2567 if (avail_spare) 2568 return (zfs_error(hdl, EZFS_ISSPARE, msg)); 2569 --- 1259 unchanged lines hidden (view full) --- 3829 3830 /* prepare an error message just in case */ 3831 (void) snprintf(errbuf, sizeof (errbuf), 3832 dgettext(TEXT_DOMAIN, "cannot label '%s'"), name); 3833 3834 if (zhp) { 3835 nvlist_t *nvroot; 3836 |
3905 if (zpool_is_bootable(zhp)) { 3906 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, 3907 "EFI labeled devices are not supported on root " 3908 "pools.")); 3909 return (zfs_error(hdl, EZFS_POOL_NOTSUP, errbuf)); 3910 } 3911 | |
3912 verify(nvlist_lookup_nvlist(zhp->zpool_config, 3913 ZPOOL_CONFIG_VDEV_TREE, &nvroot) == 0); 3914 3915 if (zhp->zpool_start_block == 0) 3916 start_block = find_start_block(nvroot); 3917 else 3918 start_block = zhp->zpool_start_block; 3919 zhp->zpool_start_block = start_block; --- 183 unchanged lines hidden --- | 3837 verify(nvlist_lookup_nvlist(zhp->zpool_config, 3838 ZPOOL_CONFIG_VDEV_TREE, &nvroot) == 0); 3839 3840 if (zhp->zpool_start_block == 0) 3841 start_block = find_start_block(nvroot); 3842 else 3843 start_block = zhp->zpool_start_block; 3844 zhp->zpool_start_block = start_block; --- 183 unchanged lines hidden --- |