]> git.proxmox.com Git - mirror_zfs-debian.git/blobdiff - module/zfs/dbuf.c
Imported Upstream version 0.6.5.8
[mirror_zfs-debian.git] / module / zfs / dbuf.c
index d340da821fc50f0e65bf34acea66383b0be42804..483067cc7ba45101c4b497d1bd131816c7270c4f 100644 (file)
@@ -2628,6 +2628,22 @@ dbuf_sync_leaf(dbuf_dirty_record_t *dr, dmu_tx_t *tx)
 
        if (db->db_blkid == DMU_SPILL_BLKID) {
                mutex_enter(&dn->dn_mtx);
+               if (!(dn->dn_phys->dn_flags & DNODE_FLAG_SPILL_BLKPTR)) {
+                       /*
+                        * In the previous transaction group, the bonus buffer
+                        * was entirely used to store the attributes for the
+                        * dnode which overrode the dn_spill field.  However,
+                        * when adding more attributes to the file a spill
+                        * block was required to hold the extra attributes.
+                        *
+                        * Make sure to clear the garbage left in the dn_spill
+                        * field from the previous attributes in the bonus
+                        * buffer.  Otherwise, after writing out the spill
+                        * block to the new allocated dva, it will free
+                        * the old block pointed to by the invalid dn_spill.
+                        */
+                       db->db_blkptr = NULL;
+               }
                dn->dn_phys->dn_flags |= DNODE_FLAG_SPILL_BLKPTR;
                mutex_exit(&dn->dn_mtx);
        }