summaryrefslogtreecommitdiffstats
path: root/module/zfs
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2016-11-30 16:18:20 -0700
committerGitHub <[email protected]>2016-11-30 16:18:20 -0700
commita3fd9d9e1525d5df18b7f8c2895270689d292ec2 (patch)
treefb38211398d59ccbd9376b2e3aa52924af133255 /module/zfs
parent7657defc48b7c47a8bf0c8f21c78783d293dc5ed (diff)
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 <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #5409
Diffstat (limited to 'module/zfs')
-rw-r--r--module/zfs/dbuf.c9
-rw-r--r--module/zfs/sa.c4
-rw-r--r--module/zfs/space_map.c8
-rw-r--r--module/zfs/zap_micro.c6
-rw-r--r--module/zfs/zfs_sa.c8
5 files changed, 17 insertions, 18 deletions
diff --git a/module/zfs/dbuf.c b/module/zfs/dbuf.c
index 6e7a5a0fb..f7857134c 100644
--- a/module/zfs/dbuf.c
+++ b/module/zfs/dbuf.c
@@ -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;
diff --git a/module/zfs/sa.c b/module/zfs/sa.c
index 0df3b4755..d4f412c2a 100644
--- a/module/zfs/sa.c
+++ b/module/zfs/sa.c
@@ -1690,7 +1690,7 @@ sa_modify_attrs(sa_handle_t *hdl, sa_attr_type_t newattr,
if ((error = sa_get_spill(hdl)) == 0) {
spill_data_size = hdl->sa_spill->db_size;
- old_data[1] = zio_buf_alloc(spill_data_size);
+ old_data[1] = vmem_alloc(spill_data_size, KM_SLEEP);
bcopy(hdl->sa_spill->db_data, old_data[1],
hdl->sa_spill->db_size);
spill_attr_count =
@@ -1773,7 +1773,7 @@ sa_modify_attrs(sa_handle_t *hdl, sa_attr_type_t newattr,
if (old_data[0])
kmem_free(old_data[0], bonus_data_size);
if (old_data[1])
- zio_buf_free(old_data[1], spill_data_size);
+ vmem_free(old_data[1], spill_data_size);
kmem_free(attr_desc, sizeof (sa_bulk_attr_t) * attr_count);
return (error);
diff --git a/module/zfs/space_map.c b/module/zfs/space_map.c
index 126fd6bee..87e90f219 100644
--- a/module/zfs/space_map.c
+++ b/module/zfs/space_map.c
@@ -72,7 +72,7 @@ space_map_load(space_map_t *sm, range_tree_t *rt, maptype_t maptype)
}
bufsize = MAX(sm->sm_blksz, SPA_MINBLOCKSIZE);
- entry_map = zio_buf_alloc(bufsize);
+ entry_map = vmem_alloc(bufsize, KM_SLEEP);
mutex_exit(sm->sm_lock);
if (end > bufsize) {
@@ -128,7 +128,7 @@ space_map_load(space_map_t *sm, range_tree_t *rt, maptype_t maptype)
else
range_tree_vacate(rt, NULL, NULL);
- zio_buf_free(entry_map, bufsize);
+ vmem_free(entry_map, bufsize);
return (error);
}
@@ -272,7 +272,7 @@ space_map_write(space_map_t *sm, range_tree_t *rt, maptype_t maptype,
expected_entries = space_map_entries(sm, rt);
- entry_map = zio_buf_alloc(sm->sm_blksz);
+ entry_map = vmem_alloc(sm->sm_blksz, KM_SLEEP);
entry_map_end = entry_map + (sm->sm_blksz / sizeof (uint64_t));
entry = entry_map;
@@ -335,7 +335,7 @@ space_map_write(space_map_t *sm, range_tree_t *rt, maptype_t maptype,
VERIFY3U(range_tree_space(rt), ==, rt_space);
VERIFY3U(range_tree_space(rt), ==, total);
- zio_buf_free(entry_map, sm->sm_blksz);
+ vmem_free(entry_map, sm->sm_blksz);
}
static int
diff --git a/module/zfs/zap_micro.c b/module/zfs/zap_micro.c
index a15e22c5b..131c33e29 100644
--- a/module/zfs/zap_micro.c
+++ b/module/zfs/zap_micro.c
@@ -584,7 +584,7 @@ mzap_upgrade(zap_t **zapp, void *tag, dmu_tx_t *tx, zap_flags_t flags)
ASSERT(RW_WRITE_HELD(&zap->zap_rwlock));
sz = zap->zap_dbuf->db_size;
- mzp = zio_buf_alloc(sz);
+ mzp = vmem_alloc(sz, KM_SLEEP);
bcopy(zap->zap_dbuf->db_data, mzp, sz);
nchunks = zap->zap_m.zap_num_chunks;
@@ -592,7 +592,7 @@ mzap_upgrade(zap_t **zapp, void *tag, dmu_tx_t *tx, zap_flags_t flags)
err = dmu_object_set_blocksize(zap->zap_objset, zap->zap_object,
1ULL << fzap_default_block_shift, 0, tx);
if (err) {
- zio_buf_free(mzp, sz);
+ vmem_free(mzp, sz);
return (err);
}
}
@@ -619,7 +619,7 @@ mzap_upgrade(zap_t **zapp, void *tag, dmu_tx_t *tx, zap_flags_t flags)
if (err)
break;
}
- zio_buf_free(mzp, sz);
+ vmem_free(mzp, sz);
*zapp = zap;
return (err);
}
diff --git a/module/zfs/zfs_sa.c b/module/zfs/zfs_sa.c
index 33b767808..e32786902 100644
--- a/module/zfs/zfs_sa.c
+++ b/module/zfs/zfs_sa.c
@@ -203,13 +203,13 @@ zfs_sa_get_xattr(znode_t *zp)
return (error);
}
- obj = zio_buf_alloc(size);
+ obj = vmem_alloc(size, KM_SLEEP);
error = sa_lookup(zp->z_sa_hdl, SA_ZPL_DXATTR(zsb), obj, size);
if (error == 0)
error = nvlist_unpack(obj, size, &zp->z_xattr_cached, KM_SLEEP);
- zio_buf_free(obj, size);
+ vmem_free(obj, size);
return (error);
}
@@ -233,7 +233,7 @@ zfs_sa_set_xattr(znode_t *zp)
if (error)
goto out;
- obj = zio_buf_alloc(size);
+ obj = vmem_alloc(size, KM_SLEEP);
error = nvlist_pack(zp->z_xattr_cached, &obj, &size,
NV_ENCODE_XDR, KM_SLEEP);
@@ -253,7 +253,7 @@ zfs_sa_set_xattr(znode_t *zp)
dmu_tx_commit(tx);
}
out_free:
- zio_buf_free(obj, size);
+ vmem_free(obj, size);
out:
return (error);
}