Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions include/sys/dbuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,8 @@ uint64_t dbuf_whichblock(const struct dnode *di, const int64_t level,
const uint64_t offset);

void dbuf_create_bonus(struct dnode *dn);
int dbuf_spill_set_blksz(dmu_buf_t *db, uint64_t blksz, dmu_tx_t *tx);
int dbuf_spill_set_blksz(dmu_buf_t *db, uint64_t blksz, boolean_t copy,
dmu_tx_t *tx);

void dbuf_rm_spill(struct dnode *dn, dmu_tx_t *tx);

Expand Down Expand Up @@ -414,7 +415,7 @@ void dbuf_free_range(struct dnode *dn, uint64_t start, uint64_t end,
void dbuf_evict_range(struct dnode *dn, uint64_t start_blkid,
uint64_t end_blkid);

void dbuf_new_size(dmu_buf_impl_t *db, int size, dmu_tx_t *tx);
void dbuf_new_size(dmu_buf_impl_t *db, int size, boolean_t copy, dmu_tx_t *tx);

void dbuf_stats_init(dbuf_hash_table_t *hash);
void dbuf_stats_destroy(void);
Expand Down
20 changes: 12 additions & 8 deletions module/zfs/dbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -2149,7 +2149,7 @@ dbuf_evict_range(dnode_t *dn, uint64_t start_blkid, uint64_t end_blkid)
}

void
dbuf_new_size(dmu_buf_impl_t *db, int size, dmu_tx_t *tx)
dbuf_new_size(dmu_buf_impl_t *db, int size, boolean_t copy, dmu_tx_t *tx)
{
arc_buf_t *buf, *old_buf;
dbuf_dirty_record_t *dr;
Expand All @@ -2173,12 +2173,15 @@ dbuf_new_size(dmu_buf_impl_t *db, int size, dmu_tx_t *tx)
/* create the data buffer for the new block */
buf = arc_alloc_buf(dn->dn_objset->os_spa, db, type, size);

/* copy old block data to the new block */
old_buf = db->db_buf;
memcpy(buf->b_data, old_buf->b_data, MIN(osize, size));
/* zero the remainder */
if (size > osize)
memset((uint8_t *)buf->b_data + osize, 0, size - osize);
if (copy) {
ASSERT(arc_get_compression(old_buf) == ZIO_COMPRESS_OFF);
/* copy old block data to the new block */
memcpy(buf->b_data, old_buf->b_data, MIN(osize, size));
/* zero the remainder */
if (size > osize)
memset((uint8_t *)buf->b_data + osize, 0, size - osize);
}

mutex_enter(&db->db_mtx);
dbuf_set_data(db, buf);
Expand Down Expand Up @@ -4129,7 +4132,8 @@ dbuf_create_bonus(dnode_t *dn)
}

int
dbuf_spill_set_blksz(dmu_buf_t *db_fake, uint64_t blksz, dmu_tx_t *tx)
dbuf_spill_set_blksz(dmu_buf_t *db_fake, uint64_t blksz, boolean_t copy,
dmu_tx_t *tx)
{
dmu_buf_impl_t *db = (dmu_buf_impl_t *)db_fake;

Expand All @@ -4140,7 +4144,7 @@ dbuf_spill_set_blksz(dmu_buf_t *db_fake, uint64_t blksz, dmu_tx_t *tx)
ASSERT3U(blksz, <=, spa_maxblocksize(dmu_objset_spa(db->db_objset)));
blksz = P2ROUNDUP(blksz, SPA_MINBLOCKSIZE);

dbuf_new_size(db, blksz, tx);
dbuf_new_size(db, blksz, copy, tx);

return (0);
}
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/dmu_recv.c
Original file line number Diff line number Diff line change
Expand Up @@ -3521,7 +3521,7 @@ receive_spill(struct receive_writer_arg *rwa, struct drr_spill *drrs,
if (db_spill->db_size != drrs->drr_length) {
dmu_buf_will_fill(db_spill, tx, B_FALSE);
VERIFY0(dbuf_spill_set_blksz(db_spill,
drrs->drr_length, tx));
drrs->drr_length, B_FALSE, tx));
}

arc_buf_t *abuf;
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/dnode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1978,7 +1978,7 @@ dnode_set_blksz(dnode_t *dn, uint64_t size, int ibs, dmu_tx_t *tx)
/* resize the old block */
err = dbuf_hold_impl(dn, 0, 0, TRUE, FALSE, FTAG, &db);
if (err == 0) {
dbuf_new_size(db, size, tx);
dbuf_new_size(db, size, B_TRUE, tx);
} else if (err != ENOENT) {
goto fail;
}
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/dsl_bookmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ dsl_bookmark_create_sync_impl_snap(const char *bookmark, const char *snapshot,
DB_RF_MUST_SUCCEED, tag, &db));
dmu_buf_will_fill(db, tx, B_FALSE);
VERIFY0(dbuf_spill_set_blksz(db, P2ROUNDUP(bonuslen,
SPA_MINBLOCKSIZE), tx));
SPA_MINBLOCKSIZE), B_TRUE, tx));
local_rl->rl_phys = db->db_data;
local_rl->rl_dbuf = db;
}
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/sa.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ sa_resize_spill(sa_handle_t *hdl, uint32_t size, dmu_tx_t *tx)
blocksize = P2ROUNDUP_TYPED(size, SPA_MINBLOCKSIZE, uint32_t);
}

error = dbuf_spill_set_blksz(hdl->sa_spill, blocksize, tx);
error = dbuf_spill_set_blksz(hdl->sa_spill, blocksize, B_TRUE, tx);
ASSERT0(error);
return (error);
}
Expand Down
Loading