Lines Matching +full:mmp +full:- +full:timer
1 // SPDX-License-Identifier: CDDL-1.0
10 * or https://opensource.org/licenses/CDDL-1.0.
49 * verify that self-healing data really works.
55 * (5) To verify that we never lose on-disk consistency after a crash,
57 * At random times, the child self-immolates with a SIGKILL.
75 * specify -V. To get more information, specify -VV, and so on.
77 * To turn this into an overnight stress test, use -T to specify run time.
79 * You can ask more vdevs [-v], datasets [-d], or threads [-t]
82 * Use the -k option to set the desired frequency of kills.
85 * temporary file which is mmap-ed in the child process. This allows shared
90 * ztest can invoke them during backwards compatibility testing (-B).
143 static int ztest_fd_data = -1;
144 static int ztest_fd_rand = -1;
167 RAIDZ_EXPAND_NONE, /* Default is none, must opt-in */
168 RAIDZ_EXPAND_REQUESTED, /* The '-X' option was used */
236 /* Simplifying assumption: -1 is not a valid default. */
237 #define NO_DEFAULT -1
303 (MAX((zs)->zs_mirrors, 1) * (ztest_opts.zo_raid_parity + 1) - 1)
334 * the rangelock_t is not a drop-in replacement for rl_t, because we
377 * Per-dataset state.
392 * Per-iteration state.
404 uint64_t zc_count; /* per-pass count */
405 uint64_t zc_time; /* per-pass time */
545 #define ID_PARALLEL -1ULL
638 * Restore default action and re-raise signal so SIGSEGV and in sig_handler()
670 (void) snprintf(buf + strlen(buf), FATAL_MSG_SZ - strlen(buf), in fatal()
763 { 's', "vdev-size", "INTEGER", "Size of each vdev",
765 { 'a', "alignment-shift", "INTEGER",
767 { 'm', "mirror-copies", "INTEGER", "Number of mirror copies",
769 { 'r', "raid-disks", "INTEGER", "Number of raidz/draid disks",
771 { 'R', "raid-parity", "INTEGER", "Raid parity",
773 { 'K', "raid-kind", "raidz|eraidz|draid|random", "Raid kind",
775 { 'D', "draid-data", "INTEGER", "Number of draid data drives",
777 { 'S', "draid-spares", "INTEGER", "Number of draid spares",
783 { 'g', "gang-block-threshold", "INTEGER",
786 { 'i', "init-count", "INTEGER", "Number of times to initialize pool",
788 { 'k', "kill-percentage", "INTEGER", "Kill percentage",
790 { 'p', "pool-name", "STRING", "Pool name",
792 { 'f', "vdev-file-directory", "PATH", "File directory for vdev files",
794 { 'M', "multi-host", NULL,
795 "Multi-host; simulate pool imported on remote host",
797 { 'E', "use-existing-pool", NULL,
799 { 'T', "run-time", "INTEGER", "Total run time",
801 { 'P', "pass-time", "INTEGER", "Time per pass",
803 { 'F', "freeze-loops", "INTEGER", "Max loops in spa_freeze()",
805 { 'B', "alt-ztest", "PATH", "Alternate ztest path",
807 { 'C', "vdev-class-state", "on|off|random", "vdev class state",
809 { 'X', "raidz-expansion", NULL,
813 "Set global variable to an unsigned 32-bit integer value",
815 { 'G', "dump-debug-msg", NULL,
875 (void) sprintf(option, " -%c --%s=%s", in usage()
880 (void) sprintf(option, " -%c --%s", in usage()
884 (void) fprintf(fp, " %-43s%s", option, in usage()
929 "'-C' argument (%s)\n", input); in ztest_parse_name_value()
947 zo->zo_special_vdevs = state; in ztest_parse_name_value()
952 if (zo->zo_verbose >= 3) in ztest_parse_name_value()
994 zo->zo_vdevs = value; in process_options()
997 zo->zo_vdev_size = MAX(SPA_MINDEVSIZE, value); in process_options()
1000 zo->zo_ashift = value; in process_options()
1003 zo->zo_mirrors = value; in process_options()
1006 zo->zo_raid_children = MAX(1, value); in process_options()
1009 zo->zo_raid_parity = MIN(MAX(value, 1), 3); in process_options()
1015 zo->zo_draid_data = MAX(1, value); in process_options()
1018 zo->zo_draid_spares = MAX(1, value); in process_options()
1021 zo->zo_datasets = MAX(1, value); in process_options()
1024 zo->zo_threads = MAX(1, value); in process_options()
1027 zo->zo_metaslab_force_ganging = in process_options()
1031 zo->zo_init = value; in process_options()
1034 zo->zo_killrate = value; in process_options()
1037 (void) strlcpy(zo->zo_pool, optarg, in process_options()
1038 sizeof (zo->zo_pool)); in process_options()
1047 (void) strlcpy(zo->zo_dir, path, in process_options()
1048 sizeof (zo->zo_dir)); in process_options()
1053 zo->zo_mmp_test = 1; in process_options()
1056 zo->zo_verbose++; in process_options()
1059 zo->zo_raidz_expand_test = RAIDZ_EXPAND_REQUESTED; in process_options()
1062 zo->zo_init = 0; in process_options()
1065 zo->zo_time = value; in process_options()
1068 zo->zo_passtime = MAX(1, value); in process_options()
1071 zo->zo_maxloops = MAX(1, value); in process_options()
1074 (void) strlcpy(zo->zo_alt_ztest, optarg, in process_options()
1075 sizeof (zo->zo_alt_ztest)); in process_options()
1081 if (zo->zo_gvars_count >= ZO_GVARS_MAX_COUNT) { in process_options()
1087 char *v = zo->zo_gvars[zo->zo_gvars_count]; in process_options()
1095 zo->zo_gvars_count++; in process_options()
1098 zo->zo_dump_dbgmsg = 1; in process_options()
1113 if (zo->zo_raidz_expand_test == RAIDZ_EXPAND_REQUESTED) { in process_options()
1114 zo->zo_mmp_test = 0; in process_options()
1115 zo->zo_mirrors = 0; in process_options()
1116 zo->zo_vdevs = 1; in process_options()
1117 zo->zo_vdev_size = DEFAULT_VDEV_SIZE * 2; in process_options()
1118 zo->zo_raid_do_expand = B_FALSE; in process_options()
1146 /* No top-level mirrors with dRAID for now */ in process_options()
1147 zo->zo_mirrors = 0; in process_options()
1150 if (zo->zo_vdevs == ztest_opts_defaults.zo_vdevs) in process_options()
1151 zo->zo_vdevs = 1; in process_options()
1152 if (zo->zo_raid_children == in process_options()
1154 zo->zo_raid_children = 16; in process_options()
1155 if (zo->zo_ashift < 12) in process_options()
1156 zo->zo_ashift = 12; in process_options()
1157 if (zo->zo_vdev_size < min_devsize) in process_options()
1158 zo->zo_vdev_size = min_devsize; in process_options()
1160 if (zo->zo_draid_data + zo->zo_raid_parity > in process_options()
1161 zo->zo_raid_children - zo->zo_draid_spares) { in process_options()
1164 zo->zo_raid_children, in process_options()
1165 zo->zo_draid_data + zo->zo_raid_parity); in process_options()
1169 (void) strlcpy(zo->zo_raid_type, VDEV_TYPE_DRAID, in process_options()
1170 sizeof (zo->zo_raid_type)); in process_options()
1174 zo->zo_raid_do_expand = B_TRUE; in process_options()
1176 /* tests expect top-level to be raidz */ in process_options()
1177 zo->zo_mirrors = 0; in process_options()
1178 zo->zo_vdevs = 1; in process_options()
1181 zo->zo_raid_parity = MIN(zo->zo_raid_parity, in process_options()
1182 zo->zo_raid_children - 1); in process_options()
1187 zo->zo_raid_parity = MIN(zo->zo_raid_parity, in process_options()
1188 zo->zo_raid_children - 1); in process_options()
1191 zo->zo_vdevtime = in process_options()
1192 (zo->zo_vdevs > 0 ? zo->zo_time * NANOSEC / zo->zo_vdevs : in process_options()
1195 if (*zo->zo_alt_ztest) { in process_options()
1197 char *val = zo->zo_alt_ztest; in process_options()
1202 int dirlen = strrchr(val, '/') - val; in process_options()
1203 strlcpy(zo->zo_alt_libpath, val, in process_options()
1204 MIN(sizeof (zo->zo_alt_libpath), dirlen + 1)); in process_options()
1205 invalid_what = "library path", val = zo->zo_alt_libpath; in process_options()
1209 strlcat(val, "/lib", sizeof (zo->zo_alt_libpath)); in process_options()
1211 if (0 != access(zo->zo_alt_libpath, X_OK)) in process_options()
1224 zs->zs_alloc = metaslab_class_get_alloc(spa_normal_class(ztest_spa)); in ztest_kill()
1225 zs->zs_space = metaslab_class_get_space(spa_normal_class(ztest_spa)); in ztest_kill()
1237 ztest_scratch_state->zs_raidz_scratch_verify_pause = in ztest_kill()
1262 ztest_shared->zs_enospc_count++; in ztest_record_enospc()
1278 if (sscanf(name, VDEV_TYPE_DRAID "%"PRIu64"-%"PRIu64"-%"PRIu64"", in ztest_is_draid_spare()
1304 vdev = ztest_shared->zs_vdev_aux; in make_vdev_file()
1310 vdev = ztest_shared->zs_vdev_next_leaf++; in make_vdev_file()
1321 if (fd == -1) in make_vdev_file()
1370 * and the number of data drives (children - spares). in make_vdev_raid()
1372 while (ngroups * (ndata + nparity) % (children - nspares) != 0) in make_vdev_raid()
1467 ztest_random(SPA_VERSION_BEFORE_FEATURES - version + 1); in ztest_random_spa_version()
1480 ASSERT3U(ztest_spa->spa_max_ashift, !=, 0); in ztest_random_blocksize()
1490 ztest_random(maxbs - ztest_spa->spa_max_ashift + 1); in ztest_random_blocksize()
1505 * dnode sizes since that is more likely to reflect real-world in ztest_random_dnodesize()
1511 slots = 5 + ztest_random(max_slots - 4); in ztest_random_dnodesize()
1528 ztest_random(DN_MAX_INDBLKSHIFT - DN_MIN_INDBLKSHIFT + 1)); in ztest_random_ibshift()
1535 vdev_t *rvd = spa->spa_root_vdev; in ztest_random_vdev_top()
1541 top = ztest_random(rvd->vdev_children); in ztest_random_vdev_top()
1542 tvd = rvd->vdev_child[top]; in ztest_random_vdev_top()
1543 } while (!vdev_is_concrete(tvd) || (tvd->vdev_islog && !log_ok) || in ztest_random_vdev_top()
1544 tvd->vdev_mg == NULL || tvd->vdev_mg->mg_class == NULL); in ztest_random_vdev_top()
1555 value = zfs_prop_random_value(prop, ztest_random(-1ULL)); in ztest_random_dsl_prop()
1680 rll->rll_writer = NULL; in ztest_rll_init()
1681 rll->rll_readers = 0; in ztest_rll_init()
1682 mutex_init(&rll->rll_lock, NULL, MUTEX_DEFAULT, NULL); in ztest_rll_init()
1683 cv_init(&rll->rll_cv, NULL, CV_DEFAULT, NULL); in ztest_rll_init()
1689 ASSERT3P(rll->rll_writer, ==, NULL); in ztest_rll_destroy()
1690 ASSERT0(rll->rll_readers); in ztest_rll_destroy()
1691 mutex_destroy(&rll->rll_lock); in ztest_rll_destroy()
1692 cv_destroy(&rll->rll_cv); in ztest_rll_destroy()
1698 mutex_enter(&rll->rll_lock); in ztest_rll_lock()
1701 while (rll->rll_writer != NULL) in ztest_rll_lock()
1702 (void) cv_wait(&rll->rll_cv, &rll->rll_lock); in ztest_rll_lock()
1703 rll->rll_readers++; in ztest_rll_lock()
1705 while (rll->rll_writer != NULL || rll->rll_readers) in ztest_rll_lock()
1706 (void) cv_wait(&rll->rll_cv, &rll->rll_lock); in ztest_rll_lock()
1707 rll->rll_writer = curthread; in ztest_rll_lock()
1710 mutex_exit(&rll->rll_lock); in ztest_rll_lock()
1716 mutex_enter(&rll->rll_lock); in ztest_rll_unlock()
1718 if (rll->rll_writer) { in ztest_rll_unlock()
1719 ASSERT0(rll->rll_readers); in ztest_rll_unlock()
1720 rll->rll_writer = NULL; in ztest_rll_unlock()
1722 ASSERT3S(rll->rll_readers, >, 0); in ztest_rll_unlock()
1723 ASSERT3P(rll->rll_writer, ==, NULL); in ztest_rll_unlock()
1724 rll->rll_readers--; in ztest_rll_unlock()
1727 if (rll->rll_writer == NULL && rll->rll_readers == 0) in ztest_rll_unlock()
1728 cv_broadcast(&rll->rll_cv); in ztest_rll_unlock()
1730 mutex_exit(&rll->rll_lock); in ztest_rll_unlock()
1736 rll_t *rll = &zd->zd_object_lock[object & (ZTEST_OBJECT_LOCKS - 1)]; in ztest_object_lock()
1744 rll_t *rll = &zd->zd_object_lock[object & (ZTEST_OBJECT_LOCKS - 1)]; in ztest_object_unlock()
1754 rll_t *rll = &zd->zd_range_lock[hash & (ZTEST_RANGE_LOCKS - 1)]; in ztest_range_lock()
1758 rl->rl_object = object; in ztest_range_lock()
1759 rl->rl_offset = offset; in ztest_range_lock()
1760 rl->rl_size = size; in ztest_range_lock()
1761 rl->rl_lock = rll; in ztest_range_lock()
1771 rll_t *rll = rl->rl_lock; in ztest_range_unlock()
1781 zd->zd_os = os; in ztest_zd_init()
1782 zd->zd_zilog = dmu_objset_zil(os); in ztest_zd_init()
1783 zd->zd_shared = szd; in ztest_zd_init()
1784 dmu_objset_name(os, zd->zd_name); in ztest_zd_init()
1787 if (zd->zd_shared != NULL) in ztest_zd_init()
1788 zd->zd_shared->zd_seq = 0; in ztest_zd_init()
1790 VERIFY0(pthread_rwlock_init(&zd->zd_zilog_lock, NULL)); in ztest_zd_init()
1791 mutex_init(&zd->zd_dirobj_lock, NULL, MUTEX_DEFAULT, NULL); in ztest_zd_init()
1794 ztest_rll_init(&zd->zd_object_lock[l]); in ztest_zd_init()
1797 ztest_rll_init(&zd->zd_range_lock[l]); in ztest_zd_init()
1805 mutex_destroy(&zd->zd_dirobj_lock); in ztest_zd_fini()
1806 (void) pthread_rwlock_destroy(&zd->zd_zilog_lock); in ztest_zd_fini()
1809 ztest_rll_destroy(&zd->zd_object_lock[l]); in ztest_zd_fini()
1812 ztest_rll_destroy(&zd->zd_range_lock[l]); in ztest_zd_fini()
1849 bt->bt_magic = BT_MAGIC; in ztest_bt_generate()
1850 bt->bt_objset = dmu_objset_id(os); in ztest_bt_generate()
1851 bt->bt_object = object; in ztest_bt_generate()
1852 bt->bt_dnodesize = dnodesize; in ztest_bt_generate()
1853 bt->bt_offset = offset; in ztest_bt_generate()
1854 bt->bt_gen = gen; in ztest_bt_generate()
1855 bt->bt_txg = txg; in ztest_bt_generate()
1856 bt->bt_crtxg = crtxg; in ztest_bt_generate()
1864 ASSERT3U(bt->bt_magic, ==, BT_MAGIC); in ztest_bt_verify()
1865 ASSERT3U(bt->bt_objset, ==, dmu_objset_id(os)); in ztest_bt_verify()
1866 ASSERT3U(bt->bt_object, ==, object); in ztest_bt_verify()
1867 ASSERT3U(bt->bt_dnodesize, ==, dnodesize); in ztest_bt_verify()
1868 ASSERT3U(bt->bt_offset, ==, offset); in ztest_bt_verify()
1869 ASSERT3U(bt->bt_gen, <=, gen); in ztest_bt_verify()
1870 ASSERT3U(bt->bt_txg, <=, txg); in ztest_bt_verify()
1871 ASSERT3U(bt->bt_crtxg, ==, crtxg); in ztest_bt_verify()
1881 ASSERT3U(doi.doi_bonus_size, <=, db->db_size); in ztest_bt_bonus()
1883 bt = (void *)((char *)db->db_data + doi.doi_bonus_size - sizeof (*bt)); in ztest_bt_bonus()
1898 * verifiable pattern. Filling the whole bonus area with non-zero data
1908 ASSERT(IS_P2ALIGNED((char *)end - (char *)db->db_data, 8)); in ztest_fill_unused_bonus()
1910 for (bonusp = db->db_data; bonusp < (uint64_t *)end; bonusp++) { in ztest_fill_unused_bonus()
1912 gen, bonusp - (uint64_t *)db->db_data); in ztest_fill_unused_bonus()
1927 for (bonusp = db->db_data; bonusp < (uint64_t *)end; bonusp++) { in ztest_verify_unused_bonus()
1929 gen, bonusp - (uint64_t *)db->db_data); in ztest_verify_unused_bonus()
1947 char *name = (char *)&lr->lr_data[0]; /* name follows lr */ in ztest_log_create()
1951 if (zil_replaying(zd->zd_zilog, tx)) in ztest_log_create()
1955 memcpy(&itx->itx_lr + 1, &lr->lr_create.lr_common + 1, in ztest_log_create()
1956 sizeof (*lr) + namesize - sizeof (lr_t)); in ztest_log_create()
1958 zil_itx_assign(zd->zd_zilog, itx, tx); in ztest_log_create()
1964 char *name = (char *)&lr->lr_data[0]; /* name follows lr */ in ztest_log_remove()
1968 if (zil_replaying(zd->zd_zilog, tx)) in ztest_log_remove()
1972 memcpy(&itx->itx_lr + 1, &lr->lr_common + 1, in ztest_log_remove()
1973 sizeof (*lr) + namesize - sizeof (lr_t)); in ztest_log_remove()
1975 itx->itx_oid = object; in ztest_log_remove()
1976 zil_itx_assign(zd->zd_zilog, itx, tx); in ztest_log_remove()
1985 if (zil_replaying(zd->zd_zilog, tx)) in ztest_log_write()
1988 if (lr->lr_length > zil_max_log_data(zd->zd_zilog, sizeof (lr_write_t))) in ztest_log_write()
1992 sizeof (*lr) + (write_state == WR_COPIED ? lr->lr_length : 0)); in ztest_log_write()
1995 dmu_read(zd->zd_os, lr->lr_foid, lr->lr_offset, lr->lr_length, in ztest_log_write()
1996 ((lr_write_t *)&itx->itx_lr) + 1, DMU_READ_NO_PREFETCH) != 0) { in ztest_log_write()
2001 itx->itx_private = zd; in ztest_log_write()
2002 itx->itx_wr_state = write_state; in ztest_log_write()
2003 itx->itx_sync = (ztest_random(8) == 0); in ztest_log_write()
2005 memcpy(&itx->itx_lr + 1, &lr->lr_common + 1, in ztest_log_write()
2006 sizeof (*lr) - sizeof (lr_t)); in ztest_log_write()
2008 zil_itx_assign(zd->zd_zilog, itx, tx); in ztest_log_write()
2016 if (zil_replaying(zd->zd_zilog, tx)) in ztest_log_truncate()
2020 memcpy(&itx->itx_lr + 1, &lr->lr_common + 1, in ztest_log_truncate()
2021 sizeof (*lr) - sizeof (lr_t)); in ztest_log_truncate()
2023 itx->itx_sync = B_FALSE; in ztest_log_truncate()
2024 zil_itx_assign(zd->zd_zilog, itx, tx); in ztest_log_truncate()
2032 if (zil_replaying(zd->zd_zilog, tx)) in ztest_log_setattr()
2036 memcpy(&itx->itx_lr + 1, &lr->lr_common + 1, in ztest_log_setattr()
2037 sizeof (*lr) - sizeof (lr_t)); in ztest_log_setattr()
2039 itx->itx_sync = B_FALSE; in ztest_log_setattr()
2040 zil_itx_assign(zd->zd_zilog, itx, tx); in ztest_log_setattr()
2051 _lr_create_t *lr = &lrc->lr_create; in ztest_replay_create()
2052 char *name = (char *)&lrc->lr_data[0]; /* name follows lr */ in ztest_replay_create()
2053 objset_t *os = zd->zd_os; in ztest_replay_create()
2064 ASSERT3U(lr->lr_doid, ==, ZTEST_DIROBJ); in ztest_replay_create()
2069 dmu_tx_hold_zap(tx, lr->lr_doid, B_TRUE, name); in ztest_replay_create()
2071 if (lr->lrz_type == DMU_OT_ZAP_OTHER) { in ztest_replay_create()
2081 ASSERT3U(dmu_objset_zil(os)->zl_replay, ==, !!lr->lr_foid); in ztest_replay_create()
2082 bonuslen = DN_BONUS_SIZE(lr->lrz_dnodesize); in ztest_replay_create()
2084 if (lr->lrz_type == DMU_OT_ZAP_OTHER) { in ztest_replay_create()
2085 if (lr->lr_foid == 0) { in ztest_replay_create()
2086 lr->lr_foid = zap_create_dnsize(os, in ztest_replay_create()
2087 lr->lrz_type, lr->lrz_bonustype, in ztest_replay_create()
2088 bonuslen, lr->lrz_dnodesize, tx); in ztest_replay_create()
2090 error = zap_create_claim_dnsize(os, lr->lr_foid, in ztest_replay_create()
2091 lr->lrz_type, lr->lrz_bonustype, in ztest_replay_create()
2092 bonuslen, lr->lrz_dnodesize, tx); in ztest_replay_create()
2095 if (lr->lr_foid == 0) { in ztest_replay_create()
2096 lr->lr_foid = dmu_object_alloc_dnsize(os, in ztest_replay_create()
2097 lr->lrz_type, 0, lr->lrz_bonustype, in ztest_replay_create()
2098 bonuslen, lr->lrz_dnodesize, tx); in ztest_replay_create()
2100 error = dmu_object_claim_dnsize(os, lr->lr_foid, in ztest_replay_create()
2101 lr->lrz_type, 0, lr->lrz_bonustype, in ztest_replay_create()
2102 bonuslen, lr->lrz_dnodesize, tx); in ztest_replay_create()
2108 ASSERT(zd->zd_zilog->zl_replay); in ztest_replay_create()
2113 ASSERT3U(lr->lr_foid, !=, 0); in ztest_replay_create()
2115 if (lr->lrz_type != DMU_OT_ZAP_OTHER) in ztest_replay_create()
2116 VERIFY0(dmu_object_set_blocksize(os, lr->lr_foid, in ztest_replay_create()
2117 lr->lrz_blocksize, lr->lrz_ibshift, tx)); in ztest_replay_create()
2119 VERIFY0(dmu_bonus_hold(os, lr->lr_foid, FTAG, &db)); in ztest_replay_create()
2122 ztest_bt_generate(bbt, os, lr->lr_foid, lr->lrz_dnodesize, -1ULL, in ztest_replay_create()
2123 lr->lr_gen, txg, txg); in ztest_replay_create()
2124 ztest_fill_unused_bonus(db, bbt, lr->lr_foid, os, lr->lr_gen); in ztest_replay_create()
2127 VERIFY0(zap_add(os, lr->lr_doid, name, sizeof (uint64_t), 1, in ztest_replay_create()
2128 &lr->lr_foid, tx)); in ztest_replay_create()
2142 char *name = (char *)&lr->lr_data[0]; /* name follows lr */ in ztest_replay_remove()
2143 objset_t *os = zd->zd_os; in ztest_replay_remove()
2151 ASSERT3U(lr->lr_doid, ==, ZTEST_DIROBJ); in ztest_replay_remove()
2155 zap_lookup(os, lr->lr_doid, name, sizeof (object), 1, &object)); in ztest_replay_remove()
2164 dmu_tx_hold_zap(tx, lr->lr_doid, B_FALSE, name); in ztest_replay_remove()
2179 VERIFY0(zap_remove(os, lr->lr_doid, name, tx)); in ztest_replay_remove()
2195 objset_t *os = zd->zd_os; in ztest_replay_write()
2196 uint8_t *data = &lr->lr_data[0]; /* data follows lr */ in ztest_replay_write()
2210 offset = lr->lr_offset; in ztest_replay_write()
2211 length = lr->lr_length; in ztest_replay_write()
2214 if (lr->lr_common.lrc_reclen == sizeof (lr_write_t)) { in ztest_replay_write()
2215 uint64_t blocksize = BP_GET_LSIZE(&lr->lr_blkptr); in ztest_replay_write()
2217 offset -= offset % blocksize; in ztest_replay_write()
2222 if (bt->bt_magic == BSWAP_64(BT_MAGIC)) in ztest_replay_write()
2225 if (bt->bt_magic != BT_MAGIC) in ztest_replay_write()
2228 ztest_object_lock(zd, lr->lr_foid, ZTRL_READER); in ztest_replay_write()
2229 rl = ztest_range_lock(zd, lr->lr_foid, offset, length, ZTRL_WRITER); in ztest_replay_write()
2231 VERIFY0(dmu_bonus_hold(os, lr->lr_foid, FTAG, &db)); in ztest_replay_write()
2236 ASSERT3U(bbt->bt_magic, ==, BT_MAGIC); in ztest_replay_write()
2237 gen = bbt->bt_gen; in ztest_replay_write()
2238 crtxg = bbt->bt_crtxg; in ztest_replay_write()
2239 lrtxg = lr->lr_common.lrc_txg; in ztest_replay_write()
2243 dmu_tx_hold_write(tx, lr->lr_foid, offset, length); in ztest_replay_write()
2255 ztest_object_unlock(zd, lr->lr_foid); in ztest_replay_write()
2261 * Usually, verify the old data before writing new data -- in ztest_replay_write()
2279 VERIFY(dmu_read(os, lr->lr_foid, offset, in ztest_replay_write()
2282 ztest_bt_verify(&rbt, os, lr->lr_foid, 0, in ztest_replay_write()
2290 * open-context data, which may be different than the data in ztest_replay_write()
2293 if (zd->zd_zilog->zl_replay) { in ztest_replay_write()
2294 ztest_bt_verify(bt, os, lr->lr_foid, 0, offset, in ztest_replay_write()
2295 MAX(gen, bt->bt_gen), MAX(txg, lrtxg), in ztest_replay_write()
2296 bt->bt_crtxg); in ztest_replay_write()
2303 ztest_bt_generate(bt, os, lr->lr_foid, 0, offset, gen, txg, in ztest_replay_write()
2308 dmu_write(os, lr->lr_foid, offset, length, data, tx); in ztest_replay_write()
2310 memcpy(abuf->b_data, data, length); in ztest_replay_write()
2321 ztest_object_unlock(zd, lr->lr_foid); in ztest_replay_write()
2331 objset_t *os = zd->zd_os; in ztest_replay_truncate()
2339 ztest_object_lock(zd, lr->lr_foid, ZTRL_READER); in ztest_replay_truncate()
2340 rl = ztest_range_lock(zd, lr->lr_foid, lr->lr_offset, lr->lr_length, in ztest_replay_truncate()
2345 dmu_tx_hold_free(tx, lr->lr_foid, lr->lr_offset, lr->lr_length); in ztest_replay_truncate()
2350 ztest_object_unlock(zd, lr->lr_foid); in ztest_replay_truncate()
2354 VERIFY0(dmu_free_range(os, lr->lr_foid, lr->lr_offset, in ztest_replay_truncate()
2355 lr->lr_length, tx)); in ztest_replay_truncate()
2362 ztest_object_unlock(zd, lr->lr_foid); in ztest_replay_truncate()
2372 objset_t *os = zd->zd_os; in ztest_replay_setattr()
2381 ztest_object_lock(zd, lr->lr_foid, ZTRL_WRITER); in ztest_replay_setattr()
2383 VERIFY0(dmu_bonus_hold(os, lr->lr_foid, FTAG, &db)); in ztest_replay_setattr()
2386 dmu_tx_hold_bonus(tx, lr->lr_foid); in ztest_replay_setattr()
2391 ztest_object_unlock(zd, lr->lr_foid); in ztest_replay_setattr()
2396 ASSERT3U(bbt->bt_magic, ==, BT_MAGIC); in ztest_replay_setattr()
2397 crtxg = bbt->bt_crtxg; in ztest_replay_setattr()
2398 lrtxg = lr->lr_common.lrc_txg; in ztest_replay_setattr()
2399 dnodesize = bbt->bt_dnodesize; in ztest_replay_setattr()
2401 if (zd->zd_zilog->zl_replay) { in ztest_replay_setattr()
2402 ASSERT3U(lr->lr_size, !=, 0); in ztest_replay_setattr()
2403 ASSERT3U(lr->lr_mode, !=, 0); in ztest_replay_setattr()
2409 lr->lr_size = (ztest_random(db->db_size / sizeof (*bbt)) + 1) * in ztest_replay_setattr()
2411 lr->lr_mode = bbt->bt_gen + 1; in ztest_replay_setattr()
2418 ztest_bt_verify(bbt, os, lr->lr_foid, dnodesize, -1ULL, lr->lr_mode, in ztest_replay_setattr()
2423 ASSERT3U(lr->lr_size, >=, sizeof (*bbt)); in ztest_replay_setattr()
2424 ASSERT3U(lr->lr_size, <=, db->db_size); in ztest_replay_setattr()
2425 VERIFY0(dmu_set_bonus(db, lr->lr_size, tx)); in ztest_replay_setattr()
2428 ztest_bt_generate(bbt, os, lr->lr_foid, dnodesize, -1ULL, lr->lr_mode, in ztest_replay_setattr()
2430 ztest_fill_unused_bonus(db, bbt, lr->lr_foid, os, bbt->bt_gen); in ztest_replay_setattr()
2437 ztest_object_unlock(zd, lr->lr_foid); in ztest_replay_setattr()
2476 ztest_ds_t *zd = zgd->zgd_private; in ztest_get_done()
2477 uint64_t object = ((rl_t *)zgd->zgd_lr)->rl_object; in ztest_get_done()
2479 if (zgd->zgd_db) in ztest_get_done()
2480 dmu_buf_rele(zgd->zgd_db, zgd); in ztest_get_done()
2482 ztest_range_unlock((rl_t *)zgd->zgd_lr); in ztest_get_done()
2494 objset_t *os = zd->zd_os; in ztest_get_data()
2495 uint64_t object = lr->lr_foid; in ztest_get_data()
2496 uint64_t offset = lr->lr_offset; in ztest_get_data()
2497 uint64_t size = lr->lr_length; in ztest_get_data()
2498 uint64_t txg = lr->lr_common.lrc_txg; in ztest_get_data()
2515 crtxg = ztest_bt_bonus(db)->bt_crtxg; in ztest_get_data()
2528 zgd->zgd_lwb = lwb; in ztest_get_data()
2529 zgd->zgd_private = zd; in ztest_get_data()
2532 zgd->zgd_lr = (struct zfs_locked_range *)ztest_range_lock(zd, in ztest_get_data()
2548 zgd->zgd_lr = (struct zfs_locked_range *)ztest_range_lock(zd, in ztest_get_data()
2554 blkptr_t *bp = &lr->lr_blkptr; in ztest_get_data()
2556 zgd->zgd_db = db; in ztest_get_data()
2557 zgd->zgd_bp = bp; in ztest_get_data()
2559 ASSERT3U(db->db_offset, ==, offset); in ztest_get_data()
2560 ASSERT3U(db->db_size, ==, size); in ztest_get_data()
2562 error = dmu_sync(zio, lr->lr_common.lrc_txg, in ztest_get_data()
2607 ASSERT(MUTEX_HELD(&zd->zd_dirobj_lock)); in ztest_lookup()
2610 od->od_object = 0; in ztest_lookup()
2611 error = zap_lookup(zd->zd_os, od->od_dir, od->od_name, in ztest_lookup()
2612 sizeof (uint64_t), 1, &od->od_object); in ztest_lookup()
2615 ASSERT0(od->od_object); in ztest_lookup()
2622 ASSERT3U(od->od_object, !=, 0); in ztest_lookup()
2625 ztest_object_lock(zd, od->od_object, ZTRL_READER); in ztest_lookup()
2626 VERIFY0(dmu_bonus_hold(zd->zd_os, od->od_object, in ztest_lookup()
2630 ASSERT3U(bbt->bt_magic, ==, BT_MAGIC); in ztest_lookup()
2631 od->od_type = doi.doi_type; in ztest_lookup()
2632 od->od_blocksize = doi.doi_data_block_size; in ztest_lookup()
2633 od->od_gen = bbt->bt_gen; in ztest_lookup()
2635 ztest_object_unlock(zd, od->od_object); in ztest_lookup()
2648 ASSERT(MUTEX_HELD(&zd->zd_dirobj_lock)); in ztest_create()
2652 od->od_object = 0; in ztest_create()
2657 lr_create_t *lrc = ztest_lr_alloc(sizeof (*lrc), od->od_name); in ztest_create()
2658 _lr_create_t *lr = &lrc->lr_create; in ztest_create()
2660 lr->lr_doid = od->od_dir; in ztest_create()
2661 lr->lr_foid = 0; /* 0 to allocate, > 0 to claim */ in ztest_create()
2662 lr->lrz_type = od->od_crtype; in ztest_create()
2663 lr->lrz_blocksize = od->od_crblocksize; in ztest_create()
2664 lr->lrz_ibshift = ztest_random_ibshift(); in ztest_create()
2665 lr->lrz_bonustype = DMU_OT_UINT64_OTHER; in ztest_create()
2666 lr->lrz_dnodesize = od->od_crdnodesize; in ztest_create()
2667 lr->lr_gen = od->od_crgen; in ztest_create()
2668 lr->lr_crtime[0] = time(NULL); in ztest_create()
2672 od->od_object = 0; in ztest_create()
2675 od->od_object = lr->lr_foid; in ztest_create()
2676 od->od_type = od->od_crtype; in ztest_create()
2677 od->od_blocksize = od->od_crblocksize; in ztest_create()
2678 od->od_gen = od->od_crgen; in ztest_create()
2679 ASSERT3U(od->od_object, !=, 0); in ztest_create()
2682 ztest_lr_free(lr, sizeof (*lr), od->od_name); in ztest_create()
2695 ASSERT(MUTEX_HELD(&zd->zd_dirobj_lock)); in ztest_remove()
2697 od += count - 1; in ztest_remove()
2699 for (i = count - 1; i >= 0; i--, od--) { in ztest_remove()
2708 if (od->od_object == 0) in ztest_remove()
2711 lr_remove_t *lr = ztest_lr_alloc(sizeof (*lr), od->od_name); in ztest_remove()
2713 lr->lr_doid = od->od_dir; in ztest_remove()
2719 od->od_object = 0; in ztest_remove()
2721 ztest_lr_free(lr, sizeof (*lr), od->od_name); in ztest_remove()
2736 lr->lr_foid = object; in ztest_write()
2737 lr->lr_offset = offset; in ztest_write()
2738 lr->lr_length = size; in ztest_write()
2739 lr->lr_blkoff = 0; in ztest_write()
2740 BP_ZERO(&lr->lr_blkptr); in ztest_write()
2742 memcpy(&lr->lr_data[0], data, size); in ztest_write()
2759 lr->lr_foid = object; in ztest_truncate()
2760 lr->lr_offset = offset; in ztest_truncate()
2761 lr->lr_length = size; in ztest_truncate()
2778 lr->lr_foid = object; in ztest_setattr()
2779 lr->lr_size = 0; in ztest_setattr()
2780 lr->lr_mode = 0; in ztest_setattr()
2792 objset_t *os = zd->zd_os; in ztest_prealloc()
2837 VERIFY0(dmu_object_info(zd->zd_os, object, &doi)); in ztest_io()
2848 (void) pthread_rwlock_rdlock(&zd->zd_zilog_lock); in ztest_io()
2853 ztest_bt_generate(&wbt, zd->zd_os, object, doi.doi_dnodesize, in ztest_io()
2864 * when using fletcher2-verify for deduplication. in ztest_io()
2889 err = ztest_dsl_prop_set_uint64(zd->zd_name, in ztest_io()
2893 err = ztest_dsl_prop_set_uint64(zd->zd_name, in ztest_io()
2900 VERIFY0(dmu_read(zd->zd_os, object, offset, blocksize, data, in ztest_io()
2907 (void) pthread_rwlock_unlock(&zd->zd_zilog_lock); in ztest_io()
2920 od->od_dir = ZTEST_DIROBJ; in ztest_od_init()
2921 od->od_object = 0; in ztest_od_init()
2923 od->od_crtype = type; in ztest_od_init()
2924 od->od_crblocksize = blocksize ? blocksize : ztest_random_blocksize(); in ztest_od_init()
2925 od->od_crdnodesize = dnodesize ? dnodesize : ztest_random_dnodesize(); in ztest_od_init()
2926 od->od_crgen = gen; in ztest_od_init()
2928 od->od_type = DMU_OT_NONE; in ztest_od_init()
2929 od->od_blocksize = 0; in ztest_od_init()
2930 od->od_gen = 0; in ztest_od_init()
2932 (void) snprintf(od->od_name, sizeof (od->od_name), in ztest_od_init()
2949 mutex_enter(&zd->zd_dirobj_lock); in ztest_object_init()
2953 rv = -1; in ztest_object_init()
2954 zd->zd_od = od; in ztest_object_init()
2955 mutex_exit(&zd->zd_dirobj_lock); in ztest_object_init()
2964 zilog_t *zilog = zd->zd_zilog; in ztest_zil_commit()
2966 (void) pthread_rwlock_rdlock(&zd->zd_zilog_lock); in ztest_zil_commit()
2975 mutex_enter(&zilog->zl_lock); in ztest_zil_commit()
2976 ASSERT3P(zd->zd_shared, !=, NULL); in ztest_zil_commit()
2977 ASSERT3U(zd->zd_shared->zd_seq, <=, zilog->zl_commit_lr_seq); in ztest_zil_commit()
2978 zd->zd_shared->zd_seq = zilog->zl_commit_lr_seq; in ztest_zil_commit()
2979 mutex_exit(&zilog->zl_lock); in ztest_zil_commit()
2981 (void) pthread_rwlock_unlock(&zd->zd_zilog_lock); in ztest_zil_commit()
2993 objset_t *os = zd->zd_os; in ztest_zil_remount()
3004 * updating the zil (i.e. adding in-memory log records) and the in ztest_zil_remount()
3007 mutex_enter(&zd->zd_dirobj_lock); in ztest_zil_remount()
3008 (void) pthread_rwlock_wrlock(&zd->zd_zilog_lock); in ztest_zil_remount()
3011 zil_close(zd->zd_zilog); in ztest_zil_remount()
3014 VERIFY3P(zil_open(os, ztest_get_data, NULL), ==, zd->zd_zilog); in ztest_zil_remount()
3017 (void) pthread_rwlock_unlock(&zd->zd_zilog_lock); in ztest_zil_remount()
3018 mutex_exit(&zd->zd_dirobj_lock); in ztest_zil_remount()
3034 if (zo->zo_mmp_test) in ztest_spa_create_destroy()
3060 spa_create(zo->zo_pool, nvroot, NULL, NULL, NULL)); in ztest_spa_create_destroy()
3074 VERIFY0(spa_open(zo->zo_pool, &spa, FTAG)); in ztest_spa_create_destroy()
3075 int error = spa_destroy(zo->zo_pool); in ztest_spa_create_destroy()
3078 spa->spa_name, error); in ztest_spa_create_destroy()
3086 * Start and then stop the MMP threads to ensure the startup and shutdown code
3087 * works properly. Actual protection and property-related code tested via ZTS.
3096 if (zo->zo_mmp_test) in ztest_mmp_enable_disable()
3100 * Since enabling MMP involves setting a property, it could not be done in ztest_mmp_enable_disable()
3107 mutex_enter(&spa->spa_props_lock); in ztest_mmp_enable_disable()
3112 spa->spa_multihost = B_TRUE; in ztest_mmp_enable_disable()
3116 mutex_exit(&spa->spa_props_lock); in ztest_mmp_enable_disable()
3124 mutex_enter(&spa->spa_props_lock); in ztest_mmp_enable_disable()
3128 spa->spa_multihost = B_FALSE; in ztest_mmp_enable_disable()
3131 mutex_exit(&spa->spa_props_lock); in ztest_mmp_enable_disable()
3144 raidvd = ztest_spa->spa_root_vdev->vdev_child[0]; in ztest_get_raidz_children()
3146 ASSERT(raidvd->vdev_ops == &vdev_raidz_ops); in ztest_get_raidz_children()
3148 return (raidvd->vdev_children); in ztest_get_raidz_children()
3228 VERIFY3U(spa_version(spa), ==, fnvlist_lookup_uint64(spa->spa_config, in ztest_spa_upgrade()
3241 int error = spa_checkpoint(spa->spa_name); in ztest_spa_checkpoint()
3254 fatal(B_FALSE, "spa_checkpoint(%s) = %d", spa->spa_name, error); in ztest_spa_checkpoint()
3263 int error = spa_checkpoint_discard(spa->spa_name); in ztest_spa_discard_checkpoint()
3272 spa->spa_name, error); in ztest_spa_discard_checkpoint()
3299 if (vd->vdev_path != NULL && strcmp(path, vd->vdev_path) == 0) in vdev_lookup_by_path()
3302 for (c = 0; c < vd->vdev_children; c++) in vdev_lookup_by_path()
3303 if ((mvd = vdev_lookup_by_path(vd->vdev_child[c], path)) != in vdev_lookup_by_path()
3313 vdev_t *rvd = spa->spa_root_vdev; in spa_num_top_vdevs()
3315 return (rvd->vdev_children); in spa_num_top_vdevs()
3339 leaves = MAX(zs->zs_mirrors + zs->zs_splits, 1) * raidz_children; in ztest_vdev_add_remove()
3343 ztest_shared->zs_vdev_next_leaf = spa_num_top_vdevs(spa) * leaves; in ztest_vdev_add_remove()
3354 mg = spa_log_class(spa)->mc_allocator[0].mca_rotor; in ztest_vdev_add_remove()
3355 while (!mg->mg_vd->vdev_islog) in ztest_vdev_add_remove()
3356 mg = mg->mg_next; in ztest_vdev_add_remove()
3358 guid = mg->mg_vd->vdev_guid; in ztest_vdev_add_remove()
3393 "log" : NULL, raidz_children, zs->zs_mirrors, in ztest_vdev_add_remove()
3438 if (zs->zs_mirrors < 2) { in ztest_vdev_class_add()
3450 leaves = MAX(zs->zs_mirrors + zs->zs_splits, 1) * raidz_children; in ztest_vdev_class_add()
3453 ztest_shared->zs_vdev_next_leaf = spa_num_top_vdevs(spa) * leaves; in ztest_vdev_class_add()
3457 class, raidz_children, zs->zs_mirrors, 1); in ztest_vdev_class_add()
3471 spa_special_class(spa)->mc_groups == 1 && ztest_random(2) == 0) { in ztest_vdev_class_add()
3474 error = ztest_dsl_prop_set_uint64(zd->zd_name, in ztest_vdev_class_add()
3489 class, (int)mc->mc_groups); in ztest_vdev_class_add()
3502 vdev_t *rvd = spa->spa_root_vdev; in ztest_vdev_aux_add_remove()
3515 sav = &spa->spa_spares; in ztest_vdev_aux_add_remove()
3518 sav = &spa->spa_l2cache; in ztest_vdev_aux_add_remove()
3526 if (sav->sav_count != 0 && ztest_random(4) == 0) { in ztest_vdev_aux_add_remove()
3530 vdev_t *svd = sav->sav_vdevs[ztest_random(sav->sav_count)]; in ztest_vdev_aux_add_remove()
3533 if (strstr(svd->vdev_path, VDEV_TYPE_DRAID) != NULL) in ztest_vdev_aux_add_remove()
3536 guid = svd->vdev_guid; in ztest_vdev_aux_add_remove()
3541 zs->zs_vdev_aux = 0; in ztest_vdev_aux_add_remove()
3546 zs->zs_vdev_aux); in ztest_vdev_aux_add_remove()
3547 for (c = 0; c < sav->sav_count; c++) in ztest_vdev_aux_add_remove()
3548 if (strcmp(sav->sav_vdevs[c]->vdev_path, in ztest_vdev_aux_add_remove()
3551 if (c == sav->sav_count && in ztest_vdev_aux_add_remove()
3554 zs->zs_vdev_aux++; in ztest_vdev_aux_add_remove()
3614 vdev_t *rvd = spa->spa_root_vdev; in ztest_split_pool()
3625 if (zs->zs_mirrors < 3 || ztest_opts.zo_raid_children > 1) { in ztest_split_pool()
3636 mutex_enter(&spa->spa_props_lock); in ztest_split_pool()
3637 tree = fnvlist_lookup_nvlist(spa->spa_config, ZPOOL_CONFIG_VDEV_TREE); in ztest_split_pool()
3638 mutex_exit(&spa->spa_props_lock); in ztest_split_pool()
3643 schild = umem_alloc(rvd->vdev_children * sizeof (nvlist_t *), in ztest_split_pool()
3646 vdev_t *tvd = rvd->vdev_child[c]; in ztest_split_pool()
3650 if (tvd->vdev_islog || tvd->vdev_ops == &vdev_hole_ops) { in ztest_split_pool()
3678 umem_free(schild, rvd->vdev_children * sizeof (nvlist_t *)); in ztest_split_pool()
3690 (void) printf("successful split - results:\n"); in ztest_split_pool()
3695 ++zs->zs_splits; in ztest_split_pool()
3696 --zs->zs_mirrors; in ztest_split_pool()
3710 spa_aux_vdev_t *sav = &spa->spa_spares; in ztest_vdev_attach_detach()
3711 vdev_t *rvd = spa->spa_root_vdev; in ztest_vdev_attach_detach()
3737 leaves = MAX(zs->zs_mirrors, 1) * raidz_children; in ztest_vdev_attach_detach()
3767 * Pick a random top-level vdev. in ztest_vdev_attach_detach()
3779 oldvd = rvd->vdev_child[top]; in ztest_vdev_attach_detach()
3782 if (zs->zs_mirrors >= 1) { in ztest_vdev_attach_detach()
3783 ASSERT3P(oldvd->vdev_ops, ==, &vdev_mirror_ops); in ztest_vdev_attach_detach()
3784 ASSERT3U(oldvd->vdev_children, >=, zs->zs_mirrors); in ztest_vdev_attach_detach()
3785 oldvd = oldvd->vdev_child[leaf / raidz_children]; in ztest_vdev_attach_detach()
3790 if (strcmp(oldvd->vdev_ops->vdev_op_type, "raidz") == 0) in ztest_vdev_attach_detach()
3791 ASSERT3P(oldvd->vdev_ops, ==, &vdev_raidz_ops); in ztest_vdev_attach_detach()
3793 ASSERT3P(oldvd->vdev_ops, ==, &vdev_draid_ops); in ztest_vdev_attach_detach()
3794 oldvd = oldvd->vdev_child[leaf % raidz_children]; in ztest_vdev_attach_detach()
3799 * mirror vdev -- in which case, pick a random child. in ztest_vdev_attach_detach()
3801 while (oldvd->vdev_children != 0) { in ztest_vdev_attach_detach()
3803 ASSERT3U(oldvd->vdev_children, >=, 2); in ztest_vdev_attach_detach()
3804 oldvd = oldvd->vdev_child[ztest_random(oldvd->vdev_children)]; in ztest_vdev_attach_detach()
3807 oldguid = oldvd->vdev_guid; in ztest_vdev_attach_detach()
3809 oldvd_is_log = oldvd->vdev_top->vdev_islog; in ztest_vdev_attach_detach()
3811 oldvd->vdev_top->vdev_alloc_bias == VDEV_BIAS_SPECIAL || in ztest_vdev_attach_detach()
3812 oldvd->vdev_top->vdev_alloc_bias == VDEV_BIAS_DEDUP; in ztest_vdev_attach_detach()
3813 (void) strlcpy(oldpath, oldvd->vdev_path, MAXPATHLEN); in ztest_vdev_attach_detach()
3814 pvd = oldvd->vdev_parent; in ztest_vdev_attach_detach()
3815 pguid = pvd->vdev_guid; in ztest_vdev_attach_detach()
3842 if (sav->sav_count != 0 && ztest_random(3) == 0) { in ztest_vdev_attach_detach()
3843 newvd = sav->sav_vdevs[ztest_random(sav->sav_count)]; in ztest_vdev_attach_detach()
3846 if (newvd->vdev_ops == &vdev_draid_spare_ops) in ztest_vdev_attach_detach()
3849 (void) strlcpy(newpath, newvd->vdev_path, MAXPATHLEN); in ztest_vdev_attach_detach()
3855 newpath[strlen(newpath) - 1] = 'b'; in ztest_vdev_attach_detach()
3877 * unless it's a replace; in that case any non-replacing parent is OK. in ztest_vdev_attach_detach()
3886 if (pvd->vdev_ops != &vdev_mirror_ops && in ztest_vdev_attach_detach()
3887 pvd->vdev_ops != &vdev_root_ops && (!replacing || in ztest_vdev_attach_detach()
3888 pvd->vdev_ops == &vdev_replacing_ops || in ztest_vdev_attach_detach()
3889 pvd->vdev_ops == &vdev_spare_ops)) in ztest_vdev_attach_detach()
3900 else if (ashift > oldvd->vdev_top->vdev_ashift) in ztest_vdev_attach_detach()
3919 if (pvd->vdev_ops == &vdev_mirror_ops || in ztest_vdev_attach_detach()
3920 pvd->vdev_ops == &vdev_root_ops) { in ztest_vdev_attach_detach()
3973 if (ztest_scratch_state->zs_raidz_scratch_verify_pause == 0) in raidz_scratch_verify()
3981 spa->spa_import_flags |= ZFS_IMPORT_SKIP_MMP; in raidz_scratch_verify()
3986 ASSERT3U(RRSS_GET_OFFSET(&spa->spa_uberblock), !=, UINT64_MAX); in raidz_scratch_verify()
3992 vre = spa->spa_raidz_expand; in raidz_scratch_verify()
3996 raidvd = vdev_lookup_top(spa, vre->vre_vdev_id); in raidz_scratch_verify()
3997 offset = RRSS_GET_OFFSET(&spa->spa_uberblock); in raidz_scratch_verify()
3998 state = RRSS_GET_STATE(&spa->spa_uberblock); in raidz_scratch_verify()
3999 write_size = P2ALIGN_TYPED(VDEV_BOOT_SIZE, 1 << raidvd->vdev_ashift, in raidz_scratch_verify()
4001 logical_size = write_size * raidvd->vdev_children; in raidz_scratch_verify()
4045 ztest_scratch_state->zs_raidz_scratch_verify_pause = 0; in raidz_scratch_verify()
4057 for (int t = 100; t > 0; t -= 1) { in ztest_scratch_thread()
4088 /* Only allow attach when raid-kind = 'eraidz' */ in ztest_vdev_raidz_attach()
4106 ASSERT(pvd->vdev_ops == &vdev_raidz_ops); in ztest_vdev_raidz_attach()
4112 newvd = pvd->vdev_child[ztest_random(pvd->vdev_children)]; in ztest_vdev_raidz_attach()
4119 leaves = MAX(zs->zs_mirrors + zs->zs_splits, 1) * raidz_children; in ztest_vdev_raidz_attach()
4120 zs->zs_vdev_next_leaf = spa_num_top_vdevs(spa) * leaves; in ztest_vdev_raidz_attach()
4122 if (spa->spa_raidz_expand) in ztest_vdev_raidz_attach()
4131 ztest_opts.zo_dir, ztest_opts.zo_pool, zs->zs_vdev_next_leaf); in ztest_vdev_raidz_attach()
4152 error = spa_vdev_attach(spa, pvd->vdev_guid, root, B_FALSE, B_FALSE); in ztest_vdev_raidz_attach()
4200 * Remove a random top-level vdev and wait for removal to finish. in ztest_device_removal()
4204 guid = vd->vdev_guid; in ztest_device_removal()
4213 * spa->spa_vdev_removal is created in a sync task that in ztest_device_removal()
4221 while (spa->spa_removing_phys.sr_state == DSS_SCANNING) in ztest_device_removal()
4251 spa_t *spa __maybe_unused = vd->vdev_spa; in grow_vdev()
4257 ASSERT(vd->vdev_ops->vdev_op_leaf); in grow_vdev()
4259 if ((fd = open(vd->vdev_path, O_RDWR)) == -1) in grow_vdev()
4267 vd->vdev_path, (ulong_t)fsize, (ulong_t)*newsize); in grow_vdev()
4280 spa_t *spa = vd->vdev_spa; in online_vdev()
4281 vdev_t *tvd = vd->vdev_top; in online_vdev()
4282 uint64_t guid = vd->vdev_guid; in online_vdev()
4283 uint64_t generation = spa->spa_config_generation + 1; in online_vdev()
4288 ASSERT(vd->vdev_ops->vdev_op_leaf); in online_vdev()
4315 if (generation != spa->spa_config_generation) { in online_vdev()
4321 tvd->vdev_state, in online_vdev()
4323 spa->spa_config_generation); in online_vdev()
4333 * children or we receive a non-NULL return from the callback.
4342 if (vd->vdev_ops->vdev_op_leaf) { in vdev_walk_tree()
4349 for (c = 0; c < vd->vdev_children; c++) { in vdev_walk_tree()
4350 vdev_t *cvd = vd->vdev_child[c]; in vdev_walk_tree()
4394 if (spa->spa_raidz_expand) { in ztest_vdev_LUN_growth()
4403 tvd = spa->spa_root_vdev->vdev_child[top]; in ztest_vdev_LUN_growth()
4404 mg = tvd->vdev_mg; in ztest_vdev_LUN_growth()
4405 mc = mg->mg_class; in ztest_vdev_LUN_growth()
4406 old_ms_count = tvd->vdev_ms_count; in ztest_vdev_LUN_growth()
4411 * our top-level device. in ztest_vdev_LUN_growth()
4415 ASSERT(vd->vdev_ops->vdev_op_leaf); in ztest_vdev_LUN_growth()
4417 psize = vd->vdev_psize; in ztest_vdev_LUN_growth()
4423 if (tvd->vdev_state != VDEV_STATE_HEALTHY || in ztest_vdev_LUN_growth()
4436 vd->vdev_path, (ulong_t)psize, (ulong_t)newsize); in ztest_vdev_LUN_growth()
4446 tvd->vdev_state != VDEV_STATE_HEALTHY) { in ztest_vdev_LUN_growth()
4466 mutex_enter(&spa->spa_async_lock); in ztest_vdev_LUN_growth()
4467 done = (spa->spa_async_thread == NULL && !spa->spa_async_tasks); in ztest_vdev_LUN_growth()
4468 mutex_exit(&spa->spa_async_lock); in ztest_vdev_LUN_growth()
4477 tvd = spa->spa_root_vdev->vdev_child[top]; in ztest_vdev_LUN_growth()
4478 new_ms_count = tvd->vdev_ms_count; in ztest_vdev_LUN_growth()
4481 if (tvd->vdev_mg != mg || mg->mg_class != mc) { in ztest_vdev_LUN_growth()
4516 spa->spa_name, oldnumbuf, newnumbuf); in ztest_vdev_LUN_growth()
4548 * using a random cipher suite and a hard-coded in ztest_dataset_create()
4813 (void) ztest_snapshot_destroy(zd->zd_name, id); in ztest_dmu_snapshot_create_destroy()
4814 (void) ztest_snapshot_create(zd->zd_name, id); in ztest_dmu_snapshot_create_destroy()
4819 * Cleanup non-standard snapshots and clones.
4886 char *osname = zd->zd_name; in ztest_dsl_dataset_promote_busy()
5009 zd->zd_od = NULL; in ztest_dmu_object_alloc_free()
5028 objset_t *os = zd->zd_os; in ztest_dmu_object_next_chunk()
5036 mutex_enter(&os->os_obj_lock); in ztest_dmu_object_next_chunk()
5037 object = ztest_random(os->os_obj_next_chunk); in ztest_dmu_object_next_chunk()
5038 os->os_obj_next_chunk = P2ALIGN_TYPED(object, dnodes_per_chunk, in ztest_dmu_object_next_chunk()
5040 mutex_exit(&os->os_obj_lock); in ztest_dmu_object_next_chunk()
5055 objset_t *os = zd->zd_os; in ztest_dmu_read_write()
5124 s = 1 + ztest_random(2 * width - 1); in ztest_dmu_read_write()
5132 s = 1 + ztest_random(width - 1); in ztest_dmu_read_write()
5208 bigT = (bufwad_t *)((char *)bigH + chunksize) - 1; in ztest_dmu_read_write()
5210 ASSERT3U((uintptr_t)bigH - (uintptr_t)bigbuf, <, bigsize); in ztest_dmu_read_write()
5211 ASSERT3U((uintptr_t)bigT - (uintptr_t)bigbuf, <, bigsize); in ztest_dmu_read_write()
5213 if (pack->bw_txg > txg) in ztest_dmu_read_write()
5216 pack->bw_txg, txg); in ztest_dmu_read_write()
5218 if (pack->bw_data != 0 && pack->bw_index != n + i) in ztest_dmu_read_write()
5221 pack->bw_index, n, i); in ztest_dmu_read_write()
5234 pack->bw_index = n + i; in ztest_dmu_read_write()
5235 pack->bw_txg = txg; in ztest_dmu_read_write()
5236 pack->bw_data = 1 + ztest_random(-2ULL); in ztest_dmu_read_write()
5311 bigT = (bufwad_t *)((char *)bigH + chunksize) - 1; in compare_and_update_pbbufs()
5313 ASSERT3U((uintptr_t)bigH - (uintptr_t)bigbuf, <, bigsize); in compare_and_update_pbbufs()
5314 ASSERT3U((uintptr_t)bigT - (uintptr_t)bigbuf, <, bigsize); in compare_and_update_pbbufs()
5316 if (pack->bw_txg > txg) in compare_and_update_pbbufs()
5319 pack->bw_txg, txg); in compare_and_update_pbbufs()
5321 if (pack->bw_data != 0 && pack->bw_index != n + i) in compare_and_update_pbbufs()
5324 pack->bw_index, n, i); in compare_and_update_pbbufs()
5334 pack->bw_index = n + i; in compare_and_update_pbbufs()
5335 pack->bw_txg = txg; in compare_and_update_pbbufs()
5336 pack->bw_data = 1 + ztest_random(-2ULL); in compare_and_update_pbbufs()
5349 objset_t *os = zd->zd_os; in ztest_dmu_read_write_zcopy()
5421 s = 1 + ztest_random(width - 1); in ztest_dmu_read_write_zcopy()
5525 memcpy(bigbuf_arcbufs[j]->b_data, in ztest_dmu_read_write_zcopy()
5526 (caddr_t)bigbuf + (off - bigoff), in ztest_dmu_read_write_zcopy()
5529 memcpy(bigbuf_arcbufs[2 * j]->b_data, in ztest_dmu_read_write_zcopy()
5530 (caddr_t)bigbuf + (off - bigoff), in ztest_dmu_read_write_zcopy()
5532 memcpy(bigbuf_arcbufs[2 * j + 1]->b_data, in ztest_dmu_read_write_zcopy()
5533 (caddr_t)bigbuf + (off - bigoff) + in ztest_dmu_read_write_zcopy()
5602 * to verify that parallel writes to an object -- even to the in ztest_dmu_write_parallel()
5603 * same blocks within the object -- doesn't cause any trouble. in ztest_dmu_write_parallel()
5611 ztest_io(zd, od->od_object, offset); in ztest_dmu_write_parallel()
5636 if (ztest_truncate(zd, od->od_object, offset, count * blocksize) != 0) { in ztest_dmu_prealloc()
5641 ztest_prealloc(zd, od->od_object, offset, count * blocksize); in ztest_dmu_prealloc()
5647 if (ztest_write(zd, od->od_object, randoff, blocksize, in ztest_dmu_prealloc()
5651 ztest_io(zd, od->od_object, randoff); in ztest_dmu_prealloc()
5668 objset_t *os = zd->zd_os; in ztest_zap()
5687 object = od->od_object; in ztest_zap()
5813 objset_t *os = zd->zd_os; in ztest_fzap()
5823 object = od->od_object; in ztest_fzap()
5828 * 2050 entries we should see ptrtbl growth and leaf-block split. in ztest_fzap()
5835 (void) snprintf(name, sizeof (name), "fzap-%"PRIu64"-%"PRIu64"", in ztest_fzap()
5856 objset_t *os = zd->zd_os; in ztest_zap_parallel()
5873 object = od->od_object; in ztest_zap_parallel()
5881 namelen = ztest_random(sizeof (name) - 5) + 5 + 1; in ztest_zap_parallel()
5884 name[i] = '!' + ztest_random('~' - '!' + 1); in ztest_zap_parallel()
5885 for (; i < namelen - 1; i++) in ztest_zap_parallel()
5899 count = -1ULL; in ztest_zap_parallel()
5901 ASSERT3S(count, !=, -1ULL); in ztest_zap_parallel()
5988 VERIFY3S(data->zcd_expected_err, ==, error); in ztest_commit_callback()
5989 VERIFY(!data->zcd_called); in ztest_commit_callback()
5991 synced_txg = spa_last_synced_txg(data->zcd_spa); in ztest_commit_callback()
5992 if (data->zcd_txg > synced_txg) in ztest_commit_callback()
5996 data->zcd_txg, synced_txg); in ztest_commit_callback()
5998 data->zcd_called = B_TRUE; in ztest_commit_callback()
6001 ASSERT0(data->zcd_txg); in ztest_commit_callback()
6002 ASSERT(!data->zcd_added); in ztest_commit_callback()
6012 ASSERT(data->zcd_added); in ztest_commit_callback()
6013 ASSERT3U(data->zcd_txg, !=, 0); in ztest_commit_callback()
6018 if ((synced_txg - data->zcd_txg) < zc_min_txg_delay) in ztest_commit_callback()
6019 zc_min_txg_delay = synced_txg - data->zcd_txg; in ztest_commit_callback()
6037 cb_data->zcd_txg = txg; in ztest_create_cb_data()
6038 cb_data->zcd_spa = dmu_objset_spa(os); in ztest_create_cb_data()
6039 list_link_init(&cb_data->zcd_node); in ztest_create_cb_data()
6050 objset_t *os = zd->zd_os; in ztest_dmu_commit_callbacks()
6070 dmu_tx_hold_write(tx, od->od_object, 0, sizeof (uint64_t)); in ztest_dmu_commit_callbacks()
6074 error = -1; in ztest_dmu_commit_callbacks()
6081 cb_data[0]->zcd_txg = txg; in ztest_dmu_commit_callbacks()
6093 cb_data[i]->zcd_expected_err = ECANCELED; in ztest_dmu_commit_callbacks()
6094 VERIFY(!cb_data[i]->zcd_called); in ztest_dmu_commit_callbacks()
6100 VERIFY(cb_data[i]->zcd_called); in ztest_dmu_commit_callbacks()
6114 VERIFY0(dmu_read(os, od->od_object, 0, sizeof (uint64_t), in ztest_dmu_commit_callbacks()
6122 dmu_write(os, od->od_object, 0, sizeof (uint64_t), &txg, tx); in ztest_dmu_commit_callbacks()
6140 tmp_cb->zcd_txg + ZTEST_COMMIT_CB_THRESH < txg) { in ztest_dmu_commit_callbacks()
6144 tmp_cb->zcd_txg, txg); in ztest_dmu_commit_callbacks()
6156 while (tmp_cb != NULL && tmp_cb->zcd_txg > txg) in ztest_dmu_commit_callbacks()
6167 cb_data[i]->zcd_added = B_TRUE; in ztest_dmu_commit_callbacks()
6168 VERIFY(!cb_data[i]->zcd_called); in ztest_dmu_commit_callbacks()
6191 objset_t *os = zd->zd_os; in ztest_verify_dnode_bt()
6210 if (bt && bt->bt_magic == BT_MAGIC) { in ztest_verify_dnode_bt()
6212 bt->bt_offset, bt->bt_gen, bt->bt_txg, in ztest_verify_dnode_bt()
6213 bt->bt_crtxg); in ztest_verify_dnode_bt()
6214 ztest_verify_unused_bonus(db, bt, obj, os, bt->bt_gen); in ztest_verify_dnode_bt()
6236 int error = ztest_dsl_prop_set_uint64(zd->zd_name, proplist[p], in ztest_dsl_prop_get_set()
6241 int error = ztest_dsl_prop_set_uint64(zd->zd_name, ZFS_PROP_RECORDSIZE, in ztest_dsl_prop_get_set()
6292 objset_t *os = zd->zd_os; in ztest_dmu_snapshot_hold()
6411 * Inject random faults into the on-disk data.
6458 if (spa->spa_raidz_expand != NULL) in ztest_fault_inject()
6463 leaves = MAX(zs->zs_mirrors, 1) * raidz_children; in ztest_fault_inject()
6464 mirror_save = zs->zs_mirrors; in ztest_fault_inject()
6476 * Failure to do can result in non-repairable damage being injected. in ztest_fault_inject()
6490 * We need SCL_STATE here because we're going to look at vd0->vdev_tsd. in ztest_fault_inject()
6499 leaf = ztest_random(leaves) + zs->zs_splits; in ztest_fault_inject()
6502 * Generate paths to the first leaf in this top-level vdev, in ztest_fault_inject()
6509 top * leaves + zs->zs_splits); in ztest_fault_inject()
6514 vd0 = vdev_lookup_by_path(spa->spa_root_vdev, path0); in ztest_fault_inject()
6515 if (vd0 != NULL && vd0->vdev_top->vdev_islog) in ztest_fault_inject()
6519 * If the top-level vdev needs to be resilvered in ztest_fault_inject()
6524 (!vdev_resilver_needed(vd0->vdev_top, NULL, NULL) || in ztest_fault_inject()
6525 vd0->vdev_resilver_txg != 0)) { in ztest_fault_inject()
6536 vdev_file_t *vf = vd0->vdev_tsd; in ztest_fault_inject()
6539 (long long)vd0->vdev_id, (int)maxfaults); in ztest_fault_inject()
6542 (void) close(vf->vf_file->f_fd); in ztest_fault_inject()
6543 vf->vf_file->f_fd = -1; in ztest_fault_inject()
6545 vd0->vdev_cant_read = B_TRUE; in ztest_fault_inject()
6547 vd0->vdev_cant_write = B_TRUE; in ztest_fault_inject()
6549 guid0 = vd0->vdev_guid; in ztest_fault_inject()
6555 spa_aux_vdev_t *sav = &spa->spa_l2cache; in ztest_fault_inject()
6557 if (sav->sav_count == 0) { in ztest_fault_inject()
6562 vd0 = sav->sav_vdevs[ztest_random(sav->sav_count)]; in ztest_fault_inject()
6563 guid0 = vd0->vdev_guid; in ztest_fault_inject()
6564 (void) strlcpy(path0, vd0->vdev_path, MAXPATHLEN); in ztest_fault_inject()
6565 (void) strlcpy(pathrand, vd0->vdev_path, MAXPATHLEN); in ztest_fault_inject()
6615 * We have at least single-fault tolerance, so inject data corruption. in ztest_fault_inject()
6619 if (fd == -1) /* we hit a gap in the device namespace */ in ztest_fault_inject()
6624 while (--iters != 0) { in ztest_fault_inject()
6633 * Each chunk is further divided into error-injection in ztest_fault_inject()
6635 * not inject errors in those). Each error-injection in ztest_fault_inject()
6637 * Error-injection ranges are separated by clear ranges. in ztest_fault_inject()
6641 * 32M to 64M: clear range - no injection allowed in ztest_fault_inject()
6643 * 96M to 128M: clear range - no injection allowed in ztest_fault_inject()
6645 * 160M to 192M: clear range - no injection allowed in ztest_fault_inject()
6654 (ztest_random(1ULL << (bshift - 1)) & -8ULL); in ztest_fault_inject()
6679 offset + sizeof (bad) > psize - VDEV_LABEL_END_SIZE) in ztest_fault_inject()
6682 if (mirror_save != zs->zs_mirrors) { in ztest_fault_inject()
6800 zs->zs_guid = spa_guid(spa); in ztest_reguid()
6807 (void) printf("Changed guid old %"PRIu64" -> %"PRIu64"\n", in ztest_reguid()
6852 VERIFY0(blake3->setname("generic")); in ztest_blake3()
6861 VERIFY0(blake3->setname("cycle")); in ztest_blake3()
6862 while (run_count-- > 0) { in ztest_blake3()
6874 /* Test ABD - data */ in ztest_blake3()
6884 /* Test ABD - metadata */ in ztest_blake3()
6935 while (run_count-- > 0) { in ztest_fletcher()
6946 /* Test ABD - data */ in ztest_fletcher()
6955 /* Test ABD - metadata */ in ztest_fletcher()
7000 while (run_count-- > 0) { in ztest_fletcher_incr()
7010 /* sometimes add few bytes to test non-simd */ in ztest_fletcher_incr()
7015 if (inc > (size - pos)) in ztest_fletcher_incr()
7016 inc = size - pos; in ztest_fletcher_incr()
7033 * equivalent to non-incremental version in ztest_fletcher_incr()
7093 *cur++ = (char *)"-o"; in ztest_global_vars_to_zdb_args()
7112 totallen -= strlen(sep); in join_strings()
7145 * Try to use $ZDB and in-tree zdb path. If not successful, just in ztest_get_zdb_bin()
7159 strstr(bin, ".libs/ztest")[0] = '\0'; /* In-tree */ in ztest_get_zdb_bin()
7173 if (vd->vdev_children == 0) in ztest_random_concrete_vdev_leaf()
7176 vdev_t *eligible[vd->vdev_children]; in ztest_random_concrete_vdev_leaf()
7178 for (i = 0; i < vd->vdev_children; i++) { in ztest_random_concrete_vdev_leaf()
7179 vdev_t *cvd = vd->vdev_child[i]; in ztest_random_concrete_vdev_leaf()
7180 if (cvd->vdev_top->vdev_removing) in ztest_random_concrete_vdev_leaf()
7182 if (cvd->vdev_children > 0 || in ztest_random_concrete_vdev_leaf()
7183 (vdev_is_concrete(cvd) && !cvd->vdev_detached)) { in ztest_random_concrete_vdev_leaf()
7205 vdev_t *rand_vd = ztest_random_concrete_vdev_leaf(spa->spa_root_vdev); in ztest_initialize()
7217 uint64_t guid = rand_vd->vdev_guid; in ztest_initialize()
7218 char *path = strdup(rand_vd->vdev_path); in ztest_initialize()
7219 boolean_t active = rand_vd->vdev_initialize_thread != NULL; in ztest_initialize()
7277 vdev_t *rand_vd = ztest_random_concrete_vdev_leaf(spa->spa_root_vdev); in ztest_trim()
7289 uint64_t guid = rand_vd->vdev_guid; in ztest_trim()
7290 char *path = strdup(rand_vd->vdev_path); in ztest_trim()
7291 boolean_t active = rand_vd->vdev_trim_thread != NULL; in ztest_trim()
7380 "%s -bcc%s%s -G -d -Y -e -y %s -p %s %"PRIu64, in ztest_run_zdb()
7493 * Try to import it again -- should fail with EEXIST. in ztest_spa_import_export()
7498 * Try to import it under a different name -- should fail with EEXIST. in ztest_spa_import_export()
7568 delay = (zs->zs_thread_stop - zs->zs_thread_start) + in ztest_deadman_thread()
7573 * Wait for the delay timer while checking occasionally in ztest_deadman_thread()
7587 if (spa_suspended(spa) || spa->spa_root_vdev == NULL) { in ztest_deadman_thread()
7593 vdev_deadman(spa->spa_root_vdev, FTAG); in ztest_deadman_thread()
7600 overdue = zs->zs_proc_stop + MSEC2NSEC(zfs_deadman_synctime_ms); in ztest_deadman_thread()
7605 (gethrtime() - zs->zs_proc_start) / NANOSEC); in ztest_deadman_thread()
7609 (gethrtime() - zs->zs_proc_start) / NANOSEC); in ztest_deadman_thread()
7626 for (i = 0; i < zi->zi_iters; i++) in ztest_execute()
7627 zi->zi_func(zd, id); in ztest_execute()
7629 functime = gethrtime() - functime; in ztest_execute()
7631 atomic_add_64(&zc->zc_count, 1); in ztest_execute()
7632 atomic_add_64(&zc->zc_time, functime); in ztest_execute()
7636 (double)functime / NANOSEC, zi->zi_funcname); in ztest_execute()
7662 ztest_ds_t *zd = &ztest_ds[info->rzx_id % ztest_opts.zo_datasets]; in ztest_rzx_thread()
7663 spa_t *spa = info->rzx_spa; in ztest_rzx_thread()
7671 ztest_od_init(od + b, info->rzx_id, FTAG, b, in ztest_rzx_thread()
7679 for (uint64_t offset = 0, written = 0; written < info->rzx_amount; in ztest_rzx_thread()
7680 offset += info->rzx_bufsize) { in ztest_rzx_thread()
7682 for (int i = 0; i < batchsize && written < info->rzx_amount; in ztest_rzx_thread()
7684 (void) pthread_rwlock_rdlock(&zd->zd_zilog_lock); in ztest_rzx_thread()
7686 info->rzx_bufsize, info->rzx_buffer); in ztest_rzx_thread()
7687 (void) pthread_rwlock_unlock(&zd->zd_zilog_lock); in ztest_rzx_thread()
7688 written += info->rzx_bufsize; in ztest_rzx_thread()
7693 info->rzx_alloc_max) { in ztest_rzx_thread()
7699 mutex_enter(&zd->zd_dirobj_lock); in ztest_rzx_thread()
7701 mutex_exit(&zd->zd_dirobj_lock); in ztest_rzx_thread()
7719 while ((now = gethrtime()) < zs->zs_thread_stop) { in ztest_thread()
7723 if (now > zs->zs_thread_kill && in ztest_thread()
7731 if (zs->zs_enospc_count > 10) in ztest_thread()
7740 call_next = zc->zc_next; in ztest_thread()
7743 atomic_cas_64(&zc->zc_next, call_next, call_next + in ztest_thread()
7744 ztest_random(2 * zi->zi_interval[0] + 1)) == call_next) { in ztest_thread()
7770 * Cleanup any non-standard clones and snapshots. In general, in ztest_dataset_destroy()
7794 * when the open-context and syncing-context values agree. in ztest_dataset_dirobj_verify()
7795 * That's because zap_count() returns the open-context value, in ztest_dataset_dirobj_verify()
7798 VERIFY0(zap_count(zd->zd_os, ZTEST_DIROBJ, &dirobjs)); in ztest_dataset_dirobj_verify()
7799 dmu_objset_space(zd->zd_os, &scratch, &scratch, &usedobjs, &scratch); in ztest_dataset_dirobj_verify()
7807 uint64_t committed_seq = ZTEST_GET_SHARED_DS(d)->zd_seq; in ztest_dataset_open()
7831 zilog = zd->zd_zilog; in ztest_dataset_open()
7833 if (zilog->zl_header->zh_claim_lr_seq != 0 && in ztest_dataset_open()
7834 zilog->zl_header->zh_claim_lr_seq < committed_seq) in ztest_dataset_open()
7837 zilog->zl_header->zh_claim_lr_seq, committed_seq); in ztest_dataset_open()
7848 zd->zd_name, in ztest_dataset_open()
7849 zilog->zl_parse_blk_count, in ztest_dataset_open()
7850 zilog->zl_parse_lr_count, in ztest_dataset_open()
7851 zilog->zl_replaying_seq); in ztest_dataset_open()
7855 if (zilog->zl_replaying_seq != 0 && in ztest_dataset_open()
7856 zilog->zl_replaying_seq < committed_seq) in ztest_dataset_open()
7859 zilog->zl_replaying_seq, committed_seq); in ztest_dataset_open()
7869 zil_close(zd->zd_zilog); in ztest_dataset_close()
7870 dmu_objset_disown(zd->zd_os, B_TRUE, zd); in ztest_dataset_close()
7891 if (dmu_objset_zil(os)->zl_parse_lr_count != 0 && in ztest_replay_zil_cb()
7898 zilog->zl_parse_blk_count, in ztest_replay_zil_cb()
7899 zilog->zl_parse_lr_count, in ztest_replay_zil_cb()
7900 zilog->zl_replaying_seq); in ztest_replay_zil_cb()
7931 * We have to do this before we freeze the pool -- otherwise in ztest_freeze()
7934 while (BP_IS_HOLE(&zd->zd_zilog->zl_header->zh_log)) { in ztest_freeze()
7936 zil_commit(zd->zd_zilog, 0); in ztest_freeze()
7978 zil_commit(zd->zd_zilog, 0); in ztest_freeze()
8047 zs->zs_metaslab_sz = in ztest_import()
8048 1ULL << spa->spa_root_vdev->vdev_child[0]->vdev_ms_shift; in ztest_import()
8049 zs->zs_guid = spa_guid(spa); in ztest_import()
8055 ztest_run_zdb(zs->zs_guid); in ztest_import()
8057 ztest_run_zdb(zs->zs_guid); in ztest_import()
8076 ztest_shared_opts->zo_raidz_expand_test = RAIDZ_EXPAND_CHECKED; in ztest_raidz_expand_check()
8091 } while (pres->pres_state != DSS_FINISHED && in ztest_raidz_expand_check()
8092 pres->pres_reflowed < pres->pres_to_reflow); in ztest_raidz_expand_check()
8099 /* Will fail here if there is non-recoverable corruption detected */ in ztest_raidz_expand_check()
8124 vdev_t *cvd, *rzvd = spa->spa_root_vdev->vdev_child[0]; in ztest_raidz_expand_run()
8125 int total_disks = rzvd->vdev_children; in ztest_raidz_expand_run()
8126 int data_disks = total_disks - vdev_get_nparity(rzvd); in ztest_raidz_expand_run()
8134 ASSERT3P(rzvd->vdev_ops, ==, &vdev_raidz_ops); in ztest_raidz_expand_run()
8187 * are joined so we can be sure none of the datasets are in-use in ztest_raidz_expand_run()
8197 zs->zs_alloc = metaslab_class_get_alloc(spa_normal_class(spa)); in ztest_raidz_expand_run()
8198 zs->zs_space = metaslab_class_get_space(spa_normal_class(spa)); in ztest_raidz_expand_run()
8206 uint64_t reflow_max = (rzvd->vdev_stat.vs_alloc * multiple) / 4; in ztest_raidz_expand_run()
8215 /* XXX - do we want some I/O load during the reflow? */ in ztest_raidz_expand_run()
8220 cvd = rzvd->vdev_child[0]; in ztest_raidz_expand_run()
8228 ztest_opts.zo_dir, ztest_opts.zo_pool, rzvd->vdev_children); in ztest_raidz_expand_run()
8239 (int)rzvd->vdev_children, (int)rzvd->vdev_children + 1, in ztest_raidz_expand_run()
8242 error = spa_vdev_attach(spa, rzvd->vdev_guid, root, B_FALSE, B_FALSE); in ztest_raidz_expand_run()
8252 while (spa->spa_raidz_expand == NULL) { in ztest_raidz_expand_run()
8259 while (pres->pres_state != DSS_SCANNING) { in ztest_raidz_expand_run()
8267 ASSERT3U(pres->pres_state, ==, DSS_SCANNING); in ztest_raidz_expand_run()
8268 ASSERT3U(pres->pres_to_reflow, !=, 0); in ztest_raidz_expand_run()
8273 ztest_shared_opts->zo_raidz_expand_test = RAIDZ_EXPAND_KILLED; in ztest_raidz_expand_run()
8282 while (pres->pres_reflowed < reflow_max) { in ztest_raidz_expand_run()
8295 "reached %llu bytes\n", (u_longlong_t)pres->pres_reflowed); in ztest_raidz_expand_run()
8338 * are joined so we can be sure none of the datasets are in-use in ztest_generic_run()
8348 zs->zs_alloc = metaslab_class_get_alloc(spa_normal_class(spa)); in ztest_generic_run()
8349 zs->zs_space = metaslab_class_get_space(spa_normal_class(spa)); in ztest_generic_run()
8377 zs->zs_thread_start = gethrtime(); in ztest_run()
8378 zs->zs_thread_stop = in ztest_run()
8379 zs->zs_thread_start + ztest_opts.zo_passtime * NANOSEC; in ztest_run()
8380 zs->zs_thread_stop = MIN(zs->zs_thread_stop, zs->zs_proc_stop); in ztest_run()
8381 zs->zs_thread_kill = zs->zs_thread_stop; in ztest_run()
8383 zs->zs_thread_kill -= in ztest_run()
8403 zs->zs_metaslab_sz = in ztest_run()
8404 1ULL << spa->spa_root_vdev->vdev_child[0]->vdev_ms_shift; in ztest_run()
8411 * XXX - BUGBUG raidz expansion do not run this for generic for now in ztest_run()
8440 spa->spa_deadman_failmode = ZIO_FAILURE_MODE_PANIC; in ztest_run()
8445 * we probe a 5-wide window around each power of two. in ztest_run()
8449 for (d = -5; d <= 5; d++) { in ztest_run()
8450 error = dmu_object_info(spa->spa_meta_objset, in ztest_run()
8460 if (zs->zs_enospc_count != 0) { in ztest_run()
8468 zs->zs_enospc_count = 0; in ztest_run()
8483 (spa->spa_removing_phys.sr_state == DSS_SCANNING || in ztest_run()
8484 spa->spa_removing_phys.sr_prev_indirect_vdev != -1)) { in ztest_run()
8485 while (spa->spa_removing_phys.sr_state == DSS_SCANNING) in ztest_run()
8524 dmu_prefetch(spa->spa_meta_objset, object, 0, 0, 1ULL << 20, in ztest_run()
8572 s -= m * 60; in print_time()
8573 m -= h * 60; in print_time()
8574 h -= d * 24; in print_time()
8634 ztest_shared->zs_vdev_next_leaf = 0; in ztest_init()
8635 zs->zs_splits = 0; in ztest_init()
8636 zs->zs_mirrors = ztest_opts.zo_mirrors; in ztest_init()
8638 NULL, ztest_opts.zo_raid_children, zs->zs_mirrors, 1); in ztest_init()
8670 VERIFY3S(-1, !=, asprintf(&buf, "feature@%s", in ztest_init()
8681 zs->zs_metaslab_sz = in ztest_init()
8682 1ULL << spa->spa_root_vdev->vdev_child[0]->vdev_ms_shift; in ztest_init()
8683 zs->zs_guid = spa_guid(spa); in ztest_init()
8689 ztest_run_zdb(zs->zs_guid); in ztest_init()
8691 ztest_run_zdb(zs->zs_guid); in ztest_init()
8714 size = hdr->zh_hdr_size; in shared_data_size()
8715 size += hdr->zh_opts_size; in shared_data_size()
8716 size += hdr->zh_size; in shared_data_size()
8717 size += hdr->zh_stats_size * hdr->zh_stats_count; in shared_data_size()
8718 size += hdr->zh_ds_size * hdr->zh_ds_count; in shared_data_size()
8719 size += hdr->zh_scratch_state_size; in shared_data_size()
8736 hdr->zh_hdr_size = sizeof (ztest_shared_hdr_t); in setup_hdr()
8737 hdr->zh_opts_size = sizeof (ztest_shared_opts_t); in setup_hdr()
8738 hdr->zh_size = sizeof (ztest_shared_t); in setup_hdr()
8739 hdr->zh_stats_size = sizeof (ztest_shared_callstate_t); in setup_hdr()
8740 hdr->zh_stats_count = ZTEST_FUNCS; in setup_hdr()
8741 hdr->zh_ds_size = sizeof (ztest_shared_ds_t); in setup_hdr()
8742 hdr->zh_ds_count = ztest_opts.zo_datasets; in setup_hdr()
8743 hdr->zh_scratch_state_size = sizeof (ztest_shared_scratch_state_t); in setup_hdr()
8770 offset = hdr->zh_hdr_size; in setup_data()
8772 offset += hdr->zh_opts_size; in setup_data()
8774 offset += hdr->zh_size; in setup_data()
8776 offset += hdr->zh_stats_size * hdr->zh_stats_count; in setup_data()
8778 offset += hdr->zh_ds_size * hdr->zh_ds_count; in setup_data()
8797 if (pid == -1) in exec_child()
8813 VERIFY3S(-1, !=, in exec_child()
8911 * As two-word space map entries may not come up often (especially in main()
8966 ASSERT3U(ztest_opts.zo_datasets, ==, ztest_shared_hdr->zh_ds_count); in main()
8979 ztest_opts.zo_dir), !=, -1); in main()
8988 zs->zs_metaslab_df_alloc_threshold; in main()
8990 if (zs->zs_do_init) in main()
9014 zs->zs_do_init = B_TRUE; in main()
9025 zs->zs_do_init = B_FALSE; in main()
9027 zs->zs_proc_start = gethrtime(); in main()
9028 zs->zs_proc_stop = zs->zs_proc_start + ztest_opts.zo_time * NANOSEC; in main()
9033 if (zs->zs_proc_start + zi->zi_interval[0] > zs->zs_proc_stop) in main()
9034 zc->zc_next = UINT64_MAX; in main()
9036 zc->zc_next = zs->zs_proc_start + in main()
9037 ztest_random(2 * zi->zi_interval[0] + 1); in main()
9042 * to verify that self-healing data works, and forced crashes in main()
9043 * to verify that we never lose on-disk consistency. in main()
9045 while (gethrtime() < zs->zs_proc_stop) { in main()
9054 zc->zc_count = 0; in main()
9055 zc->zc_time = 0; in main()
9059 zs->zs_metaslab_df_alloc_threshold = in main()
9060 ztest_random(zs->zs_metaslab_sz / 4) + 1; in main()
9086 now = MIN(now, zs->zs_proc_stop); in main()
9087 print_time(zs->zs_proc_stop - now, timebuf); in main()
9088 nicenum(zs->zs_space, numbuf, sizeof (numbuf)); in main()
9094 zs->zs_enospc_count, in main()
9095 100.0 * zs->zs_alloc / zs->zs_space, in main()
9097 100.0 * (now - zs->zs_proc_start) / in main()
9106 "-----", "----", "--------"); in main()
9110 print_time(zc->zc_time, timebuf); in main()
9112 zc->zc_count, timebuf, in main()
9113 zi->zi_funcname); in main()
9119 ztest_run_zdb(zs->zs_guid); in main()
9120 if (ztest_shared_opts->zo_raidz_expand_test == in main()
9133 kills, iters - kills, (100.0 * kills) / MAX(1, iters)); in main()