Optimize the is_l2cacheable functions
by placing the most common use case (no special vdevs) first and avoid allocating new variables. Reviewed-by: Alexander Motin <mav@FreeBSD.org> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: George Amanakis <gamanakis@gmail.com> Closes #14494 Closes #14563
This commit is contained in:
parent
9d2e5c14b2
commit
231a37c4c0
|
@ -602,58 +602,58 @@ dbuf_is_metadata(dmu_buf_impl_t *db)
|
||||||
boolean_t
|
boolean_t
|
||||||
dbuf_is_l2cacheable(dmu_buf_impl_t *db)
|
dbuf_is_l2cacheable(dmu_buf_impl_t *db)
|
||||||
{
|
{
|
||||||
vdev_t *vd = NULL;
|
if (db->db_objset->os_secondary_cache == ZFS_CACHE_ALL ||
|
||||||
zfs_cache_type_t cache = db->db_objset->os_secondary_cache;
|
(db->db_objset->os_secondary_cache ==
|
||||||
blkptr_t *bp = db->db_blkptr;
|
ZFS_CACHE_METADATA && dbuf_is_metadata(db))) {
|
||||||
|
if (l2arc_exclude_special == 0)
|
||||||
|
return (B_TRUE);
|
||||||
|
|
||||||
if (bp != NULL && !BP_IS_HOLE(bp)) {
|
blkptr_t *bp = db->db_blkptr;
|
||||||
|
if (bp == NULL || BP_IS_HOLE(bp))
|
||||||
|
return (B_FALSE);
|
||||||
uint64_t vdev = DVA_GET_VDEV(bp->blk_dva);
|
uint64_t vdev = DVA_GET_VDEV(bp->blk_dva);
|
||||||
vdev_t *rvd = db->db_objset->os_spa->spa_root_vdev;
|
vdev_t *rvd = db->db_objset->os_spa->spa_root_vdev;
|
||||||
|
vdev_t *vd = NULL;
|
||||||
|
|
||||||
if (vdev < rvd->vdev_children)
|
if (vdev < rvd->vdev_children)
|
||||||
vd = rvd->vdev_child[vdev];
|
vd = rvd->vdev_child[vdev];
|
||||||
|
|
||||||
if (cache == ZFS_CACHE_ALL ||
|
if (vd == NULL)
|
||||||
(dbuf_is_metadata(db) && cache == ZFS_CACHE_METADATA)) {
|
return (B_TRUE);
|
||||||
if (vd == NULL)
|
|
||||||
return (B_TRUE);
|
|
||||||
|
|
||||||
if ((vd->vdev_alloc_bias != VDEV_BIAS_SPECIAL &&
|
if (vd->vdev_alloc_bias != VDEV_BIAS_SPECIAL &&
|
||||||
vd->vdev_alloc_bias != VDEV_BIAS_DEDUP) ||
|
vd->vdev_alloc_bias != VDEV_BIAS_DEDUP)
|
||||||
l2arc_exclude_special == 0)
|
return (B_TRUE);
|
||||||
return (B_TRUE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (B_FALSE);
|
return (B_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline boolean_t
|
static inline boolean_t
|
||||||
dnode_level_is_l2cacheable(blkptr_t *bp, dnode_t *dn, int64_t level)
|
dnode_level_is_l2cacheable(blkptr_t *bp, dnode_t *dn, int64_t level)
|
||||||
{
|
{
|
||||||
vdev_t *vd = NULL;
|
if (dn->dn_objset->os_secondary_cache == ZFS_CACHE_ALL ||
|
||||||
zfs_cache_type_t cache = dn->dn_objset->os_secondary_cache;
|
(dn->dn_objset->os_secondary_cache == ZFS_CACHE_METADATA &&
|
||||||
|
(level > 0 ||
|
||||||
|
DMU_OT_IS_METADATA(dn->dn_handle->dnh_dnode->dn_type)))) {
|
||||||
|
if (l2arc_exclude_special == 0)
|
||||||
|
return (B_TRUE);
|
||||||
|
|
||||||
if (bp != NULL && !BP_IS_HOLE(bp)) {
|
if (bp == NULL || BP_IS_HOLE(bp))
|
||||||
|
return (B_FALSE);
|
||||||
uint64_t vdev = DVA_GET_VDEV(bp->blk_dva);
|
uint64_t vdev = DVA_GET_VDEV(bp->blk_dva);
|
||||||
vdev_t *rvd = dn->dn_objset->os_spa->spa_root_vdev;
|
vdev_t *rvd = dn->dn_objset->os_spa->spa_root_vdev;
|
||||||
|
vdev_t *vd = NULL;
|
||||||
|
|
||||||
if (vdev < rvd->vdev_children)
|
if (vdev < rvd->vdev_children)
|
||||||
vd = rvd->vdev_child[vdev];
|
vd = rvd->vdev_child[vdev];
|
||||||
|
|
||||||
if (cache == ZFS_CACHE_ALL || ((level > 0 ||
|
if (vd == NULL)
|
||||||
DMU_OT_IS_METADATA(dn->dn_handle->dnh_dnode->dn_type)) &&
|
return (B_TRUE);
|
||||||
cache == ZFS_CACHE_METADATA)) {
|
|
||||||
if (vd == NULL)
|
|
||||||
return (B_TRUE);
|
|
||||||
|
|
||||||
if ((vd->vdev_alloc_bias != VDEV_BIAS_SPECIAL &&
|
if (vd->vdev_alloc_bias != VDEV_BIAS_SPECIAL &&
|
||||||
vd->vdev_alloc_bias != VDEV_BIAS_DEDUP) ||
|
vd->vdev_alloc_bias != VDEV_BIAS_DEDUP)
|
||||||
l2arc_exclude_special == 0)
|
return (B_TRUE);
|
||||||
return (B_TRUE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (B_FALSE);
|
return (B_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -419,28 +419,28 @@ dnode_multilist_index_func(multilist_t *ml, void *obj)
|
||||||
static inline boolean_t
|
static inline boolean_t
|
||||||
dmu_os_is_l2cacheable(objset_t *os)
|
dmu_os_is_l2cacheable(objset_t *os)
|
||||||
{
|
{
|
||||||
vdev_t *vd = NULL;
|
if (os->os_secondary_cache == ZFS_CACHE_ALL ||
|
||||||
zfs_cache_type_t cache = os->os_secondary_cache;
|
os->os_secondary_cache == ZFS_CACHE_METADATA) {
|
||||||
blkptr_t *bp = os->os_rootbp;
|
if (l2arc_exclude_special == 0)
|
||||||
|
return (B_TRUE);
|
||||||
|
|
||||||
if (bp != NULL && !BP_IS_HOLE(bp)) {
|
blkptr_t *bp = os->os_rootbp;
|
||||||
|
if (bp == NULL || BP_IS_HOLE(bp))
|
||||||
|
return (B_FALSE);
|
||||||
uint64_t vdev = DVA_GET_VDEV(bp->blk_dva);
|
uint64_t vdev = DVA_GET_VDEV(bp->blk_dva);
|
||||||
vdev_t *rvd = os->os_spa->spa_root_vdev;
|
vdev_t *rvd = os->os_spa->spa_root_vdev;
|
||||||
|
vdev_t *vd = NULL;
|
||||||
|
|
||||||
if (vdev < rvd->vdev_children)
|
if (vdev < rvd->vdev_children)
|
||||||
vd = rvd->vdev_child[vdev];
|
vd = rvd->vdev_child[vdev];
|
||||||
|
|
||||||
if (cache == ZFS_CACHE_ALL || cache == ZFS_CACHE_METADATA) {
|
if (vd == NULL)
|
||||||
if (vd == NULL)
|
return (B_TRUE);
|
||||||
return (B_TRUE);
|
|
||||||
|
|
||||||
if ((vd->vdev_alloc_bias != VDEV_BIAS_SPECIAL &&
|
if (vd->vdev_alloc_bias != VDEV_BIAS_SPECIAL &&
|
||||||
vd->vdev_alloc_bias != VDEV_BIAS_DEDUP) ||
|
vd->vdev_alloc_bias != VDEV_BIAS_DEDUP)
|
||||||
l2arc_exclude_special == 0)
|
return (B_TRUE);
|
||||||
return (B_TRUE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (B_FALSE);
|
return (B_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue