dmu_tx: rename dmu_tx_assign() flags from TXG_* to DMU_TX_* (#17143)

This helps to avoids confusion with the similarly-named
txg_wait_synced().

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.

Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Mariusz Zaborski <mariusz.zaborski@klarasystems.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
This commit is contained in:
Rob Norris
2025-03-19 10:04:22 +11:00
committed by GitHub
parent 21850f519b
commit f69631992d
35 changed files with 168 additions and 155 deletions
+1 -1
View File
@@ -2188,7 +2188,7 @@ top:
}
zfs_sa_upgrade_txholds(tx, zp);
error = dmu_tx_assign(tx, TXG_NOWAIT);
error = dmu_tx_assign(tx, DMU_TX_NOWAIT);
if (error) {
mutex_exit(&zp->z_acl_lock);
mutex_exit(&zp->z_lock);
+3 -3
View File
@@ -623,7 +623,7 @@ zfs_purgedir(znode_t *dzp)
/* Is this really needed ? */
zfs_sa_upgrade_txholds(tx, xzp);
dmu_tx_mark_netfree(tx);
error = dmu_tx_assign(tx, TXG_WAIT);
error = dmu_tx_assign(tx, DMU_TX_WAIT);
if (error) {
dmu_tx_abort(tx);
zfs_zrele_async(xzp);
@@ -729,7 +729,7 @@ zfs_rmnode(znode_t *zp)
dmu_tx_hold_free(tx, acl_obj, 0, DMU_OBJECT_END);
zfs_sa_upgrade_txholds(tx, zp);
error = dmu_tx_assign(tx, TXG_WAIT);
error = dmu_tx_assign(tx, DMU_TX_WAIT);
if (error) {
/*
* Not enough space to delete the file. Leave it in the
@@ -1150,7 +1150,7 @@ zfs_make_xattrdir(znode_t *zp, vattr_t *vap, znode_t **xzpp, cred_t *cr)
fuid_dirtied = zfsvfs->z_fuid_dirty;
if (fuid_dirtied)
zfs_fuid_txhold(zfsvfs, tx);
error = dmu_tx_assign(tx, TXG_WAIT);
error = dmu_tx_assign(tx, DMU_TX_WAIT);
if (error) {
zfs_acl_ids_free(&acl_ids);
dmu_tx_abort(tx);
+1 -1
View File
@@ -1962,7 +1962,7 @@ zfs_set_version(zfsvfs_t *zfsvfs, uint64_t newvers)
ZFS_SA_ATTRS);
dmu_tx_hold_zap(tx, DMU_NEW_OBJECT, FALSE, NULL);
}
error = dmu_tx_assign(tx, TXG_WAIT);
error = dmu_tx_assign(tx, DMU_TX_WAIT);
if (error) {
dmu_tx_abort(tx);
return (error);
+36 -27
View File
@@ -105,14 +105,14 @@
* (3) All range locks must be grabbed before calling dmu_tx_assign(),
* as they can span dmu_tx_assign() calls.
*
* (4) If ZPL locks are held, pass TXG_NOWAIT as the second argument to
* (4) If ZPL locks are held, pass DMU_TX_NOWAIT as the second argument to
* dmu_tx_assign(). This is critical because we don't want to block
* while holding locks.
*
* If no ZPL locks are held (aside from zfs_enter()), use TXG_WAIT. This
* reduces lock contention and CPU usage when we must wait (note that if
* throughput is constrained by the storage, nearly every transaction
* must wait).
* If no ZPL locks are held (aside from zfs_enter()), use DMU_TX_WAIT.
* This reduces lock contention and CPU usage when we must wait (note
* that if throughput is constrained by the storage, nearly every
* transaction must wait).
*
* Note, in particular, that if a lock is sometimes acquired before
* the tx assigns, and sometimes after (e.g. z_lock), then failing
@@ -120,15 +120,16 @@
*
* Thread A has grabbed a lock before calling dmu_tx_assign().
* Thread B is in an already-assigned tx, and blocks for this lock.
* Thread A calls dmu_tx_assign(TXG_WAIT) and blocks in txg_wait_open()
* forever, because the previous txg can't quiesce until B's tx commits.
* Thread A calls dmu_tx_assign(DMU_TX_WAIT) and blocks in
* txg_wait_open() forever, because the previous txg can't quiesce
* until B's tx commits.
*
* If dmu_tx_assign() returns ERESTART and zfsvfs->z_assign is TXG_NOWAIT,
* then drop all locks, call dmu_tx_wait(), and try again. On subsequent
* calls to dmu_tx_assign(), pass TXG_NOTHROTTLE in addition to TXG_NOWAIT,
* to indicate that this operation has already called dmu_tx_wait().
* This will ensure that we don't retry forever, waiting a short bit
* each time.
* If dmu_tx_assign() returns ERESTART and zfsvfs->z_assign is
* DMU_TX_NOWAIT, then drop all locks, call dmu_tx_wait(), and try
* again. On subsequent calls to dmu_tx_assign(), pass
* DMU_TX_NOTHROTTLE in addition to DMU_TX_NOWAIT, to indicate that
* this operation has already called dmu_tx_wait(). This will ensure
* that we don't retry forever, waiting a short bit each time.
*
* (5) If the operation succeeded, generate the intent log entry for it
* before dropping locks. This ensures that the ordering of events
@@ -150,7 +151,8 @@
* rw_enter(...); // grab any other locks you need
* tx = dmu_tx_create(...); // get DMU tx
* dmu_tx_hold_*(); // hold each object you might modify
* error = dmu_tx_assign(tx, (waited ? TXG_NOTHROTTLE : 0) | TXG_NOWAIT);
* error = dmu_tx_assign(tx,
* (waited ? DMU_TX_NOTHROTTLE : 0) | DMU_TX_NOWAIT);
* if (error) {
* rw_exit(...); // drop locks
* zfs_dirent_unlock(dl); // unlock directory entry
@@ -737,7 +739,7 @@ top:
}
error = dmu_tx_assign(tx,
(waited ? TXG_NOTHROTTLE : 0) | TXG_NOWAIT);
(waited ? DMU_TX_NOTHROTTLE : 0) | DMU_TX_NOWAIT);
if (error) {
zfs_dirent_unlock(dl);
if (error == ERESTART) {
@@ -928,7 +930,8 @@ top:
dmu_tx_hold_write(tx, DMU_NEW_OBJECT,
0, acl_ids.z_aclp->z_acl_bytes);
}
error = dmu_tx_assign(tx, (waited ? TXG_NOTHROTTLE : 0) | TXG_NOWAIT);
error = dmu_tx_assign(tx,
(waited ? DMU_TX_NOTHROTTLE : 0) | DMU_TX_NOWAIT);
if (error) {
if (error == ERESTART) {
waited = B_TRUE;
@@ -1092,7 +1095,8 @@ top:
*/
dmu_tx_mark_netfree(tx);
error = dmu_tx_assign(tx, (waited ? TXG_NOTHROTTLE : 0) | TXG_NOWAIT);
error = dmu_tx_assign(tx,
(waited ? DMU_TX_NOTHROTTLE : 0) | DMU_TX_NOWAIT);
if (error) {
zfs_dirent_unlock(dl);
if (error == ERESTART) {
@@ -1338,7 +1342,8 @@ top:
dmu_tx_hold_sa_create(tx, acl_ids.z_aclp->z_acl_bytes +
ZFS_SA_BASE_ATTR_SIZE);
error = dmu_tx_assign(tx, (waited ? TXG_NOTHROTTLE : 0) | TXG_NOWAIT);
error = dmu_tx_assign(tx,
(waited ? DMU_TX_NOTHROTTLE : 0) | DMU_TX_NOWAIT);
if (error) {
zfs_dirent_unlock(dl);
if (error == ERESTART) {
@@ -1482,7 +1487,8 @@ top:
zfs_sa_upgrade_txholds(tx, zp);
zfs_sa_upgrade_txholds(tx, dzp);
dmu_tx_mark_netfree(tx);
error = dmu_tx_assign(tx, (waited ? TXG_NOTHROTTLE : 0) | TXG_NOWAIT);
error = dmu_tx_assign(tx,
(waited ? DMU_TX_NOTHROTTLE : 0) | DMU_TX_NOWAIT);
if (error) {
rw_exit(&zp->z_parent_lock);
rw_exit(&zp->z_name_lock);
@@ -1814,7 +1820,7 @@ zfs_setattr_dir(znode_t *dzp)
else
dmu_tx_hold_sa(tx, zp->z_sa_hdl, B_FALSE);
err = dmu_tx_assign(tx, TXG_WAIT);
err = dmu_tx_assign(tx, DMU_TX_WAIT);
if (err)
break;
@@ -2387,7 +2393,7 @@ top:
zfs_sa_upgrade_txholds(tx, zp);
err = dmu_tx_assign(tx, TXG_WAIT);
err = dmu_tx_assign(tx, DMU_TX_WAIT);
if (err)
goto out;
@@ -3071,7 +3077,8 @@ top:
zfs_fuid_txhold(zfsvfs, tx);
zfs_sa_upgrade_txholds(tx, szp);
dmu_tx_hold_zap(tx, zfsvfs->z_unlinkedobj, FALSE, NULL);
error = dmu_tx_assign(tx, (waited ? TXG_NOTHROTTLE : 0) | TXG_NOWAIT);
error = dmu_tx_assign(tx,
(waited ? DMU_TX_NOTHROTTLE : 0) | DMU_TX_NOWAIT);
if (error) {
if (zl != NULL)
zfs_rename_unlock(&zl);
@@ -3366,7 +3373,8 @@ top:
}
if (fuid_dirtied)
zfs_fuid_txhold(zfsvfs, tx);
error = dmu_tx_assign(tx, (waited ? TXG_NOTHROTTLE : 0) | TXG_NOWAIT);
error = dmu_tx_assign(tx,
(waited ? DMU_TX_NOTHROTTLE : 0) | DMU_TX_NOWAIT);
if (error) {
zfs_dirent_unlock(dl);
if (error == ERESTART) {
@@ -3616,7 +3624,8 @@ top:
zfs_sa_upgrade_txholds(tx, szp);
zfs_sa_upgrade_txholds(tx, tdzp);
error = dmu_tx_assign(tx, (waited ? TXG_NOTHROTTLE : 0) | TXG_NOWAIT);
error = dmu_tx_assign(tx,
(waited ? DMU_TX_NOTHROTTLE : 0) | DMU_TX_NOWAIT);
if (error) {
zfs_dirent_unlock(dl);
if (error == ERESTART) {
@@ -3853,7 +3862,7 @@ zfs_putpage(struct inode *ip, struct page *pp, struct writeback_control *wbc,
dmu_tx_hold_sa(tx, zp->z_sa_hdl, B_FALSE);
zfs_sa_upgrade_txholds(tx, zp);
err = dmu_tx_assign(tx, TXG_WAIT);
err = dmu_tx_assign(tx, DMU_TX_WAIT);
if (err != 0) {
dmu_tx_abort(tx);
#ifdef HAVE_VFS_FILEMAP_DIRTY_FOLIO
@@ -3968,7 +3977,7 @@ zfs_dirty_inode(struct inode *ip, int flags)
dmu_tx_hold_sa(tx, zp->z_sa_hdl, B_FALSE);
zfs_sa_upgrade_txholds(tx, zp);
error = dmu_tx_assign(tx, TXG_WAIT);
error = dmu_tx_assign(tx, DMU_TX_WAIT);
if (error) {
dmu_tx_abort(tx);
goto out;
@@ -4027,7 +4036,7 @@ zfs_inactive(struct inode *ip)
dmu_tx_hold_sa(tx, zp->z_sa_hdl, B_FALSE);
zfs_sa_upgrade_txholds(tx, zp);
error = dmu_tx_assign(tx, TXG_WAIT);
error = dmu_tx_assign(tx, DMU_TX_WAIT);
if (error) {
dmu_tx_abort(tx);
} else {
+3 -3
View File
@@ -1518,7 +1518,7 @@ zfs_extend(znode_t *zp, uint64_t end)
newblksz = 0;
}
error = dmu_tx_assign(tx, TXG_WAIT);
error = dmu_tx_assign(tx, DMU_TX_WAIT);
if (error) {
dmu_tx_abort(tx);
zfs_rangelock_exit(lr);
@@ -1704,7 +1704,7 @@ zfs_trunc(znode_t *zp, uint64_t end)
dmu_tx_hold_sa(tx, zp->z_sa_hdl, B_FALSE);
zfs_sa_upgrade_txholds(tx, zp);
dmu_tx_mark_netfree(tx);
error = dmu_tx_assign(tx, TXG_WAIT);
error = dmu_tx_assign(tx, DMU_TX_WAIT);
if (error) {
dmu_tx_abort(tx);
zfs_rangelock_exit(lr);
@@ -1775,7 +1775,7 @@ log:
tx = dmu_tx_create(zfsvfs->z_os);
dmu_tx_hold_sa(tx, zp->z_sa_hdl, B_FALSE);
zfs_sa_upgrade_txholds(tx, zp);
error = dmu_tx_assign(tx, TXG_WAIT);
error = dmu_tx_assign(tx, DMU_TX_WAIT);
if (error) {
dmu_tx_abort(tx);
goto out;
+2 -2
View File
@@ -300,7 +300,7 @@ zvol_write(zv_request_t *zvr)
dmu_tx_hold_write_by_dnode(tx, zv->zv_dn, off, bytes);
/* This will only fail for ENOSPC */
error = dmu_tx_assign(tx, TXG_WAIT);
error = dmu_tx_assign(tx, DMU_TX_WAIT);
if (error) {
dmu_tx_abort(tx);
break;
@@ -396,7 +396,7 @@ zvol_discard(zv_request_t *zvr)
tx = dmu_tx_create(zv->zv_objset);
dmu_tx_mark_netfree(tx);
error = dmu_tx_assign(tx, TXG_WAIT);
error = dmu_tx_assign(tx, DMU_TX_WAIT);
if (error != 0) {
dmu_tx_abort(tx);
} else {