dm: Simplify list eviction code
taken-from: DragonFlyBSD
This commit is contained in:
parent
7300145099
commit
312beb0985
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: dm_pdev.c,v 1.16 2019/12/06 16:46:14 tkusumi Exp $ */
|
||||
/* $NetBSD: dm_pdev.c,v 1.17 2019/12/07 06:26:31 tkusumi Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
@ -29,7 +29,7 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: dm_pdev.c,v 1.16 2019/12/06 16:46:14 tkusumi Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: dm_pdev.c,v 1.17 2019/12/07 06:26:31 tkusumi Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
@ -188,16 +188,16 @@ dm_pdev_rem(dm_pdev_t * dmp)
|
||||
int
|
||||
dm_pdev_destroy(void)
|
||||
{
|
||||
dm_pdev_t *dm_pdev;
|
||||
dm_pdev_t *dmp;
|
||||
|
||||
mutex_enter(&dm_pdev_mutex);
|
||||
while (!SLIST_EMPTY(&dm_pdev_list)) { /* List Deletion. */
|
||||
dm_pdev = SLIST_FIRST(&dm_pdev_list);
|
||||
|
||||
SLIST_REMOVE_HEAD(&dm_pdev_list, next_pdev);
|
||||
|
||||
dm_pdev_rem(dm_pdev);
|
||||
while ((dmp = SLIST_FIRST(&dm_pdev_list)) != NULL) {
|
||||
SLIST_REMOVE(&dm_pdev_list, dmp, dm_pdev, next_pdev);
|
||||
dm_pdev_rem(dmp);
|
||||
}
|
||||
KASSERT(SLIST_EMPTY(&dm_pdev_list));
|
||||
|
||||
mutex_exit(&dm_pdev_mutex);
|
||||
|
||||
mutex_destroy(&dm_pdev_mutex);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: dm_table.c,v 1.10 2019/12/05 16:59:43 tkusumi Exp $ */
|
||||
/* $NetBSD: dm_table.c,v 1.11 2019/12/07 06:26:31 tkusumi Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
@ -29,7 +29,7 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: dm_table.c,v 1.10 2019/12/05 16:59:43 tkusumi Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: dm_table.c,v 1.11 2019/12/07 06:26:31 tkusumi Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
@ -160,15 +160,14 @@ dm_table_destroy(dm_table_head_t * head, uint8_t table_id)
|
||||
|
||||
tbl = &head->tables[id];
|
||||
|
||||
while (!SLIST_EMPTY(tbl)) { /* List Deletion. */
|
||||
table_en = SLIST_FIRST(tbl);
|
||||
while ((table_en = SLIST_FIRST(tbl)) != NULL) {
|
||||
SLIST_REMOVE(tbl, table_en, dm_table_entry, next);
|
||||
if (table_en->target->destroy(table_en) == 0)
|
||||
table_en->target_config = NULL;
|
||||
|
||||
SLIST_REMOVE_HEAD(tbl, next);
|
||||
|
||||
kmem_free(table_en, sizeof(*table_en));
|
||||
}
|
||||
KASSERT(SLIST_EMPTY(tbl));
|
||||
|
||||
mutex_exit(&head->table_mtx);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: dm_target.c,v 1.23 2019/12/06 16:11:59 tkusumi Exp $ */
|
||||
/* $NetBSD: dm_target.c,v 1.24 2019/12/07 06:26:31 tkusumi Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
@ -29,7 +29,7 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.23 2019/12/06 16:11:59 tkusumi Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.24 2019/12/07 06:26:31 tkusumi Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
@ -220,14 +220,13 @@ dm_target_destroy(void)
|
||||
dm_target_t *dm_target;
|
||||
|
||||
mutex_enter(&dm_target_mutex);
|
||||
while (TAILQ_FIRST(&dm_target_list) != NULL) {
|
||||
dm_target = TAILQ_FIRST(&dm_target_list);
|
||||
|
||||
TAILQ_REMOVE(&dm_target_list, TAILQ_FIRST(&dm_target_list),
|
||||
dm_target_next);
|
||||
|
||||
while ((dm_target = TAILQ_FIRST(&dm_target_list)) != NULL) {
|
||||
TAILQ_REMOVE(&dm_target_list, dm_target, dm_target_next);
|
||||
(void)kmem_free(dm_target, sizeof(dm_target_t));
|
||||
}
|
||||
KASSERT(TAILQ_EMPTY(&dm_target_list));
|
||||
|
||||
mutex_exit(&dm_target_mutex);
|
||||
|
||||
mutex_destroy(&dm_target_mutex);
|
||||
|
Loading…
Reference in New Issue
Block a user