Skip to content

Commit 4254acb

Browse files
dweeezilbehlendorf
authored andcommitted
Undirty freed spill blocks.
If a spill block's dbuf hasn't yet been written when a spill block is freed, the unwritten version will still be written. This patch handles the case in which a spill block's dbuf is freed and undirties it to prevent it from being written. The most common case in which this could happen is when xattr=sa is being used and a long xattr is immediately replaced by a short xattr as in: setfattr -n user.test -v very_very_very..._long_value <file> setfattr -n user.test -v short_value <file> The first value must be sufficiently long that a spill block is generated and the second value must be short enough to not require a spill block. In practice, this would typically happen due to internal xattr operations as a result of setting acltype=posixacl. Signed-off-by: Tim Chase <tim@chase2k.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #2663 Closes #2700 Closes #2701 Closes #2717 Closes #2863 Closes #2884
1 parent bc9f413 commit 4254acb

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

module/zfs/dbuf.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -869,13 +869,16 @@ dbuf_free_range(dnode_t *dn, uint64_t start, uint64_t end, dmu_tx_t *tx)
869869
{
870870
dmu_buf_impl_t *db, *db_next;
871871
uint64_t txg = tx->tx_txg;
872+
boolean_t freespill =
873+
(start == DMU_SPILL_BLKID || end == DMU_SPILL_BLKID);
872874

873-
if (end > dn->dn_maxblkid && (end != DMU_SPILL_BLKID))
875+
if (end > dn->dn_maxblkid && !freespill)
874876
end = dn->dn_maxblkid;
875877
dprintf_dnode(dn, "start=%llu end=%llu\n", start, end);
876878

877879
mutex_enter(&dn->dn_dbufs_mtx);
878-
if (start >= dn->dn_unlisted_l0_blkid * dn->dn_datablksz) {
880+
if (start >= dn->dn_unlisted_l0_blkid * dn->dn_datablksz &&
881+
!freespill) {
879882
/* There can't be any dbufs in this range; no need to search. */
880883
mutex_exit(&dn->dn_dbufs_mtx);
881884
return;
@@ -896,7 +899,7 @@ dbuf_free_range(dnode_t *dn, uint64_t start, uint64_t end, dmu_tx_t *tx)
896899

897900
if (db->db_level != 0)
898901
continue;
899-
if (db->db_blkid < start || db->db_blkid > end)
902+
if ((db->db_blkid < start || db->db_blkid > end) && !freespill)
900903
continue;
901904

902905
/* found a level 0 buffer in the range */

0 commit comments

Comments
 (0)