* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright (c) 2012, 2017 by Delphix. All rights reserved.
+ */
#ifndef _SYS_TXG_H
#define _SYS_TXG_H
/* Number of txgs worth of frees we defer adding to in-core spacemaps */
#define TXG_DEFER_SIZE 2
-#define TXG_WAIT 1ULL
-#define TXG_NOWAIT 2ULL
-
typedef struct tx_cpu tx_cpu_t;
typedef struct txg_handle {
typedef struct txg_list {
kmutex_t tl_lock;
size_t tl_offset;
+ spa_t *tl_spa;
txg_node_t *tl_head[TXG_SIZE];
} txg_list_t;
extern void txg_rele_to_sync(txg_handle_t *txghp);
extern void txg_register_callbacks(txg_handle_t *txghp, list_t *tx_callbacks);
-/*
- * Delay the caller by the specified number of ticks or until
- * the txg closes (whichever comes first). This is intended
- * to be used to throttle writers when the system nears its
- * capacity.
- */
-extern void txg_delay(struct dsl_pool *dp, uint64_t txg, int ticks);
+extern void txg_delay(struct dsl_pool *dp, uint64_t txg, hrtime_t delta,
+ hrtime_t resolution);
+extern void txg_kick(struct dsl_pool *dp);
/*
* Wait until the given transaction group has finished syncing.
/* returns TRUE if someone is waiting for the next txg to sync */
extern boolean_t txg_sync_waiting(struct dsl_pool *dp);
+extern void txg_verify(spa_t *spa, uint64_t txg);
+
/*
* Wait for pending commit callbacks of already-synced transactions to finish
* processing.
#define TXG_CLEAN(txg) ((txg) - 1)
-extern void txg_list_create(txg_list_t *tl, size_t offset);
+extern void txg_list_create(txg_list_t *tl, spa_t *spa, size_t offset);
extern void txg_list_destroy(txg_list_t *tl);
-extern int txg_list_empty(txg_list_t *tl, uint64_t txg);
-extern int txg_list_add(txg_list_t *tl, void *p, uint64_t txg);
-extern int txg_list_add_tail(txg_list_t *tl, void *p, uint64_t txg);
+extern boolean_t txg_list_empty(txg_list_t *tl, uint64_t txg);
+extern boolean_t txg_all_lists_empty(txg_list_t *tl);
+extern boolean_t txg_list_add(txg_list_t *tl, void *p, uint64_t txg);
+extern boolean_t txg_list_add_tail(txg_list_t *tl, void *p, uint64_t txg);
extern void *txg_list_remove(txg_list_t *tl, uint64_t txg);
extern void *txg_list_remove_this(txg_list_t *tl, void *p, uint64_t txg);
-extern int txg_list_member(txg_list_t *tl, void *p, uint64_t txg);
+extern boolean_t txg_list_member(txg_list_t *tl, void *p, uint64_t txg);
extern void *txg_list_head(txg_list_t *tl, uint64_t txg);
extern void *txg_list_next(txg_list_t *tl, void *p, uint64_t txg);
+/* Global tuning */
+extern int zfs_txg_timeout;
+
+
+#ifdef ZFS_DEBUG
+#define TXG_VERIFY(spa, txg) txg_verify(spa, txg)
+#else
+#define TXG_VERIFY(spa, txg)
+#endif
+
#ifdef __cplusplus
}
#endif