mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-26 12:12:13 +03:00
Convert zio_buf_alloc() consumers
In multiple cases zio_buf_alloc() was used instead of kmem_alloc() or vmem_alloc(). This was often done because the allocations could be large and it was easy to use zfs_buf_alloc() for them. But this isn't ideal for allocations which are small or short lived. In these cases it is better to use kmem_alloc() or vmem_alloc(). If possible we want to avoid the case where we have slabs allocated for kmem caches which are rarely used. Note for small allocations vmem_alloc() will be internally converted to kmem_alloc(). Therefore as long as large allocations are infrequent and short lived the penalty for using vmem_alloc() is small. Reviewed-by: Chunwei Chen <david.chen@osnexus.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #5409
This commit is contained in:
+4
-5
@@ -1020,7 +1020,7 @@ dbuf_read_impl(dmu_buf_impl_t *db, zio_t *zio, uint32_t flags)
|
||||
int max_bonuslen = DN_SLOTS_TO_BONUSLEN(dn->dn_num_slots);
|
||||
|
||||
ASSERT3U(bonuslen, <=, db->db.db_size);
|
||||
db->db.db_data = zio_buf_alloc(max_bonuslen);
|
||||
db->db.db_data = kmem_alloc(max_bonuslen, KM_SLEEP);
|
||||
arc_space_consume(max_bonuslen, ARC_SPACE_BONUS);
|
||||
if (bonuslen < max_bonuslen)
|
||||
bzero(db->db.db_data, max_bonuslen);
|
||||
@@ -1132,10 +1132,9 @@ dbuf_fix_old_data(dmu_buf_impl_t *db, uint64_t txg)
|
||||
*/
|
||||
ASSERT(dr->dr_txg >= txg - 2);
|
||||
if (db->db_blkid == DMU_BONUS_BLKID) {
|
||||
/* Note that the data bufs here are zio_bufs */
|
||||
dnode_t *dn = DB_DNODE(db);
|
||||
int bonuslen = DN_SLOTS_TO_BONUSLEN(dn->dn_num_slots);
|
||||
dr->dt.dl.dr_data = zio_buf_alloc(bonuslen);
|
||||
dr->dt.dl.dr_data = kmem_alloc(bonuslen, KM_SLEEP);
|
||||
arc_space_consume(bonuslen, ARC_SPACE_BONUS);
|
||||
bcopy(db->db.db_data, dr->dt.dl.dr_data, bonuslen);
|
||||
} else if (refcount_count(&db->db_holds) > db->db_dirtycnt) {
|
||||
@@ -2157,7 +2156,7 @@ dbuf_destroy(dmu_buf_impl_t *db)
|
||||
int slots = DB_DNODE(db)->dn_num_slots;
|
||||
int bonuslen = DN_SLOTS_TO_BONUSLEN(slots);
|
||||
ASSERT(db->db.db_data != NULL);
|
||||
zio_buf_free(db->db.db_data, bonuslen);
|
||||
kmem_free(db->db.db_data, bonuslen);
|
||||
arc_space_return(bonuslen, ARC_SPACE_BONUS);
|
||||
db->db_state = DB_UNCACHED;
|
||||
}
|
||||
@@ -3304,7 +3303,7 @@ dbuf_sync_leaf(dbuf_dirty_record_t *dr, dmu_tx_t *tx)
|
||||
if (*datap != db->db.db_data) {
|
||||
int slots = DB_DNODE(db)->dn_num_slots;
|
||||
int bonuslen = DN_SLOTS_TO_BONUSLEN(slots);
|
||||
zio_buf_free(*datap, bonuslen);
|
||||
kmem_free(*datap, bonuslen);
|
||||
arc_space_return(bonuslen, ARC_SPACE_BONUS);
|
||||
}
|
||||
db->db_data_pending = NULL;
|
||||
|
||||
Reference in New Issue
Block a user