Print this page


Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/ztest/ztest.c
          +++ new/usr/src/cmd/ztest/ztest.c
↓ open down ↓ 79 lines elided ↑ open up ↑
  80   80  #include <sys/dmu_objset.h>
  81   81  #include <sys/poll.h>
  82   82  #include <sys/stat.h>
  83   83  #include <sys/time.h>
  84   84  #include <sys/wait.h>
  85   85  #include <sys/mman.h>
  86   86  #include <sys/resource.h>
  87   87  #include <sys/zio.h>
  88   88  #include <sys/zio_checksum.h>
  89   89  #include <sys/zio_compress.h>
       90 +#include <sys/zio_crypt.h>
  90   91  #include <sys/zil.h>
  91   92  #include <sys/vdev_impl.h>
  92   93  #include <sys/vdev_file.h>
  93   94  #include <sys/spa_impl.h>
  94   95  #include <sys/dsl_prop.h>
  95   96  #include <sys/refcount.h>
  96   97  #include <stdio.h>
  97   98  #include <stdio_ext.h>
  98   99  #include <stdlib.h>
  99  100  #include <unistd.h>
↓ open down ↓ 591 lines elided ↑ open up ↑
 691  692  
 692  693          return (checksum);
 693  694  }
 694  695  
 695  696  static uint8_t
 696  697  ztest_random_compress(void)
 697  698  {
 698  699          return ((uint8_t)ztest_random(ZIO_COMPRESS_FUNCTIONS));
 699  700  }
 700  701  
      702 +static uint8_t
      703 +ztest_random_crypt(void)
      704 +{
      705 +        return ((uint8_t)ztest_random(ZIO_CRYPT_FUNCTIONS));
      706 +}
      707 +
 701  708  static int
 702  709  ztest_replay_create(objset_t *os, lr_create_t *lr, boolean_t byteswap)
 703  710  {
 704  711          dmu_tx_t *tx;
 705  712          int error;
 706  713  
 707  714          if (byteswap)
 708  715                  byteswap_uint64_array(lr, sizeof (*lr));
 709  716  
 710  717          tx = dmu_tx_create(os);
↓ open down ↓ 829 lines elided ↑ open up ↑
1540 1547                  if (error) {
1541 1548                          fatal(0, "dmu_object_free('%s', %llu) = %d",
1542 1549                              osname, object, error);
1543 1550                  }
1544 1551                  object = 0;
1545 1552  
1546 1553                  dmu_object_set_checksum(os, batchobj,
1547 1554                      ztest_random_checksum(), tx);
1548 1555                  dmu_object_set_compress(os, batchobj,
1549 1556                      ztest_random_compress(), tx);
     1557 +                dmu_object_set_crypt(os, batchobj,
     1558 +                    ztest_random_crypt(), tx);
1550 1559  
1551 1560                  dmu_write(os, batchobj, b * sizeof (uint64_t),
1552 1561                      sizeof (uint64_t), &object, tx);
1553 1562  
1554 1563                  dmu_tx_commit(tx);
1555 1564          }
1556 1565  
1557 1566          /*
1558 1567           * Before creating the new batch of objects, generate a bunch of churn.
1559 1568           */
↓ open down ↓ 41 lines elided ↑ open up ↑
1601 1610  
1602 1611                  object = dmu_object_alloc(os, DMU_OT_UINT64_OTHER, 0,
1603 1612                      DMU_OT_PLAIN_OTHER, bonuslen, tx);
1604 1613  
1605 1614                  ztest_set_random_blocksize(os, object, tx);
1606 1615  
1607 1616                  dmu_object_set_checksum(os, object,
1608 1617                      ztest_random_checksum(), tx);
1609 1618                  dmu_object_set_compress(os, object,
1610 1619                      ztest_random_compress(), tx);
     1620 +                dmu_object_set_crypt(os, object,
     1621 +                    ztest_random_crypt(), tx);
1611 1622  
1612 1623                  dmu_write(os, batchobj, b * sizeof (uint64_t),
1613 1624                      sizeof (uint64_t), &object, tx);
1614 1625  
1615 1626                  /*
1616 1627                   * Write to both the bonus buffer and the regular data.
1617 1628                   */
1618 1629                  VERIFY(dmu_bonus_hold(os, object, FTAG, &db) == 0);
1619 1630                  za->za_dbuf = db;
1620 1631                  ASSERT3U(bonuslen, <=, db->db_size);
↓ open down ↓ 820 lines elided ↑ open up ↑
2441 2452          uint64_t value;
2442 2453          const char *prop, *valname;
2443 2454          char setpoint[MAXPATHLEN];
2444 2455          char osname[MAXNAMELEN];
2445 2456          int error;
2446 2457  
2447 2458          (void) rw_rdlock(&ztest_shared->zs_name_lock);
2448 2459  
2449 2460          dmu_objset_name(os, osname);
2450 2461  
2451      -        for (i = 0; i < 2; i++) {
     2462 +        for (i = 0; i < 3; i++) {
2452 2463                  if (i == 0) {
2453 2464                          prop = "checksum";
2454 2465                          value = ztest_random_checksum();
2455 2466                          inherit = (value == ZIO_CHECKSUM_INHERIT);
2456      -                } else {
     2467 +                } else if (i == 1) {
2457 2468                          prop = "compression";
2458 2469                          value = ztest_random_compress();
2459 2470                          inherit = (value == ZIO_COMPRESS_INHERIT);
     2471 +                } else {
     2472 +                        prop = "crypt";
     2473 +                        value = ztest_random_crypt();
     2474 +                        inherit = (value == ZIO_CRYPT_INHERIT);
2460 2475                  }
2461 2476  
2462 2477                  error = dsl_prop_set(osname, prop, sizeof (value),
2463 2478                      !inherit, &value);
2464 2479  
2465 2480                  if (error == ENOSPC) {
2466 2481                          ztest_record_enospc("dsl_prop_set");
2467 2482                          break;
2468 2483                  }
2469 2484  
2470 2485                  ASSERT3U(error, ==, 0);
2471 2486  
2472 2487                  VERIFY3U(dsl_prop_get(osname, prop, sizeof (value),
2473 2488                      1, &value, setpoint), ==, 0);
2474 2489  
2475      -                if (i == 0)
     2490 +                if (i == 0) {
2476 2491                          valname = zio_checksum_table[value].ci_name;
2477      -                else
     2492 +                } else if (i == 1) {
2478 2493                          valname = zio_compress_table[value].ci_name;
     2494 +                } else {
     2495 +                        valname = zio_crypt_table[value].ci_name;
     2496 +                }
2479 2497  
     2498 +
2480 2499                  if (zopt_verbose >= 6) {
2481 2500                          (void) printf("%s %s = %s for '%s'\n",
2482 2501                              osname, prop, valname, setpoint);
2483 2502                  }
2484 2503          }
2485 2504  
2486 2505          (void) rw_unlock(&ztest_shared->zs_name_lock);
2487 2506  }
2488 2507  
2489 2508  /*
↓ open down ↓ 999 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX