Use list_remove_head() where possible.
... instead of list_head() + list_remove(). On FreeBSD the list functions are not inlined, so in addition to more compact code this also saves another function call. Reviewed-by: Brian Atkinson <batkinson@lanl.gov> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Alexander Motin <mav@FreeBSD.org> Sponsored by: iXsystems, Inc. Closes #14955
This commit is contained in:
parent
55b1842f92
commit
b3ad3f48d9
|
@ -369,9 +369,7 @@ zfs_agent_consumer_thread(void *arg)
|
|||
return (NULL);
|
||||
}
|
||||
|
||||
if ((event = (list_head(&agent_events))) != NULL) {
|
||||
list_remove(&agent_events, event);
|
||||
|
||||
if ((event = list_remove_head(&agent_events)) != NULL) {
|
||||
(void) pthread_mutex_unlock(&agent_lock);
|
||||
|
||||
/* dispatch to all event subscribers */
|
||||
|
@ -434,8 +432,7 @@ zfs_agent_fini(void)
|
|||
(void) pthread_join(g_agents_tid, NULL);
|
||||
|
||||
/* drain any pending events */
|
||||
while ((event = (list_head(&agent_events))) != NULL) {
|
||||
list_remove(&agent_events, event);
|
||||
while ((event = list_remove_head(&agent_events)) != NULL) {
|
||||
nvlist_free(event->ae_nvl);
|
||||
free(event);
|
||||
}
|
||||
|
|
|
@ -1288,17 +1288,14 @@ zfs_slm_fini(void)
|
|||
tpool_destroy(g_tpool);
|
||||
}
|
||||
|
||||
while ((pool = (list_head(&g_pool_list))) != NULL) {
|
||||
list_remove(&g_pool_list, pool);
|
||||
while ((pool = list_remove_head(&g_pool_list)) != NULL) {
|
||||
zpool_close(pool->uap_zhp);
|
||||
free(pool);
|
||||
}
|
||||
list_destroy(&g_pool_list);
|
||||
|
||||
while ((device = (list_head(&g_device_list))) != NULL) {
|
||||
list_remove(&g_device_list, device);
|
||||
while ((device = list_remove_head(&g_device_list)) != NULL)
|
||||
free(device);
|
||||
}
|
||||
list_destroy(&g_device_list);
|
||||
|
||||
libzfs_fini(g_zfshdl);
|
||||
|
|
|
@ -495,10 +495,8 @@ zfs_acl_release_nodes(zfs_acl_t *aclp)
|
|||
{
|
||||
zfs_acl_node_t *aclnode;
|
||||
|
||||
while ((aclnode = list_head(&aclp->z_acl))) {
|
||||
list_remove(&aclp->z_acl, aclnode);
|
||||
while ((aclnode = list_remove_head(&aclp->z_acl)))
|
||||
zfs_acl_node_free(aclnode);
|
||||
}
|
||||
aclp->z_acl_count = 0;
|
||||
aclp->z_acl_bytes = 0;
|
||||
}
|
||||
|
|
|
@ -493,10 +493,8 @@ zfs_acl_release_nodes(zfs_acl_t *aclp)
|
|||
{
|
||||
zfs_acl_node_t *aclnode;
|
||||
|
||||
while ((aclnode = list_head(&aclp->z_acl))) {
|
||||
list_remove(&aclp->z_acl, aclnode);
|
||||
while ((aclnode = list_remove_head(&aclp->z_acl)))
|
||||
zfs_acl_node_free(aclnode);
|
||||
}
|
||||
aclp->z_acl_count = 0;
|
||||
aclp->z_acl_bytes = 0;
|
||||
}
|
||||
|
|
|
@ -7866,8 +7866,7 @@ arc_fini(void)
|
|||
taskq_destroy(arc_prune_taskq);
|
||||
|
||||
mutex_enter(&arc_prune_mtx);
|
||||
while ((p = list_head(&arc_prune_list)) != NULL) {
|
||||
list_remove(&arc_prune_list, p);
|
||||
while ((p = list_remove_head(&arc_prune_list)) != NULL) {
|
||||
zfs_refcount_remove(&p->p_refcnt, &arc_prune_list);
|
||||
zfs_refcount_destroy(&p->p_refcnt);
|
||||
kmem_free(p, sizeof (*p));
|
||||
|
@ -8324,20 +8323,14 @@ out:
|
|||
static void
|
||||
l2arc_do_free_on_write(void)
|
||||
{
|
||||
list_t *buflist;
|
||||
l2arc_data_free_t *df, *df_prev;
|
||||
l2arc_data_free_t *df;
|
||||
|
||||
mutex_enter(&l2arc_free_on_write_mtx);
|
||||
buflist = l2arc_free_on_write;
|
||||
|
||||
for (df = list_tail(buflist); df; df = df_prev) {
|
||||
df_prev = list_prev(buflist, df);
|
||||
while ((df = list_remove_head(l2arc_free_on_write)) != NULL) {
|
||||
ASSERT3P(df->l2df_abd, !=, NULL);
|
||||
abd_free(df->l2df_abd);
|
||||
list_remove(buflist, df);
|
||||
kmem_free(df, sizeof (l2arc_data_free_t));
|
||||
}
|
||||
|
||||
mutex_exit(&l2arc_free_on_write_mtx);
|
||||
}
|
||||
|
||||
|
|
|
@ -65,9 +65,8 @@ bplist_iterate(bplist_t *bpl, bplist_itor_t *func, void *arg, dmu_tx_t *tx)
|
|||
bplist_entry_t *bpe;
|
||||
|
||||
mutex_enter(&bpl->bpl_lock);
|
||||
while ((bpe = list_head(&bpl->bpl_list))) {
|
||||
while ((bpe = list_remove_head(&bpl->bpl_list))) {
|
||||
bplist_iterate_last_removed = bpe;
|
||||
list_remove(&bpl->bpl_list, bpe);
|
||||
mutex_exit(&bpl->bpl_lock);
|
||||
func(arg, &bpe->bpe_blk, tx);
|
||||
kmem_free(bpe, sizeof (*bpe));
|
||||
|
@ -82,10 +81,7 @@ bplist_clear(bplist_t *bpl)
|
|||
bplist_entry_t *bpe;
|
||||
|
||||
mutex_enter(&bpl->bpl_lock);
|
||||
while ((bpe = list_head(&bpl->bpl_list))) {
|
||||
bplist_iterate_last_removed = bpe;
|
||||
list_remove(&bpl->bpl_list, bpe);
|
||||
while ((bpe = list_remove_head(&bpl->bpl_list)))
|
||||
kmem_free(bpe, sizeof (*bpe));
|
||||
}
|
||||
mutex_exit(&bpl->bpl_lock);
|
||||
}
|
||||
|
|
|
@ -1755,9 +1755,8 @@ dmu_objset_sync(objset_t *os, zio_t *pio, dmu_tx_t *tx)
|
|||
taskq_wait(dmu_objset_pool(os)->dp_sync_taskq);
|
||||
|
||||
list = &DMU_META_DNODE(os)->dn_dirty_records[txgoff];
|
||||
while ((dr = list_head(list)) != NULL) {
|
||||
while ((dr = list_remove_head(list)) != NULL) {
|
||||
ASSERT0(dr->dr_dbuf->db_level);
|
||||
list_remove(list, dr);
|
||||
zio_nowait(dr->dr_zio);
|
||||
}
|
||||
|
||||
|
|
|
@ -1396,8 +1396,7 @@ dmu_tx_do_callbacks(list_t *cb_list, int error)
|
|||
{
|
||||
dmu_tx_callback_t *dcb;
|
||||
|
||||
while ((dcb = list_tail(cb_list)) != NULL) {
|
||||
list_remove(cb_list, dcb);
|
||||
while ((dcb = list_remove_tail(cb_list)) != NULL) {
|
||||
dcb->dcb_func(dcb->dcb_data, error);
|
||||
kmem_free(dcb, sizeof (dmu_tx_callback_t));
|
||||
}
|
||||
|
|
|
@ -3782,8 +3782,7 @@ snaplist_destroy(list_t *l, const void *tag)
|
|||
if (l == NULL || !list_link_active(&l->list_head))
|
||||
return;
|
||||
|
||||
while ((snap = list_tail(l)) != NULL) {
|
||||
list_remove(l, snap);
|
||||
while ((snap = list_remove_tail(l)) != NULL) {
|
||||
dsl_dataset_rele(snap->ds, tag);
|
||||
kmem_free(snap, sizeof (*snap));
|
||||
}
|
||||
|
|
|
@ -1490,7 +1490,7 @@ dsl_dir_tempreserve_clear(void *tr_cookie, dmu_tx_t *tx)
|
|||
if (tr_cookie == NULL)
|
||||
return;
|
||||
|
||||
while ((tr = list_head(tr_list)) != NULL) {
|
||||
while ((tr = list_remove_head(tr_list)) != NULL) {
|
||||
if (tr->tr_ds) {
|
||||
mutex_enter(&tr->tr_ds->dd_lock);
|
||||
ASSERT3U(tr->tr_ds->dd_tempreserved[txgidx], >=,
|
||||
|
@ -1500,7 +1500,6 @@ dsl_dir_tempreserve_clear(void *tr_cookie, dmu_tx_t *tx)
|
|||
} else {
|
||||
arc_tempreserve_clear(tr->tr_size);
|
||||
}
|
||||
list_remove(tr_list, tr);
|
||||
kmem_free(tr, sizeof (struct tempreserve));
|
||||
}
|
||||
|
||||
|
|
|
@ -3437,10 +3437,8 @@ scan_io_queues_run_one(void *arg)
|
|||
* If we were suspended in the middle of processing,
|
||||
* requeue any unfinished sios and exit.
|
||||
*/
|
||||
while ((sio = list_head(&sio_list)) != NULL) {
|
||||
list_remove(&sio_list, sio);
|
||||
while ((sio = list_remove_head(&sio_list)) != NULL)
|
||||
scan_io_queue_insert_impl(queue, sio);
|
||||
}
|
||||
|
||||
queue->q_zio = NULL;
|
||||
mutex_exit(q_lock);
|
||||
|
|
|
@ -148,8 +148,7 @@ zfs_zevent_drain(zevent_t *ev)
|
|||
list_remove(&zevent_list, ev);
|
||||
|
||||
/* Remove references to this event in all private file data */
|
||||
while ((ze = list_head(&ev->ev_ze_list)) != NULL) {
|
||||
list_remove(&ev->ev_ze_list, ze);
|
||||
while ((ze = list_remove_head(&ev->ev_ze_list)) != NULL) {
|
||||
ze->ze_zevent = NULL;
|
||||
ze->ze_dropped++;
|
||||
}
|
||||
|
|
|
@ -88,14 +88,11 @@ zfs_refcount_destroy_many(zfs_refcount_t *rc, uint64_t number)
|
|||
reference_t *ref;
|
||||
|
||||
ASSERT3U(rc->rc_count, ==, number);
|
||||
while ((ref = list_head(&rc->rc_list))) {
|
||||
list_remove(&rc->rc_list, ref);
|
||||
while ((ref = list_remove_head(&rc->rc_list)))
|
||||
kmem_cache_free(reference_cache, ref);
|
||||
}
|
||||
list_destroy(&rc->rc_list);
|
||||
|
||||
while ((ref = list_head(&rc->rc_removed))) {
|
||||
list_remove(&rc->rc_removed, ref);
|
||||
while ((ref = list_remove_head(&rc->rc_removed))) {
|
||||
kmem_cache_free(reference_history_cache, ref->ref_removed);
|
||||
kmem_cache_free(reference_cache, ref);
|
||||
}
|
||||
|
|
|
@ -1609,16 +1609,16 @@ spa_unload_log_sm_metadata(spa_t *spa)
|
|||
{
|
||||
void *cookie = NULL;
|
||||
spa_log_sm_t *sls;
|
||||
log_summary_entry_t *e;
|
||||
|
||||
while ((sls = avl_destroy_nodes(&spa->spa_sm_logs_by_txg,
|
||||
&cookie)) != NULL) {
|
||||
VERIFY0(sls->sls_mscount);
|
||||
kmem_free(sls, sizeof (spa_log_sm_t));
|
||||
}
|
||||
|
||||
for (log_summary_entry_t *e = list_head(&spa->spa_log_summary);
|
||||
e != NULL; e = list_head(&spa->spa_log_summary)) {
|
||||
while ((e = list_remove_head(&spa->spa_log_summary)) != NULL) {
|
||||
VERIFY0(e->lse_mscount);
|
||||
list_remove(&spa->spa_log_summary, e);
|
||||
kmem_free(e, sizeof (log_summary_entry_t));
|
||||
}
|
||||
|
||||
|
|
|
@ -814,8 +814,7 @@ spa_remove(spa_t *spa)
|
|||
if (spa->spa_root)
|
||||
spa_strfree(spa->spa_root);
|
||||
|
||||
while ((dp = list_head(&spa->spa_config_list)) != NULL) {
|
||||
list_remove(&spa->spa_config_list, dp);
|
||||
while ((dp = list_remove_head(&spa->spa_config_list)) != NULL) {
|
||||
if (dp->scd_path != NULL)
|
||||
spa_strfree(dp->scd_path);
|
||||
kmem_free(dp, sizeof (spa_config_dirent_t));
|
||||
|
|
|
@ -293,17 +293,16 @@ vdev_indirect_map_free(zio_t *zio)
|
|||
indirect_vsd_t *iv = zio->io_vsd;
|
||||
|
||||
indirect_split_t *is;
|
||||
while ((is = list_head(&iv->iv_splits)) != NULL) {
|
||||
while ((is = list_remove_head(&iv->iv_splits)) != NULL) {
|
||||
for (int c = 0; c < is->is_children; c++) {
|
||||
indirect_child_t *ic = &is->is_child[c];
|
||||
if (ic->ic_data != NULL)
|
||||
abd_free(ic->ic_data);
|
||||
}
|
||||
list_remove(&iv->iv_splits, is);
|
||||
|
||||
indirect_child_t *ic;
|
||||
while ((ic = list_head(&is->is_unique_child)) != NULL)
|
||||
list_remove(&is->is_unique_child, ic);
|
||||
while ((ic = list_remove_head(&is->is_unique_child)) != NULL)
|
||||
;
|
||||
|
||||
list_destroy(&is->is_unique_child);
|
||||
|
||||
|
@ -1659,8 +1658,8 @@ out:
|
|||
for (indirect_split_t *is = list_head(&iv->iv_splits);
|
||||
is != NULL; is = list_next(&iv->iv_splits, is)) {
|
||||
indirect_child_t *ic;
|
||||
while ((ic = list_head(&is->is_unique_child)) != NULL)
|
||||
list_remove(&is->is_unique_child, ic);
|
||||
while ((ic = list_remove_head(&is->is_unique_child)) != NULL)
|
||||
;
|
||||
|
||||
is->is_unique_children = 0;
|
||||
}
|
||||
|
|
|
@ -1522,9 +1522,8 @@ zfs_ereport_fini(void)
|
|||
{
|
||||
recent_events_node_t *entry;
|
||||
|
||||
while ((entry = list_head(&recent_events_list)) != NULL) {
|
||||
while ((entry = list_remove_head(&recent_events_list)) != NULL) {
|
||||
avl_remove(&recent_events_tree, entry);
|
||||
list_remove(&recent_events_list, entry);
|
||||
kmem_free(entry, sizeof (*entry));
|
||||
}
|
||||
avl_destroy(&recent_events_tree);
|
||||
|
|
|
@ -699,19 +699,15 @@ zfs_fuid_info_free(zfs_fuid_info_t *fuidp)
|
|||
zfs_fuid_t *zfuid;
|
||||
zfs_fuid_domain_t *zdomain;
|
||||
|
||||
while ((zfuid = list_head(&fuidp->z_fuids)) != NULL) {
|
||||
list_remove(&fuidp->z_fuids, zfuid);
|
||||
while ((zfuid = list_remove_head(&fuidp->z_fuids)) != NULL)
|
||||
kmem_free(zfuid, sizeof (zfs_fuid_t));
|
||||
}
|
||||
|
||||
if (fuidp->z_domain_table != NULL)
|
||||
kmem_free(fuidp->z_domain_table,
|
||||
(sizeof (char *)) * fuidp->z_domain_cnt);
|
||||
|
||||
while ((zdomain = list_head(&fuidp->z_domains)) != NULL) {
|
||||
list_remove(&fuidp->z_domains, zdomain);
|
||||
while ((zdomain = list_remove_head(&fuidp->z_domains)) != NULL)
|
||||
kmem_free(zdomain, sizeof (zfs_fuid_domain_t));
|
||||
}
|
||||
|
||||
kmem_free(fuidp, sizeof (zfs_fuid_info_t));
|
||||
}
|
||||
|
|
|
@ -87,8 +87,7 @@ zfs_onexit_destroy(zfs_onexit_t *zo)
|
|||
zfs_onexit_action_node_t *ap;
|
||||
|
||||
mutex_enter(&zo->zo_lock);
|
||||
while ((ap = list_head(&zo->zo_actions)) != NULL) {
|
||||
list_remove(&zo->zo_actions, ap);
|
||||
while ((ap = list_remove_head(&zo->zo_actions)) != NULL) {
|
||||
mutex_exit(&zo->zo_lock);
|
||||
ap->za_func(ap->za_data);
|
||||
kmem_free(ap, sizeof (zfs_onexit_action_node_t));
|
||||
|
|
|
@ -1203,8 +1203,7 @@ zvol_create_minors_recursive(const char *name)
|
|||
* Prefetch is completed, we can do zvol_os_create_minor
|
||||
* sequentially.
|
||||
*/
|
||||
while ((job = list_head(&minors_list)) != NULL) {
|
||||
list_remove(&minors_list, job);
|
||||
while ((job = list_remove_head(&minors_list)) != NULL) {
|
||||
if (!job->error)
|
||||
(void) zvol_os_create_minor(job->name);
|
||||
kmem_strfree(job->name);
|
||||
|
@ -1311,10 +1310,8 @@ zvol_remove_minors_impl(const char *name)
|
|||
rw_exit(&zvol_state_lock);
|
||||
|
||||
/* Drop zvol_state_lock before calling zvol_free() */
|
||||
while ((zv = list_head(&free_list)) != NULL) {
|
||||
list_remove(&free_list, zv);
|
||||
while ((zv = list_remove_head(&free_list)) != NULL)
|
||||
zvol_os_free(zv);
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove minor for this specific volume only */
|
||||
|
|
Loading…
Reference in New Issue