656 }
657 dnode_free_range(dn, chunk_begin, chunk_end - chunk_begin, tx);
658 dmu_tx_commit(tx);
659
660 length -= chunk_end - chunk_begin;
661 }
662 return (0);
663 }
664
665 int
666 dmu_free_long_range(objset_t *os, uint64_t object,
667 uint64_t offset, uint64_t length)
668 {
669 dnode_t *dn;
670 int err;
671
672 err = dnode_hold(os, object, FTAG, &dn);
673 if (err != 0)
674 return (err);
675 err = dmu_free_long_range_impl(os, dn, offset, length);
676 dnode_rele(dn, FTAG);
677 return (err);
678 }
679
680 int
681 dmu_free_long_object(objset_t *os, uint64_t object)
682 {
683 dmu_tx_t *tx;
684 int err;
685
686 err = dmu_free_long_range(os, object, 0, DMU_OBJECT_END);
687 if (err != 0)
688 return (err);
689
690 tx = dmu_tx_create(os);
691 dmu_tx_hold_bonus(tx, object);
692 dmu_tx_hold_free(tx, object, 0, DMU_OBJECT_END);
693 err = dmu_tx_assign(tx, TXG_WAIT);
694 if (err == 0) {
695 err = dmu_object_free(os, object, tx);
|
656 }
657 dnode_free_range(dn, chunk_begin, chunk_end - chunk_begin, tx);
658 dmu_tx_commit(tx);
659
660 length -= chunk_end - chunk_begin;
661 }
662 return (0);
663 }
664
665 int
666 dmu_free_long_range(objset_t *os, uint64_t object,
667 uint64_t offset, uint64_t length)
668 {
669 dnode_t *dn;
670 int err;
671
672 err = dnode_hold(os, object, FTAG, &dn);
673 if (err != 0)
674 return (err);
675 err = dmu_free_long_range_impl(os, dn, offset, length);
676
677 /*
678 * It is important to zero out the maxblkid when freeing the entire
679 * file, so that (a) subsequent calls to dmu_free_long_range_impl()
680 * will take the fast path, and (b) dnode_reallocate() can verify
681 * that the entire file has been freed.
682 */
683 if (offset == 0 && length == DMU_OBJECT_END)
684 dn->dn_maxblkid = 0;
685
686 dnode_rele(dn, FTAG);
687 return (err);
688 }
689
690 int
691 dmu_free_long_object(objset_t *os, uint64_t object)
692 {
693 dmu_tx_t *tx;
694 int err;
695
696 err = dmu_free_long_range(os, object, 0, DMU_OBJECT_END);
697 if (err != 0)
698 return (err);
699
700 tx = dmu_tx_create(os);
701 dmu_tx_hold_bonus(tx, object);
702 dmu_tx_hold_free(tx, object, 0, DMU_OBJECT_END);
703 err = dmu_tx_assign(tx, TXG_WAIT);
704 if (err == 0) {
705 err = dmu_object_free(os, object, tx);
|