Print this page
4185 New hash algorithm support

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/zfs/spa.c
          +++ new/usr/src/uts/common/fs/zfs/spa.c
↓ open down ↓ 15 lines elided ↑ open up ↑
  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  /*
  23   23   * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  24   24   * Copyright (c) 2013 by Delphix. All rights reserved.
  25   25   * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
       26 + * Copyright 2013 Saso Kiselkov. All rights reserved.
  26   27   */
  27   28  
  28   29  /*
  29   30   * SPA: Storage Pool Allocator
  30   31   *
  31   32   * This file contains all the routines used when modifying on-disk SPA state.
  32   33   * This includes opening, importing, destroying, exporting a pool, and syncing a
  33   34   * pool.
  34   35   */
  35   36  
↓ open down ↓ 2367 lines elided ↑ open up ↑
2403 2404                              ZPOOL_REWIND_POLICY, policy) == 0);
2404 2405  
2405 2406                  spa_config_set(spa, nvconfig);
2406 2407                  spa_unload(spa);
2407 2408                  spa_deactivate(spa);
2408 2409                  spa_activate(spa, orig_mode);
2409 2410  
2410 2411                  return (spa_load(spa, state, SPA_IMPORT_EXISTING, B_TRUE));
2411 2412          }
2412 2413  
     2414 +        /* Grab the secret checksum salt from the MOS. */
     2415 +        if (spa_dir_prop(spa, DMU_POOL_CHECKSUM_SALT,
     2416 +            &spa->spa_cksum_salt_obj) == 0) {
     2417 +                if (zap_lookup(spa->spa_meta_objset, spa->spa_cksum_salt_obj,
     2418 +                    DMU_POOL_CHECKSUM_SALT, 1,
     2419 +                    sizeof (spa->spa_cksum_salt.zcs_bytes),
     2420 +                    spa->spa_cksum_salt.zcs_bytes) != 0) {
     2421 +                        /*
     2422 +                         * MOS format is broken, the salt object is there but
     2423 +                         * is missing the actual salt value.
     2424 +                         */
     2425 +                        return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
     2426 +                }
     2427 +        } else {
     2428 +                /* Generate a new salt for subsequent use */
     2429 +                (void) random_get_pseudo_bytes(spa->spa_cksum_salt.zcs_bytes,
     2430 +                    sizeof (spa->spa_cksum_salt.zcs_bytes));
     2431 +        }
     2432 +
2413 2433          if (spa_dir_prop(spa, DMU_POOL_SYNC_BPOBJ, &obj) != 0)
2414 2434                  return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2415 2435          error = bpobj_open(&spa->spa_deferred_bpobj, spa->spa_meta_objset, obj);
2416 2436          if (error != 0)
2417 2437                  return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
2418 2438  
2419 2439          /*
2420 2440           * Load the bit that tells us to use the new accounting function
2421 2441           * (raid-z deflation).  If we have an older pool, this will not
2422 2442           * be present.
↓ open down ↓ 1126 lines elided ↑ open up ↑
3549 3569          VERIFY3U(0, ==, bpobj_open(&spa->spa_deferred_bpobj,
3550 3570              spa->spa_meta_objset, obj));
3551 3571  
3552 3572          /*
3553 3573           * Create the pool's history object.
3554 3574           */
3555 3575          if (version >= SPA_VERSION_ZPOOL_HISTORY)
3556 3576                  spa_history_create_obj(spa, tx);
3557 3577  
3558 3578          /*
     3579 +         * Generate some random noise for salted checksums to operate on. As
     3580 +         * soon as a salted checksum is used for the first time we will
     3581 +         * generate the persistent MOS object to hold the salt (see
     3582 +         * spa_activate_salted_cksum).
     3583 +         */
     3584 +        (void) random_get_pseudo_bytes(spa->spa_cksum_salt.zcs_bytes,
     3585 +            sizeof (spa->spa_cksum_salt.zcs_bytes));
     3586 +
     3587 +        /*
3559 3588           * Set pool properties.
3560 3589           */
3561 3590          spa->spa_bootfs = zpool_prop_default_numeric(ZPOOL_PROP_BOOTFS);
3562 3591          spa->spa_delegation = zpool_prop_default_numeric(ZPOOL_PROP_DELEGATION);
3563 3592          spa->spa_failmode = zpool_prop_default_numeric(ZPOOL_PROP_FAILUREMODE);
3564 3593          spa->spa_autoexpand = zpool_prop_default_numeric(ZPOOL_PROP_AUTOEXPAND);
3565 3594  
3566 3595          if (props != NULL) {
3567 3596                  spa_configfile_set(spa, props, B_FALSE);
3568 3597                  spa_sync_props(props, tx);
↓ open down ↓ 2955 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX