Print this page
1693 persistent 'comment' field for a zpool

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/zpool/zpool_main.c
          +++ new/usr/src/cmd/zpool/zpool_main.c
↓ open down ↓ 1326 lines elided ↑ open up ↑
1327 1327          uint64_t pool_state;
1328 1328          vdev_stat_t *vs;
1329 1329          char *name;
1330 1330          uint64_t guid;
1331 1331          char *msgid;
1332 1332          nvlist_t *nvroot;
1333 1333          int reason;
1334 1334          const char *health;
1335 1335          uint_t vsc;
1336 1336          int namewidth;
     1337 +        char *comment;
1337 1338  
1338 1339          verify(nvlist_lookup_string(config, ZPOOL_CONFIG_POOL_NAME,
1339 1340              &name) == 0);
1340 1341          verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_GUID,
1341 1342              &guid) == 0);
1342 1343          verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_STATE,
1343 1344              &pool_state) == 0);
1344 1345          verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE,
1345 1346              &nvroot) == 0);
1346 1347  
1347 1348          verify(nvlist_lookup_uint64_array(nvroot, ZPOOL_CONFIG_VDEV_STATS,
1348 1349              (uint64_t **)&vs, &vsc) == 0);
1349 1350          health = zpool_state_to_name(vs->vs_state, vs->vs_aux);
1350 1351  
1351 1352          reason = zpool_import_status(config, &msgid);
1352 1353  
1353      -        (void) printf(gettext("  pool: %s\n"), name);
1354      -        (void) printf(gettext("    id: %llu\n"), (u_longlong_t)guid);
1355      -        (void) printf(gettext(" state: %s"), health);
     1354 +        (void) printf(gettext("   pool: %s\n"), name);
     1355 +        (void) printf(gettext("     id: %llu\n"), (u_longlong_t)guid);
     1356 +        (void) printf(gettext("  state: %s"), health);
