# HG changeset patch # User Matthew Ahrens # Date 1377854375 28800 # Node ID be36a38bac3d032c7ea2748b481c01fd39c0dc17 # Parent 98413c8cf54d97e8c8b1ae68054ff771d6e44cf8 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 diff -r 98413c8cf54d -r be36a38bac3d usr/src/uts/common/fs/zfs/dmu.c --- a/usr/src/uts/common/fs/zfs/dmu.c Thu Aug 29 10:56:49 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/dmu.c Fri Aug 30 01:19:35 2013 -0800 @@ -673,6 +673,16 @@ 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 -r 98413c8cf54d -r be36a38bac3d usr/src/uts/common/fs/zfs/dmu_tx.c --- a/usr/src/uts/common/fs/zfs/dmu_tx.c Thu Aug 29 10:56:49 2013 -0800 +++ b/usr/src/uts/common/fs/zfs/dmu_tx.c Fri Aug 30 01:19:35 2013 -0800 @@ -605,7 +605,6 @@ if (len == DMU_OBJECT_END) len = (dn->dn_maxblkid+1) * dn->dn_datablksz - off; - /* * For i/o error checking, we read the first and last level-0 * blocks if they are not aligned, and all the level-1 blocks. @@ -617,7 +616,7 @@ */ 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))