zfs_trunc() should use dmu_tx_assign(tx, TXG_WAIT)

As part of the write throttle & i/o schedule performance work the
zfs_trunc() function should have been updated to use TXG_WAIT.
Using TXG_WAIT ensures that the tx will be part of the next txg.
If TXG_NOWAIT is used and retried for ERESTART errors then the
tx can suffer from starvation.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ned Bass <bass6@llnl.gov>
Closes #2488
This commit is contained in:
Brian Behlendorf 2014-07-21 10:19:25 -07:00
parent 080b310015
commit 7a8f0e80ea

View File

@ -1423,17 +1423,11 @@ zfs_trunc(znode_t *zp, uint64_t end)
zfs_range_unlock(rl);
return (error);
}
top:
tx = dmu_tx_create(zsb->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_NOWAIT);
error = dmu_tx_assign(tx, TXG_WAIT);
if (error) {
if (error == ERESTART) {
dmu_tx_wait(tx);
dmu_tx_abort(tx);
goto top;
}
dmu_tx_abort(tx);
zfs_range_unlock(rl);
return (error);