zpool_main.c (236960) | zpool_main.c (238926) |
---|---|
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 --- 375 unchanged lines hidden (view full) --- 384 385 vname = zpool_vdev_name(g_zfs, zhp, child[c], B_FALSE); 386 print_vdev_tree(zhp, vname, child[c], indent + 2, 387 B_FALSE); 388 free(vname); 389 } 390} 391 | 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 --- 375 unchanged lines hidden (view full) --- 384 385 vname = zpool_vdev_name(g_zfs, zhp, child[c], B_FALSE); 386 print_vdev_tree(zhp, vname, child[c], indent + 2, 387 B_FALSE); 388 free(vname); 389 } 390} 391 |
392static boolean_t 393prop_list_contains_feature(nvlist_t *proplist) 394{ 395 nvpair_t *nvp; 396 for (nvp = nvlist_next_nvpair(proplist, NULL); NULL != nvp; 397 nvp = nvlist_next_nvpair(proplist, nvp)) { 398 if (zpool_prop_feature(nvpair_name(nvp))) 399 return (B_TRUE); 400 } 401 return (B_FALSE); 402} 403 |
|
392/* 393 * Add a property pair (name, string-value) into a property nvlist. 394 */ 395static int 396add_prop_list(const char *propname, char *propval, nvlist_t **props, 397 boolean_t poolprop) 398{ 399 zpool_prop_t prop = ZPROP_INVAL; --- 7 unchanged lines hidden (view full) --- 407 (void) fprintf(stderr, 408 gettext("internal error: out of memory\n")); 409 return (1); 410 } 411 412 proplist = *props; 413 414 if (poolprop) { | 404/* 405 * Add a property pair (name, string-value) into a property nvlist. 406 */ 407static int 408add_prop_list(const char *propname, char *propval, nvlist_t **props, 409 boolean_t poolprop) 410{ 411 zpool_prop_t prop = ZPROP_INVAL; --- 7 unchanged lines hidden (view full) --- 419 (void) fprintf(stderr, 420 gettext("internal error: out of memory\n")); 421 return (1); 422 } 423 424 proplist = *props; 425 426 if (poolprop) { |
427 const char *vname = zpool_prop_to_name(ZPOOL_PROP_VERSION); 428 |
|
415 if ((prop = zpool_name_to_prop(propname)) == ZPROP_INVAL && 416 !zpool_prop_feature(propname)) { 417 (void) fprintf(stderr, gettext("property '%s' is " 418 "not a valid pool property\n"), propname); 419 return (2); 420 } | 429 if ((prop = zpool_name_to_prop(propname)) == ZPROP_INVAL && 430 !zpool_prop_feature(propname)) { 431 (void) fprintf(stderr, gettext("property '%s' is " 432 "not a valid pool property\n"), propname); 433 return (2); 434 } |
435 436 /* 437 * feature@ properties and version should not be specified 438 * at the same time. 439 */ 440 if ((prop == ZPROP_INVAL && zpool_prop_feature(propname) && 441 nvlist_exists(proplist, vname)) || 442 (prop == ZPOOL_PROP_VERSION && 443 prop_list_contains_feature(proplist))) { 444 (void) fprintf(stderr, gettext("'feature@' and " 445 "'version' properties cannot be specified " 446 "together\n")); 447 return (2); 448 } 449 450 |
|
421 if (zpool_prop_feature(propname)) 422 normnm = propname; 423 else 424 normnm = zpool_prop_to_name(prop); 425 } else { 426 if ((fprop = zfs_name_to_prop(propname)) != ZPROP_INVAL) { 427 normnm = zfs_prop_to_name(fprop); 428 } else { --- 1149 unchanged lines hidden (view full) --- 1578 break; 1579 1580 case ZPOOL_STATUS_CORRUPT_POOL: 1581 (void) printf(gettext(" status: The pool metadata is " 1582 "corrupted.\n")); 1583 break; 1584 1585 case ZPOOL_STATUS_VERSION_OLDER: | 451 if (zpool_prop_feature(propname)) 452 normnm = propname; 453 else 454 normnm = zpool_prop_to_name(prop); 455 } else { 456 if ((fprop = zfs_name_to_prop(propname)) != ZPROP_INVAL) { 457 normnm = zfs_prop_to_name(fprop); 458 } else { --- 1149 unchanged lines hidden (view full) --- 1608 break; 1609 1610 case ZPOOL_STATUS_CORRUPT_POOL: 1611 (void) printf(gettext(" status: The pool metadata is " 1612 "corrupted.\n")); 1613 break; 1614 1615 case ZPOOL_STATUS_VERSION_OLDER: |
1586 (void) printf(gettext(" status: The pool is formatted using an " 1587 "older on-disk version.\n")); | 1616 (void) printf(gettext(" status: The pool is formatted using a " 1617 "legacy on-disk version.\n")); |
1588 break; 1589 1590 case ZPOOL_STATUS_VERSION_NEWER: 1591 (void) printf(gettext(" status: The pool is formatted using an " 1592 "incompatible version.\n")); 1593 break; 1594 | 1618 break; 1619 1620 case ZPOOL_STATUS_VERSION_NEWER: 1621 (void) printf(gettext(" status: The pool is formatted using an " 1622 "incompatible version.\n")); 1623 break; 1624 |
1625 case ZPOOL_STATUS_FEAT_DISABLED: 1626 (void) printf(gettext(" status: Some supported features are " 1627 "not enabled on the pool.\n")); 1628 break; 1629 |
|
1595 case ZPOOL_STATUS_UNSUP_FEAT_READ: 1596 (void) printf(gettext("status: The pool uses the following " 1597 "feature(s) not supported on this sytem:\n")); 1598 zpool_print_unsup_feat(config); 1599 break; 1600 1601 case ZPOOL_STATUS_UNSUP_FEAT_WRITE: 1602 (void) printf(gettext("status: The pool can only be accessed " --- 30 unchanged lines hidden (view full) --- 1633 */ 1634 assert(reason == ZPOOL_STATUS_OK); 1635 } 1636 1637 /* 1638 * Print out an action according to the overall state of the pool. 1639 */ 1640 if (vs->vs_state == VDEV_STATE_HEALTHY) { | 1630 case ZPOOL_STATUS_UNSUP_FEAT_READ: 1631 (void) printf(gettext("status: The pool uses the following " 1632 "feature(s) not supported on this sytem:\n")); 1633 zpool_print_unsup_feat(config); 1634 break; 1635 1636 case ZPOOL_STATUS_UNSUP_FEAT_WRITE: 1637 (void) printf(gettext("status: The pool can only be accessed " --- 30 unchanged lines hidden (view full) --- 1668 */ 1669 assert(reason == ZPOOL_STATUS_OK); 1670 } 1671 1672 /* 1673 * Print out an action according to the overall state of the pool. 1674 */ 1675 if (vs->vs_state == VDEV_STATE_HEALTHY) { |
1641 if (reason == ZPOOL_STATUS_VERSION_OLDER) | 1676 if (reason == ZPOOL_STATUS_VERSION_OLDER || 1677 reason == ZPOOL_STATUS_FEAT_DISABLED) { |
1642 (void) printf(gettext(" action: The pool can be " 1643 "imported using its name or numeric identifier, " 1644 "though\n\tsome features will not be available " 1645 "without an explicit 'zpool upgrade'.\n")); | 1678 (void) printf(gettext(" action: The pool can be " 1679 "imported using its name or numeric identifier, " 1680 "though\n\tsome features will not be available " 1681 "without an explicit 'zpool upgrade'.\n")); |
1646 else if (reason == ZPOOL_STATUS_HOSTID_MISMATCH) | 1682 } else if (reason == ZPOOL_STATUS_HOSTID_MISMATCH) { |
1647 (void) printf(gettext(" action: The pool can be " 1648 "imported using its name or numeric " 1649 "identifier and\n\tthe '-f' flag.\n")); | 1683 (void) printf(gettext(" action: The pool can be " 1684 "imported using its name or numeric " 1685 "identifier and\n\tthe '-f' flag.\n")); |
1650 else | 1686 } else { |
1651 (void) printf(gettext(" action: The pool can be " 1652 "imported using its name or numeric " 1653 "identifier.\n")); | 1687 (void) printf(gettext(" action: The pool can be " 1688 "imported using its name or numeric " 1689 "identifier.\n")); |
1690 } |
|
1654 } else if (vs->vs_state == VDEV_STATE_DEGRADED) { 1655 (void) printf(gettext(" action: The pool can be imported " 1656 "despite missing or damaged devices. The\n\tfault " 1657 "tolerance of the pool may be compromised if imported.\n")); 1658 } else { 1659 switch (reason) { 1660 case ZPOOL_STATUS_VERSION_NEWER: 1661 (void) printf(gettext(" action: The pool cannot be " --- 2441 unchanged lines hidden (view full) --- 4103 case ZPOOL_STATUS_CORRUPT_POOL: 4104 (void) printf(gettext("status: The pool metadata is corrupted " 4105 "and the pool cannot be opened.\n")); 4106 zpool_explain_recover(zpool_get_handle(zhp), 4107 zpool_get_name(zhp), reason, config); 4108 break; 4109 4110 case ZPOOL_STATUS_VERSION_OLDER: | 1691 } else if (vs->vs_state == VDEV_STATE_DEGRADED) { 1692 (void) printf(gettext(" action: The pool can be imported " 1693 "despite missing or damaged devices. The\n\tfault " 1694 "tolerance of the pool may be compromised if imported.\n")); 1695 } else { 1696 switch (reason) { 1697 case ZPOOL_STATUS_VERSION_NEWER: 1698 (void) printf(gettext(" action: The pool cannot be " --- 2441 unchanged lines hidden (view full) --- 4140 case ZPOOL_STATUS_CORRUPT_POOL: 4141 (void) printf(gettext("status: The pool metadata is corrupted " 4142 "and the pool cannot be opened.\n")); 4143 zpool_explain_recover(zpool_get_handle(zhp), 4144 zpool_get_name(zhp), reason, config); 4145 break; 4146 4147 case ZPOOL_STATUS_VERSION_OLDER: |
4111 (void) printf(gettext("status: The pool is formatted using an " 4112 "older on-disk format. The pool can\n\tstill be used, but " 4113 "some features are unavailable.\n")); | 4148 (void) printf(gettext("status: The pool is formatted using a " 4149 "legacy on-disk format. The pool can\n\tstill be used, " 4150 "but some features are unavailable.\n")); |
4114 (void) printf(gettext("action: Upgrade the pool using 'zpool " 4115 "upgrade'. Once this is done, the\n\tpool will no longer " | 4151 (void) printf(gettext("action: Upgrade the pool using 'zpool " 4152 "upgrade'. Once this is done, the\n\tpool will no longer " |
4116 "be accessible on older software versions.\n")); | 4153 "be accessible on software that does not support feature\n" 4154 "\tflags.\n")); |
4117 break; 4118 4119 case ZPOOL_STATUS_VERSION_NEWER: 4120 (void) printf(gettext("status: The pool has been upgraded to a " 4121 "newer, incompatible on-disk version.\n\tThe pool cannot " 4122 "be accessed on this system.\n")); 4123 (void) printf(gettext("action: Access the pool from a system " 4124 "running more recent software, or\n\trestore the pool from " 4125 "backup.\n")); 4126 break; 4127 | 4155 break; 4156 4157 case ZPOOL_STATUS_VERSION_NEWER: 4158 (void) printf(gettext("status: The pool has been upgraded to a " 4159 "newer, incompatible on-disk version.\n\tThe pool cannot " 4160 "be accessed on this system.\n")); 4161 (void) printf(gettext("action: Access the pool from a system " 4162 "running more recent software, or\n\trestore the pool from " 4163 "backup.\n")); 4164 break; 4165 |
4166 case ZPOOL_STATUS_FEAT_DISABLED: 4167 (void) printf(gettext("status: Some supported features are not " 4168 "enabled on the pool. The pool can\n\tstill be used, but " 4169 "some features are unavailable.\n")); 4170 (void) printf(gettext("action: Enable all features using " 4171 "'zpool upgrade'. Once this is done,\n\tthe pool may no " 4172 "longer be accessible by software that does not support\n\t" 4173 "the features. See zpool-features(5) for details.\n")); 4174 break; 4175 |
|
4128 case ZPOOL_STATUS_UNSUP_FEAT_READ: 4129 (void) printf(gettext("status: The pool cannot be accessed on " 4130 "this system because it uses the\n\tfollowing feature(s) " 4131 "not supported on this system:\n")); 4132 zpool_print_unsup_feat(config); 4133 (void) printf("\n"); 4134 (void) printf(gettext("action: Access the pool from a system " 4135 "that supports the required feature(s),\n\tor restore the " --- 213 unchanged lines hidden (view full) --- 4349 4350 (void) sleep(interval); 4351 } 4352 4353 return (0); 4354} 4355 4356typedef struct upgrade_cbdata { | 4176 case ZPOOL_STATUS_UNSUP_FEAT_READ: 4177 (void) printf(gettext("status: The pool cannot be accessed on " 4178 "this system because it uses the\n\tfollowing feature(s) " 4179 "not supported on this system:\n")); 4180 zpool_print_unsup_feat(config); 4181 (void) printf("\n"); 4182 (void) printf(gettext("action: Access the pool from a system " 4183 "that supports the required feature(s),\n\tor restore the " --- 213 unchanged lines hidden (view full) --- 4397 4398 (void) sleep(interval); 4399 } 4400 4401 return (0); 4402} 4403 4404typedef struct upgrade_cbdata { |
4357 int cb_all; | |
4358 int cb_first; | 4405 int cb_first; |
4359 int cb_newer; | |
4360 char cb_poolname[ZPOOL_MAXNAMELEN]; 4361 int cb_argc; 4362 uint64_t cb_version; 4363 char **cb_argv; 4364} upgrade_cbdata_t; 4365 4366static int 4367is_root_pool(zpool_handle_t *zhp) --- 16 unchanged lines hidden (view full) --- 4384 poolname = sfs.f_mntfromname; 4385 if ((slash = strchr(poolname, '/')) != NULL) 4386 *slash = '\0'; 4387 } 4388 return (poolname != NULL && strcmp(poolname, zpool_get_name(zhp)) == 0); 4389} 4390 4391static int | 4406 char cb_poolname[ZPOOL_MAXNAMELEN]; 4407 int cb_argc; 4408 uint64_t cb_version; 4409 char **cb_argv; 4410} upgrade_cbdata_t; 4411 4412static int 4413is_root_pool(zpool_handle_t *zhp) --- 16 unchanged lines hidden (view full) --- 4430 poolname = sfs.f_mntfromname; 4431 if ((slash = strchr(poolname, '/')) != NULL) 4432 *slash = '\0'; 4433 } 4434 return (poolname != NULL && strcmp(poolname, zpool_get_name(zhp)) == 0); 4435} 4436 4437static int |
4438upgrade_version(zpool_handle_t *zhp, uint64_t version) 4439{ 4440 int ret; 4441 nvlist_t *config; 4442 uint64_t oldversion; 4443 4444 config = zpool_get_config(zhp, NULL); 4445 verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_VERSION, 4446 &oldversion) == 0); 4447 4448 assert(SPA_VERSION_IS_SUPPORTED(oldversion)); 4449 assert(oldversion < version); 4450 4451 ret = zpool_upgrade(zhp, version); 4452 if (ret != 0) 4453 return (ret); 4454 4455 if (version >= SPA_VERSION_FEATURES) { 4456 (void) printf(gettext("Successfully upgraded " 4457 "'%s' from version %llu to feature flags.\n"), 4458 zpool_get_name(zhp), oldversion); 4459 } else { 4460 (void) printf(gettext("Successfully upgraded " 4461 "'%s' from version %llu to version %llu.\n"), 4462 zpool_get_name(zhp), oldversion, version); 4463 } 4464 4465 return (0); 4466} 4467 4468static int 4469upgrade_enable_all(zpool_handle_t *zhp, int *countp) 4470{ 4471 int i, ret, count; 4472 boolean_t firstff = B_TRUE; 4473 nvlist_t *enabled = zpool_get_features(zhp); 4474 4475 count = 0; 4476 for (i = 0; i < SPA_FEATURES; i++) { 4477 const char *fname = spa_feature_table[i].fi_uname; 4478 const char *fguid = spa_feature_table[i].fi_guid; 4479 if (!nvlist_exists(enabled, fguid)) { 4480 char *propname; 4481 verify(-1 != asprintf(&propname, "feature@%s", fname)); 4482 ret = zpool_set_prop(zhp, propname, 4483 ZFS_FEATURE_ENABLED); 4484 if (ret != 0) { 4485 free(propname); 4486 return (ret); 4487 } 4488 count++; 4489 4490 if (firstff) { 4491 (void) printf(gettext("Enabled the " 4492 "following features on '%s':\n"), 4493 zpool_get_name(zhp)); 4494 firstff = B_FALSE; 4495 } 4496 (void) printf(gettext(" %s\n"), fname); 4497 free(propname); 4498 } 4499 } 4500 4501 if (countp != NULL) 4502 *countp = count; 4503 return (0); 4504} 4505 4506static int |
|
4392upgrade_cb(zpool_handle_t *zhp, void *arg) 4393{ 4394 upgrade_cbdata_t *cbp = arg; 4395 nvlist_t *config; 4396 uint64_t version; | 4507upgrade_cb(zpool_handle_t *zhp, void *arg) 4508{ 4509 upgrade_cbdata_t *cbp = arg; 4510 nvlist_t *config; 4511 uint64_t version; |
4397 int ret = 0; | 4512 boolean_t printnl = B_FALSE; 4513 int ret; |
4398 4399 config = zpool_get_config(zhp, NULL); 4400 verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_VERSION, 4401 &version) == 0); 4402 | 4514 4515 config = zpool_get_config(zhp, NULL); 4516 verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_VERSION, 4517 &version) == 0); 4518 |
4403 if (!cbp->cb_newer && SPA_VERSION_IS_SUPPORTED(version) && 4404 version != SPA_VERSION) { 4405 if (!cbp->cb_all) { 4406 if (cbp->cb_first) { 4407 (void) printf(gettext("The following pools are " 4408 "out of date, and can be upgraded. After " 4409 "being\nupgraded, these pools will no " 4410 "longer be accessible by older software " 4411 "versions.\n\n")); 4412 (void) printf(gettext("VER POOL\n")); 4413 (void) printf(gettext("--- ------------\n")); 4414 cbp->cb_first = B_FALSE; 4415 } | 4519 assert(SPA_VERSION_IS_SUPPORTED(version)); |
4416 | 4520 |
4417 (void) printf("%2llu %s\n", (u_longlong_t)version, 4418 zpool_get_name(zhp)); 4419 } else { | 4521 if (version < cbp->cb_version) { 4522 cbp->cb_first = B_FALSE; 4523 ret = upgrade_version(zhp, cbp->cb_version); 4524 if (ret != 0) 4525 return (ret); 4526#ifdef __FreeBSD__ 4527 if (cbp->cb_poolname[0] == '\0' && 4528 is_root_pool(zhp)) { 4529 (void) strlcpy(cbp->cb_poolname, 4530 zpool_get_name(zhp), 4531 sizeof(cbp->cb_poolname)); 4532 } 4533#endif /* ___FreeBSD__ */ 4534 printnl = B_TRUE; 4535 4536#ifdef illumos 4537 /* 4538 * If they did "zpool upgrade -a", then we could 4539 * be doing ioctls to different pools. We need 4540 * to log this history once to each pool, and bypass 4541 * the normal history logging that happens in main(). 4542 */ 4543 (void) zpool_log_history(g_zfs, history_str); 4544 log_history = B_FALSE; 4545#endif 4546 } 4547 4548 if (cbp->cb_version >= SPA_VERSION_FEATURES) { 4549 int count; 4550 ret = upgrade_enable_all(zhp, &count); 4551 if (ret != 0) 4552 return (ret); 4553 4554 if (count > 0) { |
4420 cbp->cb_first = B_FALSE; | 4555 cbp->cb_first = B_FALSE; |
4421 ret = zpool_upgrade(zhp, cbp->cb_version); 4422 if (!ret) { 4423 (void) printf(gettext("Successfully upgraded " 4424 "'%s'\n\n"), zpool_get_name(zhp)); 4425 if (cbp->cb_poolname[0] == '\0' && 4426 is_root_pool(zhp)) { 4427 (void) strlcpy(cbp->cb_poolname, 4428 zpool_get_name(zhp), 4429 sizeof(cbp->cb_poolname)); 4430 } 4431 } | 4556 printnl = B_TRUE; |
4432 } | 4557 } |
4433 } else if (cbp->cb_newer && !SPA_VERSION_IS_SUPPORTED(version)) { 4434 assert(!cbp->cb_all); | 4558 } |
4435 | 4559 |
4560 if (printnl) { 4561 (void) printf(gettext("\n")); 4562 } 4563 4564 return (0); 4565} 4566 4567static int 4568upgrade_list_older_cb(zpool_handle_t *zhp, void *arg) 4569{ 4570 upgrade_cbdata_t *cbp = arg; 4571 nvlist_t *config; 4572 uint64_t version; 4573 4574 config = zpool_get_config(zhp, NULL); 4575 verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_VERSION, 4576 &version) == 0); 4577 4578 assert(SPA_VERSION_IS_SUPPORTED(version)); 4579 4580 if (version < SPA_VERSION_FEATURES) { |
|
4436 if (cbp->cb_first) { 4437 (void) printf(gettext("The following pools are " | 4581 if (cbp->cb_first) { 4582 (void) printf(gettext("The following pools are " |
4438 "formatted using an unsupported software version " 4439 "and\ncannot be accessed on the current " 4440 "system.\n\n")); | 4583 "formatted with legacy version numbers and can\n" 4584 "be upgraded to use feature flags. After " 4585 "being upgraded, these pools\nwill no " 4586 "longer be accessible by software that does not " 4587 "support feature\nflags.\n\n")); |
4441 (void) printf(gettext("VER POOL\n")); 4442 (void) printf(gettext("--- ------------\n")); 4443 cbp->cb_first = B_FALSE; 4444 } 4445 4446 (void) printf("%2llu %s\n", (u_longlong_t)version, 4447 zpool_get_name(zhp)); 4448 } 4449 | 4588 (void) printf(gettext("VER POOL\n")); 4589 (void) printf(gettext("--- ------------\n")); 4590 cbp->cb_first = B_FALSE; 4591 } 4592 4593 (void) printf("%2llu %s\n", (u_longlong_t)version, 4594 zpool_get_name(zhp)); 4595 } 4596 |
4450 zpool_close(zhp); 4451 return (ret); | 4597 return (0); |
4452} 4453 | 4598} 4599 |
4600static int 4601upgrade_list_disabled_cb(zpool_handle_t *zhp, void *arg) 4602{ 4603 upgrade_cbdata_t *cbp = arg; 4604 nvlist_t *config; 4605 uint64_t version; 4606 4607 config = zpool_get_config(zhp, NULL); 4608 verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_VERSION, 4609 &version) == 0); 4610 4611 if (version >= SPA_VERSION_FEATURES) { 4612 int i; 4613 boolean_t poolfirst = B_TRUE; 4614 nvlist_t *enabled = zpool_get_features(zhp); 4615 4616 for (i = 0; i < SPA_FEATURES; i++) { 4617 const char *fguid = spa_feature_table[i].fi_guid; 4618 const char *fname = spa_feature_table[i].fi_uname; 4619 if (!nvlist_exists(enabled, fguid)) { 4620 if (cbp->cb_first) { 4621 (void) printf(gettext("\nSome " 4622 "supported features are not " 4623 "enabled on the following pools. " 4624 "Once a\nfeature is enabled the " 4625 "pool may become incompatible with " 4626 "software\nthat does not support " 4627 "the feature. See " 4628 "zpool-features(5) for " 4629 "details.\n\n")); 4630 (void) printf(gettext("POOL " 4631 "FEATURE\n")); 4632 (void) printf(gettext("------" 4633 "---------\n")); 4634 cbp->cb_first = B_FALSE; 4635 } 4636 4637 if (poolfirst) { 4638 (void) printf(gettext("%s\n"), 4639 zpool_get_name(zhp)); 4640 poolfirst = B_FALSE; 4641 } 4642 4643 (void) printf(gettext(" %s\n"), fname); 4644 } 4645 } 4646 } 4647 4648 return (0); 4649} 4650 |
|
4454/* ARGSUSED */ 4455static int 4456upgrade_one(zpool_handle_t *zhp, void *data) 4457{ | 4651/* ARGSUSED */ 4652static int 4653upgrade_one(zpool_handle_t *zhp, void *data) 4654{ |
4655 boolean_t printnl = B_FALSE; |
|
4458 upgrade_cbdata_t *cbp = data; 4459 uint64_t cur_version; 4460 int ret; 4461 4462 if (strcmp("log", zpool_get_name(zhp)) == 0) { 4463 (void) printf(gettext("'log' is now a reserved word\n" 4464 "Pool 'log' must be renamed using export and import" 4465 " to upgrade.\n")); 4466 return (1); 4467 } 4468 4469 cur_version = zpool_get_prop_int(zhp, ZPOOL_PROP_VERSION, NULL); 4470 if (cur_version > cbp->cb_version) { 4471 (void) printf(gettext("Pool '%s' is already formatted " | 4656 upgrade_cbdata_t *cbp = data; 4657 uint64_t cur_version; 4658 int ret; 4659 4660 if (strcmp("log", zpool_get_name(zhp)) == 0) { 4661 (void) printf(gettext("'log' is now a reserved word\n" 4662 "Pool 'log' must be renamed using export and import" 4663 " to upgrade.\n")); 4664 return (1); 4665 } 4666 4667 cur_version = zpool_get_prop_int(zhp, ZPOOL_PROP_VERSION, NULL); 4668 if (cur_version > cbp->cb_version) { 4669 (void) printf(gettext("Pool '%s' is already formatted " |
4472 "using more current version '%llu'.\n"), | 4670 "using more current version '%llu'.\n\n"), |
4473 zpool_get_name(zhp), cur_version); 4474 return (0); 4475 } | 4671 zpool_get_name(zhp), cur_version); 4672 return (0); 4673 } |
4476 if (cur_version == cbp->cb_version) { | 4674 4675 if (cbp->cb_version != SPA_VERSION && cur_version == cbp->cb_version) { |
4477 (void) printf(gettext("Pool '%s' is already formatted " | 4676 (void) printf(gettext("Pool '%s' is already formatted " |
4478 "using the current version.\n"), zpool_get_name(zhp)); | 4677 "using version %llu.\n\n"), zpool_get_name(zhp), 4678 cbp->cb_version); |
4479 return (0); 4480 } 4481 | 4679 return (0); 4680 } 4681 |
4482 ret = zpool_upgrade(zhp, cbp->cb_version); | 4682 if (cur_version != cbp->cb_version) { 4683 printnl = B_TRUE; 4684 ret = upgrade_version(zhp, cbp->cb_version); 4685 if (ret != 0) { 4686#ifdef __FreeBSD__ 4687 if (cbp->cb_poolname[0] == '\0' && 4688 is_root_pool(zhp)) { 4689 (void) strlcpy(cbp->cb_poolname, 4690 zpool_get_name(zhp), 4691 sizeof(cbp->cb_poolname)); 4692 } 4693#endif /* ___FreeBSD__ */ 4694 return (ret); 4695 } 4696 } |
4483 | 4697 |
4484 if (!ret) { 4485 (void) printf(gettext("Successfully upgraded '%s' " 4486 "from version %llu to version %llu\n\n"), 4487 zpool_get_name(zhp), (u_longlong_t)cur_version, 4488 (u_longlong_t)cbp->cb_version); | 4698 if (cbp->cb_version >= SPA_VERSION_FEATURES) { 4699 int count = 0; 4700 ret = upgrade_enable_all(zhp, &count); 4701 if (ret != 0) 4702 return (ret); 4703 4704 if (count != 0) { 4705 printnl = B_TRUE; 4706 } else if (cur_version == SPA_VERSION) { 4707 (void) printf(gettext("Pool '%s' already has all " 4708 "supported features enabled.\n"), 4709 zpool_get_name(zhp)); 4710 } |
4489 if (cbp->cb_poolname[0] == '\0' && is_root_pool(zhp)) { 4490 (void) strlcpy(cbp->cb_poolname, zpool_get_name(zhp), 4491 sizeof(cbp->cb_poolname)); 4492 } 4493 } 4494 | 4711 if (cbp->cb_poolname[0] == '\0' && is_root_pool(zhp)) { 4712 (void) strlcpy(cbp->cb_poolname, zpool_get_name(zhp), 4713 sizeof(cbp->cb_poolname)); 4714 } 4715 } 4716 |
4495 return (ret != 0); | 4717 if (printnl) { 4718 (void) printf(gettext("\n")); 4719 } 4720 4721 return (0); |
4496} 4497 4498/* 4499 * zpool upgrade 4500 * zpool upgrade -v 4501 * zpool upgrade [-V version] <-a | pool ...> 4502 * 4503 * With no arguments, display downrev'd ZFS pool available for upgrade. 4504 * Individual pools can be upgraded by specifying the pool, and '-a' will 4505 * upgrade all pools. 4506 */ 4507int 4508zpool_do_upgrade(int argc, char **argv) 4509{ 4510 int c; 4511 upgrade_cbdata_t cb = { 0 }; 4512 int ret = 0; 4513 boolean_t showversions = B_FALSE; | 4722} 4723 4724/* 4725 * zpool upgrade 4726 * zpool upgrade -v 4727 * zpool upgrade [-V version] <-a | pool ...> 4728 * 4729 * With no arguments, display downrev'd ZFS pool available for upgrade. 4730 * Individual pools can be upgraded by specifying the pool, and '-a' will 4731 * upgrade all pools. 4732 */ 4733int 4734zpool_do_upgrade(int argc, char **argv) 4735{ 4736 int c; 4737 upgrade_cbdata_t cb = { 0 }; 4738 int ret = 0; 4739 boolean_t showversions = B_FALSE; |
4740 boolean_t upgradeall = B_FALSE; |
|
4514 char *end; 4515 4516 4517 /* check options */ 4518 while ((c = getopt(argc, argv, ":avV:")) != -1) { 4519 switch (c) { 4520 case 'a': | 4741 char *end; 4742 4743 4744 /* check options */ 4745 while ((c = getopt(argc, argv, ":avV:")) != -1) { 4746 switch (c) { 4747 case 'a': |
4521 cb.cb_all = B_TRUE; | 4748 upgradeall = B_TRUE; |
4522 break; 4523 case 'v': 4524 showversions = B_TRUE; 4525 break; 4526 case 'V': 4527 cb.cb_version = strtoll(optarg, &end, 10); 4528 if (*end != '\0' || 4529 !SPA_VERSION_IS_SUPPORTED(cb.cb_version)) { --- 16 unchanged lines hidden (view full) --- 4546 4547 cb.cb_argc = argc; 4548 cb.cb_argv = argv; 4549 argc -= optind; 4550 argv += optind; 4551 4552 if (cb.cb_version == 0) { 4553 cb.cb_version = SPA_VERSION; | 4749 break; 4750 case 'v': 4751 showversions = B_TRUE; 4752 break; 4753 case 'V': 4754 cb.cb_version = strtoll(optarg, &end, 10); 4755 if (*end != '\0' || 4756 !SPA_VERSION_IS_SUPPORTED(cb.cb_version)) { --- 16 unchanged lines hidden (view full) --- 4773 4774 cb.cb_argc = argc; 4775 cb.cb_argv = argv; 4776 argc -= optind; 4777 argv += optind; 4778 4779 if (cb.cb_version == 0) { 4780 cb.cb_version = SPA_VERSION; |
4554 } else if (!cb.cb_all && argc == 0) { | 4781 } else if (!upgradeall && argc == 0) { |
4555 (void) fprintf(stderr, gettext("-V option is " 4556 "incompatible with other arguments\n")); 4557 usage(B_FALSE); 4558 } 4559 4560 if (showversions) { | 4782 (void) fprintf(stderr, gettext("-V option is " 4783 "incompatible with other arguments\n")); 4784 usage(B_FALSE); 4785 } 4786 4787 if (showversions) { |
4561 if (cb.cb_all || argc != 0) { | 4788 if (upgradeall || argc != 0) { |
4562 (void) fprintf(stderr, gettext("-v option is " 4563 "incompatible with other arguments\n")); 4564 usage(B_FALSE); 4565 } | 4789 (void) fprintf(stderr, gettext("-v option is " 4790 "incompatible with other arguments\n")); 4791 usage(B_FALSE); 4792 } |
4566 } else if (cb.cb_all) { | 4793 } else if (upgradeall) { |
4567 if (argc != 0) { 4568 (void) fprintf(stderr, gettext("-a option should not " 4569 "be used along with a pool name\n")); 4570 usage(B_FALSE); 4571 } 4572 } 4573 4574 (void) printf(gettext("This system supports ZFS pool feature " 4575 "flags.\n\n")); | 4794 if (argc != 0) { 4795 (void) fprintf(stderr, gettext("-a option should not " 4796 "be used along with a pool name\n")); 4797 usage(B_FALSE); 4798 } 4799 } 4800 4801 (void) printf(gettext("This system supports ZFS pool feature " 4802 "flags.\n\n")); |
4576 cb.cb_first = B_TRUE; | |
4577 if (showversions) { | 4803 if (showversions) { |
4578 (void) printf(gettext("The following versions are " | 4804 int i; 4805 4806 (void) printf(gettext("The following features are " |
4579 "supported:\n\n")); | 4807 "supported:\n\n")); |
4808 (void) printf(gettext("FEAT DESCRIPTION\n")); 4809 (void) printf("----------------------------------------------" 4810 "---------------\n"); 4811 for (i = 0; i < SPA_FEATURES; i++) { 4812 zfeature_info_t *fi = &spa_feature_table[i]; 4813 const char *ro = fi->fi_can_readonly ? 4814 " (read-only compatible)" : ""; 4815 4816 (void) printf("%-37s%s\n", fi->fi_uname, ro); 4817 (void) printf(" %s\n", fi->fi_desc); 4818 } 4819 (void) printf("\n"); 4820 4821 (void) printf(gettext("The following legacy versions are also " 4822 "supported:\n\n")); |
|
4580 (void) printf(gettext("VER DESCRIPTION\n")); 4581 (void) printf("--- -----------------------------------------" 4582 "---------------\n"); 4583 (void) printf(gettext(" 1 Initial ZFS version\n")); 4584 (void) printf(gettext(" 2 Ditto blocks " 4585 "(replicated metadata)\n")); 4586 (void) printf(gettext(" 3 Hot spares and double parity " 4587 "RAID-Z\n")); --- 25 unchanged lines hidden (view full) --- 4613 (void) printf(gettext(" 26 Improved snapshot deletion " 4614 "performance\n")); 4615 (void) printf(gettext(" 27 Improved snapshot creation " 4616 "performance\n")); 4617 (void) printf(gettext(" 28 Multiple vdev replacements\n")); 4618 (void) printf(gettext("\nFor more information on a particular " 4619 "version, including supported releases,\n")); 4620 (void) printf(gettext("see the ZFS Administration Guide.\n\n")); | 4823 (void) printf(gettext("VER DESCRIPTION\n")); 4824 (void) printf("--- -----------------------------------------" 4825 "---------------\n"); 4826 (void) printf(gettext(" 1 Initial ZFS version\n")); 4827 (void) printf(gettext(" 2 Ditto blocks " 4828 "(replicated metadata)\n")); 4829 (void) printf(gettext(" 3 Hot spares and double parity " 4830 "RAID-Z\n")); --- 25 unchanged lines hidden (view full) --- 4856 (void) printf(gettext(" 26 Improved snapshot deletion " 4857 "performance\n")); 4858 (void) printf(gettext(" 27 Improved snapshot creation " 4859 "performance\n")); 4860 (void) printf(gettext(" 28 Multiple vdev replacements\n")); 4861 (void) printf(gettext("\nFor more information on a particular " 4862 "version, including supported releases,\n")); 4863 (void) printf(gettext("see the ZFS Administration Guide.\n\n")); |
4621 } else if (argc == 0) { 4622 int notfound; 4623 | 4864 } else if (argc == 0 && upgradeall) { 4865 cb.cb_first = B_TRUE; |
4624 ret = zpool_iter(g_zfs, upgrade_cb, &cb); | 4866 ret = zpool_iter(g_zfs, upgrade_cb, &cb); |
4625 notfound = cb.cb_first; 4626 4627 if (!cb.cb_all && ret == 0) { 4628 if (!cb.cb_first) 4629 (void) printf("\n"); 4630 cb.cb_first = B_TRUE; 4631 cb.cb_newer = B_TRUE; 4632 ret = zpool_iter(g_zfs, upgrade_cb, &cb); 4633 if (!cb.cb_first) { 4634 notfound = B_FALSE; 4635 (void) printf("\n"); | 4867 if (ret == 0 && cb.cb_first) { 4868 if (cb.cb_version == SPA_VERSION) { 4869 (void) printf(gettext("All pools are already " 4870 "formatted using feature flags.\n\n")); 4871 (void) printf(gettext("Every feature flags " 4872 "pool already has all supported features " 4873 "enabled.\n")); 4874 } else { 4875 (void) printf(gettext("All pools are already " 4876 "formatted with version %llu or higher.\n"), 4877 cb.cb_version); |
4636 } 4637 } | 4878 } 4879 } |
4880 } else if (argc == 0) { 4881 cb.cb_first = B_TRUE; 4882 ret = zpool_iter(g_zfs, upgrade_list_older_cb, &cb); 4883 assert(ret == 0); |
|
4638 | 4884 |
4639 if (ret == 0) { 4640 if (notfound) 4641 (void) printf(gettext("All pools are formatted " 4642 "using this version.\n")); 4643 else if (!cb.cb_all) 4644 (void) printf(gettext("Use 'zpool upgrade -v' " 4645 "for a list of available versions and " 4646 "their associated\nfeatures.\n")); | 4885 if (cb.cb_first) { 4886 (void) printf(gettext("All pools are formatted " 4887 "using feature flags.\n\n")); 4888 } else { 4889 (void) printf(gettext("\nUse 'zpool upgrade -v' " 4890 "for a list of available legacy versions.\n")); |
4647 } | 4891 } |
4892 4893 cb.cb_first = B_TRUE; 4894 ret = zpool_iter(g_zfs, upgrade_list_disabled_cb, &cb); 4895 assert(ret == 0); 4896 4897 if (cb.cb_first) { 4898 (void) printf(gettext("Every feature flags pool has " 4899 "all supported features enabled.\n")); 4900 } else { 4901 (void) printf(gettext("\n")); 4902 } |
|
4648 } else { 4649 ret = for_each_pool(argc, argv, B_FALSE, NULL, 4650 upgrade_one, &cb); 4651 } 4652 4653 if (cb.cb_poolname[0] != '\0') { 4654 (void) printf( 4655 "If you boot from pool '%s', don't forget to update boot code.\n" --- 406 unchanged lines hidden --- | 4903 } else { 4904 ret = for_each_pool(argc, argv, B_FALSE, NULL, 4905 upgrade_one, &cb); 4906 } 4907 4908 if (cb.cb_poolname[0] != '\0') { 4909 (void) printf( 4910 "If you boot from pool '%s', don't forget to update boot code.\n" --- 406 unchanged lines hidden --- |