1356 1357          if (pool_state == POOL_STATE_DESTROYED)
1357 1358                  (void) printf(gettext(" (DESTROYED)"));
1358 1359          (void) printf("\n");
1359 1360  
1360 1361          switch (reason) {
1361 1362          case ZPOOL_STATUS_MISSING_DEV_R:
1362 1363          case ZPOOL_STATUS_MISSING_DEV_NR:
1363 1364          case ZPOOL_STATUS_BAD_GUID_SUM:
1364      -                (void) printf(gettext("status: One or more devices are missing "
1365      -                    "from the system.\n"));
     1365 +                (void) printf(gettext(" status: One or more devices are "
     1366 +                    "missing from the system.\n"));
1366 1367                  break;
1367 1368  
1368 1369          case ZPOOL_STATUS_CORRUPT_LABEL_R:
1369 1370          case ZPOOL_STATUS_CORRUPT_LABEL_NR:
1370      -                (void) printf(gettext("status: One or more devices contains "
     1371 +                (void) printf(gettext(" status: One or more devices contains "
1371 1372                      "corrupted data.\n"));
1372 1373                  break;
1373 1374  
1374 1375          case ZPOOL_STATUS_CORRUPT_DATA:
1375      -                (void) printf(gettext("status: The pool data is corrupted.\n"));
     1376 +                (void) printf(
     1377 +                    gettext(" status: The pool data is corrupted.\n"));
1376 1378                  break;
1377 1379  
1378 1380          case ZPOOL_STATUS_OFFLINE_DEV:
1379      -                (void) printf(gettext("status: One or more devices "
     1381 +                (void) printf(gettext(" status: One or more devices "
1380 1382                      "are offlined.\n"));
1381 1383                  break;
1382 1384  
1383 1385          case ZPOOL_STATUS_CORRUPT_POOL:
1384      -                (void) printf(gettext("status: The pool metadata is "
     1386 +                (void) printf(gettext(" status: The pool metadata is "
1385 1387                      "corrupted.\n"));
1386 1388                  break;
1387 1389  
1388 1390          case ZPOOL_STATUS_VERSION_OLDER:
1389      -                (void) printf(gettext("status: The pool is formatted using an "
     1391 +                (void) printf(gettext(" status: The pool is formatted using an "
1390 1392                      "older on-disk version.\n"));
1391 1393                  break;
1392 1394  
1393 1395          case ZPOOL_STATUS_VERSION_NEWER:
1394      -                (void) printf(gettext("status: The pool is formatted using an "
     1396 +                (void) printf(gettext(" status: The pool is formatted using an "
1395 1397                      "incompatible version.\n"));
1396 1398                  break;
1397 1399  
1398 1400          case ZPOOL_STATUS_HOSTID_MISMATCH:
1399      -                (void) printf(gettext("status: The pool was last accessed by "
     1401 +                (void) printf(gettext(" status: The pool was last accessed by "
1400 1402                      "another system.\n"));
1401 1403                  break;
1402 1404  
1403 1405          case ZPOOL_STATUS_FAULTED_DEV_R:
1404 1406          case ZPOOL_STATUS_FAULTED_DEV_NR:
1405      -                (void) printf(gettext("status: One or more devices are "
     1407 +                (void) printf(gettext(" status: One or more devices are "
1406 1408                      "faulted.\n"));
1407 1409                  break;
1408 1410  
1409 1411          case ZPOOL_STATUS_BAD_LOG:
1410      -                (void) printf(gettext("status: An intent log record cannot be "
     1412 +                (void) printf(gettext(" status: An intent log record cannot be "
1411 1413                      "read.\n"));
1412 1414                  break;
1413 1415  
1414 1416          case ZPOOL_STATUS_RESILVERING:
1415      -                (void) printf(gettext("status: One or more devices were being "
     1417 +                (void) printf(gettext(" status: One or more devices were being "
1416 1418                      "resilvered.\n"));
1417 1419                  break;
1418 1420  
1419 1421          default:
1420 1422                  /*
1421 1423                   * No other status can be seen when importing pools.
1422 1424                   */
1423 1425                  assert(reason == ZPOOL_STATUS_OK);
1424 1426          }
1425 1427  
1426 1428          /*
1427 1429           * Print out an action according to the overall state of the pool.
1428 1430           */
1429 1431          if (vs->vs_state == VDEV_STATE_HEALTHY) {
1430 1432                  if (reason == ZPOOL_STATUS_VERSION_OLDER)
1431      -                        (void) printf(gettext("action: The pool can be "
     1433 +                        (void) printf(gettext(" action: The pool can be "
1432 1434                              "imported using its name or numeric identifier, "
1433 1435                              "though\n\tsome features will not be available "
1434 1436                              "without an explicit 'zpool upgrade'.\n"));
1435 1437                  else if (reason == ZPOOL_STATUS_HOSTID_MISMATCH)
1436      -                        (void) printf(gettext("action: The pool can be "
     1438 +                        (void) printf(gettext(" action: The pool can be "
1437 1439                              "imported using its name or numeric "
1438 1440                              "identifier and\n\tthe '-f' flag.\n"));
1439 1441                  else
1440      -                        (void) printf(gettext("action: The pool can be "
     1442 +                        (void) printf(gettext(" action: The pool can be "
1441 1443                              "imported using its name or numeric "
1442 1444                              "identifier.\n"));
1443 1445          } else if (vs->vs_state == VDEV_STATE_DEGRADED) {
1444      -                (void) printf(gettext("action: The pool can be imported "
     1446 +                (void) printf(gettext(" action: The pool can be imported "
1445 1447                      "despite missing or damaged devices.  The\n\tfault "
1446 1448                      "tolerance of the pool may be compromised if imported.\n"));
1447 1449          } else {
1448 1450                  switch (reason) {
1449 1451                  case ZPOOL_STATUS_VERSION_NEWER:
1450      -                        (void) printf(gettext("action: The pool cannot be "
     1452 +                        (void) printf(gettext(" action: The pool cannot be "
1451 1453                              "imported.  Access the pool on a system running "
1452 1454                              "newer\n\tsoftware, or recreate the pool from "
1453 1455                              "backup.\n"));
1454 1456                          break;
1455 1457                  case ZPOOL_STATUS_MISSING_DEV_R:
1456 1458                  case ZPOOL_STATUS_MISSING_DEV_NR:
1457 1459                  case ZPOOL_STATUS_BAD_GUID_SUM:
1458      -                        (void) printf(gettext("action: The pool cannot be "
     1460 +                        (void) printf(gettext(" action: The pool cannot be "
1459 1461                              "imported. Attach the missing\n\tdevices and try "
1460 1462                              "again.\n"));
1461 1463                          break;
1462 1464                  default:
1463      -                        (void) printf(gettext("action: The pool cannot be "
     1465 +                        (void) printf(gettext(" action: The pool cannot be "
1464 1466                              "imported due to damaged devices or data.\n"));
1465 1467                  }
1466 1468          }
1467 1469  
     1470 +        /* Print the comment attached to the pool. */
     1471 +        if (nvlist_lookup_string(config, ZPOOL_CONFIG_COMMENT, &comment) == 0)
     1472 +                (void) printf(gettext("comment: %s\n"), comment);
     1473 +
1468 1474          /*
1469 1475           * If the state is "closed" or "can't open", and the aux state
1470 1476           * is "corrupt data":
1471 1477           */
1472 1478          if (((vs->vs_state == VDEV_STATE_CLOSED) ||
1473 1479              (vs->vs_state == VDEV_STATE_CANT_OPEN)) &&
1474 1480              (vs->vs_aux == VDEV_AUX_CORRUPT_DATA)) {
1475 1481                  if (pool_state == POOL_STATE_DESTROYED)
1476 1482                          (void) printf(gettext("\tThe pool was destroyed, "
1477 1483                              "but can be imported using the '-Df' flags.\n"));
1478 1484                  else if (pool_state != POOL_STATE_EXPORTED)
1479 1485                          (void) printf(gettext("\tThe pool may be active on "
1480 1486                              "another system, but can be imported using\n\t"
1481 1487                              "the '-f' flag.\n"));
1482 1488          }
1483 1489  
1484 1490          if (msgid != NULL)
1485 1491                  (void) printf(gettext("   see: http://www.sun.com/msg/%s\n"),
1486 1492                      msgid);
1487 1493  
1488      -        (void) printf(gettext("config:\n\n"));
     1494 +        (void) printf(gettext(" config:\n\n"));
1489 1495  
1490 1496          namewidth = max_width(NULL, nvroot, 0, 0);
1491 1497          if (namewidth < 10)
1492 1498                  namewidth = 10;
1493 1499  
1494 1500          print_import_config(name, nvroot, namewidth, 0);
1495 1501          if (num_logs(nvroot) > 0)
1496 1502                  print_logs(NULL, nvroot, namewidth, B_FALSE);
1497 1503  
1498 1504          if (reason == ZPOOL_STATUS_BAD_GUID_SUM) {
↓ open down ↓ 3059 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX