/* Global commit callback list */
static ztest_cb_list_t zcl;
+/* Commit cb delay */
+static uint64_t zc_min_txg_delay = UINT64_MAX;
+static int zc_cb_counter = 0;
+
+/*
+ * Minimum number of commit callbacks that need to be registered for us to check
+ * whether the minimum txg delay is acceptable.
+ */
+#define ZTEST_COMMIT_CB_MIN_REG 100
+
+/*
+ * If a number of txgs equal to this threshold have been created after a commit
+ * callback has been registered but not called, then we assume there is an
+ * implementation bug.
+ */
+#define ZTEST_COMMIT_CB_THRESH (TXG_CONCURRENT_STATES + 1000)
extern uint64_t metaslab_gang_bang;
extern uint64_t metaslab_df_alloc_threshold;
* debugging facilities.
*/
const char *
-_umem_debug_init()
+_umem_debug_init(void)
{
return ("default,verbose"); /* $UMEM_DEBUG setting */
}
*ip++ = value;
}
+#ifndef NDEBUG
static boolean_t
ztest_pattern_match(void *buf, uint64_t size, uint64_t value)
{
return (diff == 0);
}
+#endif
static void
ztest_bt_generate(ztest_block_tag_t *bt, objset_t *os, uint64_t object,
}
zil_replay_func_t *ztest_replay_vector[TX_MAX_TYPE] = {
- NULL, /* 0 no such transaction type */
- ztest_replay_create, /* TX_CREATE */
- NULL, /* TX_MKDIR */
- NULL, /* TX_MKXATTR */
- NULL, /* TX_SYMLINK */
- ztest_replay_remove, /* TX_REMOVE */
- NULL, /* TX_RMDIR */
- NULL, /* TX_LINK */
- NULL, /* TX_RENAME */
- ztest_replay_write, /* TX_WRITE */
- ztest_replay_truncate, /* TX_TRUNCATE */
- ztest_replay_setattr, /* TX_SETATTR */
- NULL, /* TX_ACL */
- NULL, /* TX_CREATE_ACL */
- NULL, /* TX_CREATE_ATTR */
- NULL, /* TX_CREATE_ACL_ATTR */
- NULL, /* TX_MKDIR_ACL */
- NULL, /* TX_MKDIR_ATTR */
- NULL, /* TX_MKDIR_ACL_ATTR */
- NULL, /* TX_WRITE2 */
+ NULL, /* 0 no such transaction type */
+ (zil_replay_func_t *)ztest_replay_create, /* TX_CREATE */
+ NULL, /* TX_MKDIR */
+ NULL, /* TX_MKXATTR */
+ NULL, /* TX_SYMLINK */
+ (zil_replay_func_t *)ztest_replay_remove, /* TX_REMOVE */
+ NULL, /* TX_RMDIR */
+ NULL, /* TX_LINK */
+ NULL, /* TX_RENAME */
+ (zil_replay_func_t *)ztest_replay_write, /* TX_WRITE */
+ (zil_replay_func_t *)ztest_replay_truncate, /* TX_TRUNCATE */
+ (zil_replay_func_t *)ztest_replay_setattr, /* TX_SETATTR */
+ NULL, /* TX_ACL */
+ NULL, /* TX_CREATE_ACL */
+ NULL, /* TX_CREATE_ATTR */
+ NULL, /* TX_CREATE_ACL_ATTR */
+ NULL, /* TX_MKDIR_ACL */
+ NULL, /* TX_MKDIR_ATTR */
+ NULL, /* TX_MKDIR_ACL_ATTR */
+ NULL, /* TX_WRITE2 */
};
/*
case ZTEST_IO_SETATTR:
(void) ztest_setattr(zd, object);
break;
+ default:
+ break;
}
umem_free(data, blocksize);
od->od_gen = 0;
(void) snprintf(od->od_name, sizeof (od->od_name), "%s(%lld)[%llu]",
- tag, (int64_t)id, index);
+ tag, (longlong_t)id, (u_longlong_t)index);
}
/*
vdev_t *
grow_vdev(vdev_t *vd, void *arg)
{
- spa_t *spa = vd->vdev_spa;
+ ASSERTV(spa_t *spa = vd->vdev_spa);
size_t *newsize = arg;
size_t fsize;
int fd;
return (vd);
fsize = lseek(fd, 0, SEEK_END);
- (void) ftruncate(fd, *newsize);
+ VERIFY(ftruncate(fd, *newsize) == 0);
if (zopt_verbose >= 6) {
(void) printf("%s grew from %lu to %lu bytes\n",
char snap3name[MAXNAMELEN];
int error;
- (void) snprintf(snap1name, MAXNAMELEN, "%s@s1_%llu", osname, id);
- (void) snprintf(clone1name, MAXNAMELEN, "%s/c1_%llu", osname, id);
- (void) snprintf(snap2name, MAXNAMELEN, "%s@s2_%llu", clone1name, id);
- (void) snprintf(clone2name, MAXNAMELEN, "%s/c2_%llu", osname, id);
- (void) snprintf(snap3name, MAXNAMELEN, "%s@s3_%llu", clone1name, id);
+ (void) snprintf(snap1name, MAXNAMELEN, "%s@s1_%llu",
+ osname, (u_longlong_t)id);
+ (void) snprintf(clone1name, MAXNAMELEN, "%s/c1_%llu",
+ osname, (u_longlong_t)id);
+ (void) snprintf(snap2name, MAXNAMELEN, "%s@s2_%llu",
+ clone1name, (u_longlong_t)id);
+ (void) snprintf(clone2name, MAXNAMELEN, "%s/c2_%llu",
+ osname, (u_longlong_t)id);
+ (void) snprintf(snap3name, MAXNAMELEN, "%s@s3_%llu",
+ clone1name, (u_longlong_t)id);
error = dmu_objset_destroy(clone2name, B_FALSE);
if (error && error != ENOENT)
ztest_dsl_dataset_cleanup(osname, id);
- (void) snprintf(snap1name, MAXNAMELEN, "%s@s1_%llu", osname, id);
- (void) snprintf(clone1name, MAXNAMELEN, "%s/c1_%llu", osname, id);
- (void) snprintf(snap2name, MAXNAMELEN, "%s@s2_%llu", clone1name, id);
- (void) snprintf(clone2name, MAXNAMELEN, "%s/c2_%llu", osname, id);
- (void) snprintf(snap3name, MAXNAMELEN, "%s@s3_%llu", clone1name, id);
+ (void) snprintf(snap1name, MAXNAMELEN, "%s@s1_%llu",
+ osname, (u_longlong_t)id);
+ (void) snprintf(clone1name, MAXNAMELEN, "%s/c1_%llu",
+ osname, (u_longlong_t)id);
+ (void) snprintf(snap2name, MAXNAMELEN, "%s@s2_%llu",
+ clone1name, (u_longlong_t)id);
+ (void) snprintf(clone2name, MAXNAMELEN, "%s/c2_%llu",
+ osname, (u_longlong_t)id);
+ (void) snprintf(snap3name, MAXNAMELEN, "%s@s3_%llu",
+ clone1name, (u_longlong_t)id);
error = dmu_objset_snapshot(osname, strchr(snap1name, '@')+1,
NULL, NULL, B_FALSE, B_FALSE, -1);
int error;
(void) snprintf(name, sizeof (name), "fzap-%llu-%llu",
- id, value);
+ (u_longlong_t)id, (u_longlong_t)value);
tx = dmu_tx_create(os);
dmu_tx_hold_zap(tx, object, B_TRUE, name);
return;
}
- /* Was this callback added to the global callback list? */
- if (!data->zcd_added)
- goto out;
-
+ ASSERT(data->zcd_added);
ASSERT3U(data->zcd_txg, !=, 0);
- /* Remove our callback from the list */
(void) mutex_lock(&zcl.zcl_callbacks_lock);
+
+ /* See if this cb was called more quickly */
+ if ((synced_txg - data->zcd_txg) < zc_min_txg_delay)
+ zc_min_txg_delay = synced_txg - data->zcd_txg;
+
+ /* Remove our callback from the list */
list_remove(&zcl.zcl_callbacks, data);
+
(void) mutex_unlock(&zcl.zcl_callbacks_lock);
-out:
umem_free(data, sizeof (ztest_cb_data_t));
}
}
/*
- * If a number of txgs equal to this threshold have been created after a commit
- * callback has been registered but not called, then we assume there is an
- * implementation bug.
- */
-#define ZTEST_COMMIT_CALLBACK_THRESH (TXG_CONCURRENT_STATES + 2)
-
-/*
* Commit callback test.
*/
void
dmu_tx_t *tx;
ztest_cb_data_t *cb_data[3], *tmp_cb;
uint64_t old_txg, txg;
- int i, error;
+ int i, error = 0;
ztest_od_init(&od[0], id, FTAG, 0, DMU_OT_UINT64_OTHER, 0, 0);
*/
tmp_cb = list_head(&zcl.zcl_callbacks);
if (tmp_cb != NULL &&
- tmp_cb->zcd_txg > txg - ZTEST_COMMIT_CALLBACK_THRESH) {
+ tmp_cb->zcd_txg + ZTEST_COMMIT_CB_THRESH < txg) {
fatal(0, "Commit callback threshold exceeded, oldest txg: %"
PRIu64 ", open txg: %" PRIu64 "\n", tmp_cb->zcd_txg, txg);
}
tmp_cb = cb_data[i];
}
+ zc_cb_counter += 3;
+
(void) mutex_unlock(&zcl.zcl_callbacks_lock);
dmu_tx_commit(tx);
for (uint64_t object = 1; object < 50; object++)
dmu_prefetch(spa->spa_meta_objset, object, 0, 1ULL << 20);
+ /* Verify that at least one commit cb was called in a timely fashion */
+ if (zc_cb_counter >= ZTEST_COMMIT_CB_MIN_REG)
+ VERIFY3U(zc_min_txg_delay, ==, 0);
+
spa_close(spa, FTAG);
/*
}
static nvlist_t *
-make_random_props()
+make_random_props(void)
{
nvlist_t *props;
process_options(argc, argv);
/* Override location of zpool.cache */
- (void) asprintf((char **)&spa_config_path, "%s/zpool.cache", zopt_dir);
+ VERIFY(asprintf((char **)&spa_config_path, "%s/zpool.cache",
+ zopt_dir) != -1);
/*
* Blow away any existing copy of zpool.cache