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

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libzfs/common/libzfs_import.c
          +++ new/usr/src/lib/libzfs/common/libzfs_import.c
↓ open down ↓ 12 lines elided ↑ open up ↑
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
       23 + * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
       24 + * Copyright (c) 2011 by Delphix. All rights reserved.
  23   25   */
  24   26  
  25   27  /*
  26   28   * Pool import support functions.
  27   29   *
  28   30   * To import a pool, we rely on reading the configuration information from the
  29   31   * ZFS label of each device.  If we successfully read the label, then we
  30   32   * organize the configuration information in the following hierarchy:
  31   33   *
  32   34   *      pool guid -> toplevel vdev guid -> label txg
↓ open down ↓ 397 lines elided ↑ open up ↑
 430  432  get_configs(libzfs_handle_t *hdl, pool_list_t *pl, boolean_t active_ok)
 431  433  {
 432  434          pool_entry_t *pe;
 433  435          vdev_entry_t *ve;
 434  436          config_entry_t *ce;
 435  437          nvlist_t *ret = NULL, *config = NULL, *tmp, *nvtop, *nvroot;
 436  438          nvlist_t **spares, **l2cache;
 437  439          uint_t i, nspares, nl2cache;
 438  440          boolean_t config_seen;
 439  441          uint64_t best_txg;
 440      -        char *name, *hostname;
      442 +        char *name, *hostname, *comment;
 441  443          uint64_t version, guid;
 442  444          uint_t children = 0;
 443  445          nvlist_t **child = NULL;
 444  446          uint_t holes;
 445  447          uint64_t *hole_array, max_id;
 446  448          uint_t c;
 447  449          boolean_t isactive;
 448  450          uint64_t hostid;
 449  451          nvlist_t *nvl;
 450  452          boolean_t found_one = B_FALSE;
↓ open down ↓ 68 lines elided ↑ open up ↑
 519  521                          }
 520  522  
 521  523                          if (!config_seen) {
 522  524                                  /*
 523  525                                   * Copy the relevant pieces of data to the pool
 524  526                                   * configuration:
 525  527                                   *
 526  528                                   *      version
 527  529                                   *      pool guid
 528  530                                   *      name
      531 +                                 *      comment (if available)
 529  532                                   *      pool state
 530  533                                   *      hostid (if available)
 531  534                                   *      hostname (if available)
 532  535                                   */
 533  536                                  uint64_t state;
 534  537  
 535  538                                  verify(nvlist_lookup_uint64(tmp,
 536  539                                      ZPOOL_CONFIG_VERSION, &version) == 0);
 537  540                                  if (nvlist_add_uint64(config,
 538  541                                      ZPOOL_CONFIG_VERSION, version) != 0)
↓ open down ↓ 1 lines elided ↑ open up ↑
 540  543                                  verify(nvlist_lookup_uint64(tmp,
 541  544                                      ZPOOL_CONFIG_POOL_GUID, &guid) == 0);
 542  545                                  if (nvlist_add_uint64(config,
 543  546                                      ZPOOL_CONFIG_POOL_GUID, guid) != 0)
 544  547                                          goto nomem;
 545  548                                  verify(nvlist_lookup_string(tmp,
 546  549                                      ZPOOL_CONFIG_POOL_NAME, &name) == 0);
 547  550                                  if (nvlist_add_string(config,
 548  551                                      ZPOOL_CONFIG_POOL_NAME, name) != 0)
 549  552                                          goto nomem;
      553 +
      554 +                                /*
      555 +                                 * COMMENT is optional, don't bail if it's not
      556 +                                 * there, instead, set it to NULL.
      557 +                                 */
      558 +                                if (nvlist_lookup_string(tmp,
      559 +                                    ZPOOL_CONFIG_COMMENT, &comment) != 0)
      560 +                                        comment = NULL;
      561 +                                else if (nvlist_add_string(config,
      562 +                                    ZPOOL_CONFIG_COMMENT, comment) != 0)
      563 +                                        goto nomem;
      564 +
 550  565                                  verify(nvlist_lookup_uint64(tmp,
 551  566                                      ZPOOL_CONFIG_POOL_STATE, &state) == 0);
 552  567                                  if (nvlist_add_uint64(config,
 553  568                                      ZPOOL_CONFIG_POOL_STATE, state) != 0)
 554  569                                          goto nomem;
      570 +
 555  571                                  hostid = 0;
 556  572                                  if (nvlist_lookup_uint64(tmp,
 557  573                                      ZPOOL_CONFIG_HOSTID, &hostid) == 0) {
 558  574                                          if (nvlist_add_uint64(config,
 559  575                                              ZPOOL_CONFIG_HOSTID, hostid) != 0)
 560  576                                                  goto nomem;
 561  577                                          verify(nvlist_lookup_string(tmp,
 562  578                                              ZPOOL_CONFIG_HOSTNAME,
 563  579                                              &hostname) == 0);
 564  580                                          if (nvlist_add_string(config,
↓ open down ↓ 1124 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX