dmu_tx: make DMU_TX_* flags an enum

Mostly for a little more type checking and debugging visibility.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Paul Dagnelie <paul.dagnelie@klarasystems.com>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #17355
This commit is contained in:
Rob Norris 2025-05-16 14:56:12 +10:00 committed by Brian Behlendorf
parent 468d22d60c
commit ac2e579521
3 changed files with 21 additions and 6 deletions

View File

@ -281,9 +281,24 @@ typedef enum dmu_object_type {
* the transaction is full. See the comment above dmu_tx_assign() for more
* details on the meaning of these flags.
*/
#define DMU_TX_NOWAIT (0ULL)
#define DMU_TX_WAIT (1ULL<<0)
#define DMU_TX_NOTHROTTLE (1ULL<<1)
typedef enum {
/*
* If the tx cannot be assigned to a transaction for any reason, do
* not block but return immediately.
*/
DMU_TX_NOWAIT = 0,
/*
* Assign the tx to the open transaction. If the open transaction is
* full, or the write throttle is active, block until the next
* transaction and try again. If the pool suspends while waiting,
* return an error.
*/
DMU_TX_WAIT = (1 << 0),
/* If the write throttle would prevent the assignment, ignore it. */
DMU_TX_NOTHROTTLE = (1 << 1),
} dmu_tx_flag_t;
void byteswap_uint64_array(void *buf, size_t size);
void byteswap_uint32_array(void *buf, size_t size);
@ -849,7 +864,7 @@ void dmu_tx_hold_spill(dmu_tx_t *tx, uint64_t object);
void dmu_tx_hold_sa(dmu_tx_t *tx, struct sa_handle *hdl, boolean_t may_grow);
void dmu_tx_hold_sa_create(dmu_tx_t *tx, int total_size);
void dmu_tx_abort(dmu_tx_t *tx);
int dmu_tx_assign(dmu_tx_t *tx, uint64_t flags);
int dmu_tx_assign(dmu_tx_t *tx, dmu_tx_flag_t flags);
void dmu_tx_wait(dmu_tx_t *tx);
void dmu_tx_commit(dmu_tx_t *tx);
void dmu_tx_mark_netfree(dmu_tx_t *tx);

View File

@ -143,7 +143,7 @@ extern dmu_tx_stats_t dmu_tx_stats;
* These routines are defined in dmu.h, and are called by the user.
*/
dmu_tx_t *dmu_tx_create(objset_t *dd);
int dmu_tx_assign(dmu_tx_t *tx, uint64_t txg_how);
int dmu_tx_assign(dmu_tx_t *tx, dmu_tx_flag_t flags);
void dmu_tx_commit(dmu_tx_t *tx);
void dmu_tx_abort(dmu_tx_t *tx);
uint64_t dmu_tx_get_txg(dmu_tx_t *tx);

View File

@ -1201,7 +1201,7 @@ dmu_tx_unassign(dmu_tx_t *tx)
* 1 <- dmu_tx_get_txg(T3)
*/
int
dmu_tx_assign(dmu_tx_t *tx, uint64_t flags)
dmu_tx_assign(dmu_tx_t *tx, dmu_tx_flag_t flags)
{
int err;