Don't use dmu_buf_is_dirty() for unassigned transaction.

The dmu_buf_is_dirty() call doesn't make sense here for two reasons:
1. txg is 0 for unassigned tx, so it was a no-op.
2. It is equivalent of checking if we have dirty records and we are doing
   this few lines earlier.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Pawel Jakub Dawidek <pawel@dawidek.net>
Closes #14825
This commit is contained in:
Pawel Jakub Dawidek 2023-05-02 15:46:14 -07:00 committed by Brian Behlendorf
parent bd8c6bd66f
commit d0d91f185e
3 changed files with 7 additions and 14 deletions

View File

@ -1065,7 +1065,7 @@ int dmu_offset_next(objset_t *os, uint64_t object, boolean_t hole,
uint64_t *off);
int dmu_read_l0_bps(objset_t *os, uint64_t object, uint64_t offset,
uint64_t length, dmu_tx_t *tx, struct blkptr *bps, size_t *nbpsp);
uint64_t length, struct blkptr *bps, size_t *nbpsp);
int dmu_brt_clone(objset_t *os, uint64_t object, uint64_t offset,
uint64_t length, dmu_tx_t *tx, const struct blkptr *bps, size_t nbps,
boolean_t replay);

View File

@ -2173,7 +2173,7 @@ restart:
int
dmu_read_l0_bps(objset_t *os, uint64_t object, uint64_t offset, uint64_t length,
dmu_tx_t *tx, blkptr_t *bps, size_t *nbpsp)
blkptr_t *bps, size_t *nbpsp)
{
dmu_buf_t **dbp, *dbuf;
dmu_buf_impl_t *db;
@ -2235,10 +2235,6 @@ dmu_read_l0_bps(objset_t *os, uint64_t object, uint64_t offset, uint64_t length,
error = SET_ERROR(EAGAIN);
goto out;
}
if (dmu_buf_is_dirty(dbuf, tx)) {
error = SET_ERROR(EAGAIN);
goto out;
}
/*
* Make sure we clone only data blocks.
*/

View File

@ -1246,16 +1246,10 @@ zfs_clone_range(znode_t *inzp, uint64_t *inoffp, znode_t *outzp,
break;
}
/*
* Start a transaction.
*/
tx = dmu_tx_create(outos);
nbps = maxblocks;
error = dmu_read_l0_bps(inos, inzp->z_id, inoff, size, tx, bps,
error = dmu_read_l0_bps(inos, inzp->z_id, inoff, size, bps,
&nbps);
if (error != 0) {
dmu_tx_abort(tx);
/*
* If we are tyring to clone a block that was created
* in the current transaction group. Return an error,
@ -1276,12 +1270,15 @@ zfs_clone_range(znode_t *inzp, uint64_t *inoffp, znode_t *outzp,
*/
if (BP_IS_PROTECTED(&bps[0])) {
if (inzfsvfs != outzfsvfs) {
dmu_tx_abort(tx);
error = SET_ERROR(EXDEV);
break;
}
}
/*
* Start a transaction.
*/
tx = dmu_tx_create(outos);
dmu_tx_hold_sa(tx, outzp->z_sa_hdl, B_FALSE);
db = (dmu_buf_impl_t *)sa_get_db(outzp->z_sa_hdl);
DB_DNODE_ENTER(db);