mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2025-04-06 17:49:11 +03:00
Code cleanups
- Allocate ve_search on the stack, so we avoid allocating memory for every I/O even if the VDEV cache is disabled. - Reduce lock scope. - Avoid locking in vdev_cache_read() when the VDEV cache is disabled. - Sort file names properly. - Correct comment. Reviewed-by: Allan Jude <allan@klarasystems.com> Reviewed-by: Ryan Moeller <ryan@iXsystems.com> Reviewed-by: Matthew Ahrens <mahrens@delphix.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Pawel Jakub Dawidek <pawel@dawidek.net> Closes #12749
This commit is contained in:
parent
cfc62062ae
commit
547df81641
@ -58,8 +58,8 @@ KERNEL_C = \
|
|||||||
bplist.c \
|
bplist.c \
|
||||||
bpobj.c \
|
bpobj.c \
|
||||||
bptree.c \
|
bptree.c \
|
||||||
btree.c \
|
|
||||||
bqueue.c \
|
bqueue.c \
|
||||||
|
btree.c \
|
||||||
cityhash.c \
|
cityhash.c \
|
||||||
dbuf.c \
|
dbuf.c \
|
||||||
dbuf_stats.c \
|
dbuf_stats.c \
|
||||||
@ -78,23 +78,23 @@ KERNEL_C = \
|
|||||||
dnode.c \
|
dnode.c \
|
||||||
dnode_sync.c \
|
dnode_sync.c \
|
||||||
dsl_bookmark.c \
|
dsl_bookmark.c \
|
||||||
|
dsl_crypt.c \
|
||||||
dsl_dataset.c \
|
dsl_dataset.c \
|
||||||
dsl_deadlist.c \
|
dsl_deadlist.c \
|
||||||
dsl_deleg.c \
|
dsl_deleg.c \
|
||||||
|
dsl_destroy.c \
|
||||||
dsl_dir.c \
|
dsl_dir.c \
|
||||||
dsl_crypt.c \
|
|
||||||
dsl_pool.c \
|
dsl_pool.c \
|
||||||
dsl_prop.c \
|
dsl_prop.c \
|
||||||
dsl_scan.c \
|
dsl_scan.c \
|
||||||
dsl_synctask.c \
|
dsl_synctask.c \
|
||||||
dsl_destroy.c \
|
|
||||||
dsl_userhold.c \
|
dsl_userhold.c \
|
||||||
edonr_zfs.c \
|
edonr_zfs.c \
|
||||||
hkdf.c \
|
|
||||||
fm.c \
|
fm.c \
|
||||||
gzip.c \
|
gzip.c \
|
||||||
lzjb.c \
|
hkdf.c \
|
||||||
lz4.c \
|
lz4.c \
|
||||||
|
lzjb.c \
|
||||||
metaslab.c \
|
metaslab.c \
|
||||||
mmp.c \
|
mmp.c \
|
||||||
multilist.c \
|
multilist.c \
|
||||||
@ -117,8 +117,8 @@ KERNEL_C = \
|
|||||||
spa_stats.c \
|
spa_stats.c \
|
||||||
space_map.c \
|
space_map.c \
|
||||||
space_reftree.c \
|
space_reftree.c \
|
||||||
txg.c \
|
|
||||||
trace.c \
|
trace.c \
|
||||||
|
txg.c \
|
||||||
uberblock.c \
|
uberblock.c \
|
||||||
unique.c \
|
unique.c \
|
||||||
vdev.c \
|
vdev.c \
|
||||||
@ -126,8 +126,8 @@ KERNEL_C = \
|
|||||||
vdev_draid.c \
|
vdev_draid.c \
|
||||||
vdev_draid_rand.c \
|
vdev_draid_rand.c \
|
||||||
vdev_file.c \
|
vdev_file.c \
|
||||||
vdev_indirect_births.c \
|
|
||||||
vdev_indirect.c \
|
vdev_indirect.c \
|
||||||
|
vdev_indirect_births.c \
|
||||||
vdev_indirect_mapping.c \
|
vdev_indirect_mapping.c \
|
||||||
vdev_initialize.c \
|
vdev_initialize.c \
|
||||||
vdev_label.c \
|
vdev_label.c \
|
||||||
@ -135,16 +135,16 @@ KERNEL_C = \
|
|||||||
vdev_missing.c \
|
vdev_missing.c \
|
||||||
vdev_queue.c \
|
vdev_queue.c \
|
||||||
vdev_raidz.c \
|
vdev_raidz.c \
|
||||||
|
vdev_raidz_math.c \
|
||||||
vdev_raidz_math_aarch64_neon.c \
|
vdev_raidz_math_aarch64_neon.c \
|
||||||
vdev_raidz_math_aarch64_neonx2.c \
|
vdev_raidz_math_aarch64_neonx2.c \
|
||||||
vdev_raidz_math_avx2.c \
|
vdev_raidz_math_avx2.c \
|
||||||
vdev_raidz_math_avx512bw.c \
|
vdev_raidz_math_avx512bw.c \
|
||||||
vdev_raidz_math_avx512f.c \
|
vdev_raidz_math_avx512f.c \
|
||||||
vdev_raidz_math.c \
|
vdev_raidz_math_powerpc_altivec.c \
|
||||||
vdev_raidz_math_scalar.c \
|
vdev_raidz_math_scalar.c \
|
||||||
vdev_raidz_math_sse2.c \
|
vdev_raidz_math_sse2.c \
|
||||||
vdev_raidz_math_ssse3.c \
|
vdev_raidz_math_ssse3.c \
|
||||||
vdev_raidz_math_powerpc_altivec.c \
|
|
||||||
vdev_rebuild.c \
|
vdev_rebuild.c \
|
||||||
vdev_removal.c \
|
vdev_removal.c \
|
||||||
vdev_root.c \
|
vdev_root.c \
|
||||||
@ -165,9 +165,9 @@ KERNEL_C = \
|
|||||||
zfs_fuid.c \
|
zfs_fuid.c \
|
||||||
zfs_racct.c \
|
zfs_racct.c \
|
||||||
zfs_sa.c \
|
zfs_sa.c \
|
||||||
zfs_znode.c \
|
|
||||||
zfs_ratelimit.c \
|
zfs_ratelimit.c \
|
||||||
zfs_rlock.c \
|
zfs_rlock.c \
|
||||||
|
zfs_znode.c \
|
||||||
zil.c \
|
zil.c \
|
||||||
zio.c \
|
zio.c \
|
||||||
zio_checksum.c \
|
zio_checksum.c \
|
||||||
|
@ -268,12 +268,12 @@ SRCS+= abd.c \
|
|||||||
vdev_raidz.c \
|
vdev_raidz.c \
|
||||||
vdev_raidz_math.c \
|
vdev_raidz_math.c \
|
||||||
vdev_raidz_math_scalar.c \
|
vdev_raidz_math_scalar.c \
|
||||||
vdev_rebuild.c \
|
|
||||||
vdev_raidz_math_avx2.c \
|
vdev_raidz_math_avx2.c \
|
||||||
vdev_raidz_math_avx512bw.c \
|
vdev_raidz_math_avx512bw.c \
|
||||||
vdev_raidz_math_avx512f.c \
|
vdev_raidz_math_avx512f.c \
|
||||||
vdev_raidz_math_sse2.c \
|
vdev_raidz_math_sse2.c \
|
||||||
vdev_raidz_math_ssse3.c \
|
vdev_raidz_math_ssse3.c \
|
||||||
|
vdev_rebuild.c \
|
||||||
vdev_removal.c \
|
vdev_removal.c \
|
||||||
vdev_root.c \
|
vdev_root.c \
|
||||||
vdev_trim.c \
|
vdev_trim.c \
|
||||||
|
@ -1997,8 +1997,8 @@ dbuf_free_range(dnode_t *dn, uint64_t start_blkid, uint64_t end_blkid,
|
|||||||
mutex_exit(&db->db_mtx);
|
mutex_exit(&db->db_mtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
kmem_free(db_search, sizeof (dmu_buf_impl_t));
|
|
||||||
mutex_exit(&dn->dn_dbufs_mtx);
|
mutex_exit(&dn->dn_dbufs_mtx);
|
||||||
|
kmem_free(db_search, sizeof (dmu_buf_impl_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -251,13 +251,16 @@ boolean_t
|
|||||||
vdev_cache_read(zio_t *zio)
|
vdev_cache_read(zio_t *zio)
|
||||||
{
|
{
|
||||||
vdev_cache_t *vc = &zio->io_vd->vdev_cache;
|
vdev_cache_t *vc = &zio->io_vd->vdev_cache;
|
||||||
vdev_cache_entry_t *ve, *ve_search;
|
vdev_cache_entry_t *ve, ve_search;
|
||||||
uint64_t cache_offset = P2ALIGN(zio->io_offset, VCBS);
|
uint64_t cache_offset = P2ALIGN(zio->io_offset, VCBS);
|
||||||
zio_t *fio;
|
zio_t *fio;
|
||||||
uint64_t cache_phase __maybe_unused = P2PHASE(zio->io_offset, VCBS);
|
uint64_t cache_phase __maybe_unused = P2PHASE(zio->io_offset, VCBS);
|
||||||
|
|
||||||
ASSERT3U(zio->io_type, ==, ZIO_TYPE_READ);
|
ASSERT3U(zio->io_type, ==, ZIO_TYPE_READ);
|
||||||
|
|
||||||
|
if (zfs_vdev_cache_size == 0)
|
||||||
|
return (B_FALSE);
|
||||||
|
|
||||||
if (zio->io_flags & ZIO_FLAG_DONT_CACHE)
|
if (zio->io_flags & ZIO_FLAG_DONT_CACHE)
|
||||||
return (B_FALSE);
|
return (B_FALSE);
|
||||||
|
|
||||||
@ -274,10 +277,8 @@ vdev_cache_read(zio_t *zio)
|
|||||||
|
|
||||||
mutex_enter(&vc->vc_lock);
|
mutex_enter(&vc->vc_lock);
|
||||||
|
|
||||||
ve_search = kmem_alloc(sizeof (vdev_cache_entry_t), KM_SLEEP);
|
ve_search.ve_offset = cache_offset;
|
||||||
ve_search->ve_offset = cache_offset;
|
ve = avl_find(&vc->vc_offset_tree, &ve_search, NULL);
|
||||||
ve = avl_find(&vc->vc_offset_tree, ve_search, NULL);
|
|
||||||
kmem_free(ve_search, sizeof (vdev_cache_entry_t));
|
|
||||||
|
|
||||||
if (ve != NULL) {
|
if (ve != NULL) {
|
||||||
if (ve->ve_missed_update) {
|
if (ve->ve_missed_update) {
|
||||||
|
@ -408,7 +408,7 @@ vdev_queue_class_max_active(spa_t *spa, vdev_queue_t *vq, zio_priority_t p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return the i/o class to issue from, or ZIO_PRIORITY_MAX_QUEUEABLE if
|
* Return the i/o class to issue from, or ZIO_PRIORITY_NUM_QUEUEABLE if
|
||||||
* there is no eligible class.
|
* there is no eligible class.
|
||||||
*/
|
*/
|
||||||
static zio_priority_t
|
static zio_priority_t
|
||||||
|
Loading…
Reference in New Issue
Block a user