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:
Alexander Motin
2023-06-09 13:12:52 -04:00
committed by GitHub
parent 55b1842f92
commit b3ad3f48d9
20 changed files with 34 additions and 76 deletions
+2 -5
View File
@@ -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);
}
+2 -5
View File
@@ -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);