diff --git a/include/sys/dmu_tx.h b/include/sys/dmu_tx.h index 7d2fdab290..1ee513fdc8 100644 --- a/include/sys/dmu_tx.h +++ b/include/sys/dmu_tx.h @@ -171,7 +171,7 @@ extern dmu_tx_t *dmu_tx_create_assigned(struct dsl_pool *dp, uint64_t txg); dmu_tx_t *dmu_tx_create_dd(dsl_dir_t *dd); int dmu_tx_is_syncing(dmu_tx_t *tx); int dmu_tx_private_ok(dmu_tx_t *tx); -void dmu_tx_add_new_object(dmu_tx_t *tx, objset_t *os, dnode_t *dn); +void dmu_tx_add_new_object(dmu_tx_t *tx, dnode_t *dn); void dmu_tx_willuse_space(dmu_tx_t *tx, int64_t delta); void dmu_tx_dirty_buf(dmu_tx_t *tx, struct dmu_buf_impl *db); int dmu_tx_holds(dmu_tx_t *tx, uint64_t object); diff --git a/module/zfs/dmu_object.c b/module/zfs/dmu_object.c index 3e3efe0c13..8ca699ebff 100644 --- a/module/zfs/dmu_object.c +++ b/module/zfs/dmu_object.c @@ -131,7 +131,7 @@ dmu_object_alloc_dnsize(objset_t *os, dmu_object_type_t ot, int blocksize, dnode_allocate(dn, ot, blocksize, 0, bonustype, bonuslen, dn_slots, tx); mutex_exit(&os->os_obj_lock); - dmu_tx_add_new_object(tx, os, dn); + dmu_tx_add_new_object(tx, dn); dnode_rele(dn, FTAG); return (object); @@ -168,7 +168,7 @@ dmu_object_claim_dnsize(objset_t *os, uint64_t object, dmu_object_type_t ot, return (err); dnode_allocate(dn, ot, blocksize, 0, bonustype, bonuslen, dn_slots, tx); - dmu_tx_add_new_object(tx, os, dn); + dmu_tx_add_new_object(tx, dn); dnode_rele(dn, FTAG); diff --git a/module/zfs/dmu_tx.c b/module/zfs/dmu_tx.c index 7c1801be47..4d4c74f512 100644 --- a/module/zfs/dmu_tx.c +++ b/module/zfs/dmu_tx.c @@ -119,7 +119,7 @@ dmu_tx_hold_dnode_impl(dmu_tx_t *tx, dnode_t *dn, enum dmu_tx_hold_type type, dmu_tx_hold_t *txh; if (dn != NULL) { - refcount_add(&dn->dn_holds, tx); + (void) refcount_add(&dn->dn_holds, tx); if (tx->tx_txg != 0) { mutex_enter(&dn->dn_mtx); /* @@ -163,7 +163,7 @@ dmu_tx_hold_object_impl(dmu_tx_t *tx, objset_t *os, uint64_t object, if (object != DMU_NEW_OBJECT) { err = dnode_hold(os, object, FTAG, &dn); - if (err) { + if (err != 0) { tx->tx_err = err; return (NULL); } @@ -175,7 +175,7 @@ dmu_tx_hold_object_impl(dmu_tx_t *tx, objset_t *os, uint64_t object, } void -dmu_tx_add_new_object(dmu_tx_t *tx, objset_t *os, dnode_t *dn) +dmu_tx_add_new_object(dmu_tx_t *tx, dnode_t *dn) { /* * If we're syncing, they can manipulate any object anyhow, and @@ -462,17 +462,16 @@ dmu_tx_hold_write(dmu_tx_t *tx, uint64_t object, uint64_t off, int len) { dmu_tx_hold_t *txh; - ASSERT(tx->tx_txg == 0); - ASSERT(len <= DMU_MAX_ACCESS); + ASSERT0(tx->tx_txg); + ASSERT3U(len, <=, DMU_MAX_ACCESS); ASSERT(len == 0 || UINT64_MAX - off >= len - 1); txh = dmu_tx_hold_object_impl(tx, tx->tx_objset, object, THT_WRITE, off, len); - if (txh == NULL) - return; - - dmu_tx_count_write(txh, off, len); - dmu_tx_count_dnode(txh); + if (txh != NULL) { + dmu_tx_count_write(txh, off, len); + dmu_tx_count_dnode(txh); + } } void @@ -480,16 +479,15 @@ dmu_tx_hold_write_by_dnode(dmu_tx_t *tx, dnode_t *dn, uint64_t off, int len) { dmu_tx_hold_t *txh; - ASSERT(tx->tx_txg == 0); - ASSERT(len <= DMU_MAX_ACCESS); + ASSERT0(tx->tx_txg); + ASSERT3U(len, <=, DMU_MAX_ACCESS); ASSERT(len == 0 || UINT64_MAX - off >= len - 1); txh = dmu_tx_hold_dnode_impl(tx, dn, THT_WRITE, off, len); - if (txh == NULL) - return; - - dmu_tx_count_write(txh, off, len); - dmu_tx_count_dnode(txh); + if (txh != NULL) { + dmu_tx_count_write(txh, off, len); + dmu_tx_count_dnode(txh); + } } static void @@ -792,9 +790,8 @@ dmu_tx_hold_free(dmu_tx_t *tx, uint64_t object, uint64_t off, uint64_t len) txh = dmu_tx_hold_object_impl(tx, tx->tx_objset, object, THT_FREE, off, len); - if (txh == NULL) - return; - (void) dmu_tx_hold_free_impl(txh, off, len); + if (txh != NULL) + (void) dmu_tx_hold_free_impl(txh, off, len); } void @@ -803,9 +800,8 @@ dmu_tx_hold_free_by_dnode(dmu_tx_t *tx, dnode_t *dn, uint64_t off, uint64_t len) dmu_tx_hold_t *txh; txh = dmu_tx_hold_dnode_impl(tx, dn, THT_FREE, off, len); - if (txh == NULL) - return; - (void) dmu_tx_hold_free_impl(txh, off, len); + if (txh != NULL) + (void) dmu_tx_hold_free_impl(txh, off, len); } static void @@ -916,13 +912,12 @@ dmu_tx_hold_zap(dmu_tx_t *tx, uint64_t object, int add, const char *name) { dmu_tx_hold_t *txh; - ASSERT(tx->tx_txg == 0); + ASSERT0(tx->tx_txg); txh = dmu_tx_hold_object_impl(tx, tx->tx_objset, object, THT_ZAP, add, (uintptr_t)name); - if (txh == NULL) - return; - dmu_tx_hold_zap_impl(txh, add, name); + if (txh != NULL) + dmu_tx_hold_zap_impl(txh, add, name); } void @@ -930,13 +925,12 @@ dmu_tx_hold_zap_by_dnode(dmu_tx_t *tx, dnode_t *dn, int add, const char *name) { dmu_tx_hold_t *txh; - ASSERT(tx->tx_txg == 0); + ASSERT0(tx->tx_txg); ASSERT(dn != NULL); txh = dmu_tx_hold_dnode_impl(tx, dn, THT_ZAP, add, (uintptr_t)name); - if (txh == NULL) - return; - dmu_tx_hold_zap_impl(txh, add, name); + if (txh != NULL) + dmu_tx_hold_zap_impl(txh, add, name); } void @@ -957,7 +951,7 @@ dmu_tx_hold_bonus_by_dnode(dmu_tx_t *tx, dnode_t *dn) { dmu_tx_hold_t *txh; - ASSERT(tx->tx_txg == 0); + ASSERT0(tx->tx_txg); txh = dmu_tx_hold_dnode_impl(tx, dn, THT_BONUS, 0, 0); if (txh) diff --git a/module/zfs/zap_micro.c b/module/zfs/zap_micro.c index 0c8ee9d25a..53f8d2313a 100644 --- a/module/zfs/zap_micro.c +++ b/module/zfs/zap_micro.c @@ -1207,7 +1207,8 @@ zap_add_impl(zap_t *zap, const char *key, } ASSERT(zap == zn->zn_zap); zap_name_free(zn); - zap_unlockdir(zap, tag); + if (zap != NULL) /* may be NULL if fzap_add() failed */ + zap_unlockdir(zap, tag); return (err); }