From 92bc214c2e00bd4a430eac1629f1bcf2fc590d51 Mon Sep 17 00:00:00 2001 From: Matthew Ahrens Date: Fri, 30 Aug 2013 01:19:35 -0800 Subject: [PATCH] Illumos #4082 4082 zfs receive gets EFBIG from dmu_tx_hold_free() Reviewed by: Eric Schrock Reviewed by: Christopher Siden Reviewed by: George Wilson Approved by: Richard Lowe References: https://www.illumos.org/issues/4082 illumos/illumos-gate@5253393b09789ec67bec153b866d7285a1cf1645 Ported-by: Richard Yao Signed-off-by: Brian Behlendorf Issue #1775 --- module/zfs/dmu.c | 10 ++++++++++ module/zfs/dmu_tx.c | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/module/zfs/dmu.c b/module/zfs/dmu.c index 1136e1d70..72fce35c5 100644 --- a/module/zfs/dmu.c +++ b/module/zfs/dmu.c @@ -672,6 +672,16 @@ dmu_free_long_range(objset_t *os, uint64_t object, if (err != 0) return (err); err = dmu_free_long_range_impl(os, dn, offset, length); + + /* + * It is important to zero out the maxblkid when freeing the entire + * file, so that (a) subsequent calls to dmu_free_long_range_impl() + * will take the fast path, and (b) dnode_reallocate() can verify + * that the entire file has been freed. + */ + if (offset == 0 && length == DMU_OBJECT_END) + dn->dn_maxblkid = 0; + dnode_rele(dn, FTAG); return (err); } diff --git a/module/zfs/dmu_tx.c b/module/zfs/dmu_tx.c index 1fe1099a8..ece6b14b3 100644 --- a/module/zfs/dmu_tx.c +++ b/module/zfs/dmu_tx.c @@ -633,7 +633,7 @@ dmu_tx_hold_free(dmu_tx_t *tx, uint64_t object, uint64_t off, uint64_t len) */ if (dn->dn_datablkshift == 0) { if (off != 0 || len < dn->dn_datablksz) - dmu_tx_count_write(txh, off, len); + dmu_tx_count_write(txh, 0, dn->dn_datablksz); } else { /* first block will be modified if it is not aligned */ if (!IS_P2ALIGNED(off, 1 << dn->dn_datablkshift)) -- 2.40.0